public inbox for bpf@vger.kernel.org
 help / color / mirror / Atom feed
From: Yonghong Song <yhs@fb.com>
To: Jiri Olsa <olsajiri@gmail.com>
Cc: bpf@vger.kernel.org, Alexei Starovoitov <ast@kernel.org>,
	Andrii Nakryiko <andrii@kernel.org>,
	Daniel Borkmann <daniel@iogearbox.net>,
	kernel-team@fb.com
Subject: Re: [PATCH bpf-next v4 3/8] bpf: Update descriptions for helpers bpf_get_func_arg[_cnt]()
Date: Tue, 6 Sep 2022 09:12:04 -0700	[thread overview]
Message-ID: <90ee59ae-6257-5e0e-067c-d37210a1df7f@fb.com> (raw)
In-Reply-To: <YxG3OVk72IaSEJd6@krava>



On 9/2/22 12:56 AM, Jiri Olsa wrote:
> On Wed, Aug 31, 2022 at 08:26:57AM -0700, Yonghong Song wrote:
>> Now instead of the number of arguments, the number of registers
>> holding argument values are stored in trampoline. Update
>> the description of bpf_get_func_arg[_cnt]() helpers. Previous
>> programs without struct arguments should continue to work
>> as usual.
>>
>> Signed-off-by: Yonghong Song <yhs@fb.com>
>> ---
>>   include/uapi/linux/bpf.h       | 9 +++++----
>>   tools/include/uapi/linux/bpf.h | 9 +++++----
>>   2 files changed, 10 insertions(+), 8 deletions(-)
>>
>> diff --git a/include/uapi/linux/bpf.h b/include/uapi/linux/bpf.h
>> index 962960a98835..f9f43343ef93 100644
>> --- a/include/uapi/linux/bpf.h
>> +++ b/include/uapi/linux/bpf.h
>> @@ -5079,12 +5079,12 @@ union bpf_attr {
>>    *
>>    * long bpf_get_func_arg(void *ctx, u32 n, u64 *value)
>>    *	Description
>> - *		Get **n**-th argument (zero based) of the traced function (for tracing programs)
>> + *		Get **n**-th argument register (zero based) of the traced function (for tracing programs)
> 
> I'm bit worried about the confusion between args/regs we create with
> this, but I don't any have better idea how to solve this
> 
> keeping extra stack values for nr_args and nr_regs and have new helpers
> to get reg values.. but then bpf_get_func_arg still does not return the
> full argument value.. also given that the struct args should be rare,
> I guess it's fine ;-)

You are right. Since an argument may takes two u64 space, the helper
bpf_get_func_arg() might not return the *whole* argument any more.
But it still returns a func arg, maybe just a partial func arg.
So the 'n' here has a semantic change, instead of 'n'th argument,
it becomes 'n'th argument register. To create new helpers probably
not needed, so that is why I made the description change to the
existing helper which maintains backward compatability too.

> 
> jirka
> 
>>    *		returned in **value**.
>>    *
>>    *	Return
>>    *		0 on success.
>> - *		**-EINVAL** if n >= arguments count of traced function.
>> + *		**-EINVAL** if n >= argument register count of traced function.
>>    *
>>    * long bpf_get_func_ret(void *ctx, u64 *value)
>>    *	Description
>> @@ -5097,10 +5097,11 @@ union bpf_attr {
>>    *
>>    * long bpf_get_func_arg_cnt(void *ctx)
>>    *	Description
>> - *		Get number of arguments of the traced function (for tracing programs).
>> + *		Get number of registers of the traced function (for tracing programs) where
>> + *		function arguments are stored in these registers.
>>    *
>>    *	Return
>> - *		The number of arguments of the traced function.
>> + *		The number of argument registers of the traced function.
>>    *
>>    * int bpf_get_retval(void)
>>    *	Description
[...]

  reply	other threads:[~2022-09-06 16:36 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-08-31 15:26 [PATCH bpf-next v4 0/8] bpf: Support struct argument for trampoline base progs Yonghong Song
2022-08-31 15:26 ` [PATCH bpf-next v4 1/8] bpf: Allow struct argument in trampoline based programs Yonghong Song
2022-08-31 15:26 ` [PATCH bpf-next v4 2/8] bpf: x86: Support in-register struct arguments in trampoline programs Yonghong Song
2022-09-06 16:40   ` Kui-Feng Lee
2022-09-06 19:30     ` Yonghong Song
2022-09-07  3:00   ` Alexei Starovoitov
2022-09-07 18:04     ` Yonghong Song
2022-08-31 15:26 ` [PATCH bpf-next v4 3/8] bpf: Update descriptions for helpers bpf_get_func_arg[_cnt]() Yonghong Song
2022-09-02  7:56   ` Jiri Olsa
2022-09-06 16:12     ` Yonghong Song [this message]
2022-08-31 15:27 ` [PATCH bpf-next v4 4/8] bpf: arm64: No support of struct argument in trampoline programs Yonghong Song
2022-08-31 15:27 ` [PATCH bpf-next v4 5/8] libbpf: Add new BPF_PROG2 macro Yonghong Song
2022-09-09  0:11   ` Andrii Nakryiko
2022-09-09 16:31     ` Yonghong Song
2022-09-09 18:07       ` Andrii Nakryiko
2022-08-31 15:27 ` [PATCH bpf-next v4 6/8] selftests/bpf: Add struct argument tests with fentry/fexit programs Yonghong Song
2022-08-31 15:27 ` [PATCH bpf-next v4 7/8] selftests/bpf: Use BPF_PROG2 for some fentry programs without struct arguments Yonghong Song
2022-08-31 15:27 ` [PATCH bpf-next v4 8/8] selftests/bpf: Add tracing_struct test in DENYLIST.s390x Yonghong Song
2022-09-07  3:10 ` [PATCH bpf-next v4 0/8] bpf: Support struct argument for trampoline base progs patchwork-bot+netdevbpf

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=90ee59ae-6257-5e0e-067c-d37210a1df7f@fb.com \
    --to=yhs@fb.com \
    --cc=andrii@kernel.org \
    --cc=ast@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=daniel@iogearbox.net \
    --cc=kernel-team@fb.com \
    --cc=olsajiri@gmail.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