Linux Kernel Selftest development
 help / color / mirror / Atom feed
* [PATCH bpf-next v2] bpf: handle implicit declaration of function gettid in bpf_iter.c
@ 2024-10-29  7:46 Jason Xing
  2024-10-29 16:35 ` Alan Maguire
  2024-10-29 18:30 ` patchwork-bot+netdevbpf
  0 siblings, 2 replies; 3+ messages in thread
From: Jason Xing @ 2024-10-29  7:46 UTC (permalink / raw)
  To: ast, daniel, andrii, eddyz87, mykolal, martin.lau, song,
	yonghong.song, john.fastabend, kpsingh, sdf, haoluo, jolsa, shuah
  Cc: bpf, linux-kselftest, Jason Xing

From: Jason Xing <kernelxing@tencent.com>

As we can see from the title, when I compiled the selftests/bpf, I
saw the error:
implicit declaration of function ‘gettid’ ; did you mean ‘getgid’? [-Werror=implicit-function-declaration]
  skel->bss->tid = gettid();
                   ^~~~~~
                   getgid

Directly call the syscall solves this issue.

Signed-off-by: Jason Xing <kernelxing@tencent.com>
---
v2
Link: https://lore.kernel.org/all/20241028034143.14675-1-kerneljasonxing@gmail.com/
1. directly call the syscall (Andrii)
---
 tools/testing/selftests/bpf/prog_tests/bpf_iter.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/tools/testing/selftests/bpf/prog_tests/bpf_iter.c b/tools/testing/selftests/bpf/prog_tests/bpf_iter.c
