RE: [PATCH] bpf: Avoid allocing memory on memoryless numa node

From: Tianxianting
Date: Sun Oct 11 2020 - 21:26:56 EST


Thanks Alexei for your suggestion,
I will try to do it.

-----Original Message-----
From: Alexei Starovoitov [mailto:alexei.starovoitov@xxxxxxxxx]
Sent: Monday, October 12, 2020 9:21 AM
To: tianxianting (RD) <tian.xianting@xxxxxxx>
Cc: Alexei Starovoitov <ast@xxxxxxxxxx>; Daniel Borkmann <daniel@xxxxxxxxxxxxx>; David S. Miller <davem@xxxxxxxxxxxxx>; Jakub Kicinski <kuba@xxxxxxxxxx>; Jesper Dangaard Brouer <hawk@xxxxxxxxxx>; John Fastabend <john.fastabend@xxxxxxxxx>; Martin KaFai Lau <kafai@xxxxxx>; Song Liu <songliubraving@xxxxxx>; Yonghong Song <yhs@xxxxxx>; Andrii Nakryiko <andriin@xxxxxx>; KP Singh <kpsingh@xxxxxxxxxxxx>; Network Development <netdev@xxxxxxxxxxxxxxx>; bpf <bpf@xxxxxxxxxxxxxxx>; LKML <linux-kernel@xxxxxxxxxxxxxxx>
Subject: Re: [PATCH] bpf: Avoid allocing memory on memoryless numa node

On Sat, Oct 10, 2020 at 1:55 AM Xianting Tian <tian.xianting@xxxxxxx> 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.