Commit 8dbde28d authored by Eric Dumazet's avatar Eric Dumazet Committed by David S. Miller

[NET]: NET_CLS_ROUTE : convert ip_rt_acct to per_cpu variables

ip_rt_acct needs 4096 bytes per cpu to perform some accounting.
It is actually allocated as a single huge array [4096*NR_CPUS]
(rounded up to a power of two)

Converting it to a per cpu variable is wanted to :
 - Save space on machines were num_possible_cpus() < NR_CPUS
 - Better NUMA placement (each cpu gets memory on its node)
Signed-off-by: default avatarEric Dumazet <dada1@cosmosbay.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 68f8353b
...@@ -347,7 +347,7 @@ static int ip_rcv_finish(struct sk_buff *skb) ...@@ -347,7 +347,7 @@ static int ip_rcv_finish(struct sk_buff *skb)
#ifdef CONFIG_NET_CLS_ROUTE #ifdef CONFIG_NET_CLS_ROUTE
if (unlikely(skb->dst->tclassid)) { if (unlikely(skb->dst->tclassid)) {
struct ip_rt_acct *st = ip_rt_acct + 256*smp_processor_id(); struct ip_rt_acct *st = per_cpu_ptr(ip_rt_acct, smp_processor_id());
u32 idx = skb->dst->tclassid; u32 idx = skb->dst->tclassid;
st[idx&0xFF].o_packets++; st[idx&0xFF].o_packets++;
st[idx&0xFF].o_bytes+=skb->len; st[idx&0xFF].o_bytes+=skb->len;
......
...@@ -2858,12 +2858,10 @@ ctl_table ipv4_route_table[] = { ...@@ -2858,12 +2858,10 @@ ctl_table ipv4_route_table[] = {
#endif #endif
#ifdef CONFIG_NET_CLS_ROUTE #ifdef CONFIG_NET_CLS_ROUTE
struct ip_rt_acct *ip_rt_acct; struct ip_rt_acct *ip_rt_acct __read_mostly;
/* This code sucks. But you should have seen it before! --RR */
/* IP route accounting ptr for this logical cpu number. */ /* IP route accounting ptr for this logical cpu number. */
#define IP_RT_ACCT_CPU(i) (ip_rt_acct + i * 256) #define IP_RT_ACCT_CPU(cpu) (per_cpu_ptr(ip_rt_acct, cpu))
#ifdef CONFIG_PROC_FS #ifdef CONFIG_PROC_FS
static int ip_rt_acct_read(char *buffer, char **start, off_t offset, static int ip_rt_acct_read(char *buffer, char **start, off_t offset,
...@@ -2923,16 +2921,9 @@ int __init ip_rt_init(void) ...@@ -2923,16 +2921,9 @@ int __init ip_rt_init(void)
(jiffies ^ (jiffies >> 7))); (jiffies ^ (jiffies >> 7)));
#ifdef CONFIG_NET_CLS_ROUTE #ifdef CONFIG_NET_CLS_ROUTE
{ ip_rt_acct = __alloc_percpu(256 * sizeof(struct ip_rt_acct));
int order;
for (order = 0;
(PAGE_SIZE << order) < 256 * sizeof(struct ip_rt_acct) * NR_CPUS; order++)
/* NOTHING */;
ip_rt_acct = (struct ip_rt_acct *)__get_free_pages(GFP_KERNEL, order);
if (!ip_rt_acct) if (!ip_rt_acct)
panic("IP: failed to allocate ip_rt_acct\n"); panic("IP: failed to allocate ip_rt_acct\n");
memset(ip_rt_acct, 0, PAGE_SIZE << order);
}
#endif #endif
ipv4_dst_ops.kmem_cachep = ipv4_dst_ops.kmem_cachep =
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment