All of lore.kernel.org
 help / color / mirror / Atom feed
From: Alexei Starovoitov <alexei.starovoitov@gmail.com>
To: Andrii Nakryiko <andrii.nakryiko@gmail.com>
Cc: Mykyta Yatsenko <mykyta.yatsenko5@gmail.com>,
	bpf <bpf@vger.kernel.org>,  Alexei Starovoitov <ast@kernel.org>,
	Andrii Nakryiko <andrii@kernel.org>,
	 Daniel Borkmann <daniel@iogearbox.net>,
	Martin Lau <kafai@meta.com>,  Kernel Team <kernel-team@meta.com>,
	Quentin Monnet <qmo@kernel.org>,
	 Mykyta Yatsenko <yatsenko@meta.com>
Subject: Re: [PATCH v3 bpf-next] bpftool: introduce btf c dump sorting
Date: Mon, 13 May 2024 16:34:19 -0700	[thread overview]
Message-ID: <CAADnVQKRkap+uusEqM937bHWtojkth+aSdS8fFn7VRJrzPVOqw@mail.gmail.com> (raw)
In-Reply-To: <CAEf4BzY6ugkAMt23xVFM36XjD8c8Jh9vXBDPiWrR7NB42yvXKw@mail.gmail.com>

On Mon, May 13, 2024 at 4:08 PM Andrii Nakryiko
<andrii.nakryiko@gmail.com> wrote:
>
> On Mon, May 13, 2024 at 1:29 PM Mykyta Yatsenko
> <mykyta.yatsenko5@gmail.com> wrote:
> >
> > From: Mykyta Yatsenko <yatsenko@meta.com>
> >
> > Sort bpftool c dump output; aiming to simplify vmlinux.h diffing and
> > forcing more natural type definitions ordering.
> >
> > Definitions are sorted first by their BTF kind ranks, then by their base
> > type name and by their own name.
> >
> > Type ranks
> >
> > Assign ranks to btf kinds (defined in function btf_type_rank) to set
> > next order:
> > 1. Anonymous enums/enums64
> > 2. Named enums/enums64
> > 3. Trivial types typedefs (ints, then floats)
> > 4. Structs/Unions
> > 5. Function prototypes
> > 6. Forward declarations
> >
> > Type rank is set to maximum for unnamed reference types, structs and
> > unions to avoid emitting those types early. They will be emitted as
> > part of the type chain starting with named type.
> >
> > Lexicographical ordering
> >
> > Each type is assigned a sort_name and own_name.
> > sort_name is the resolved name of the final base type for reference
> > types (typedef, pointer, array etc). Sorting by sort_name allows to
> > group typedefs of the same base type. sort_name for non-reference type
> > is the same as own_name. own_name is a direct name of particular type,
> > is used as final sorting step.
> >
> > Signed-off-by: Mykyta Yatsenko <yatsenko@meta.com>
> > ---
> >  .../bpf/bpftool/Documentation/bpftool-btf.rst |   5 +-
> >  tools/bpf/bpftool/bash-completion/bpftool     |   3 +
> >  tools/bpf/bpftool/btf.c                       | 138 +++++++++++++++++-
> >  3 files changed, 139 insertions(+), 7 deletions(-)
> >
>
> LGTM, tried it locally and it works well. In fact, see 6.8 kernel vs
> latest bpf-next/master (with basically the same config) comparison.
> It's quite minimal and easy to use to see what changes about some of
> the BPF internal types.
>
> Acked-by: Andrii Nakryiko <andrii@kernel.org>
> Tested-by: Andrii Nakryiko <andrii@kernel.org>
>
>   [0] https://gist.github.com/anakryiko/8fd8ebf2aba73961ebd3cf6587de6822

Just noticed:

+ ETHTOOL_A_TS_STAT_UNSPEC = 0,
+ ETHTOOL_A_TS_STAT_TX_PKTS = 1,
+ ETHTOOL_A_TS_STAT_TX_LOST = 2,
+ ETHTOOL_A_TS_STAT_TX_ERR = 3,
+ __ETHTOOL_A_TS_STAT_CNT = 4,
+ ETHTOOL_A_TS_STAT_MAX = 3,
};

I'm a bit surprised that enum values are not sorted.
I'm guessing the enum names come in dwarf order and copied
the same way in BTF ?
I guess it's not an issue.

  reply	other threads:[~2024-05-13 23:34 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-05-13 19:29 [PATCH v3 bpf-next] bpftool: introduce btf c dump sorting Mykyta
2024-05-13 23:08 ` Andrii Nakryiko
2024-05-13 23:34   ` Alexei Starovoitov [this message]
2024-05-14  3:51     ` Andrii Nakryiko
2024-05-14 10:27 ` Quentin Monnet

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=CAADnVQKRkap+uusEqM937bHWtojkth+aSdS8fFn7VRJrzPVOqw@mail.gmail.com \
    --to=alexei.starovoitov@gmail.com \
    --cc=andrii.nakryiko@gmail.com \
    --cc=andrii@kernel.org \
    --cc=ast@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=daniel@iogearbox.net \
    --cc=kafai@meta.com \
    --cc=kernel-team@meta.com \
    --cc=mykyta.yatsenko5@gmail.com \
    --cc=qmo@kernel.org \
    --cc=yatsenko@meta.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.