* [PATCH][v2] xfrm: replace NR_CPU with nr_cpu_ids
@ 2018-06-19 7:11 Li RongQing
2018-06-19 7:48 ` Yunsheng Lin
2018-06-19 7:53 ` Florian Westphal
0 siblings, 2 replies; 5+ messages in thread
From: Li RongQing @ 2018-06-19 7:11 UTC (permalink / raw)
To: netdev, steffen.klassert
The default NR_CPUS can be very large, but actual possible nr_cpu_ids
usually is very small. For some x86 distribution, the NR_CPUS is 8192
and nr_cpu_ids is 4, so replace NR_CPU to save some memory
Signed-off-by: Li RongQing <lirongqing@baidu.com>
Signed-off-by: Wang Li <wangli39@baidu.com>
---
net/xfrm/xfrm_policy.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/net/xfrm/xfrm_policy.c b/net/xfrm/xfrm_policy.c
index 40b54cc64243..f8188685c1e9 100644
--- a/net/xfrm/xfrm_policy.c
+++ b/net/xfrm/xfrm_policy.c
@@ -2989,11 +2989,11 @@ void __init xfrm_init(void)
{
int i;
- xfrm_pcpu_work = kmalloc_array(NR_CPUS, sizeof(*xfrm_pcpu_work),
+ xfrm_pcpu_work = kmalloc_array(nr_cpu_ids, sizeof(*xfrm_pcpu_work),
GFP_KERNEL);
BUG_ON(!xfrm_pcpu_work);
- for (i = 0; i < NR_CPUS; i++)
+ for (i = 0; i < nr_cpu_ids; i++)
INIT_WORK(&xfrm_pcpu_work[i], xfrm_pcpu_work_fn);
register_pernet_subsys(&xfrm_net_ops);
--
2.16.2
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH][v2] xfrm: replace NR_CPU with nr_cpu_ids
2018-06-19 7:11 [PATCH][v2] xfrm: replace NR_CPU with nr_cpu_ids Li RongQing
@ 2018-06-19 7:48 ` Yunsheng Lin
2018-06-19 7:53 ` Florian Westphal
1 sibling, 0 replies; 5+ messages in thread
From: Yunsheng Lin @ 2018-06-19 7:48 UTC (permalink / raw)
To: Li RongQing, netdev, steffen.klassert
On 2018/6/19 15:11, Li RongQing wrote:
> The default NR_CPUS can be very large, but actual possible nr_cpu_ids
> usually is very small. For some x86 distribution, the NR_CPUS is 8192
> and nr_cpu_ids is 4, so replace NR_CPU to save some memory
>
> Signed-off-by: Li RongQing <lirongqing@baidu.com>
> Signed-off-by: Wang Li <wangli39@baidu.com>
> ---
> net/xfrm/xfrm_policy.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/net/xfrm/xfrm_policy.c b/net/xfrm/xfrm_policy.c
> index 40b54cc64243..f8188685c1e9 100644
> --- a/net/xfrm/xfrm_policy.c
> +++ b/net/xfrm/xfrm_policy.c
> @@ -2989,11 +2989,11 @@ void __init xfrm_init(void)
> {
> int i;
>
> - xfrm_pcpu_work = kmalloc_array(NR_CPUS, sizeof(*xfrm_pcpu_work),
> + xfrm_pcpu_work = kmalloc_array(nr_cpu_ids, sizeof(*xfrm_pcpu_work),
> GFP_KERNEL);
It seems that xfrm_pcpu_work is not used anymore, maybe it can be deleted to
save more memory.
> BUG_ON(!xfrm_pcpu_work);
>
> - for (i = 0; i < NR_CPUS; i++)
> + for (i = 0; i < nr_cpu_ids; i++)
> INIT_WORK(&xfrm_pcpu_work[i], xfrm_pcpu_work_fn);
>
> register_pernet_subsys(&xfrm_net_ops);
>
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH][v2] xfrm: replace NR_CPU with nr_cpu_ids
2018-06-19 7:11 [PATCH][v2] xfrm: replace NR_CPU with nr_cpu_ids Li RongQing
2018-06-19 7:48 ` Yunsheng Lin
@ 2018-06-19 7:53 ` Florian Westphal
2018-06-19 12:17 ` Steffen Klassert
1 sibling, 1 reply; 5+ messages in thread
From: Florian Westphal @ 2018-06-19 7:53 UTC (permalink / raw)
To: Li RongQing; +Cc: netdev, steffen.klassert
Li RongQing <lirongqing@baidu.com> wrote:
> The default NR_CPUS can be very large, but actual possible nr_cpu_ids
> usually is very small. For some x86 distribution, the NR_CPUS is 8192
> and nr_cpu_ids is 4, so replace NR_CPU to save some memory
Steffen,
I will soon submit a patch to remove the percpu cache; removal
improved performance for at least one user (and by quite a sizeable
amount).
Would you consider such removal for ipsec or ipsec-next?
If -next, consider applying this patch for ipsec.git.
Otherwise consider not applying this, as the code will go away soon.
Thanks,
Florian
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH][v2] xfrm: replace NR_CPU with nr_cpu_ids
2018-06-19 7:53 ` Florian Westphal
@ 2018-06-19 12:17 ` Steffen Klassert
2018-06-20 9:55 ` Florian Westphal
0 siblings, 1 reply; 5+ messages in thread
From: Steffen Klassert @ 2018-06-19 12:17 UTC (permalink / raw)
To: Florian Westphal; +Cc: Li RongQing, netdev
On Tue, Jun 19, 2018 at 09:53:49AM +0200, Florian Westphal wrote:
> Li RongQing <lirongqing@baidu.com> wrote:
> > The default NR_CPUS can be very large, but actual possible nr_cpu_ids
> > usually is very small. For some x86 distribution, the NR_CPUS is 8192
> > and nr_cpu_ids is 4, so replace NR_CPU to save some memory
>
> Steffen,
>
> I will soon submit a patch to remove the percpu cache; removal
> improved performance for at least one user (and by quite a sizeable
> amount).
>
> Would you consider such removal for ipsec or ipsec-next?
I think this removel would better fit to ipsec-next.
> If -next, consider applying this patch for ipsec.git.
>
> Otherwise consider not applying this, as the code will go away soon.
This patch more an optimization than a fix, so I
considered to apply it to ipsec-next. If you plan
to remove it, I'll wait for that.
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH][v2] xfrm: replace NR_CPU with nr_cpu_ids
2018-06-19 12:17 ` Steffen Klassert
@ 2018-06-20 9:55 ` Florian Westphal
0 siblings, 0 replies; 5+ messages in thread
From: Florian Westphal @ 2018-06-20 9:55 UTC (permalink / raw)
To: Steffen Klassert; +Cc: Florian Westphal, Li RongQing, netdev
Steffen Klassert <steffen.klassert@secunet.com> wrote:
> On Tue, Jun 19, 2018 at 09:53:49AM +0200, Florian Westphal wrote:
> > Li RongQing <lirongqing@baidu.com> wrote:
> > > The default NR_CPUS can be very large, but actual possible nr_cpu_ids
> > > usually is very small. For some x86 distribution, the NR_CPUS is 8192
> > > and nr_cpu_ids is 4, so replace NR_CPU to save some memory
> >
> > Steffen,
> >
> > I will soon submit a patch to remove the percpu cache; removal
> > improved performance for at least one user (and by quite a sizeable
> > amount).
> >
> > Would you consider such removal for ipsec or ipsec-next?
>
> I think this removel would better fit to ipsec-next.
Agree, it slows things down further for me in my tests.
Problem is that I get quite good re-use of pcpu cache due to
unidirectional flows and only one tunnel.
I suspect that even with tunnel the removal is a win in practice
though, netperf is quite artifical, so I rather trust Kristians results
(real world) than my own.
> considered to apply it to ipsec-next. If you plan
> to remove it, I'll wait for that.
I'll submit once net-next opens.
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2018-06-20 9:55 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-06-19 7:11 [PATCH][v2] xfrm: replace NR_CPU with nr_cpu_ids Li RongQing
2018-06-19 7:48 ` Yunsheng Lin
2018-06-19 7:53 ` Florian Westphal
2018-06-19 12:17 ` Steffen Klassert
2018-06-20 9:55 ` Florian Westphal
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.