Message ID | 20240528223643.1166776-1-namhyung@kernel.org (mailing list archive) |
---|---|
State | Superseded |
Delegated to: | BPF |
Headers | show |
Series | bpf: Allocate bpf_event_entry with node info | expand |
Hi Namhyung, kernel test robot noticed the following build errors: [auto build test ERROR on bpf-next/master] [also build test ERROR on bpf/master linus/master v6.10-rc1 next-20240528] [If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use '--base' as documented in https://git-scm.com/docs/git-format-patch#_base_tree_information] url: https://github.com/intel-lab-lkp/linux/commits/Namhyung-Kim/bpf-Allocate-bpf_event_entry-with-node-info/20240529-063828 base: https://git.kernel.org/pub/scm/linux/kernel/git/bpf/bpf-next.git master patch link: https://lore.kernel.org/r/20240528223643.1166776-1-namhyung%40kernel.org patch subject: [PATCH] bpf: Allocate bpf_event_entry with node info config: m68k-defconfig (https://download.01.org/0day-ci/archive/20240529/202405291415.6JlTkRMF-lkp@intel.com/config) compiler: m68k-linux-gcc (GCC) 13.2.0 reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20240529/202405291415.6JlTkRMF-lkp@intel.com/reproduce) If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags | Reported-by: kernel test robot <lkp@intel.com> | Closes: https://lore.kernel.org/oe-kbuild-all/202405291415.6JlTkRMF-lkp@intel.com/ All error/warnings (new ones prefixed by >>): kernel/bpf/arraymap.c: In function 'bpf_event_entry_gen': >> kernel/bpf/arraymap.c:1200:18: error: 'struct perf_event' has no member named 'cpu' 1200 | if (event->cpu >= 0) | ^~ In file included from ./arch/m68k/include/generated/asm/topology.h:1, from include/linux/topology.h:36, from include/linux/gfp.h:8, from include/linux/umh.h:4, from include/linux/kmod.h:9, from include/linux/module.h:17, from include/linux/bpf.h:20, from kernel/bpf/arraymap.c:5: kernel/bpf/arraymap.c:1201:36: error: 'cpu' undeclared (first use in this function) 1201 | node = cpu_to_node(cpu); | ^~~ include/asm-generic/topology.h:35:41: note: in definition of macro 'cpu_to_node' 35 | #define cpu_to_node(cpu) ((void)(cpu),0) | ^~~ kernel/bpf/arraymap.c:1201:36: note: each undeclared identifier is reported only once for each function it appears in 1201 | node = cpu_to_node(cpu); | ^~~ include/asm-generic/topology.h:35:41: note: in definition of macro 'cpu_to_node' 35 | #define cpu_to_node(cpu) ((void)(cpu),0) | ^~~ >> include/asm-generic/topology.h:35:45: warning: left-hand operand of comma expression has no effect [-Wunused-value] 35 | #define cpu_to_node(cpu) ((void)(cpu),0) | ^ kernel/bpf/arraymap.c:1201:24: note: in expansion of macro 'cpu_to_node' 1201 | node = cpu_to_node(cpu); | ^~~~~~~~~~~ vim +1200 kernel/bpf/arraymap.c 1192 1193 static struct bpf_event_entry *bpf_event_entry_gen(struct file *perf_file, 1194 struct file *map_file) 1195 { 1196 struct bpf_event_entry *ee; 1197 struct perf_event *event = perf_file->private_data; 1198 int node = -1; 1199 > 1200 if (event->cpu >= 0) 1201 node = cpu_to_node(cpu); 1202 1203 ee = kzalloc_node(sizeof(*ee), GFP_KERNEL, node); 1204 if (ee) { 1205 ee->event = event; 1206 ee->perf_file = perf_file; 1207 ee->map_file = map_file; 1208 } 1209 1210 return ee; 1211 } 1212
diff --git a/kernel/bpf/arraymap.c b/kernel/bpf/arraymap.c index feabc0193852..3f7718c261d7 100644 --- a/kernel/bpf/arraymap.c +++ b/kernel/bpf/arraymap.c @@ -1194,10 +1194,15 @@ static struct bpf_event_entry *bpf_event_entry_gen(struct file *perf_file, struct file *map_file) { struct bpf_event_entry *ee; + struct perf_event *event = perf_file->private_data; + int node = -1; - ee = kzalloc(sizeof(*ee), GFP_KERNEL); + if (event->cpu >= 0) + node = cpu_to_node(cpu); + + ee = kzalloc_node(sizeof(*ee), GFP_KERNEL, node); if (ee) { - ee->event = perf_file->private_data; + ee->event = event; ee->perf_file = perf_file; ee->map_file = map_file; }
It was reported that accessing perf_event map entry caused pretty high LLC misses in get_map_perf_counter(). As reading perf_event is allowed for the local CPU only, I think we can use the target CPU of the event as hint for the allocation like in perf_event_alloc() so that the event and the entry can be in the same node at least. Reported-by: Aleksei Shchekotikhin <alekseis@google.com> Reported-by: Nilay Vaish <nilayvaish@google.com> Signed-off-by: Namhyung Kim <namhyung@kernel.org> --- kernel/bpf/arraymap.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-)