linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] libbpf: Use the correct fd when attaching to perf events
@ 2021-03-12 21:43 Sultan Alsawaf
  2021-03-13  1:31 ` Andrii Nakryiko
  0 siblings, 1 reply; 6+ messages in thread
From: Sultan Alsawaf @ 2021-03-12 21:43 UTC (permalink / raw)
  Cc: Sultan Alsawaf, Alexei Starovoitov, Daniel Borkmann,
	Andrii Nakryiko, Martin KaFai Lau, Song Liu, Yonghong Song,
	John Fastabend, KP Singh, Stanislav Fomichev, netdev, bpf,
	linux-kernel

From: Sultan Alsawaf <sultan@kerneltoast.com>

We should be using the program fd here, not the perf event fd.

Fixes: 63f2f5ee856ba ("libbpf: add ability to attach/detach BPF program to perf event")
Signed-off-by: Sultan Alsawaf <sultan@kerneltoast.com>
---
 tools/lib/bpf/libbpf.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/lib/bpf/libbpf.c b/tools/lib/bpf/libbpf.c
index d43cc3f29dae..3d20d57d4af5 100644
--- a/tools/lib/bpf/libbpf.c
+++ b/tools/lib/bpf/libbpf.c
@@ -9538,7 +9538,7 @@ struct bpf_link *bpf_program__attach_perf_event(struct bpf_program *prog,
 	if (!link)
 		return ERR_PTR(-ENOMEM);
 	link->detach = &bpf_link__detach_perf_event;
-	link->fd = pfd;
+	link->fd = prog_fd;
 
 	if (ioctl(pfd, PERF_EVENT_IOC_SET_BPF, prog_fd) < 0) {
 		err = -errno;
-- 
2.30.2


^ permalink raw reply related	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2021-03-13  2:51 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-03-12 21:43 [PATCH] libbpf: Use the correct fd when attaching to perf events Sultan Alsawaf
2021-03-13  1:31 ` Andrii Nakryiko
2021-03-13  2:22   ` Sultan Alsawaf
2021-03-13  2:33     ` Andrii Nakryiko
2021-03-13  2:43       ` Sultan Alsawaf
2021-03-13  2:50         ` Andrii Nakryiko

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).