On Sat, 27 Apr 2013 19:34:00 +0300, Kevin Wilson said:
> Hello,

> static int __init init_zeromib(void)

This is your init routine...

> {
> int ret = 0;
> printk("in %s\n",__func__);

Missing KERN_DEBUG or similar here.  This can cause it to fail
to appear in dmesg output, causing much confusion.


> #define SNMP_ZERO_STATS(mib, field) 
> this_cpu_add(mib[0]->mibs[field],-(mib[0]->mibs[field]))

You *do* realize that this doesn't in fact zero the statistics, right?

If you have a 32-core machine, this will zero 1/32 of the statistics.

this_cpu_add and friends are there specifically so that on multi-core systems
there's a lockless way to update the statistics values - to actually find
the values, you need to walk across all the per_cpu areas and sum them
up.

And why for the love of all that is good did you do this bletcherous thing
with this_cpu_add() instead of using 'this_cpu_write(whatever, 0)'? Or at
least use this_cpu_sub()? ;)

Attachment: pgpVU13OrNS6Q.pgp
Description: PGP signature

_______________________________________________
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies

Reply via email to