linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Namhyung Kim <namhyung@kernel.org>
To: Andrii Nakryiko <andrii.nakryiko@gmail.com>
Cc: Alexei Starovoitov <ast@kernel.org>,
	Daniel Borkmann <daniel@iogearbox.net>,
	Andrii Nakryiko <andrii@kernel.org>,
	Martin KaFai Lau <kafai@fb.com>, Song Liu <songliubraving@fb.com>,
	Yonghong Song <yhs@fb.com>,
	John Fastabend <john.fastabend@gmail.com>,
	KP Singh <kpsingh@kernel.org>,
	Networking <netdev@vger.kernel.org>, bpf <bpf@vger.kernel.org>,
	LKML <linux-kernel@vger.kernel.org>,
	Arnaldo Carvalho de Melo <acme@kernel.org>,
	Peter Zijlstra <peterz@infradead.org>,
	Eugene Loh <eugene.loh@oracle.com>, Hao Luo <haoluo@google.com>
Subject: Re: [PATCH 2/2] bpf/selftests: Test skipping stacktrace
Date: Mon, 14 Mar 2022 10:28:56 -0700	[thread overview]
Message-ID: <CAM9d7chtq2DV28GU=_eb+MSUTPFg8oGX8NDeeLdnf=Vr+7E1Yg@mail.gmail.com> (raw)
In-Reply-To: <CAEf4BzZUEvCqz-zGdKAeyg3vywEEnFWuZ4Q446BrTGOsFqNqyQ@mail.gmail.com>

Hello,

On Fri, Mar 11, 2022 at 2:23 PM Andrii Nakryiko
<andrii.nakryiko@gmail.com> wrote:
>
> On Thu, Mar 10, 2022 at 12:22 AM Namhyung Kim <namhyung@kernel.org> wrote:
> > +SEC("tracepoint/sched/sched_switch")
> > +int oncpu(struct sched_switch_args *ctx)
> > +{
> > +       __u32 max_len = TEST_STACK_DEPTH * sizeof(__u64);
> > +       __u32 key = 0, val = 0, *value_p;
> > +       __u64 *stack_p;
> > +
>
> please also add filtering by PID to avoid interference from other
> selftests when run in parallel mode

Will do!

Thanks,
Namhyung

>
> > +       value_p = bpf_map_lookup_elem(&control_map, &key);
> > +       if (value_p && *value_p)
> > +               return 0; /* skip if non-zero *value_p */
> > +
> > +       /* it should allow skipping whole buffer size entries */
> > +       key = bpf_get_stackid(ctx, &stackmap, TEST_STACK_DEPTH);
> > +       if ((int)key >= 0) {
> > +               /* The size of stackmap and stack_amap should be the same */
> > +               bpf_map_update_elem(&stackid_hmap, &key, &val, 0);
> > +               stack_p = bpf_map_lookup_elem(&stack_amap, &key);
> > +               if (stack_p) {
> > +                       bpf_get_stack(ctx, stack_p, max_len, TEST_STACK_DEPTH);
> > +                       /* it wrongly skipped all the entries and filled zero */
> > +                       if (stack_p[0] == 0)
> > +                               failed = 1;
> > +               }
> > +       } else if ((int)key == -14/*EFAULT*/) {
> > +               /* old kernel doesn't support skipping that many entries */
> > +               failed = 2;
> > +       }
> > +
> > +       return 0;
> > +}
> > +
> > +char _license[] SEC("license") = "GPL";
> > --
> > 2.35.1.723.g4982287a31-goog
> >

  reply	other threads:[~2022-03-14 17:29 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-03-10  8:22 [PATCH 1/2] bpf: Adjust BPF stack helper functions to accommodate skip > 0 Namhyung Kim
2022-03-10  8:22 ` [PATCH 2/2] bpf/selftests: Test skipping stacktrace Namhyung Kim
2022-03-10 23:21   ` Yonghong Song
2022-03-11  0:40     ` Namhyung Kim
2022-03-11 22:23   ` Andrii Nakryiko
2022-03-14 17:28     ` Namhyung Kim [this message]
2022-03-10 22:54 ` [PATCH 1/2] bpf: Adjust BPF stack helper functions to accommodate skip > 0 Yonghong Song
2022-03-11  0:23   ` Hao Luo
2022-03-11  0:33     ` Namhyung Kim
2022-03-11  0:32   ` Namhyung Kim

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='CAM9d7chtq2DV28GU=_eb+MSUTPFg8oGX8NDeeLdnf=Vr+7E1Yg@mail.gmail.com' \
    --to=namhyung@kernel.org \
    --cc=acme@kernel.org \
    --cc=andrii.nakryiko@gmail.com \
    --cc=andrii@kernel.org \
    --cc=ast@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=daniel@iogearbox.net \
    --cc=eugene.loh@oracle.com \
    --cc=haoluo@google.com \
    --cc=john.fastabend@gmail.com \
    --cc=kafai@fb.com \
    --cc=kpsingh@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=peterz@infradead.org \
    --cc=songliubraving@fb.com \
    --cc=yhs@fb.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;
as well as URLs for NNTP newsgroup(s).