Message ID | 1275311580.3291.44.camel@edumazet-laptop |
---|---|
State | Not Applicable, archived |
Delegated to: | David Miller |
Headers | show |
On Monday 2010-05-31 15:13, Eric Dumazet wrote: > >All cpus share a single cache line for their 'stackptr' storage, >introduced in commit f3c5c1bfd4 > >This is a stable candidate (2.6.34) Stackptr was first introduced for 2.6.35-rcX. >+ i->stackptr = alloc_percpu(unsigned int); > if (i->stackptr == NULL) > return -ENOMEM; >- memset(i->stackptr, 0, size); > > size = sizeof(void **) * nr_cpu_ids; > if (size > PAGE_SIZE) Are alloc_percpu areas cleared? Acked-By: Jan Engelhardt <jengelh@medozas.de> -- To unsubscribe from this list: send the line "unsubscribe netdev" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Le lundi 31 mai 2010 à 15:22 +0200, Jan Engelhardt a écrit : > On Monday 2010-05-31 15:13, Eric Dumazet wrote: > > > >All cpus share a single cache line for their 'stackptr' storage, > >introduced in commit f3c5c1bfd4 > > > >This is a stable candidate (2.6.34) > > Stackptr was first introduced for 2.6.35-rcX. > Indeed, I was fooled by 'git describe' > >+ i->stackptr = alloc_percpu(unsigned int); > > if (i->stackptr == NULL) > > return -ENOMEM; > >- memset(i->stackptr, 0, size); > > > > size = sizeof(void **) * nr_cpu_ids; > > if (size > PAGE_SIZE) > > Are alloc_percpu areas cleared? > Yes, allocated chunks are cleared. -- To unsubscribe from this list: send the line "unsubscribe netdev" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
On Monday 2010-05-31 15:44, Eric Dumazet wrote: >Le lundi 31 mai 2010 à 15:22 +0200, Jan Engelhardt a écrit : >> On Monday 2010-05-31 15:13, Eric Dumazet wrote: >> > >> >All cpus share a single cache line for their 'stackptr' storage, >> >introduced in commit f3c5c1bfd4 >> > >> >This is a stable candidate (2.6.34) >> >> Stackptr was first introduced for 2.6.35-rcX. > >Indeed, I was fooled by 'git describe' Keep your friends close, and your enemies closer ;-) git describe --contains f3c5c1bfd -- To unsubscribe from this list: send the line "unsubscribe netdev" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Le lundi 31 mai 2010 à 16:09 +0200, Jan Engelhardt a écrit : > Keep your friends close, and your enemies closer ;-) > > git describe --contains f3c5c1bfd Yes, --contains should be the default, and --predates the option :) This is a bit OT anyway :) -- To unsubscribe from this list: send the line "unsubscribe netdev" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Jan Engelhardt wrote: > On Monday 2010-05-31 15:13, Eric Dumazet wrote: >> All cpus share a single cache line for their 'stackptr' storage, >> introduced in commit f3c5c1bfd4 >> >> This is a stable candidate (2.6.34) > > Stackptr was first introduced for 2.6.35-rcX. > >> + i->stackptr = alloc_percpu(unsigned int); >> if (i->stackptr == NULL) >> return -ENOMEM; >> - memset(i->stackptr, 0, size); >> >> size = sizeof(void **) * nr_cpu_ids; >> if (size > PAGE_SIZE) > > Are alloc_percpu areas cleared? > > Acked-By: Jan Engelhardt <jengelh@medozas.de> Applied, thanks. -- To unsubscribe from this list: send the line "unsubscribe netdev" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
diff --git a/include/linux/netfilter/x_tables.h b/include/linux/netfilter/x_tables.h index c00cc0c..24e5d01 100644 --- a/include/linux/netfilter/x_tables.h +++ b/include/linux/netfilter/x_tables.h @@ -397,7 +397,7 @@ struct xt_table_info { * @stacksize jumps (number of user chains) can possibly be made. */ unsigned int stacksize; - unsigned int *stackptr; + unsigned int __percpu *stackptr; void ***jumpstack; /* ipt_entry tables: one per CPU */ /* Note : this field MUST be the last one, see XT_TABLE_INFO_SZ */ diff --git a/net/ipv4/netfilter/ip_tables.c b/net/ipv4/netfilter/ip_tables.c index 63958f3..4b6c5ca 100644 --- a/net/ipv4/netfilter/ip_tables.c +++ b/net/ipv4/netfilter/ip_tables.c @@ -336,7 +336,7 @@ ipt_do_table(struct sk_buff *skb, cpu = smp_processor_id(); table_base = private->entries[cpu]; jumpstack = (struct ipt_entry **)private->jumpstack[cpu]; - stackptr = &private->stackptr[cpu]; + stackptr = per_cpu_ptr(private->stackptr, cpu); origptr = *stackptr; e = get_entry(table_base, private->hook_entry[hook]); diff --git a/net/ipv6/netfilter/ip6_tables.c b/net/ipv6/netfilter/ip6_tables.c index 6f517bd..9d2d68f 100644 --- a/net/ipv6/netfilter/ip6_tables.c +++ b/net/ipv6/netfilter/ip6_tables.c @@ -363,7 +363,7 @@ ip6t_do_table(struct sk_buff *skb, cpu = smp_processor_id(); table_base = private->entries[cpu]; jumpstack = (struct ip6t_entry **)private->jumpstack[cpu]; - stackptr = &private->stackptr[cpu]; + stackptr = per_cpu_ptr(private->stackptr, cpu); origptr = *stackptr; e = get_entry(table_base, private->hook_entry[hook]); diff --git a/net/netfilter/x_tables.c b/net/netfilter/x_tables.c index 445de70..7e8a93d 100644 --- a/net/netfilter/x_tables.c +++ b/net/netfilter/x_tables.c @@ -699,10 +699,8 @@ void xt_free_table_info(struct xt_table_info *info) vfree(info->jumpstack); else kfree(info->jumpstack); - if (sizeof(unsigned int) * nr_cpu_ids > PAGE_SIZE) - vfree(info->stackptr); - else - kfree(info->stackptr); + + free_percpu(info->stackptr); kfree(info); } @@ -753,14 +751,9 @@ static int xt_jumpstack_alloc(struct xt_table_info *i) unsigned int size; int cpu; - size = sizeof(unsigned int) * nr_cpu_ids; - if (size > PAGE_SIZE) - i->stackptr = vmalloc(size); - else - i->stackptr = kmalloc(size, GFP_KERNEL); + i->stackptr = alloc_percpu(unsigned int); if (i->stackptr == NULL) return -ENOMEM; - memset(i->stackptr, 0, size); size = sizeof(void **) * nr_cpu_ids; if (size > PAGE_SIZE)