[patch 24/28] cpu alloc: convert mib handling to cpu alloc

[patch 24/28] cpu alloc: convert mib handling to cpu alloc

Post by Christoph » Thu, 08 Nov 2007 05:10:10


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 | 14 +++++++-------
net/dccp/proto.c | 12 +++++++-----
net/ipv4/af_inet.c | 32 ++++++++++++++++++--------------
net/ipv6/addrconf.c | 10 +++++-----
net/ipv6/af_inet6.c | 18 +++++++++---------
net/sctp/proc.c | 4 ++--
net/sctp/protocol.c | 13 ++++++++-----
8 files changed, 57 insertions(+), 48 deletions(-)

Index: linux-2.6/include/net/snmp.h
===================================================================
--- linux-2.6.orig/include/net/snmp.h 2007-11-04 20:19:49.000000000 -0800
+++ linux-2.6/include/net/snmp.h 2007-11-04 20:57:16.000000000 -0800
@@ -133,18 +133,18 @@ struct linux_mib {
#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]++)
+ (__THIS_CPU(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)]++)
+ (__THIS_CPU(mib[0])->mibs[field + (offset)]++)
#define SNMP_INC_STATS_USER(mib, field) \
- (per_cpu_ptr(mib[1], raw_smp_processor_id())->mibs[field]++)
+ (__THIS_CPU(mib[1])->mibs[field]++)
#define SNMP_INC_STATS(mib, field) \
- (per_cpu_ptr(mib[!in_softirq()], raw_smp_processor_id())->mibs[field]++)
+ (__THIS_CPU(mib[!in_softirq()])->mibs[field]++)
#define SNMP_DEC_STATS(mib, field) \
- (per_cpu_ptr(mib[!in_softirq()], raw_smp_processor_id())->mibs[field]--)
+ (__THIS_CPU(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)
+ (__THIS_CPU(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)
+ (__THIS_CPU(mib[1])->mibs[field] += addend)

#endif
Index: linux-2.6/net/dccp/proto.c
===================================================================
--- linux-2.6.orig/net/dccp/proto.c 2007-11-04 20:19:49.000000000 -0800
+++ linux-2.6/net/dccp/proto.c 2007-11-04 20:57:16.000000000 -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_ZERO);
if (dccp_statistics[1] == NULL)
goto out_free_one;

@@ -1002,7 +1004,7 @@ static int __init dccp_mib_init(void)
out:
return rc;
out_free_one:
- free_percpu(dccp_statistics[0]);
+ CPU_FREE(dccp_statistics[0]);
dccp_statistics[0] = NULL;
goto out;

@@ -1010,8 +1012,8 @@ out_free_one:

static void dccp_mib_exit(void)
{
- free_percpu(dccp_statistics[0]);
- free_percpu(dccp_statistics[1]);
+ CPU_FREE(dccp_statistics[0]);
+ CPU_FREE(dccp_statistics[1]);
dccp_statistics[0] = dccp_statistics[1] = NULL;
}

Index: linux-2.6/net/sctp/protocol.c
===================================================================