Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1354820

[PATCH] bpf: make bpf_stackmap_copy conditionally called

From Arnd Bergmann <arnd@arndb.de>
Newsgroups linux.kernel
Subject [PATCH] bpf: make bpf_stackmap_copy conditionally called
Date 2016-03-10 04:30 +0100
Message-ID <raZst-Vy-5@gated-at.bofh.it> (permalink)
Organization linux.* mail to news gateway

Show all headers | View raw


Changing the bpf syscall to use the new bpf_stackmap_copy() helper for
BPF_MAP_TYPE_STACK_TRACE causes a link error when CONFIG_PERF_EVENTS
is disabled:

kernel/built-in.o: In function `map_lookup_elem':
:(.text+0x7fca4): undefined reference to `bpf_stackmap_copy'

This patch simply avoids handling that case, which may or may not
be the correct answer here.

Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Fixes: 557c0c6e7df8 ("bpf: convert stackmap to pre-allocation")
---
 kernel/bpf/syscall.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/kernel/bpf/syscall.c b/kernel/bpf/syscall.c
index 2978d0d08869..b014b64b6116 100644
--- a/kernel/bpf/syscall.c
+++ b/kernel/bpf/syscall.c
@@ -290,7 +290,8 @@ static int map_lookup_elem(union bpf_attr *attr)
 		err = bpf_percpu_hash_copy(map, key, value);
 	} else if (map->map_type == BPF_MAP_TYPE_PERCPU_ARRAY) {
 		err = bpf_percpu_array_copy(map, key, value);
-	} else if (map->map_type == BPF_MAP_TYPE_STACK_TRACE) {
+	} else if (map->map_type == BPF_MAP_TYPE_STACK_TRACE &&
+		   IS_ENABLED(CONFIG_PERF_EVENTS)) {
 		err = bpf_stackmap_copy(map, key, value);
 	} else {
 		rcu_read_lock();
-- 
2.7.0

Back to linux.kernel | Previous | Next — Next in thread | Find similar | Unroll thread


Thread

[PATCH] bpf: make bpf_stackmap_copy conditionally called Arnd Bergmann <arnd@arndb.de> - 2016-03-10 04:30 +0100
  Re: [PATCH] bpf: make bpf_stackmap_copy conditionally called Alexei Starovoitov <alexei.starovoitov@gmail.com> - 2016-03-10 04:40 +0100
    Re: [PATCH] bpf: make bpf_stackmap_copy conditionally called Arnd Bergmann <arnd@arndb.de> - 2016-03-10 10:20 +0100

csiph-web