bpf.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] selftests/bpf/get_cgroup_id: Use nanosleep() syscall instead of sleep()
@ 2021-03-16 15:30 Ravi Bangoria
  2021-03-16 23:20 ` patchwork-bot+netdevbpf
  0 siblings, 1 reply; 2+ messages in thread
From: Ravi Bangoria @ 2021-03-16 15:30 UTC (permalink / raw)
  To: ast, shuah
  Cc: ravi.bangoria, daniel, yhs, andrii, kafai, songliubraving,
	john.fastabend, bpf, linux-kselftest

Glibc sleep() switched to clock_nanosleep() from nanosleep(),
thus syscalls:sys_enter_nanosleep tracepoint is not hitting
which is causing testcase failure. Instead of depending on
glibc sleep(), call nanosleep() systemcall directly.

Before:
  # ./get_cgroup_id_user
  ...
  main:FAIL:compare_cgroup_id kern cgid 0 user cgid 483

After:
  # ./get_cgroup_id_user
  ...
  main:PASS:compare_cgroup_id

Signed-off-by: Ravi Bangoria <ravi.bangoria@linux.ibm.com>
---
 tools/testing/selftests/bpf/get_cgroup_id_user.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/tools/testing/selftests/bpf/get_cgroup_id_user.c b/tools/testing/selftests/bpf/get_cgroup_id_user.c
index b8d6aef99db4..99628e1a1e58 100644
--- a/tools/testing/selftests/bpf/get_cgroup_id_user.c
+++ b/tools/testing/selftests/bpf/get_cgroup_id_user.c
@@ -57,6 +57,10 @@ int main(int argc, char **argv)
 	__u32 key = 0, pid;
 	int exit_code = 1;
 	char buf[256];
+	const struct timespec req = {
+		.tv_sec = 1,
+		.tv_nsec = 0,
+	};
 
 	cgroup_fd = cgroup_setup_and_join(TEST_CGROUP);
 	if (CHECK(cgroup_fd < 0, "cgroup_setup_and_join", "err %d errno %d\n", cgroup_fd, errno))
@@ -115,7 +119,7 @@ int main(int argc, char **argv)
 		goto close_pmu;
 
 	/* trigger some syscalls */
-	sleep(1);
+	syscall(__NR_nanosleep, &req, NULL);
 
 	err = bpf_map_lookup_elem(cgidmap_fd, &key, &kcgid);
 	if (CHECK(err, "bpf_map_lookup_elem", "err %d errno %d\n", err, errno))
-- 
2.29.2


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

* Re: [PATCH] selftests/bpf/get_cgroup_id: Use nanosleep() syscall instead of sleep()
  2021-03-16 15:30 [PATCH] selftests/bpf/get_cgroup_id: Use nanosleep() syscall instead of sleep() Ravi Bangoria
@ 2021-03-16 23:20 ` patchwork-bot+netdevbpf
  0 siblings, 0 replies; 2+ messages in thread
From: patchwork-bot+netdevbpf @ 2021-03-16 23:20 UTC (permalink / raw)
  To: Ravi Bangoria
  Cc: ast, shuah, daniel, yhs, andrii, kafai, songliubraving,
	john.fastabend, bpf, linux-kselftest

Hello:

This patch was applied to bpf/bpf-next.git (refs/heads/master):

On Tue, 16 Mar 2021 21:00:48 +0530 you wrote:
> Glibc sleep() switched to clock_nanosleep() from nanosleep(),
> thus syscalls:sys_enter_nanosleep tracepoint is not hitting
> which is causing testcase failure. Instead of depending on
> glibc sleep(), call nanosleep() systemcall directly.
> 
> Before:
>   # ./get_cgroup_id_user
>   ...
>   main:FAIL:compare_cgroup_id kern cgid 0 user cgid 483
> 
> [...]

Here is the summary with links:
  - selftests/bpf/get_cgroup_id: Use nanosleep() syscall instead of sleep()
    https://git.kernel.org/bpf/bpf-next/c/56901d483bf1

You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html



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

end of thread, other threads:[~2021-03-16 23:20 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-03-16 15:30 [PATCH] selftests/bpf/get_cgroup_id: Use nanosleep() syscall instead of sleep() Ravi Bangoria
2021-03-16 23:20 ` patchwork-bot+netdevbpf

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).