Exemple #1
0
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;
}
Exemple #2
0
__initfunc(int net_profile_init(void))
{
	int i;

#ifdef CONFIG_PROC_FS
	struct proc_dir_entry *ent;

	ent = create_proc_entry("net/profile", 0, 0);
	ent->read_proc = profile_read_proc;
#endif

	register_netdevice(&whitehole_dev);

	printk("Evaluating net profiler cost ...");
#if CPU == 586 || CPU == 686
	if (!(boot_cpu_data.x86_capability & X86_FEATURE_TSC)) {
		printk(KERN_ERR "Sorry, your CPU does not support TSC. Net profiler disabled.\n");
		return -1;
	}
#endif
	start_bh_atomic();
#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);
	end_bh_atomic();
	return 0;
}
Exemple #3
0
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;
		printk(KERN_CRIT "Yep, guys... our template for proc_*_read is crappy :-)\n");
	}
	if (offset == 0) {
		cli();
		net_prof_total.active = 0;
		net_prof_total.hits = 0;
		net_profile_stamp(&net_prof_total.entered);
		sti();
	}
	return len;
}