Re: [patch 26/41] cpu alloc: Convert mib handling to cpu alloc

Previous thread: [patch 24/41] cpu alloc: Use in the crypto subsystem. by Christoph Lameter on Thursday, May 29, 2008 - 8:56 pm. (1 message)

Next thread: [patch 38/41] x86: Extend percpu ops to 64 bit by Christoph Lameter on Thursday, May 29, 2008 - 8:56 pm. (1 message)
From: Christoph Lameter
Date: Thursday, May 29, 2008 - 8:56 pm

Use the cpu alloc functions for the mib handling functions in the net
layer. The API for snmp_mib_free() is changed to add a size parameter
since cpu_free() requires a size parameter.

Signed-off-by: Christoph Lameter <clameter@sgi.com>
---
 include/net/ip.h     |    2 +-
 include/net/snmp.h   |   32 ++++++++------------------------
 net/dccp/proto.c     |    2 +-
 net/ipv4/af_inet.c   |   31 +++++++++++++++++--------------
 net/ipv6/addrconf.c  |   11 ++++++-----
 net/ipv6/af_inet6.c  |   20 +++++++++++---------
 net/sctp/protocol.c  |    2 +-
 net/xfrm/xfrm_proc.c |    4 ++--
 8 files changed, 47 insertions(+), 57 deletions(-)

Index: linux-2.6/include/net/ip.h
===================================================================
--- linux-2.6.orig/include/net/ip.h	2008-05-29 19:41:20.000000000 -0700
+++ linux-2.6/include/net/ip.h	2008-05-29 20:15:34.000000000 -0700
@@ -170,7 +170,7 @@ DECLARE_SNMP_STAT(struct linux_mib, net_
 
 extern unsigned long snmp_fold_field(void *mib[], int offt);
 extern int snmp_mib_init(void *ptr[2], size_t mibsize);
-extern void snmp_mib_free(void *ptr[2]);
+extern void snmp_mib_free(void *ptr[2], size_t mibsize);
 
 extern void inet_get_local_port_range(int *low, int *high);
 
Index: linux-2.6/include/net/snmp.h
===================================================================
--- linux-2.6.orig/include/net/snmp.h	2008-05-29 19:41:20.000000000 -0700
+++ linux-2.6/include/net/snmp.h	2008-05-29 20:15:34.000000000 -0700
@@ -138,29 +138,13 @@ struct linux_xfrm_mib {
 #define SNMP_STAT_BHPTR(name)	(name[0])
 #define SNMP_STAT_USRPTR(name)	(name[1])
 
-#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) \
-	do { \
-		per_cpu_ptr(mib[1], get_cpu())->mibs[field]++; \
-		put_cpu(); \
-	} while (0)
-#define SNMP_INC_STATS(mib, field) 	\
-	do { \
-		per_cpu_ptr(mib[!in_softirq()], get_cpu())->mibs[field]++; \
-		put_cpu(); \
-	} while (0)
-#define ...
From: Eric Dumazet
Date: Thursday, May 29, 2008 - 11:47 pm

We also can avoid the use of two arrays when CONFIG_HAVE_CPU_OPS
since _CPU_INC() and __CPU_INC() are both interrupt safe.
This would reduce size of mibs by 50% and complexity (no need to sum)




--

From: Christoph Lameter
Date: Friday, May 30, 2008 - 11:01 am

Right.

--

Previous thread: [patch 24/41] cpu alloc: Use in the crypto subsystem. by Christoph Lameter on Thursday, May 29, 2008 - 8:56 pm. (1 message)

Next thread: [patch 38/41] x86: Extend percpu ops to 64 bit by Christoph Lameter on Thursday, May 29, 2008 - 8:56 pm. (1 message)