From: Jiri Olsa <jolsa@kernel.org>
To: Alexei Starovoitov <ast@kernel.org>,
Daniel Borkmann <daniel@iogearbox.net>
Cc: "Song Liu" <songliubraving@fb.com>,
netdev@vger.kernel.org, bpf@vger.kernel.org,
"Andrii Nakryiko" <andriin@fb.com>, "Yonghong Song" <yhs@fb.com>,
"Martin KaFai Lau" <kafai@fb.com>,
"Jakub Kicinski" <kuba@kernel.org>,
"David Miller" <davem@redhat.com>,
"Björn Töpel" <bjorn.topel@intel.com>,
"John Fastabend" <john.fastabend@gmail.com>,
"Jesper Dangaard Brouer" <hawk@kernel.org>,
"Arnaldo Carvalho de Melo" <acme@redhat.com>,
"Song Liu" <song@kernel.org>
Subject: [PATCH 02/15] bpf: Add bpf_trampoline_ name prefix for DECLARE_BPF_DISPATCHER
Date: Mon, 2 Mar 2020 15:31:41 +0100 [thread overview]
Message-ID: <20200302143154.258569-3-jolsa@kernel.org> (raw)
In-Reply-To: <20200302143154.258569-1-jolsa@kernel.org>
From: Björn Töpel <bjorn.topel@intel.com>
Adding bpf_trampoline_ name prefix for DECLARE_BPF_DISPATCHER,
so all the dispatchers have the common name prefix.
And also a small '_' cleanup for bpf_dispatcher_nopfunc function
name.
Acked-by: Song Liu <songliubraving@fb.com>
Signed-off-by: Björn Töpel <bjorn.topel@intel.com>
Signed-off-by: Jiri Olsa <jolsa@kernel.org>
---
include/linux/bpf.h | 21 +++++++++++----------
include/linux/filter.h | 7 +++----
net/core/filter.c | 5 ++---
3 files changed, 16 insertions(+), 17 deletions(-)
diff --git a/include/linux/bpf.h b/include/linux/bpf.h
index 49b1a70e12c8..be7afccc9459 100644
--- a/include/linux/bpf.h
+++ b/include/linux/bpf.h
@@ -512,7 +512,7 @@ struct bpf_dispatcher {
u32 image_off;
};
-static __always_inline unsigned int bpf_dispatcher_nopfunc(
+static __always_inline unsigned int bpf_dispatcher_nop_func(
const void *ctx,
const struct bpf_insn *insnsi,
unsigned int (*bpf_func)(const void *,
@@ -527,7 +527,7 @@ int bpf_trampoline_unlink_prog(struct bpf_prog *prog);
void bpf_trampoline_put(struct bpf_trampoline *tr);
#define BPF_DISPATCHER_INIT(name) { \
.mutex = __MUTEX_INITIALIZER(name.mutex), \
- .func = &name##func, \
+ .func = &name##_func, \
.progs = {}, \
.num_progs = 0, \
.image = NULL, \
@@ -535,7 +535,7 @@ void bpf_trampoline_put(struct bpf_trampoline *tr);
}
#define DEFINE_BPF_DISPATCHER(name) \
- noinline unsigned int name##func( \
+ noinline unsigned int bpf_dispatcher_##name##_func( \
const void *ctx, \
const struct bpf_insn *insnsi, \
unsigned int (*bpf_func)(const void *, \
@@ -543,17 +543,18 @@ void bpf_trampoline_put(struct bpf_trampoline *tr);
{ \
return bpf_func(ctx, insnsi); \
} \
- EXPORT_SYMBOL(name##func); \
- struct bpf_dispatcher name = BPF_DISPATCHER_INIT(name);
+ EXPORT_SYMBOL(bpf_dispatcher_##name##_func); \
+ struct bpf_dispatcher bpf_dispatcher_##name = \
+ BPF_DISPATCHER_INIT(bpf_dispatcher_##name);
#define DECLARE_BPF_DISPATCHER(name) \
- unsigned int name##func( \
+ unsigned int bpf_dispatcher_##name##_func( \
const void *ctx, \
const struct bpf_insn *insnsi, \
unsigned int (*bpf_func)(const void *, \
const struct bpf_insn *)); \
- extern struct bpf_dispatcher name;
-#define BPF_DISPATCHER_FUNC(name) name##func
-#define BPF_DISPATCHER_PTR(name) (&name)
+ extern struct bpf_dispatcher bpf_dispatcher_##name;
+#define BPF_DISPATCHER_FUNC(name) bpf_dispatcher_##name##_func
+#define BPF_DISPATCHER_PTR(name) (&bpf_dispatcher_##name)
void bpf_dispatcher_change_prog(struct bpf_dispatcher *d, struct bpf_prog *from,
struct bpf_prog *to);
struct bpf_image {
@@ -579,7 +580,7 @@ static inline int bpf_trampoline_unlink_prog(struct bpf_prog *prog)
static inline void bpf_trampoline_put(struct bpf_trampoline *tr) {}
#define DEFINE_BPF_DISPATCHER(name)
#define DECLARE_BPF_DISPATCHER(name)
-#define BPF_DISPATCHER_FUNC(name) bpf_dispatcher_nopfunc
+#define BPF_DISPATCHER_FUNC(name) bpf_dispatcher_nop_func
#define BPF_DISPATCHER_PTR(name) NULL
static inline void bpf_dispatcher_change_prog(struct bpf_dispatcher *d,
struct bpf_prog *from,
diff --git a/include/linux/filter.h b/include/linux/filter.h
index f349e2c0884c..eafe72644282 100644
--- a/include/linux/filter.h
+++ b/include/linux/filter.h
@@ -577,7 +577,7 @@ DECLARE_STATIC_KEY_FALSE(bpf_stats_enabled_key);
ret; })
#define BPF_PROG_RUN(prog, ctx) __BPF_PROG_RUN(prog, ctx, \
- bpf_dispatcher_nopfunc)
+ bpf_dispatcher_nop_func)
#define BPF_SKB_CB_LEN QDISC_CB_PRIV_LEN
@@ -701,7 +701,7 @@ static inline u32 bpf_prog_run_clear_cb(const struct bpf_prog *prog,
return res;
}
-DECLARE_BPF_DISPATCHER(bpf_dispatcher_xdp)
+DECLARE_BPF_DISPATCHER(xdp)
static __always_inline u32 bpf_prog_run_xdp(const struct bpf_prog *prog,
struct xdp_buff *xdp)
@@ -712,8 +712,7 @@ static __always_inline u32 bpf_prog_run_xdp(const struct bpf_prog *prog,
* already takes rcu_read_lock() when fetching the program, so
* it's not necessary here anymore.
*/
- return __BPF_PROG_RUN(prog, xdp,
- BPF_DISPATCHER_FUNC(bpf_dispatcher_xdp));
+ return __BPF_PROG_RUN(prog, xdp, BPF_DISPATCHER_FUNC(xdp));
}
void bpf_prog_change_xdp(struct bpf_prog *prev_prog, struct bpf_prog *prog);
diff --git a/net/core/filter.c b/net/core/filter.c
index c180871e606d..9048453e235c 100644
--- a/net/core/filter.c
+++ b/net/core/filter.c
@@ -8835,10 +8835,9 @@ const struct bpf_prog_ops sk_reuseport_prog_ops = {
};
#endif /* CONFIG_INET */
-DEFINE_BPF_DISPATCHER(bpf_dispatcher_xdp)
+DEFINE_BPF_DISPATCHER(xdp)
void bpf_prog_change_xdp(struct bpf_prog *prev_prog, struct bpf_prog *prog)
{
- bpf_dispatcher_change_prog(BPF_DISPATCHER_PTR(bpf_dispatcher_xdp),
- prev_prog, prog);
+ bpf_dispatcher_change_prog(BPF_DISPATCHER_PTR(xdp), prev_prog, prog);
}
--
2.24.1
next prev parent reply other threads:[~2020-03-02 14:32 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-03-02 14:31 [PATCHv4 00/15] bpf: Add trampoline and dispatcher to /proc/kallsyms Jiri Olsa
2020-03-02 14:31 ` [PATCH 01/15] x86/mm: Rename is_kernel_text to __is_kernel_text Jiri Olsa
2020-03-02 14:31 ` Jiri Olsa [this message]
2020-03-02 14:31 ` [PATCH 03/15] bpf: Add struct bpf_ksym Jiri Olsa
2020-03-02 14:31 ` [PATCH 04/15] bpf: Add name to " Jiri Olsa
2020-03-02 14:31 ` [PATCH 05/15] bpf: Move lnode list node " Jiri Olsa
2020-03-02 14:31 ` [PATCH 06/15] bpf: Add bpf_ksym_tree tree Jiri Olsa
2020-03-03 18:03 ` Alexei Starovoitov
2020-03-03 20:12 ` Jiri Olsa
2020-03-02 14:31 ` [PATCH 07/15] bpf: Move bpf_tree add/del from bpf_prog_ksym_node_add/del Jiri Olsa
2020-03-02 14:31 ` [PATCH 08/15] bpf: Separate kallsyms add/del functions Jiri Olsa
2020-03-02 14:31 ` [PATCH 09/15] bpf: Add bpf_ksym_add/del functions Jiri Olsa
2020-03-02 14:31 ` [PATCH 10/15] bpf: Rename bpf_tree to bpf_progs_tree Jiri Olsa
2020-03-02 14:31 ` [PATCH 11/15] bpf: Add trampolines to kallsyms Jiri Olsa
2020-03-02 14:31 ` [PATCH 12/15] bpf: Add dispatchers " Jiri Olsa
2020-03-02 14:31 ` [PATCH 13/15] perf tools: Synthesize bpf_trampoline/dispatcher ksymbol event Jiri Olsa
2020-03-02 14:31 ` [PATCH 14/15] perf tools: Set ksymbol dso as loaded on arrival Jiri Olsa
2020-03-02 14:31 ` [PATCH 15/15] perf annotate: Add base support for bpf_image Jiri Olsa
2020-03-12 19:55 [PATCHv5 00/15] bpf: Add trampoline and dispatcher to /proc/kallsyms Jiri Olsa
2020-03-12 19:55 ` [PATCH 02/15] bpf: Add bpf_trampoline_ name prefix for DECLARE_BPF_DISPATCHER Jiri Olsa
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=20200302143154.258569-3-jolsa@kernel.org \
--to=jolsa@kernel.org \
--cc=acme@redhat.com \
--cc=andriin@fb.com \
--cc=ast@kernel.org \
--cc=bjorn.topel@intel.com \
--cc=bpf@vger.kernel.org \
--cc=daniel@iogearbox.net \
--cc=davem@redhat.com \
--cc=hawk@kernel.org \
--cc=john.fastabend@gmail.com \
--cc=kafai@fb.com \
--cc=kuba@kernel.org \
--cc=netdev@vger.kernel.org \
--cc=song@kernel.org \
--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 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).