From: Yonghong Song <yhs@fb.com>
To: <ast@fb.com>, <kafai@fb.com>, <daniel@iogearbox.net>,
<netdev@vger.kernel.org>
Cc: <kernel-team@fb.com>
Subject: [PATCH bpf-next 0/3] bpf: implement percpu map pretty print for bpffs and bpftool
Date: Wed, 29 Aug 2018 14:43:12 -0700 [thread overview]
Message-ID: <20180829214315.4065753-1-yhs@fb.com> (raw)
Commit a26ca7c982cb ("bpf: btf: Add pretty print support to the
basic arraymap") and Commit 699c86d6ec21 ("bpf: btf: add pretty print
for hash/lru_hash maps") added bpffs pretty print for array, hash and
lru hash maps. The pretty print gives users a structurally formatted
dump for keys/values which much easy to understand than raw bytes.
This patch set implemented bpffs pretty print support for
percpu arraymap, percpu hashmap and percpu lru hashmap.
For complex key/value types, the pretty print here is even more useful
due to
. large volumne of data making it even harder to correlate bytes
to a particular field in a particular cpu.
. kernel rounds the value size for each cpu to multiple of 8.
User has to be aware of this otherwise wrong value may be
derived from cpu 1/2/...
For example, we may have a bpffs pretty print like below:
43602: {
cpu0: {43602,0,-43602,0x3,0xaa52,0x3,{43602|[82,170,0,0,0,0,0,0]},ENUM_TWO}
cpu1: {43602,0,-43602,0x3,0xaa52,0x3,{43602|[82,170,0,0,0,0,0,0]},ENUM_TWO}
cpu2: {43602,0,-43602,0x3,0xaa52,0x3,{43602|[82,170,0,0,0,0,0,0]},ENUM_TWO}
cpu3: {43602,0,-43602,0x3,0xaa52,0x3,{43602|[82,170,0,0,0,0,0,0]},ENUM_TWO}
}
for a percpu map.
This patch also added percpu formatted print on bpftool. For example,
bpftool may print like below:
{
"key": 0,
"values": [{
"cpu": 0,
"value": {
"ui32": 0,
"ui16": 0,
}
},{
"cpu": 1,
"value": {
"ui32": 1,
"ui16": 0,
}
},{
"cpu": 2,
"value": {
"ui32": 2,
"ui16": 0,
}
},{
"cpu": 3,
"value": {
"ui32": 3,
"ui16": 0,
}
}
]
}
Patch #1 implemented bpffs pretty print for percpu arraymap/hash/lru_hash
in kernel. Patch #2 added the test case in tools bpf selftest test_btf.
Patch #3 added percpu map btf based dump.
Yonghong Song (3):
bpf: add bpffs pretty print for percpu arraymap/hash/lru_hash
tools/bpf: add bpffs percpu map pretty print tests in test_btf
tools/bpf: bpftool: add btf percpu map formated dump
kernel/bpf/arraymap.c | 24 +++++
kernel/bpf/hashtab.c | 31 ++++++
tools/bpf/bpftool/map.c | 33 +++++-
tools/testing/selftests/bpf/test_btf.c | 179 ++++++++++++++++++++++++++-------
4 files changed, 230 insertions(+), 37 deletions(-)
--
2.14.3
next reply other threads:[~2018-08-30 1:42 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-08-29 21:43 Yonghong Song [this message]
2018-08-29 21:43 ` [PATCH bpf-next 1/3] bpf: add bpffs pretty print for percpu arraymap/hash/lru_hash Yonghong Song
2018-08-29 21:43 ` [PATCH bpf-next 2/3] tools/bpf: add bpffs percpu map pretty print tests in test_btf Yonghong Song
2018-08-29 21:43 ` [PATCH bpf-next 3/3] tools/bpf: bpftool: add btf percpu map formated dump Yonghong Song
2018-08-30 12:25 ` [PATCH bpf-next 0/3] bpf: implement percpu map pretty print for bpffs and bpftool Daniel Borkmann
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=20180829214315.4065753-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