bpf.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Eduard Zingerman <eddyz87@gmail.com>
To: bpf@vger.kernel.org, ast@kernel.org
Cc: andrii@kernel.org, daniel@iogearbox.net, martin.lau@linux.dev,
	 kernel-team@fb.com, yonghong.song@linux.dev,
	jose.marchesi@oracle.com,  alan.maguire@oracle.com
Subject: Re: [PATCH bpf-next 0/3] API to access btf_dump emit queue and print single type
Date: Thu, 16 May 2024 19:03:08 -0700	[thread overview]
Message-ID: <875d8ac4289bba082d2b5c4515d169d62bdb64a6.camel@gmail.com> (raw)
In-Reply-To: <15424756c16cb1ace48c1b8de6d99074e31d859c.camel@gmail.com>

On Thu, 2024-05-16 at 17:02 -0700, Eduard Zingerman wrote:
> On Thu, 2024-05-16 at 16:04 -0700, Eduard Zingerman wrote:
> > This is a follow-up to the following discussion:
> > https://lore.kernel.org/bpf/20240503111836.25275-1-jose.marchesi@oracle.com/
> > 
> > As suggested by Andrii, this series adds several API functions to
> > allow more flexibility with btf dump:
> > - a function to add a type and all its dependencies to the emit queue;
> > - functions to provide access to the emit queue owned by btf_dump object;
> > - a function to print a given type (skipping any dependencies).
> 
> The series fails on the CI despite passing local testing,
> I'll submit v2 when ready.
> 
> [...]

The bug was caused by a logical error in typedefs handling.
Do not mark typedef as ORDERED, always emit a forward declaration for
it instead. Otherwise the following situation would be troublesome:

  typedef struct foo foo_alias;

  struct foo {};

  struct root {
     foo_alias *a;    <-- foo->a leads to forward declaration for 'foo',
     foo_alias b;         if 'foo_alias' is marked ORDERED
  };                      foo->b will not traverse to generate
                          full declaration for 'foo'.

The patch below fixes error.
CI builds seem ok:
https://github.com/kernel-patches/bpf/pull/7052

---

diff --git a/tools/lib/bpf/btf_dump.c b/tools/lib/bpf/btf_dump.c
index cb233f891582..7e845ad9ca9e 100644
--- a/tools/lib/bpf/btf_dump.c
+++ b/tools/lib/bpf/btf_dump.c
@@ -653,12 +653,9 @@ static int btf_dump_order_type(struct btf_dump *d, __u32 id, __u32 cont_id, bool
                if (err < 0)
                        return err;
 
-               /* typedef is always a named definition */
-               err = btf_dump_add_emit_queue_id(d, id);
+               err = btf_dump_add_emit_queue_fwd(d, id);
                if (err)
                        return err;
-
-               d->type_states[id].order_state = ORDERED;
                return 0;
        }
        case BTF_KIND_VOLATILE:


      reply	other threads:[~2024-05-17  2:03 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-05-16 23:04 [PATCH bpf-next 0/3] API to access btf_dump emit queue and print single type Eduard Zingerman
2024-05-16 23:04 ` [PATCH bpf-next 1/3] libbpf: put forward declarations to btf_dump->emit_queue Eduard Zingerman
2024-05-16 23:04 ` [PATCH bpf-next 2/3] libbpf: API to access btf_dump emit queue and print single type Eduard Zingerman
2024-05-16 23:04 ` [PATCH bpf-next 3/3] selftests/bpf: tests for btf_dump emit queue API Eduard Zingerman
2024-05-17  0:02 ` [PATCH bpf-next 0/3] API to access btf_dump emit queue and print single type Eduard Zingerman
2024-05-17  2:03   ` Eduard Zingerman [this message]

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=875d8ac4289bba082d2b5c4515d169d62bdb64a6.camel@gmail.com \
    --to=eddyz87@gmail.com \
    --cc=alan.maguire@oracle.com \
    --cc=andrii@kernel.org \
    --cc=ast@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=daniel@iogearbox.net \
    --cc=jose.marchesi@oracle.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;
as well as URLs for NNTP newsgroup(s).