diff mbox series

selftests/bpf/get_cgroup_id: Use nanosleep() syscall instead of sleep()

Message ID 20210316153048.136447-1-ravi.bangoria@linux.ibm.com (mailing list archive)
State Accepted
Commit 56901d483bf14ca729a6c4e06d2b49590b9f1971
Headers show
Series selftests/bpf/get_cgroup_id: Use nanosleep() syscall instead of sleep() | expand

Commit Message

Ravi Bangoria March 16, 2021, 3:30 p.m. UTC
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(-)

Comments

patchwork-bot+netdevbpf@kernel.org March 16, 2021, 11:20 p.m. UTC | #1
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
diff mbox series

Patch

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