From: Song Liu <songliubraving@fb.com>
To: Alexei Starovoitov <alexei.starovoitov@gmail.com>
Cc: bpf <bpf@vger.kernel.org>,
Network Development <netdev@vger.kernel.org>,
Alexei Starovoitov <ast@kernel.org>,
Daniel Borkmann <daniel@iogearbox.net>,
Kernel Team <Kernel-team@fb.com>,
John Fastabend <john.fastabend@gmail.com>,
KP Singh <kpsingh@chromium.org>
Subject: Re: [PATCH bpf-next 1/3] bpf: introduce helper bpf_get_task_stack_trace()
Date: Tue, 23 Jun 2020 17:40:36 +0000 [thread overview]
Message-ID: <C0EBD4AF-C9D4-41AE-9F18-57D4097B7DE2@fb.com> (raw)
In-Reply-To: <FF92494E-D1EB-4B84-9D2F-8CD43FEAB164@fb.com>
> On Jun 23, 2020, at 9:59 AM, Song Liu <songliubraving@fb.com> wrote:
>
>
>
>> On Jun 23, 2020, at 8:19 AM, Alexei Starovoitov <alexei.starovoitov@gmail.com> wrote:
>>
>> On Tue, Jun 23, 2020 at 12:08 AM Song Liu <songliubraving@fb.com> wrote:
>>>
>
> [...]
>
>>>
>>> +BPF_CALL_3(bpf_get_task_stack_trace, struct task_struct *, task,
>>> + void *, entries, u32, size)
>>> +{
>>> + return stack_trace_save_tsk(task, (unsigned long *)entries, size, 0);
>>> +}
>>> +
>>> +static int bpf_get_task_stack_trace_btf_ids[5];
>>> +static const struct bpf_func_proto bpf_get_task_stack_trace_proto = {
>>> + .func = bpf_get_task_stack_trace,
>>> + .gpl_only = true,
>>
>> why?
>
> Actually, I am not sure when we should use gpl_only = true.
>
>>
>>> + .ret_type = RET_INTEGER,
>>> + .arg1_type = ARG_PTR_TO_BTF_ID,
>>> + .arg2_type = ARG_PTR_TO_MEM,
>>> + .arg3_type = ARG_CONST_SIZE_OR_ZERO,
>>
>> OR_ZERO ? why?
>
> Will fix.
>
>>
>>> + .btf_id = bpf_get_task_stack_trace_btf_ids,
>>> +};
>>> +
>>> static const struct bpf_func_proto *
>>> raw_tp_prog_func_proto(enum bpf_func_id func_id, const struct bpf_prog *prog)
>>> {
>>> @@ -1521,6 +1538,10 @@ tracing_prog_func_proto(enum bpf_func_id func_id, const struct bpf_prog *prog)
>>> return prog->expected_attach_type == BPF_TRACE_ITER ?
>>> &bpf_seq_write_proto :
>>> NULL;
>>> + case BPF_FUNC_get_task_stack_trace:
>>> + return prog->expected_attach_type == BPF_TRACE_ITER ?
>>> + &bpf_get_task_stack_trace_proto :
>>
>> why limit to iter only?
>
> I guess it is also useful for other types. Maybe move to bpf_tracing_func_proto()?
>
>>
>>> + *
>>> + * int bpf_get_task_stack_trace(struct task_struct *task, void *entries, u32 size)
>>> + * Description
>>> + * Save a task stack trace into array *entries*. This is a wrapper
>>> + * over stack_trace_save_tsk().
>>
>> size is not documented and looks wrong.
>> the verifier checks it in bytes, but it's consumed as number of u32s.
>
> I am not 100% sure, but verifier seems check it correctly. And I think it is consumed
> as u64s?
I was wrong. Verifier checks as bytes. Will fix.
Song
next prev parent reply other threads:[~2020-06-23 17:41 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-06-23 7:07 [PATCH bpf-next 0/3] bpf: introduce bpf_get_task_stack_trace() Song Liu
2020-06-23 7:08 ` [PATCH bpf-next 1/3] bpf: introduce helper bpf_get_task_stack_trace() Song Liu
2020-06-23 15:19 ` Alexei Starovoitov
2020-06-23 16:59 ` Song Liu
2020-06-23 17:40 ` Song Liu [this message]
2020-06-23 18:41 ` Andrii Nakryiko
2020-06-23 15:22 ` Daniel Borkmann
2020-06-23 17:19 ` Song Liu
2020-06-23 18:45 ` Andrii Nakryiko
2020-06-23 22:53 ` Song Liu
2020-06-23 7:08 ` [PATCH bpf-next 2/3] bpf: allow %pB in bpf_seq_printf() Song Liu
2020-06-23 15:29 ` Daniel Borkmann
2020-06-23 17:19 ` Song Liu
2020-06-23 7:08 ` [PATCH bpf-next 3/3] selftests/bpf: add bpf_iter test with bpf_get_task_stack_trace() Song Liu
2020-06-23 18:57 ` Yonghong Song
2020-06-23 22:07 ` Song Liu
2020-06-23 22:27 ` Yonghong Song
2020-06-24 20:37 ` Song Liu
2020-06-25 5:29 ` Yonghong Song
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=C0EBD4AF-C9D4-41AE-9F18-57D4097B7DE2@fb.com \
--to=songliubraving@fb.com \
--cc=Kernel-team@fb.com \
--cc=alexei.starovoitov@gmail.com \
--cc=ast@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=daniel@iogearbox.net \
--cc=john.fastabend@gmail.com \
--cc=kpsingh@chromium.org \
--cc=netdev@vger.kernel.org \
/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;
as well as URLs for NNTP newsgroup(s).