[PATCH] bpf: Avoid allocing memory on memoryless numa node
From: Xianting Tian <hidden>
Date: 2020-10-10 09:02:31
Subsystems: bpf [general] (safe dynamic programs and tools), the rest, xdp (express data path) · Maintainers: Alexei Starovoitov, Daniel Borkmann, Andrii Nakryiko, Eduard Zingerman, Kumar Kartikeya Dwivedi, Linus Torvalds, David S. Miller, Jakub Kicinski, Jesper Dangaard Brouer, John Fastabend
3 messages, 2 authors, 2020-10-12 · open the first message on its own page
From: Xianting Tian <hidden>
Date: 2020-10-10 09:02:31
In architecture like powerpc, we can have cpus without any local memory attached to it. In such cases the node does not have real memory. Use local_memory_node(), which is guaranteed to have memory. local_memory_node is a noop in other architectures that does not support memoryless nodes. Signed-off-by: Xianting Tian <redacted> --- kernel/bpf/cpumap.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/kernel/bpf/cpumap.c b/kernel/bpf/cpumap.c
index 6386b7bb9..2c885c00a 100644
--- a/kernel/bpf/cpumap.c
+++ b/kernel/bpf/cpumap.c@@ -423,7 +423,7 @@ __cpu_map_entry_alloc(struct bpf_cpumap_val *value, u32 cpu, int map_id) struct xdp_bulk_queue *bq; /* Have map->numa_node, but choose node of redirect target CPU */ - numa = cpu_to_node(cpu); + numa = local_memory_node(cpu_to_node(cpu)); rcpu = kzalloc_node(sizeof(*rcpu), gfp, numa); if (!rcpu)
--
2.17.1
From: Alexei Starovoitov <hidden>
Date: 2020-10-12 01:21:23
On Sat, Oct 10, 2020 at 1:55 AM Xianting Tian [off-list ref] wrote:
In architecture like powerpc, we can have cpus without any local memory attached to it. In such cases the node does not have real memory. Use local_memory_node(), which is guaranteed to have memory. local_memory_node is a noop in other architectures that does not support memoryless nodes.
...
/* Have map->numa_node, but choose node of redirect target CPU */ - numa = cpu_to_node(cpu); + numa = local_memory_node(cpu_to_node(cpu));
There are so many calls to cpu_to_node() throughout the kernel. Are you going to convert all of them one patch at a time to the above sequence? Why not do this CONFIG_HAVE_MEMORYLESS_NODES in cpu_to_node() instead? and save the churn.
From: Tianxianting <hidden>
Date: 2020-10-12 01:26:56
Thanks Alexei for your suggestion, I will try to do it. -----Original Message----- From: Alexei Starovoitov [mailto:<redacted>] Sent: Monday, October 12, 2020 9:21 AM To: tianxianting (RD) <redacted> Cc: Alexei Starovoitov <ast@kernel.org>; Daniel Borkmann <daniel@iogearbox.net>; David S. Miller <davem@davemloft.net>; Jakub Kicinski <kuba@kernel.org>; Jesper Dangaard Brouer <hawk@kernel.org>; John Fastabend <john.fastabend@gmail.com>; Martin KaFai Lau <redacted>; Song Liu <redacted>; Yonghong Song <redacted>; Andrii Nakryiko <redacted>; KP Singh <redacted>; Network Development <redacted>; bpf <redacted>; LKML <redacted> Subject: Re: [PATCH] bpf: Avoid allocing memory on memoryless numa node On Sat, Oct 10, 2020 at 1:55 AM Xianting Tian [off-list ref] wrote:
In architecture like powerpc, we can have cpus without any local memory attached to it. In such cases the node does not have real memory. Use local_memory_node(), which is guaranteed to have memory. local_memory_node is a noop in other architectures that does not support memoryless nodes.
...
/* Have map->numa_node, but choose node of redirect target CPU */ - numa = cpu_to_node(cpu); + numa = local_memory_node(cpu_to_node(cpu));
There are so many calls to cpu_to_node() throughout the kernel. Are you going to convert all of them one patch at a time to the above sequence? Why not do this CONFIG_HAVE_MEMORYLESS_NODES in cpu_to_node() instead? and save the churn.