diff mbox series

bpf: Allocate bpf_event_entry with node info

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

Checks

Context Check Description
bpf/vmtest-bpf-next-PR fail PR summary
netdev/series_format warning Single patches do not need cover letters; Target tree name not specified in the subject
netdev/tree_selection success Guessed tree name to be net-next
netdev/ynl success Generated files up to date; no warnings/errors; no diff in generated;
netdev/fixes_present success Fixes tag not required for -next series
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit fail Errors and warnings before: 907 this patch: 16
netdev/build_tools success No tools touched, skip
netdev/cc_maintainers success CCed 13 of 13 maintainers
netdev/build_clang fail Errors and warnings before: 906 this patch: 16
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/deprecated_api success None detected
netdev/check_selftest success No net selftest shell script
netdev/verify_fixes success No Fixes tag
netdev/build_allmodconfig_warn fail Errors and warnings before: 911 this patch: 15
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 17 lines checked
netdev/build_clang_rust success No Rust files in patch. Skipping build
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0
bpf/vmtest-bpf-next-VM_Test-4 fail Logs for aarch64-gcc / build / build for aarch64 with gcc
bpf/vmtest-bpf-next-VM_Test-2 success Logs for Unittests
bpf/vmtest-bpf-next-VM_Test-3 success Logs for Validate matrix.py
bpf/vmtest-bpf-next-VM_Test-9 success Logs for s390x-gcc / build-release
bpf/vmtest-bpf-next-VM_Test-1 success Logs for ShellCheck
bpf/vmtest-bpf-next-VM_Test-5 success Logs for aarch64-gcc / build-release
bpf/vmtest-bpf-next-VM_Test-7 success Logs for aarch64-gcc / veristat
bpf/vmtest-bpf-next-VM_Test-6 success Logs for aarch64-gcc / test
bpf/vmtest-bpf-next-VM_Test-0 success Logs for Lint
bpf/vmtest-bpf-next-VM_Test-22 fail Logs for x86_64-llvm-18 / build-release / build for x86_64 with llvm-18 and -O2 optimization
bpf/vmtest-bpf-next-VM_Test-18 fail Logs for x86_64-llvm-17 / build-release / build for x86_64 with llvm-17 and -O2 optimization
bpf/vmtest-bpf-next-VM_Test-13 fail Logs for x86_64-gcc / build / build for x86_64 with gcc
bpf/vmtest-bpf-next-VM_Test-8 fail Logs for s390x-gcc / build / build for s390x with gcc
bpf/vmtest-bpf-next-VM_Test-11 success Logs for s390x-gcc / veristat
bpf/vmtest-bpf-next-VM_Test-21 fail Logs for x86_64-llvm-18 / build / build for x86_64 with llvm-18
bpf/vmtest-bpf-next-VM_Test-12 success Logs for set-matrix
bpf/vmtest-bpf-next-VM_Test-23 success Logs for x86_64-llvm-18 / test
bpf/vmtest-bpf-next-VM_Test-15 success Logs for x86_64-gcc / test
bpf/vmtest-bpf-next-VM_Test-17 fail Logs for x86_64-llvm-17 / build / build for x86_64 with llvm-17
bpf/vmtest-bpf-next-VM_Test-19 success Logs for x86_64-llvm-17 / test
bpf/vmtest-bpf-next-VM_Test-10 success Logs for s390x-gcc / test
bpf/vmtest-bpf-next-VM_Test-14 success Logs for x86_64-gcc / build-release
bpf/vmtest-bpf-next-VM_Test-16 success Logs for x86_64-gcc / veristat
bpf/vmtest-bpf-next-VM_Test-24 success Logs for x86_64-llvm-18 / veristat
bpf/vmtest-bpf-next-VM_Test-20 success Logs for x86_64-llvm-17 / veristat

Commit Message

Namhyung Kim May 28, 2024, 10:36 p.m. UTC
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(-)

Comments

kernel test robot May 29, 2024, 6:29 a.m. UTC | #1
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 mbox series

Patch

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;
 	}