netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Daniel T. Lee" <danieltimlee@gmail.com>
To: Daniel Borkmann <daniel@iogearbox.net>,
	Alexei Starovoitov <ast@kernel.org>,
	Andrii Nakryiko <andrii.nakryiko@gmail.com>
Cc: Martin KaFai Lau <martin.lau@linux.dev>,
	Eduard Zingerman <eddyz87@gmail.com>, Song Liu <song@kernel.org>,
	Yonghong Song <yonghong.song@linux.dev>,
	John Fastabend <john.fastabend@gmail.com>,
	KP Singh <kpsingh@kernel.org>,
	Stanislav Fomichev <sdf@fomichev.me>, Hao Luo <haoluo@google.com>,
	Jiri Olsa <jolsa@kernel.org>, Mykola Lysenko <mykolal@fb.com>,
	Shuah Khan <shuah@kernel.org>, Yipeng Zou <zouyipeng@huawei.com>,
	linux-kselftest@vger.kernel.org, bpf@vger.kernel.org,
	netdev@vger.kernel.org
Subject: [bpf-next 1/3] selftests/bpf: migrate tracepoint overhead test to prog_tests
Date: Mon, 12 Aug 2024 00:45:01 +0000	[thread overview]
Message-ID: <20240812004503.43206-2-danieltimlee@gmail.com> (raw)
In-Reply-To: <20240812004503.43206-1-danieltimlee@gmail.com>

As part of the cleanup of outdated test cases in sample/bpf, this
commit migrates test for tracepoint overhead to selftest prog_tests.

The test_overhead in selftest/bpf focus on the 'raw_tracepoint' only,
and do not cover tracepoint-specific tests. To support this, this
commit utilize 'vmlinux.h', and additional test program for tracepoint
has been added.

Signed-off-by: Daniel T. Lee <danieltimlee@gmail.com>
---
 .../selftests/bpf/prog_tests/test_overhead.c       | 14 +++++++++++++-
 tools/testing/selftests/bpf/progs/test_overhead.c  | 11 +++++++----
 2 files changed, 20 insertions(+), 5 deletions(-)

diff --git a/tools/testing/selftests/bpf/prog_tests/test_overhead.c b/tools/testing/selftests/bpf/prog_tests/test_overhead.c
index f27013e38d03..06153602a859 100644
--- a/tools/testing/selftests/bpf/prog_tests/test_overhead.c
+++ b/tools/testing/selftests/bpf/prog_tests/test_overhead.c
@@ -61,9 +61,10 @@ void test_test_overhead(void)
 	const char *raw_tp_name = "prog3";
 	const char *fentry_name = "prog4";
 	const char *fexit_name = "prog5";
+	const char *tp_name = "prog6";
 	const char *kprobe_func = "__set_task_comm";
 	struct bpf_program *kprobe_prog, *kretprobe_prog, *raw_tp_prog;
-	struct bpf_program *fentry_prog, *fexit_prog;
+	struct bpf_program *fentry_prog, *fexit_prog, *tp_prog;
 	struct bpf_object *obj;
 	struct bpf_link *link;
 	int err, duration = 0;
@@ -96,6 +97,10 @@ void test_test_overhead(void)
 	if (CHECK(!fexit_prog, "find_probe",
 		  "prog '%s' not found\n", fexit_name))
 		goto cleanup;
+	tp_prog = bpf_object__find_program_by_name(obj, tp_name);
+	if (CHECK(!tp_prog, "find_probe",
+		  "prog '%s' not found\n", tp_name))
+		goto cleanup;
 	err = bpf_object__load(obj);
 	if (CHECK(err, "obj_load", "err %d\n", err))
 		goto cleanup;
@@ -142,6 +147,13 @@ void test_test_overhead(void)
 	test_run("fexit");
 	bpf_link__destroy(link);
 
+	/* attach tp */
+	link = bpf_program__attach_tracepoint(tp_prog, "task", "task_rename");
+	if (!ASSERT_OK_PTR(link, "attach_tp"))
+		goto cleanup;
+	test_run("tp");
+	bpf_link__destroy(link);
+
 cleanup:
 	prctl(PR_SET_NAME, comm, 0L, 0L, 0L);
 	bpf_object__close(obj);
diff --git a/tools/testing/selftests/bpf/progs/test_overhead.c b/tools/testing/selftests/bpf/progs/test_overhead.c
index abb7344b531f..6dc1f68180e0 100644
--- a/tools/testing/selftests/bpf/progs/test_overhead.c
+++ b/tools/testing/selftests/bpf/progs/test_overhead.c
@@ -1,9 +1,6 @@
 // SPDX-License-Identifier: GPL-2.0
 /* Copyright (c) 2019 Facebook */
-#include <stdbool.h>
-#include <stddef.h>
-#include <linux/bpf.h>
-#include <linux/ptrace.h>
+#include "vmlinux.h"
 #include <bpf/bpf_helpers.h>
 #include <bpf/bpf_tracing.h>
 
@@ -39,4 +36,10 @@ int BPF_PROG(prog5, struct task_struct *tsk, const char *buf, bool exec)
 	return 0;
 }
 
+SEC("tracepoint/task/task_rename")
+int prog6(struct trace_event_raw_task_rename *ctx)
+{
+	return 0;
+}
+
 char _license[] SEC("license") = "GPL";
-- 
2.43.0


  reply	other threads:[~2024-08-12  0:45 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-08-12  0:45 [bpf-next 0/3] samples/bpf: Remove obsolete tracing-related tests Daniel T. Lee
2024-08-12  0:45 ` Daniel T. Lee [this message]
2024-08-12 11:11   ` [bpf-next 1/3] selftests/bpf: migrate tracepoint overhead test to prog_tests Jiri Olsa
2024-08-12  0:45 ` [bpf-next 2/3] selftests/bpf: add rename tracepoint bench test Daniel T. Lee
2024-08-12 11:12   ` Jiri Olsa
2024-08-12  0:45 ` [bpf-next 3/3] samples/bpf: remove obsolete tracing related tests Daniel T. Lee
2024-08-12 21:17 ` [bpf-next 0/3] samples/bpf: Remove obsolete tracing-related tests Andrii Nakryiko
2024-08-13 17:39   ` Daniel T. Lee

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20240812004503.43206-2-danieltimlee@gmail.com \
    --to=danieltimlee@gmail.com \
    --cc=andrii.nakryiko@gmail.com \
    --cc=ast@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=daniel@iogearbox.net \
    --cc=eddyz87@gmail.com \
    --cc=haoluo@google.com \
    --cc=john.fastabend@gmail.com \
    --cc=jolsa@kernel.org \
    --cc=kpsingh@kernel.org \
    --cc=linux-kselftest@vger.kernel.org \
    --cc=martin.lau@linux.dev \
    --cc=mykolal@fb.com \
    --cc=netdev@vger.kernel.org \
    --cc=sdf@fomichev.me \
    --cc=shuah@kernel.org \
    --cc=song@kernel.org \
    --cc=yonghong.song@linux.dev \
    --cc=zouyipeng@huawei.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).