Re: oops in a kernel module

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Valdis,
Thanks a lot for you answer.

this_cpu_sub() in fact is defined thus:
# define this_cpu_sub(pcp, val)         this_cpu_add((pcp), -(val))

so it does not matter so much.
I did not know this_cpu_write() and it does work.

Is __this_cpu_write() an atomic operation ?

rgs
Kevin


On Sun, Apr 28, 2013 at 7:07 PM,  <Valdis.Kletnieks@xxxxxx> wrote:
> 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()? ;)
>

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




[Index of Archives]     [Newbies FAQ]     [Linux Kernel Mentors]     [Linux Kernel Development]     [IETF Annouce]     [Git]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux SCSI]     [Linux ACPI]
  Powered by Linux