oops in a kernel module

Valdis.Kletnieks at vt.edu Valdis.Kletnieks at vt.edu
Sun Apr 28 12:07:05 EDT 2013


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()? ;)

-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 865 bytes
Desc: not available
Url : http://lists.kernelnewbies.org/pipermail/kernelnewbies/attachments/20130428/d3c5ce97/attachment.bin 


More information about the Kernelnewbies mailing list