[rfc 27/45] cpu alloc: convert mib handling to cpu alloc

[rfc 27/45] cpu alloc: convert mib handling to cpu alloc

Post by clamete » Wed, 21 Nov 2007 10:30:22


se 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_fre requires that.

Signed-off-by: Christoph Lameter < XXXX@XXXXX.COM >
---
include/net/ip.h | 2 +-
include/net/snmp.h | 15 +++++++--------
net/dccp/proto.c | 12 +++++++-----
net/ipv4/af_inet.c | 31 +++++++++++++++++--------------
net/ipv6/addrconf.c | 10 +++++-----
net/ipv6/af_inet6.c | 18 +++++++++---------
net/sctp/proc.c | 4 ++--
net/sctp/protocol.c | 12 +++++++-----
8 files changed, 55 insertions(+), 49 deletions(-)

Index: linux-2.6/include/net/ip.h
===================================================================
--- linux-2.6.orig/include/net/ip.h 2007-11-18 14:38:23.385283253 -0800
+++ linux-2.6/include/net/ip.h 2007-11-18 21:55:27.684797168 -0800
@@ -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, size_t mibalign);
-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 2007-11-18 14:38:23.393283116 -0800
+++ linux-2.6/include/net/snmp.h 2007-11-18 22:04:47.477773921 -0800
@@ -132,19 +132,18 @@ struct linux_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_BH(mib, field) __CPU_INC(mib[0]->mibs[field])
#define SNMP_INC_STATS_OFFSET_BH(mib, field, offset) \
- (per_cpu_ptr(mib[0], raw_smp_processor_id())->mibs[field + (offset)]++)
+ __CPU_INC(mib[0]->mibs[field + (offset)])
#define SNMP_INC_STATS_USER(mib, field) \
- (per_cpu_ptr(mib[1], raw_smp_processor_id())->mibs[field]++)
+ __CPU_INC(mib[1]->mibs[field])
#define SNMP_INC_STATS(mib, field) \
- (per_cpu_ptr(mib[!in_softirq()], raw_smp_processor_id())->mibs[field]++)
+ __CPU_INC(mib[!in_softirq()]->mibs[field])
#define SNMP_DEC_STATS(mib, field) \
- (per_cpu_ptr(mib[!in_softirq()], raw_smp_processor_id())->mibs[field]--)
+ __CPU_DEC(mib[!in_softirq()]->mibs[field])
#define SNMP_ADD_STATS_BH(mib, field, addend) \
- (per_cpu_ptr(mib[0], raw_smp_processor_id())->mibs[field] += addend)
+ __CPU_ADD(mib[0]->mibs[field], addend)
#define SNMP_ADD_STATS_USER(mib, field, addend) \
- (per_cpu_ptr(mib[1], raw_smp_processor_id())->mibs[field] += addend)
+ __CPU_ADD(mib[1]->mibs[field], addend)

#endif
Index: linux-2.6/net/dccp/proto.c
===================================================================
--- linux-2.6.orig/net/dccp/proto.c 2007-11-18 14:38:23.397283534 -0800
+++ linux-2.6/net/dccp/proto.c 2007-11-18 21:55:27.704797139 -0800
@@ -990,11 +990,13 @@ static int __init dccp_mib_init(void)
{
int rc = -ENOMEM;

- dccp_statistics[0] = alloc_percpu(struct dccp_mib);
+ dccp_statistics[0] = CPU_ALLOC(struct dccp_mib,
+ GFP_KERNEL | __GFP_ZERO);
if (dccp_statistics[0] == NULL)
goto out;

- dccp_statistics[1] = alloc_percpu(struct dccp_mib);
+ dccp_statistics[1] = CPU_ALLOC(struct dccp_mib,
+ GFP_KERNEL | __GFP_ZE