index f0a3a9c18e9e..9006549a1294 100644
--- a/tools/testing/selftests/bpf/prog_tests/bpf_iter.c
+++ b/tools/testing/selftests/bpf/prog_tests/bpf_iter.c
@@ -226,7 +226,7 @@ static void test_task_common_nocheck(struct bpf_iter_attach_opts *opts,
 	ASSERT_OK(pthread_create(&thread_id, NULL, &do_nothing_wait, NULL),
 		  "pthread_create");
 
-	skel->bss->tid = gettid();
+	skel->bss->tid = syscall(SYS_gettid);
 
 	do_dummy_read_opts(skel->progs.dump_task, opts);
 
@@ -255,10 +255,10 @@ static void *run_test_task_tid(void *arg)
 	union bpf_iter_link_info linfo;
 	int num_unknown_tid, num_known_tid;
 
-	ASSERT_NEQ(getpid(), gettid(), "check_new_thread_id");
+	ASSERT_NEQ(getpid(), syscall(SYS_gettid), "check_new_thread_id");
 
 	memset(&linfo, 0, sizeof(linfo));
-	linfo.task.tid = gettid();
+	linfo.task.tid = syscall(SYS_gettid);
 	opts.link_info = &linfo;
 	opts.link_info_len = sizeof(linfo);
 	test_task_common(&opts, 0, 1);
-- 
2.37.3


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

* Re: [PATCH bpf-next v2] bpf: handle implicit declaration of function gettid in bpf_iter.c
  2024-10-29  7:46 [PATCH bpf-next v2] bpf: handle implicit declaration of function gettid in bpf_iter.c Jason Xing
@ 2024-10-29 16:35 ` Alan Maguire
  2024-10-29 18:30 ` patchwork-bot+netdevbpf
  1 sibling, 0 replies; 3+ messages in thread
From: Alan Maguire @ 2024-10-29 16:35 UTC (permalink / raw)
  To: Jason Xing, ast, daniel, andrii, eddyz87, mykolal, martin.lau,
	song, yonghong.song, john.fastabend, kpsingh, sdf, haoluo, jolsa,
	shuah
  Cc: bpf, linux-kselftest, Jason Xing

On 29/10/2024 07:46, Jason Xing wrote:
> From: Jason Xing <kernelxing@tencent.com>
> 
> As we can see from the title, when I compiled the selftests/bpf, I
> saw the error:
> implicit declaration of function ‘gettid’ ; did you mean ‘getgid’? [-Werror=implicit-function-declaration]
>   skel->bss->tid = gettid();
>                    ^~~~~~
>                    getgid
> 
> Directly call the syscall solves this issue.
> 
> Signed-off-by: Jason Xing <kernelxing@tencent.com>

Reviewed-by: Alan Maguire <alan.maguire@oracle.com>
Tested-by: Alan Maguire <alan.maguire@oracle.com>

> ---
> v2
> Link: https://lore.kernel.org/all/20241028034143.14675-1-kerneljasonxing@gmail.com/
> 1. directly call the syscall (Andrii)
> ---
>  tools/testing/selftests/bpf/prog_tests/bpf_iter.c | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/tools/testing/selftests/bpf/prog_tests/bpf_iter.c b/tools/testing/selftests/bpf/prog_tests/bpf_iter.c
> index f0a3a9c18e9e..9006549a1294 100644
> --- a/tools/testing/selftests/bpf/prog_tests/bpf_iter.c
> +++ b/tools/testing/selftests/bpf/prog_tests/bpf_iter.c
> @@ -226,7 +226,7 @@ static void test_task_common_nocheck(struct bpf_iter_attach_opts *opts,
>  	ASSERT_OK(pthread_create(&thread_id, NULL, &do_nothing_wait, NULL),
>  		  "pthread_create");
>  
> -	skel->bss->tid = gettid();
> +	skel->bss->tid = syscall(SYS_gettid);
>  
>  	do_dummy_read_opts(skel->progs.dump_task, opts);
>  
> @@ -255,10 +255,10 @@ static void *run_test_task_tid(void *arg)
>  	union bpf_iter_link_info linfo;
>  	int num_unknown_tid, num_known_tid;
>  
> -	ASSERT_NEQ(getpid(), gettid(), "check_new_thread_id");
> +	ASSERT_NEQ(getpid(), syscall(SYS_gettid), "check_new_thread_id");
>  
>  	memset(&linfo, 0, sizeof(linfo));
> -	linfo.task.tid = gettid();
> +	linfo.task.tid = syscall(SYS_gettid);
>  	opts.link_info = &linfo;
>  	opts.link_info_len = sizeof(linfo);
>  	test_task_common(&opts, 0, 1);


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

* Re: [PATCH bpf-next v2] bpf: handle implicit declaration of function gettid in bpf_iter.c
  2024-10-29  7:46 [PATCH bpf-next v2] bpf: handle implicit declaration of function gettid in bpf_iter.c Jason Xing
  2024-10-29 16:35 ` Alan Maguire
@ 2024-10-29 18:30 ` patchwork-bot+netdevbpf
  1 sibling, 0 replies; 3+ messages in thread
From: patchwork-bot+netdevbpf @ 2024-10-29 18:30 UTC (permalink / raw)
  To: Jason Xing
  Cc: ast, daniel, andrii, eddyz87, mykolal, martin.lau, song,
	yonghong.song, john.fastabend, kpsingh, sdf, haoluo, jolsa, shuah,
	bpf, linux-kselftest, kernelxing

Hello:

This patch was applied to bpf/bpf-next.git (master)
by Martin KaFai Lau <martin.lau@kernel.org>:

On Tue, 29 Oct 2024 15:46:27 +0800 you wrote:
> From: Jason Xing <kernelxing@tencent.com>
> 
> As we can see from the title, when I compiled the selftests/bpf, I
> saw the error:
> implicit declaration of function ‘gettid’ ; did you mean ‘getgid’? [-Werror=implicit-function-declaration]
>   skel->bss->tid = gettid();
>                    ^~~~~~
>                    getgid
> 
> [...]

Here is the summary with links:
  - [bpf-next,v2] bpf: handle implicit declaration of function gettid in bpf_iter.c
    https://git.kernel.org/bpf/bpf-next/c/42602e3a06f8

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] 3+ messages in thread

end of thread, other threads:[~2024-10-29 18:30 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-10-29  7:46 [PATCH bpf-next v2] bpf: handle implicit declaration of function gettid in bpf_iter.c Jason Xing
2024-10-29 16:35 ` Alan Maguire
2024-10-29 18:30 ` 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