Gitweb:     
http://git.kernel.org/git/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commit;h=d647b36a69bf0a630ebf981bde3c0651e2779e5e
Commit:     d647b36a69bf0a630ebf981bde3c0651e2779e5e
Parent:     2caf62f6cae46e36b1c4a1b0f2d9ef82af89cad2
Author:     Herbert Xu <[EMAIL PROTECTED]>
AuthorDate: Thu Dec 20 04:13:21 2007 -0800
Committer:  David S. Miller <[EMAIL PROTECTED]>
CommitDate: Mon Jan 28 14:59:16 2008 -0800

    [SNMP]: Fix SNMP counters with PREEMPT
    
    The SNMP macros use raw_smp_processor_id() in process context
    which is illegal because the process may be preempted and then
    migrated to another CPU.
    
    This patch makes it use get_cpu/put_cpu to disable preemption.
    
    Signed-off-by: Herbert Xu <[EMAIL PROTECTED]>
    Signed-off-by: David S. Miller <[EMAIL PROTECTED]>
---
 include/net/snmp.h |   21 +++++++++++++++++----
 1 files changed, 17 insertions(+), 4 deletions(-)

diff --git a/include/net/snmp.h b/include/net/snmp.h
index 9c5793d..fbb6666 100644
--- a/include/net/snmp.h
+++ b/include/net/snmp.h
@@ -23,6 +23,7 @@
 
 #include <linux/cache.h>
 #include <linux/snmp.h>
+#include <linux/smp.h>
 
 /*
  * Mibs are stored in array of unsigned long.
@@ -135,14 +136,26 @@ struct linux_mib {
 #define SNMP_INC_STATS_BH(mib, field)  \
        (per_cpu_ptr(mib[0], raw_smp_processor_id())->mibs[field]++)
 #define SNMP_INC_STATS_USER(mib, field) \
-       (per_cpu_ptr(mib[1], raw_smp_processor_id())->mibs[field]++)
+       do { \
+               per_cpu_ptr(mib[1], get_cpu())->mibs[field]++; \
+               put_cpu(); \
+       } while (0)
 #define SNMP_INC_STATS(mib, field)     \
-       (per_cpu_ptr(mib[!in_softirq()], raw_smp_processor_id())->mibs[field]++)
+       do { \
+               per_cpu_ptr(mib[!in_softirq()], get_cpu())->mibs[field]++; \
+               put_cpu(); \
+       } while (0)
 #define SNMP_DEC_STATS(mib, field)     \
-       (per_cpu_ptr(mib[!in_softirq()], raw_smp_processor_id())->mibs[field]--)
+       do { \
+               per_cpu_ptr(mib[!in_softirq()], get_cpu())->mibs[field]--; \
+               put_cpu(); \
+       } while (0)
 #define SNMP_ADD_STATS_BH(mib, field, addend)  \
        (per_cpu_ptr(mib[0], raw_smp_processor_id())->mibs[field] += addend)
 #define SNMP_ADD_STATS_USER(mib, field, addend)        \
-       (per_cpu_ptr(mib[1], raw_smp_processor_id())->mibs[field] += addend)
+       do { \
+               per_cpu_ptr(mib[1], get_cpu())->mibs[field] += addend; \
+               put_cpu(); \
+       } while (0)
 
 #endif
-
To unsubscribe from this list: send the line "unsubscribe git-commits-head" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to