[patch 22/41] cpu alloc: Convert network sockets inuse counter

Christoph Lameter
2008-05-30T04:14:18Z

[-- Attachment #1: cpu_alloc_network_sockets_conversion --]
[-- Type: text/plain, Size: 1383 bytes --]

Convert handling of the inuse counters to cpu alloc.

Signed-off-by: Christoph Lameter <clameter@sgi.com>
---
net/core/sock.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)

Index: linux-2.6/net/core/sock.c
===================================================================
--- linux-2.6.orig/net/core/sock.c 2008-05-14 19:40:34.000000000 -0700
+++ linux-2.6/net/core/sock.c 2008-05-21 22:00:56.000000000 -0700
@@ -1943,8 +1943,7 @@
#ifdef CONFIG_NET_NS
void sock_prot_inuse_add(struct net *net, struct proto *prot, int val)
{
- int cpu = smp_processor_id();
- per_cpu_ptr(net->core.inuse, cpu)->val[prot->inuse_idx] += val;
+ __CPU_ADD(net->core.inuse->val[prot->inuse_idx], val);
}
EXPORT_SYMBOL_GPL(sock_prot_inuse_add);

@@ -1954,7 +1953,7 @@
int res = 0;

for_each_possible_cpu(cpu)
- res += per_cpu_ptr(net->core.inuse, cpu)->val[idx];
+ res += CPU_PTR(net->core.inuse, cpu)->val[idx];

return res >= 0 ? res : 0;
}
@@ -1962,13 +1961,13 @@

static int sock_inuse_init_net(struct net *net)
{
- net->core.inuse = alloc_percpu(struct prot_inuse);
+ net->core.inuse = CPU_ALLOC(struct prot_inuse, GFP_KERNEL|__GFP_ZERO);
return net->core.inuse ? 0 : -ENOMEM;
}

static void sock_inuse_exit_net(struct net *net)
{
- free_percpu(net->core.inuse);
+ CPU_FREE(net->core.inuse);
}

static struct pernet_operations net_inuse_ops = {

--