netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Yonghong Song <yhs@fb.com>
To: <netdev@vger.kernel.org>
Cc: Alexei Starovoitov <ast@fb.com>,
	Daniel Borkmann <daniel@iogearbox.net>, <kernel-team@fb.com>,
	Martin KaFai Lau <kafai@fb.com>
Subject: [PATCH bpf-next 0/7] bpf: btf: fix struct/union/fwd types with kind_flag
Date: Tue, 11 Dec 2018 16:46:30 -0800	[thread overview]
Message-ID: <20181212004630.395424-1-yhs@fb.com> (raw)

Commit 69b693f0aefa ("bpf: btf: Introduce BPF Type Format (BTF)")
introduced BTF, a debug info format for BTF.

The original design has a couple of issues though.
First, the bitfield size is only encoded in int type.
If the struct member bitfield type is enum, pahole ([1])
or llvm is forced to replace enum with int type. As a result, the original
type information gets lost.

Second, the original BTF design does not envision the possibility of
BTF=>header_file conversion ([2]), hence does not encode "struct" or
"union" info for a forward type. Such information is necessary to
convert BTF to a header file.

This patch set fixed the issue by introducing kind_flag, using one bit
in type->info. When kind_flag, the struct/union btf_member->offset
will encode both bitfield_size and bit_offset, covering both
int and enum base types. The kind_flag is also used to indicate whether
the forward type is a union (when set) or a struct.

Please see each individual patches for details.

[1] https://git.kernel.org/pub/scm/devel/pahole/pahole.git/commit/?id=b18354f64cc215368c3bc0df4a7e5341c55c378c
[2] https://lwn.net/SubscriberLink/773198/fe3074838f5c3f26/

Yonghong Song (7):
  bpf: btf: refactor btf_int_bits_seq_show()
  bpf: btf: fix struct/union/fwd types with kind_flag
  tools/bpf: sync btf.h header from kernel to tools
  tools/bpf: add test_btf unit tests for kind_flag
  tools/bpf: test kernel bpffs map pretty print with struct kind_flag
  tools: bpftool: refactor btf_dumper_int_bits()
  tools: bpftool: support pretty print with kind_flag set

 include/uapi/linux/btf.h               |  15 +-
 kernel/bpf/btf.c                       | 266 +++++++++--
 tools/bpf/bpftool/btf_dumper.c         |  58 ++-
 tools/include/uapi/linux/btf.h         |  15 +-
 tools/testing/selftests/bpf/test_btf.c | 593 ++++++++++++++++++++++++-
 5 files changed, 881 insertions(+), 66 deletions(-)

-- 
2.17.1

             reply	other threads:[~2018-12-12  0:46 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-12-12  0:46 Yonghong Song [this message]
2018-12-12  0:46 ` [PATCH bpf-next 1/7] bpf: btf: refactor btf_int_bits_seq_show() Yonghong Song
2018-12-12  0:46 ` [PATCH bpf-next 2/7] bpf: btf: fix struct/union/fwd types with kind_flag Yonghong Song
2018-12-12  0:46 ` [PATCH bpf-next 3/7] tools/bpf: sync btf.h header from kernel to tools Yonghong Song
2018-12-12  0:46 ` [PATCH bpf-next 4/7] tools/bpf: add test_btf unit tests for kind_flag Yonghong Song
2018-12-12  0:46 ` [PATCH bpf-next 5/7] tools/bpf: test kernel bpffs map pretty print with struct kind_flag Yonghong Song
2018-12-12  0:46 ` [PATCH bpf-next 6/7] tools: bpftool: refactor btf_dumper_int_bits() Yonghong Song
2018-12-12  0:46 ` [PATCH bpf-next 7/7] tools: bpftool: support pretty print with kind_flag set 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=20181212004630.395424-1-yhs@fb.com \
    --to=yhs@fb.com \
    --cc=ast@fb.com \
    --cc=daniel@iogearbox.net \
    --cc=kafai@fb.com \
    --cc=kernel-team@fb.com \
    --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).