From: Joe Burton <jevburton.kernel@gmail.com>
To: Alexei Starovoitov <ast@kernel.org>,
Daniel Borkmann <daniel@iogearbox.net>,
Andrii Nakryiko <andrii@kernel.org>,
Martin KaFai Lau <kafai@fb.com>, Song Liu <songliubraving@fb.com>,
Yonghong Song <yhs@fb.com>,
John Fastabend <john.fastabend@gmail.com>,
KP Singh <kpsingh@kernel.org>,
linux-kernel@vger.kernel.org, netdev@vger.kernel.org,
bpf@vger.kernel.org, ppenkov@google.com, sdf@google.com,
haoluo@google.com
Cc: Joe Burton <jevburton@google.com>
Subject: [PATCH bpf-next v4 0/3] Introduce BPF map tracing capability
Date: Wed, 5 Jan 2022 03:03:42 +0000 [thread overview]
Message-ID: <20220105030345.3255846-1-jevburton.kernel@gmail.com> (raw)
From: Joe Burton <jevburton@google.com>
This is the fourth version of a patch series implementing map tracing.
Map tracing enables executing BPF programs upon BPF map updates. This
might be useful to perform upgrades of stateful programs; e.g., tracing
programs can propagate changes to maps that occur during an upgrade
operation.
This version uses trampoline hooks to provide the capability.
fentry/fexit/fmod_ret programs can attach to two new functions:
int bpf_map_trace_update_elem(struct bpf_map* map, void* key,
void* val, u32 flags);
int bpf_map_trace_delete_elem(struct bpf_map* map, void* key);
These hooks work as intended for the following map types:
BPF_MAP_TYPE_ARRAY
BPF_MAP_TYPE_PERCPU_ARRAY
BPF_MAP_TYPE_HASH
BPF_MAP_TYPE_PERCPU_HASH
BPF_MAP_TYPE_LRU_HASH
BPF_MAP_TYPE_LRU_PERCPU_HASH
The only guarantee about the semantics of these hooks is that they execute
after the operation takes place. We cannot call them with locks held
because the hooked program might try to acquire the same locks.
Changes from v3 -> v4:
* Hooks execute *after* the associated operation, not before.
* Replaced `#pragma once' with traditional `#ifdef' guards.
* Explicitly constrained selftests to x86, since trampolines are only
implemented there.
* Use /dev/null instead of /tmp/map_trace_test_file in selftests.
Changes from v2 -> v3:
* Reimplemented using trampoline hooks, simplifying greatly.
Changes from v1 -> v2:
* None. Resent series to a broader audience.
Joe Burton (3):
bpf: Add map tracing functions and call sites
bpf: Add selftests
bpf: Add real world example for map tracing
kernel/bpf/Makefile | 2 +-
kernel/bpf/arraymap.c | 4 +-
kernel/bpf/hashtab.c | 20 +-
kernel/bpf/map_trace.c | 17 +
kernel/bpf/map_trace.h | 19 +
.../selftests/bpf/prog_tests/map_trace.c | 427 ++++++++++++++++++
.../selftests/bpf/progs/bpf_map_trace.c | 95 ++++
.../bpf/progs/bpf_map_trace_common.h | 12 +
.../progs/bpf_map_trace_real_world_common.h | 125 +++++
.../bpf_map_trace_real_world_migration.c | 102 +++++
.../bpf/progs/bpf_map_trace_real_world_new.c | 4 +
.../bpf/progs/bpf_map_trace_real_world_old.c | 5 +
12 files changed, 829 insertions(+), 3 deletions(-)
create mode 100644 kernel/bpf/map_trace.c
create mode 100644 kernel/bpf/map_trace.h
create mode 100644 tools/testing/selftests/bpf/prog_tests/map_trace.c
create mode 100644 tools/testing/selftests/bpf/progs/bpf_map_trace.c
create mode 100644 tools/testing/selftests/bpf/progs/bpf_map_trace_common.h
create mode 100644 tools/testing/selftests/bpf/progs/bpf_map_trace_real_world_common.h
create mode 100644 tools/testing/selftests/bpf/progs/bpf_map_trace_real_world_migration.c
create mode 100644 tools/testing/selftests/bpf/progs/bpf_map_trace_real_world_new.c
create mode 100644 tools/testing/selftests/bpf/progs/bpf_map_trace_real_world_old.c
--
2.34.1.448.ga2b2bfdf31-goog
next reply other threads:[~2022-01-05 3:03 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-01-05 3:03 Joe Burton [this message]
2022-01-05 3:03 ` [PATCH bpf-next v4 1/3] bpf: Add map tracing functions and call sites Joe Burton
2022-01-06 23:11 ` Daniel Borkmann
2022-01-05 3:03 ` [PATCH bpf-next v4 2/3] bpf: Add selftests Joe Burton
2022-01-07 0:56 ` Alexei Starovoitov
2022-01-05 3:03 ` [PATCH bpf-next v4 3/3] bpf: Add real world example for map tracing Joe Burton
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=20220105030345.3255846-1-jevburton.kernel@gmail.com \
--to=jevburton.kernel@gmail.com \
--cc=andrii@kernel.org \
--cc=ast@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=daniel@iogearbox.net \
--cc=haoluo@google.com \
--cc=jevburton@google.com \
--cc=john.fastabend@gmail.com \
--cc=kafai@fb.com \
--cc=kpsingh@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=ppenkov@google.com \
--cc=sdf@google.com \
--cc=songliubraving@fb.com \
--cc=yhs@fb.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.