* [PATCH net-next v2] bpf/tracing: fix kernel/events/core.c compilation error
@ 2017-12-13 18:35 Yonghong Song
2017-12-13 21:51 ` Daniel Borkmann
0 siblings, 1 reply; 2+ messages in thread
From: Yonghong Song @ 2017-12-13 18:35 UTC (permalink / raw)
To: ast, daniel, sfr, netdev; +Cc: kernel-team
Commit f371b304f12e ("bpf/tracing: allow user space to
query prog array on the same tp") introduced a perf
ioctl command to query prog array attached to the
same perf tracepoint. The commit introduced a
compilation error under certain config conditions, e.g.,
(1). CONFIG_BPF_SYSCALL is not defined, or
(2). CONFIG_TRACING is defined but neither CONFIG_UPROBE_EVENTS
nor CONFIG_KPROBE_EVENTS is defined.
Error message:
kernel/events/core.o: In function `perf_ioctl':
core.c:(.text+0x98c4): undefined reference to `bpf_event_query_prog_array'
This patch fixed this error by guarding the real definition under
CONFIG_BPF_EVENTS and provided static inline dummy function
if CONFIG_BPF_EVENTS was not defined.
It renamed the function from bpf_event_query_prog_array to
perf_event_query_prog_array and moved the definition from linux/bpf.h
to linux/trace_events.h so the definition is in proximity to
other prog_array related functions.
Fixes: f371b304f12e ("bpf/tracing: allow user space to query prog array on the same tp")
Reported-by: Stephen Rothwell <sfr@canb.auug.org.au>
Signed-off-by: Yonghong Song <yhs@fb.com>
---
include/linux/bpf.h | 1 -
include/linux/trace_events.h | 6 ++++++
kernel/events/core.c | 2 +-
kernel/trace/bpf_trace.c | 2 +-
4 files changed, 8 insertions(+), 3 deletions(-)
Changelog:
v1 -> v2:
. Updated the commit message
. Using CONFIG_BPF_EVENTS to guard the real definition
. Renamed the function and move the definition from linux/bpf.h
to linux/trace_events.h
diff --git a/include/linux/bpf.h b/include/linux/bpf.h
index 93e15b9..54dc7ca 100644
--- a/include/linux/bpf.h
+++ b/include/linux/bpf.h
@@ -254,7 +254,6 @@ typedef unsigned long (*bpf_ctx_copy_t)(void *dst, const void *src,
u64 bpf_event_output(struct bpf_map *map, u64 flags, void *meta, u64 meta_size,
void *ctx, u64 ctx_size, bpf_ctx_copy_t ctx_copy);
-int bpf_event_query_prog_array(struct perf_event *event, void __user *info);
int bpf_prog_test_run_xdp(struct bpf_prog *prog, const union bpf_attr *kattr,
union bpf_attr __user *uattr);
diff --git a/include/linux/trace_events.h b/include/linux/trace_events.h
index 5fea451..8a1442c 100644
--- a/include/linux/trace_events.h
+++ b/include/linux/trace_events.h
@@ -467,6 +467,7 @@ trace_trigger_soft_disabled(struct trace_event_file *file)
unsigned int trace_call_bpf(struct trace_event_call *call, void *ctx);
int perf_event_attach_bpf_prog(struct perf_event *event, struct bpf_prog *prog);
void perf_event_detach_bpf_prog(struct perf_event *event);
+int perf_event_query_prog_array(struct perf_event *event, void __user *info);
#else
static inline unsigned int trace_call_bpf(struct trace_event_call *call, void *ctx)
{
@@ -481,6 +482,11 @@ perf_event_attach_bpf_prog(struct perf_event *event, struct bpf_prog *prog)
static inline void perf_event_detach_bpf_prog(struct perf_event *event) { }
+static inline int
+perf_event_query_prog_array(struct perf_event *event, void __user *info)
+{
+ return -EOPNOTSUPP;
+}
#endif
enum {
diff --git a/kernel/events/core.c b/kernel/events/core.c
index 5857c500..34fda6a 100644
--- a/kernel/events/core.c
+++ b/kernel/events/core.c
@@ -4725,7 +4725,7 @@ static long _perf_ioctl(struct perf_event *event, unsigned int cmd, unsigned lon
}
case PERF_EVENT_IOC_QUERY_BPF:
- return bpf_event_query_prog_array(event, (void __user *)arg);
+ return perf_event_query_prog_array(event, (void __user *)arg);
default:
return -ENOTTY;
}
diff --git a/kernel/trace/bpf_trace.c b/kernel/trace/bpf_trace.c
index e009b7e..c5dd60c 100644
--- a/kernel/trace/bpf_trace.c
+++ b/kernel/trace/bpf_trace.c
@@ -856,7 +856,7 @@ void perf_event_detach_bpf_prog(struct perf_event *event)
mutex_unlock(&bpf_event_mutex);
}
-int bpf_event_query_prog_array(struct perf_event *event, void __user *info)
+int perf_event_query_prog_array(struct perf_event *event, void __user *info)
{
struct perf_event_query_bpf __user *uquery = info;
struct perf_event_query_bpf query = {};
--
2.9.5
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH net-next v2] bpf/tracing: fix kernel/events/core.c compilation error
2017-12-13 18:35 [PATCH net-next v2] bpf/tracing: fix kernel/events/core.c compilation error Yonghong Song
@ 2017-12-13 21:51 ` Daniel Borkmann
0 siblings, 0 replies; 2+ messages in thread
From: Daniel Borkmann @ 2017-12-13 21:51 UTC (permalink / raw)
To: Yonghong Song, ast, sfr, netdev; +Cc: kernel-team
On 12/13/2017 07:35 PM, Yonghong Song wrote:
> Commit f371b304f12e ("bpf/tracing: allow user space to
> query prog array on the same tp") introduced a perf
> ioctl command to query prog array attached to the
> same perf tracepoint. The commit introduced a
> compilation error under certain config conditions, e.g.,
> (1). CONFIG_BPF_SYSCALL is not defined, or
> (2). CONFIG_TRACING is defined but neither CONFIG_UPROBE_EVENTS
> nor CONFIG_KPROBE_EVENTS is defined.
>
> Error message:
> kernel/events/core.o: In function `perf_ioctl':
> core.c:(.text+0x98c4): undefined reference to `bpf_event_query_prog_array'
>
> This patch fixed this error by guarding the real definition under
> CONFIG_BPF_EVENTS and provided static inline dummy function
> if CONFIG_BPF_EVENTS was not defined.
> It renamed the function from bpf_event_query_prog_array to
> perf_event_query_prog_array and moved the definition from linux/bpf.h
> to linux/trace_events.h so the definition is in proximity to
> other prog_array related functions.
>
> Fixes: f371b304f12e ("bpf/tracing: allow user space to query prog array on the same tp")
> Reported-by: Stephen Rothwell <sfr@canb.auug.org.au>
> Signed-off-by: Yonghong Song <yhs@fb.com>
That's better, applied to bpf-next, thanks Yonghong!
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2017-12-13 21:52 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-12-13 18:35 [PATCH net-next v2] bpf/tracing: fix kernel/events/core.c compilation error Yonghong Song
2017-12-13 21:51 ` Daniel Borkmann
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.