Commit d2231420 authored by David S. Miller's avatar David S. Miller

[NET]: Kill NET_PROFILE, has not built for years.

parent 5c84b8c4
...@@ -37,9 +37,6 @@ ...@@ -37,9 +37,6 @@
#ifdef __KERNEL__ #ifdef __KERNEL__
#include <linux/config.h> #include <linux/config.h>
#ifdef CONFIG_NET_PROFILE
#include <net/profile.h>
#endif
struct divert_blk; struct divert_blk;
struct vlan_group; struct vlan_group;
......
#include <linux/config.h> /* for CONFIG_NET_PROFILE */
#ifndef _NET_PROFILE_H_
#define _NET_PROFILE_H_ 1
#ifdef CONFIG_NET_PROFILE
#include <linux/types.h>
#include <linux/time.h>
#include <linux/kernel.h>
#include <asm/system.h>
#ifdef CONFIG_X86_TSC
#include <asm/msr.h>
#endif
struct net_profile_slot
{
char id[16];
struct net_profile_slot *next;
struct timeval entered;
struct timeval accumulator;
struct timeval irq;
int hits;
int active;
int underflow;
};
extern atomic_t net_profile_active;
extern struct timeval net_profile_adjust;
extern void net_profile_irq_adjust(struct timeval *entered, struct timeval* leaved);
#ifdef CONFIG_X86_TSC
static inline void net_profile_stamp(struct timeval *pstamp)
{
rdtsc(pstamp->tv_usec, pstamp->tv_sec);
}
static inline void net_profile_accumulate(struct timeval *entered,
struct timeval *leaved,
struct timeval *acc)
{
__asm__ __volatile__ ("subl %2,%0\n\t"
"sbbl %3,%1\n\t"
"addl %4,%0\n\t"
"adcl %5,%1\n\t"
"subl net_profile_adjust+4,%0\n\t"
"sbbl $0,%1\n\t"
: "=r" (acc->tv_usec), "=r" (acc->tv_sec)
: "g" (entered->tv_usec), "g" (entered->tv_sec),
"g" (leaved->tv_usec), "g" (leaved->tv_sec),
"0" (acc->tv_usec), "1" (acc->tv_sec));
}
static inline void net_profile_sub(struct timeval *sub,
struct timeval *acc)
{
__asm__ __volatile__ ("subl %2,%0\n\t"
"sbbl %3,%1\n\t"
: "=r" (acc->tv_usec), "=r" (acc->tv_sec)
: "g" (sub->tv_usec), "g" (sub->tv_sec),
"0" (acc->tv_usec), "1" (acc->tv_sec));
}
static inline void net_profile_add(struct timeval *add,
struct timeval *acc)
{
__asm__ __volatile__ ("addl %2,%0\n\t"
"adcl %3,%1\n\t"
: "=r" (acc->tv_usec), "=r" (acc->tv_sec)
: "g" (add->tv_usec), "g" (add->tv_sec),
"0" (acc->tv_usec), "1" (acc->tv_sec));
}
#elif defined (__alpha__)
extern __u32 alpha_lo;
extern long alpha_hi;
/* On alpha cycle counter has only 32 bits :-( :-( */
static inline void net_profile_stamp(struct timeval *pstamp)
{
__u32 result;
__asm__ __volatile__ ("rpcc %0" : "r="(result));
if (result <= alpha_lo)
alpha_hi++;
alpha_lo = result;
pstamp->tv_sec = alpha_hi;
pstamp->tv_usec = alpha_lo;
}
static inline void net_profile_accumulate(struct timeval *entered,
struct timeval *leaved,
struct timeval *acc)
{
time_t usecs = acc->tv_usec + leaved->tv_usec - entered->tv_usec
- net_profile_adjust.tv_usec;
time_t secs = acc->tv_sec + leaved->tv_sec - entered->tv_sec;
if (usecs >= 0x100000000L) {
usecs -= 0x100000000L;
secs++;
} else if (usecs < -0x100000000L) {
usecs += 0x200000000L;
secs -= 2;
} else if (usecs < 0) {
usecs += 0x100000000L;
secs--;
}
acc->tv_sec = secs;
acc->tv_usec = usecs;
}
static inline void net_profile_sub(struct timeval *entered,
struct timeval *leaved)
{
time_t usecs = leaved->tv_usec - entered->tv_usec;
time_t secs = leaved->tv_sec - entered->tv_sec;
if (usecs < 0) {
usecs += 0x100000000L;
secs--;
}
leaved->tv_sec = secs;
leaved->tv_usec = usecs;
}
static inline void net_profile_add(struct timeval *entered, struct timeval *leaved)
{
time_t usecs = leaved->tv_usec + entered->tv_usec;
time_t secs = leaved->tv_sec + entered->tv_sec;
if (usecs >= 0x100000000L) {
usecs -= 0x100000000L;
secs++;
}
leaved->tv_sec = secs;
leaved->tv_usec = usecs;
}
#else
static inline void net_profile_stamp(struct timeval *pstamp)
{
/* Not "fast" counterpart! On architectures without
cpu clock "fast" routine is absolutely useless in this
situation. do_gettimeofday still says something on slow-slow-slow
boxes, though it eats more cpu time than the subject of
investigation :-) :-)
*/
do_gettimeofday(pstamp);
}
static inline void net_profile_accumulate(struct timeval *entered,
struct timeval *leaved,
struct timeval *acc)
{
time_t usecs = acc->tv_usec + leaved->tv_usec - entered->tv_usec
- net_profile_adjust.tv_usec;
time_t secs = acc->tv_sec + leaved->tv_sec - entered->tv_sec;
if (usecs >= 1000000) {
usecs -= 1000000;
secs++;
} else if (usecs < -1000000) {
usecs += 2000000;
secs -= 2;
} else if (usecs < 0) {
usecs += 1000000;
secs--;
}
acc->tv_sec = secs;
acc->tv_usec = usecs;
}
static inline void net_profile_sub(struct timeval *entered,
struct timeval *leaved)
{
time_t usecs = leaved->tv_usec - entered->tv_usec;
time_t secs = leaved->tv_sec - entered->tv_sec;
if (usecs < 0) {
usecs += 1000000;
secs--;
}
leaved->tv_sec = secs;
leaved->tv_usec = usecs;
}
static inline void net_profile_add(struct timeval *entered, struct timeval *leaved)
{
time_t usecs = leaved->tv_usec + entered->tv_usec;
time_t secs = leaved->tv_sec + entered->tv_sec;
if (usecs >= 1000000) {
usecs -= 1000000;
secs++;
}
leaved->tv_sec = secs;
leaved->tv_usec = usecs;
}
#endif
static inline void net_profile_enter(struct net_profile_slot *s)
{
unsigned long flags;
save_flags(flags);
cli();
if (s->active++ == 0) {
net_profile_stamp(&s->entered);
atomic_inc(&net_profile_active);
}
restore_flags(flags);
}
static inline void net_profile_leave_irq(struct net_profile_slot *s)
{
unsigned long flags;
save_flags(flags);
cli();
if (--s->active <= 0) {
if (s->active == 0) {
struct timeval curr_pstamp;
net_profile_stamp(&curr_pstamp);
net_profile_accumulate(&s->entered, &curr_pstamp, &s->accumulator);
if (!atomic_dec_and_test(&net_profile_active))
net_profile_irq_adjust(&s->entered, &curr_pstamp);
} else {
s->underflow++;
}
}
s->hits++;
restore_flags(flags);
}
static inline void net_profile_leave(struct net_profile_slot *s)
{
unsigned long flags;
save_flags(flags);
cli();
if (--s->active <= 0) {
if (s->active == 0) {
struct timeval curr_pstamp;
net_profile_stamp(&curr_pstamp);
net_profile_accumulate(&s->entered, &curr_pstamp, &s->accumulator);
atomic_dec(&net_profile_active);
} else {
s->underflow++;
}
}
s->hits++;
restore_flags(flags);
}
#define NET_PROFILE_ENTER(slot) net_profile_enter(&net_prof_##slot)
#define NET_PROFILE_LEAVE(slot) net_profile_leave(&net_prof_##slot)
#define NET_PROFILE_LEAVE_IRQ(slot) net_profile_leave_irq(&net_prof_##slot)
#define NET_PROFILE_SKB_CLEAR(skb) ({ \
skb->pstamp.tv_usec = 0; \
})
#define NET_PROFILE_SKB_INIT(skb) ({ \
net_profile_stamp(&skb->pstamp); \
})
#define NET_PROFILE_SKB_PASSED(skb, slot) ({ \
if (skb->pstamp.tv_usec) { \
struct timeval cur_pstamp = skb->pstamp; \
net_profile_stamp(&skb->pstamp); \
net_profile_accumulate(&cur_pstamp, &skb->pstamp, &net_prof_##slot.accumulator); \
net_prof_##slot.hits++; \
}})
#define NET_PROFILE_DECL(slot) \
extern struct net_profile_slot net_prof_##slot;
#define NET_PROFILE_DEFINE(slot) \
struct net_profile_slot net_prof_##slot = { #slot, };
#define NET_PROFILE_REGISTER(slot) net_profile_register(&net_prof_##slot)
#define NET_PROFILE_UNREGISTER(slot) net_profile_unregister(&net_prof_##slot)
extern int net_profile_init(void);
extern int net_profile_register(struct net_profile_slot *);
extern int net_profile_unregister(struct net_profile_slot *);
#else
#define NET_PROFILE_ENTER(slot) do { /* nothing */ } while(0)
#define NET_PROFILE_LEAVE(slot) do { /* nothing */ } while(0)
#define NET_PROFILE_LEAVE_IRQ(slot) do { /* nothing */ } while(0)
#define NET_PROFILE_SKB_CLEAR(skb) do { /* nothing */ } while(0)
#define NET_PROFILE_SKB_INIT(skb) do { /* nothing */ } while(0)
#define NET_PROFILE_SKB_PASSED(skb, slot) do { /* nothing */ } while(0)
#define NET_PROFILE_DECL(slot)
#define NET_PROFILE_DEFINE(slot)
#define NET_PROFILE_REGISTER(slot) do { /* nothing */ } while(0)
#define NET_PROFILE_UNREGISTER(slot) do { /* nothing */ } while(0)
#endif
#endif
...@@ -676,7 +676,6 @@ config NET_SCHED ...@@ -676,7 +676,6 @@ config NET_SCHED
source "net/sched/Kconfig" source "net/sched/Kconfig"
#bool 'Network code profiler' CONFIG_NET_PROFILE
endmenu endmenu
menu "Network testing" menu "Network testing"
......
...@@ -11,6 +11,5 @@ obj-y += flow.o dev.o ethtool.o net-sysfs.o dev_mcast.o dst.o \ ...@@ -11,6 +11,5 @@ obj-y += flow.o dev.o ethtool.o net-sysfs.o dev_mcast.o dst.o \
obj-$(CONFIG_NETFILTER) += netfilter.o obj-$(CONFIG_NETFILTER) += netfilter.o
obj-$(CONFIG_NET_DIVERT) += dv.o obj-$(CONFIG_NET_DIVERT) += dv.o
obj-$(CONFIG_NET_PROFILE) += profile.o
obj-$(CONFIG_NET_PKTGEN) += pktgen.o obj-$(CONFIG_NET_PKTGEN) += pktgen.o
obj-$(CONFIG_NET_RADIO) += wireless.o obj-$(CONFIG_NET_RADIO) += wireless.o
...@@ -99,7 +99,6 @@ ...@@ -99,7 +99,6 @@
#include <linux/divert.h> #include <linux/divert.h>
#include <net/dst.h> #include <net/dst.h>
#include <net/pkt_sched.h> #include <net/pkt_sched.h>
#include <net/profile.h>
#include <net/checksum.h> #include <net/checksum.h>
#include <linux/highmem.h> #include <linux/highmem.h>
#include <linux/init.h> #include <linux/init.h>
...@@ -128,9 +127,6 @@ extern int plip_init(void); ...@@ -128,9 +127,6 @@ extern int plip_init(void);
*/ */
#undef OFFLINE_SAMPLE #undef OFFLINE_SAMPLE
NET_PROFILE_DEFINE(dev_queue_xmit)
NET_PROFILE_DEFINE(softnet_process)
/* /*
* The list of packet types we will receive (as opposed to discard) * The list of packet types we will receive (as opposed to discard)
* and the routines to invoke. * and the routines to invoke.
...@@ -3015,12 +3011,6 @@ static int __init net_dev_init(void) ...@@ -3015,12 +3011,6 @@ static int __init net_dev_init(void)
atomic_set(&queue->backlog_dev.refcnt, 1); atomic_set(&queue->backlog_dev.refcnt, 1);
} }
#ifdef CONFIG_NET_PROFILE
net_profile_init();
NET_PROFILE_REGISTER(dev_queue_xmit);
NET_PROFILE_REGISTER(softnet_process);
#endif
#ifdef OFFLINE_SAMPLE #ifdef OFFLINE_SAMPLE
samp_timer.expires = jiffies + (10 * HZ); samp_timer.expires = jiffies + (10 * HZ);
add_timer(&samp_timer); add_timer(&samp_timer);
......
#include <linux/config.h>
#include <linux/types.h>
#include <linux/kernel.h>
#include <linux/jiffies.h>
#include <linux/mm.h>
#include <linux/interrupt.h>
#include <linux/netdevice.h>
#include <linux/string.h>
#include <linux/skbuff.h>
#include <linux/proc_fs.h>
#include <linux/init.h>
#include <linux/ip.h>
#include <linux/inet.h>
#include <net/checksum.h>
#include <asm/processor.h>
#include <asm/uaccess.h>
#include <asm/system.h>
#include <net/profile.h>
#ifdef CONFIG_NET_PROFILE
atomic_t net_profile_active;
struct timeval net_profile_adjust;
NET_PROFILE_DEFINE(total);
struct net_profile_slot *net_profile_chain = &net_prof_total;
#ifdef __alpha__
__u32 alpha_lo;
long alpha_hi;
static void alpha_tick(unsigned long);
static struct timer_list alpha_timer = TIMER_INITIALIZER(alpha_tick, 0, 0);
void alpha_tick(unsigned long dummy)
{
struct timeval dummy_stamp;
net_profile_stamp(&dummy_stamp);
alpha_timer.expires = jiffies + 4*HZ;
add_timer(&alpha_timer);
}
#endif
void net_profile_irq_adjust(struct timeval *entered, struct timeval* leaved)
{
struct net_profile_slot *s;
net_profile_sub(entered, leaved);
for (s = net_profile_chain; s; s = s->next) {
if (s->active)
net_profile_add(leaved, &s->irq);
}
}
#ifdef CONFIG_PROC_FS
static int profile_read_proc(char *buffer, char **start, off_t offset,
int length, int *eof, void *data)
{
off_t pos=0;
off_t begin=0;
int len=0;
struct net_profile_slot *s;
len+= sprintf(buffer, "Slot Hits Hi Lo OnIrqHi OnIrqLo Ufl\n");
if (offset == 0) {
cli();
net_prof_total.active = 1;
atomic_inc(&net_profile_active);
NET_PROFILE_LEAVE(total);
sti();
}
for (s = net_profile_chain; s; s = s->next) {
struct net_profile_slot tmp;
cli();
tmp = *s;
/* Wrong, but pretty close to truth */
s->accumulator.tv_sec = 0;
s->accumulator.tv_usec = 0;
s->irq.tv_sec = 0;
s->irq.tv_usec = 0;
s->hits = 0;
s->underflow = 0;
/* Repair active count, it is possible, only if code has a bug */
if (s->active) {
s->active = 0;
atomic_dec(&net_profile_active);
}
sti();
net_profile_sub(&tmp.irq, &tmp.accumulator);
len += sprintf(buffer+len,"%-15s %-10d %-10ld %-10lu %-10lu %-10lu %d/%d",
tmp.id,
tmp.hits,
tmp.accumulator.tv_sec,
tmp.accumulator.tv_usec,
tmp.irq.tv_sec,
tmp.irq.tv_usec,
tmp.underflow, tmp.active);
buffer[len++]='\n';
pos=begin+len;
if(pos<offset) {
len=0;
begin=pos;
}
if(pos>offset+length)
goto done;
}
*eof = 1;
done:
*start=buffer+(offset-begin);
len-=(offset-begin);
if(len>length)
len=length;
if (len < 0)
len = 0;
if (offset == 0) {
cli();
net_prof_total.active = 0;
net_prof_total.hits = 0;
net_profile_stamp(&net_prof_total.entered);
sti();
}
return len;
}
#endif
struct iphdr whitehole_iph;
int whitehole_count;
static int whitehole_xmit(struct sk_buff *skb, struct net_device *dev)
{
struct net_device_stats *stats;
stats = (struct net_device_stats *)dev->priv;
stats->tx_packets++;
stats->tx_bytes+=skb->len;
dev_kfree_skb(skb);
return 0;
}
static void whitehole_inject(unsigned long);
int whitehole_init(struct net_device *dev);
static struct timer_list whitehole_timer =
TIMER_INITIALIZER(whitehole_inject, 0, 0);
static struct net_device whitehole_dev = {
.name = "whitehole",
.init = whitehole_init,
};
static int whitehole_open(struct net_device *dev)
{
whitehole_count = 100000;
whitehole_timer.expires = jiffies + 5*HZ;
add_timer(&whitehole_timer);
return 0;
}
static int whitehole_close(struct net_device *dev)
{
del_timer(&whitehole_timer);
return 0;
}
static void whitehole_inject(unsigned long dummy)
{
struct net_device_stats *stats = (struct net_device_stats *)whitehole_dev.priv;
extern int netdev_dropping;
do {
struct iphdr *iph;
struct sk_buff *skb = alloc_skb(128, GFP_ATOMIC);
if (!skb)
break;
skb_reserve(skb, 32);
iph = (struct iphdr*)skb_put(skb, sizeof(*iph));
skb->mac.raw = ((u8*)iph) - 14;
memcpy(iph, &whitehole_iph, sizeof(*iph));
skb->protocol = __constant_htons(ETH_P_IP);
skb->dev = &whitehole_dev;
skb->pkt_type = PACKET_HOST;
stats->rx_packets++;
stats->rx_bytes += skb->len;
netif_rx(skb);
whitehole_count--;
} while (netdev_dropping == 0 && whitehole_count>0);
if (whitehole_count > 0) {
whitehole_timer.expires = jiffies + 1;
add_timer(&whitehole_timer);
}
}
static struct net_device_stats *whitehole_get_stats(struct net_device *dev)
{
struct net_device_stats *stats = (struct net_device_stats *) dev->priv;
return stats;
}
int __init whitehole_init(struct net_device *dev)
{
dev->priv = kmalloc(sizeof(struct net_device_stats), GFP_KERNEL);
if (dev->priv == NULL)
return -ENOBUFS;
memset(dev->priv, 0, sizeof(struct net_device_stats));
dev->get_stats = whitehole_get_stats;
dev->hard_start_xmit = whitehole_xmit;
dev->open = whitehole_open;
dev->stop = whitehole_close;
ether_setup(dev);
dev->tx_queue_len = 0;
dev->flags |= IFF_NOARP;
dev->flags &= ~(IFF_BROADCAST|IFF_MULTICAST);
dev->iflink = 0;
whitehole_iph.ihl = 5;
whitehole_iph.version = 4;
whitehole_iph.ttl = 2;
whitehole_iph.saddr = in_aton("193.233.7.21");
whitehole_iph.daddr = in_aton("193.233.7.10");
whitehole_iph.tot_len = htons(20);
whitehole_iph.check = ip_compute_csum((void *)&whitehole_iph, 20);
return 0;
}
int net_profile_register(struct net_profile_slot *slot)
{
cli();
slot->next = net_profile_chain;
net_profile_chain = slot;
sti();
return 0;
}
int net_profile_unregister(struct net_profile_slot *slot)
{
struct net_profile_slot **sp, *s;
for (sp = &net_profile_chain; (s = *sp) != NULL; sp = &s->next) {
if (s == slot) {
cli();
*sp = s->next;
sti();
return 0;
}
}
return -ESRCH;
}
int __init net_profile_init(void)
{
int i;
#ifdef CONFIG_PROC_FS
create_proc_read_entry("net/profile", 0, 0, profile_read_proc, NULL);
#endif
register_netdevice(&whitehole_dev);
printk("Evaluating net profiler cost ...");
#ifdef __alpha__
alpha_tick(0);
#endif
for (i=0; i<1024; i++) {
NET_PROFILE_ENTER(total);
NET_PROFILE_LEAVE(total);
}
if (net_prof_total.accumulator.tv_sec) {
printk(" too high!\n");
} else {
net_profile_adjust.tv_usec = net_prof_total.accumulator.tv_usec>>10;
printk("%ld units\n", net_profile_adjust.tv_usec);
}
net_prof_total.hits = 0;
net_profile_stamp(&net_prof_total.entered);
return 0;
}
#endif
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment