All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH bpf-next] selftests/bpf: restore original comm in test_overhead
@ 2020-01-08 19:21 Stanislav Fomichev
  2020-01-08 23:18 ` Petar Penkov
  2020-01-09 16:43 ` Alexei Starovoitov
  0 siblings, 2 replies; 4+ messages in thread
From: Stanislav Fomichev @ 2020-01-08 19:21 UTC (permalink / raw)
  To: netdev, bpf; +Cc: davem, ast, daniel, Stanislav Fomichev

test_overhead changes task comm in order to estimate BPF trampoline
overhead but never sets the comm back to the original one.
We have the tests (like core_reloc.c) that have 'test_progs'
as hard-coded expected comm, so let's try to preserve the
original comm.

Currently, everything works because the order of execution is:
first core_recloc, then test_overhead; but let's make it a bit
future-proof.

Other related changes: use 'test_overhead' as new comm instead of
'test' to make it easy to debug and drop '\n' at the end.

Signed-off-by: Stanislav Fomichev <sdf@google.com>
---
 tools/testing/selftests/bpf/prog_tests/test_overhead.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/tools/testing/selftests/bpf/prog_tests/test_overhead.c b/tools/testing/selftests/bpf/prog_tests/test_overhead.c
index c32aa28bd93f..465b371a561d 100644
--- a/tools/testing/selftests/bpf/prog_tests/test_overhead.c
+++ b/tools/testing/selftests/bpf/prog_tests/test_overhead.c
@@ -2,6 +2,7 @@
 /* Copyright (c) 2019 Facebook */
 #define _GNU_SOURCE
 #include <sched.h>
+#include <sys/prctl.h>
 #include <test_progs.h>
 
 #define MAX_CNT 100000
@@ -17,7 +18,7 @@ static __u64 time_get_ns(void)
 static int test_task_rename(const char *prog)
 {
 	int i, fd, duration = 0, err;
-	char buf[] = "test\n";
+	char buf[] = "test_overhead";
 	__u64 start_time;
 
 	fd = open("/proc/self/comm", O_WRONLY|O_TRUNC);
@@ -66,6 +67,10 @@ void test_test_overhead(void)
 	struct bpf_object *obj;
 	struct bpf_link *link;
 	int err, duration = 0;
+	char comm[16] = {};
+
+	if (CHECK_FAIL(prctl(PR_GET_NAME, comm, 0L, 0L, 0L)))
+		return;
 
 	obj = bpf_object__open_file("./test_overhead.o", NULL);
 	if (CHECK(IS_ERR(obj), "obj_open_file", "err %ld\n", PTR_ERR(obj)))
@@ -138,5 +143,6 @@ void test_test_overhead(void)
 	test_run("fexit");
 	bpf_link__destroy(link);
 cleanup:
+	prctl(PR_SET_NAME, comm, 0L, 0L, 0L);
 	bpf_object__close(obj);
 }
-- 
2.24.1.735.g03f4e72817-goog


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

* Re: [PATCH bpf-next] selftests/bpf: restore original comm in test_overhead
  2020-01-08 19:21 [PATCH bpf-next] selftests/bpf: restore original comm in test_overhead Stanislav Fomichev
@ 2020-01-08 23:18 ` Petar Penkov
  2020-01-09  1:04   ` Song Liu
  2020-01-09 16:43 ` Alexei Starovoitov
  1 sibling, 1 reply; 4+ messages in thread
From: Petar Penkov @ 2020-01-08 23:18 UTC (permalink / raw)
  To: Stanislav Fomichev
  Cc: Networking, bpf, davem, Alexei Starovoitov, Daniel Borkmann

On Wed, Jan 8, 2020 at 11:49 AM Stanislav Fomichev <sdf@google.com> wrote:
>
> test_overhead changes task comm in order to estimate BPF trampoline
> overhead but never sets the comm back to the original one.
> We have the tests (like core_reloc.c) that have 'test_progs'
> as hard-coded expected comm, so let's try to preserve the
> original comm.
>
> Currently, everything works because the order of execution is:
> first core_recloc, then test_overhead; but let's make it a bit
> future-proof.
>
> Other related changes: use 'test_overhead' as new comm instead of
> 'test' to make it easy to debug and drop '\n' at the end.
>
> Signed-off-by: Stanislav Fomichev <sdf@google.com>

Acked-by: Petar Penkov <ppenkov@google.com>

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

* Re: [PATCH bpf-next] selftests/bpf: restore original comm in test_overhead
  2020-01-08 23:18 ` Petar Penkov
@ 2020-01-09  1:04   ` Song Liu
  0 siblings, 0 replies; 4+ messages in thread
From: Song Liu @ 2020-01-09  1:04 UTC (permalink / raw)
  To: Petar Penkov
  Cc: Stanislav Fomichev, Networking, bpf, David S . Miller,
	Alexei Starovoitov, Daniel Borkmann

On Wed, Jan 8, 2020 at 3:19 PM Petar Penkov <ppenkov.kernel@gmail.com> wrote:
>
> On Wed, Jan 8, 2020 at 11:49 AM Stanislav Fomichev <sdf@google.com> wrote:
> >
> > test_overhead changes task comm in order to estimate BPF trampoline
> > overhead but never sets the comm back to the original one.
> > We have the tests (like core_reloc.c) that have 'test_progs'
> > as hard-coded expected comm, so let's try to preserve the
> > original comm.
> >
> > Currently, everything works because the order of execution is:
> > first core_recloc, then test_overhead; but let's make it a bit
> > future-proof.
> >
> > Other related changes: use 'test_overhead' as new comm instead of
> > 'test' to make it easy to debug and drop '\n' at the end.
> >
> > Signed-off-by: Stanislav Fomichev <sdf@google.com>
>
> Acked-by: Petar Penkov <ppenkov@google.com>

Acked-by: Song Liu <songliubraving@fb.com>

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

* Re: [PATCH bpf-next] selftests/bpf: restore original comm in test_overhead
  2020-01-08 19:21 [PATCH bpf-next] selftests/bpf: restore original comm in test_overhead Stanislav Fomichev
  2020-01-08 23:18 ` Petar Penkov
@ 2020-01-09 16:43 ` Alexei Starovoitov
  1 sibling, 0 replies; 4+ messages in thread
From: Alexei Starovoitov @ 2020-01-09 16:43 UTC (permalink / raw)
  To: Stanislav Fomichev
  Cc: Network Development, bpf, David S. Miller, Alexei Starovoitov,
	Daniel Borkmann

On Wed, Jan 8, 2020 at 11:21 AM Stanislav Fomichev <sdf@google.com> wrote:
>
> test_overhead changes task comm in order to estimate BPF trampoline
> overhead but never sets the comm back to the original one.
> We have the tests (like core_reloc.c) that have 'test_progs'
> as hard-coded expected comm, so let's try to preserve the
> original comm.
>
> Currently, everything works because the order of execution is:
> first core_recloc, then test_overhead; but let's make it a bit
> future-proof.
>
> Other related changes: use 'test_overhead' as new comm instead of
> 'test' to make it easy to debug and drop '\n' at the end.
>
> Signed-off-by: Stanislav Fomichev <sdf@google.com>

Applied. Thanks

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

end of thread, other threads:[~2020-01-09 16:43 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-01-08 19:21 [PATCH bpf-next] selftests/bpf: restore original comm in test_overhead Stanislav Fomichev
2020-01-08 23:18 ` Petar Penkov
2020-01-09  1:04   ` Song Liu
2020-01-09 16:43 ` Alexei Starovoitov

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.