BPF List
 help / color / mirror / Atom feed
From: Eduard Zingerman <eddyz87@gmail.com>
To: Alexei Starovoitov <alexei.starovoitov@gmail.com>
Cc: bpf <bpf@vger.kernel.org>, Alexei Starovoitov <ast@kernel.org>,
	Andrii Nakryiko <andrii@kernel.org>,
	Daniel Borkmann <daniel@iogearbox.net>,
	Martin KaFai Lau <martin.lau@linux.dev>,
	Kernel Team <kernel-team@fb.com>,
	Yonghong Song <yonghong.song@linux.dev>,
	Leon Hwang <hffilwlqm@gmail.com>
Subject: Re: [PATCH bpf-next v3 5/8] selftests/bpf: utility function to get program disassembly after jit
Date: Wed, 21 Aug 2024 11:13:13 -0700	[thread overview]
Message-ID: <47a5267b4cd1395dfc9893f1826888a7ee39966f.camel@gmail.com> (raw)
In-Reply-To: <CAADnVQLJNDB9XKVAiMMTdB+YPrb8FO-CbHp4cx_Pd_Nk9ri0JQ@mail.gmail.com>

On Wed, 2024-08-21 at 11:07 -0700, Alexei Starovoitov wrote:

[...]

> > +static const char *lookup_symbol(void *data, uint64_t ref_value, uint64_t *ref_type,
> > +                                uint64_t ref_pc, const char **ref_name)
> > +{
> > +       struct local_labels *labels = data;
> > +       uint64_t type = *ref_type;
> > +       int i;
> > +
> > +       *ref_type = LLVMDisassembler_ReferenceType_InOut_None;
> > +       *ref_name = NULL;
> > +       if (type != LLVMDisassembler_ReferenceType_In_Branch)
> > +               return NULL;
> > +       /* Depending on labels->print_phase either discover local labels or
> > +        * return a name assigned with local jump target:
> > +        * - if print_phase is true and ref_value is in labels->pcs,
> > +        *   return corresponding labels->name.
> > +        * - if print_phase is false, save program-local jump targets
> > +        *   in labels->pcs;
> > +        */
> > +       if (labels->print_phase) {
> > +               for (i = 0; i < labels->cnt; ++i)
> > +                       if (labels->pcs[i] == ref_value)
> > +                               return labels->names[i];
> > +       } else {
> > +               if (labels->cnt < MAX_LOCAL_LABELS && ref_value < labels->prog_len)
> > +                       labels->pcs[labels->cnt++] = ref_value;
> > +       }
> > +       return NULL;
> > +}
> 
> bpftool should probably adopt similar logic
> just to be consistent?

Makes sense, will prepare patch for bpftool.

[...]

> > +       qsort(labels.pcs, labels.cnt, sizeof(*labels.pcs), cmp_u32);
> > +       for (i = 0; i < labels.cnt; ++i)
> > +               /* use (i % 100) to avoid format truncation warning */
> > +               snprintf(labels.names[i], sizeof(labels.names[i]), "L%d", i % 100);
> 
> 100 here and names[..][4] are a bit of magic.
> Pls add some #define and comments to clarify in the follow up.

Will do.

> Overall it looks to be a great improvement to selftests.
> Applied.
> 
> Pls add necessary packages to bpf CI.

Thank you!


  reply	other threads:[~2024-08-21 18:13 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-08-20 10:23 [PATCH bpf-next v3 0/8] __jited test tag to check disassembly after jit Eduard Zingerman
2024-08-20 10:23 ` [PATCH bpf-next v3 1/8] selftests/bpf: less spam in the log for message matching Eduard Zingerman
2024-08-20 10:23 ` [PATCH bpf-next v3 2/8] selftests/bpf: correctly move 'log' upon successful match Eduard Zingerman
2024-08-20 10:23 ` [PATCH bpf-next v3 3/8] selftests/bpf: fix to avoid __msg tag de-duplication by clang Eduard Zingerman
2024-08-20 10:23 ` [PATCH bpf-next v3 4/8] selftests/bpf: replace __regex macro with "{{...}}" patterns Eduard Zingerman
2024-08-20 10:23 ` [PATCH bpf-next v3 5/8] selftests/bpf: utility function to get program disassembly after jit Eduard Zingerman
2024-08-21 18:07   ` Alexei Starovoitov
2024-08-21 18:13     ` Eduard Zingerman [this message]
2024-08-20 10:23 ` [PATCH bpf-next v3 6/8] selftests/bpf: __jited test tag to check " Eduard Zingerman
2024-08-20 10:23 ` [PATCH bpf-next v3 6/8] selftests/bpf: __jited_x86 test tag to check x86 assembly " Eduard Zingerman
2024-08-20 10:23 ` [PATCH bpf-next v3 7/8] selftests/bpf: validate jit behaviour for tail calls Eduard Zingerman
2024-08-20 10:23 ` [PATCH bpf-next v3 8/8] selftests/bpf: validate __xlated same way as __jited Eduard Zingerman
2024-08-21 18:10 ` [PATCH bpf-next v3 0/8] __jited test tag to check disassembly after jit 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=47a5267b4cd1395dfc9893f1826888a7ee39966f.camel@gmail.com \
    --to=eddyz87@gmail.com \
    --cc=alexei.starovoitov@gmail.com \
    --cc=andrii@kernel.org \
    --cc=ast@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=daniel@iogearbox.net \
    --cc=hffilwlqm@gmail.com \
    --cc=kernel-team@fb.com \
    --cc=martin.lau@linux.dev \
    --cc=yonghong.song@linux.dev \
    /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