From: Jiri Olsa <jolsa@redhat.com>
To: Daniel Borkmann <daniel@iogearbox.net>
Cc: Jiri Olsa <jolsa@kernel.org>, Alexei Starovoitov <ast@kernel.org>,
Andrii Nakryiko <andriin@fb.com>,
Arnaldo Carvalho de Melo <acme@kernel.org>,
Yonghong Song <yhs@fb.com>, Song Liu <songliubraving@fb.com>,
Andrii Nakryiko <andrii@kernel.org>,
netdev@vger.kernel.org, bpf@vger.kernel.org,
Martin KaFai Lau <kafai@fb.com>,
John Fastabend <john.fastabend@gmail.com>,
KP Singh <kpsingh@chromium.org>
Subject: Re: [PATCHv5 bpf] bpf: Move iterator functions into special init section
Date: Tue, 10 Nov 2020 11:35:09 +0100 [thread overview]
Message-ID: <20201110103509.GD387652@krava> (raw)
In-Reply-To: <9205a69f-95db-6bc3-51f8-8b6f79c5e8fd@iogearbox.net>
On Mon, Nov 09, 2020 at 11:04:34PM +0100, Daniel Borkmann wrote:
SNIP
> > index 7b53cb3092ee..a7c71e3b5f9a 100644
> > --- a/include/linux/init.h
> > +++ b/include/linux/init.h
> > @@ -52,6 +52,7 @@
> > #define __initconst __section(".init.rodata")
> > #define __exitdata __section(".exit.data")
> > #define __exit_call __used __section(".exitcall.exit")
> > +#define __init_bpf_preserve_type __section(".init.bpf.preserve_type")
>
> Small nit, why this detour via BPF_INIT define? Couldn't we just:
>
> #ifdef CONFIG_DEBUG_INFO_BTF
> #define __init_bpf_preserve_type __section(".init.bpf.preserve_type")
> #else
> #define __init_bpf_preserve_type __init
> #endif
>
> Also, the comment above the existing defines says '/* These are for everybody (although
> not all archs will actually discard it in modules) */' ... We should probably not add
> the __init_bpf_preserve_type right under this listing as-is in your patch, but instead
> 'separate' it by adding a small comment on top of its definition by explaining its
> purpose more clearly for others.
ok, for some reason I thought I needed to add it to init.h,
but as it's bpf specific, perhaps we can omit init.h change
completely.. how about the change below?
thanks,
jirka
---
diff --git a/include/asm-generic/vmlinux.lds.h b/include/asm-generic/vmlinux.lds.h
index b2b3d81b1535..f91029b3443b 100644
--- a/include/asm-generic/vmlinux.lds.h
+++ b/include/asm-generic/vmlinux.lds.h
@@ -685,8 +685,21 @@
.BTF_ids : AT(ADDR(.BTF_ids) - LOAD_OFFSET) { \
*(.BTF_ids) \
}
+
+/*
+ * .init.bpf.preserve_type
+ *
+ * This section store special BPF function and marks them
+ * with begin/end symbols pair for the sake of pahole tool.
+ */
+#define INIT_BPF_PRESERVE_TYPE \
+ __init_bpf_preserve_type_begin = .; \
+ *(.init.bpf.preserve_type) \
+ __init_bpf_preserve_type_end = .; \
+ MEM_DISCARD(init.bpf.preserve_type)
#else
#define BTF
+#define INIT_BPF_PRESERVE_TYPE
#endif
/*
@@ -741,7 +754,8 @@
#define INIT_TEXT \
*(.init.text .init.text.*) \
*(.text.startup) \
- MEM_DISCARD(init.text*)
+ MEM_DISCARD(init.text*) \
+ INIT_BPF_PRESERVE_TYPE
#define EXIT_DATA \
*(.exit.data .exit.data.*) \
diff --git a/include/linux/bpf.h b/include/linux/bpf.h
index 2b16bf48aab6..1739a92516ed 100644
--- a/include/linux/bpf.h
+++ b/include/linux/bpf.h
@@ -1276,10 +1276,20 @@ struct bpf_link *bpf_link_get_from_fd(u32 ufd);
int bpf_obj_pin_user(u32 ufd, const char __user *pathname);
int bpf_obj_get_user(const char __user *pathname, int flags);
+/* In case we generate BTF data, we need to group all iterator
+ * functions into special init section, so pahole can track them.
+ * Otherwise pure __init section is enough.
+ */
+#ifdef CONFIG_DEBUG_INFO_BTF
+#define __init_bpf_preserve_type __section(".init.bpf.preserve_type")
+#else
+#define __init_bpf_preserve_type __init
+#endif
+
#define BPF_ITER_FUNC_PREFIX "bpf_iter_"
#define DEFINE_BPF_ITER_FUNC(target, args...) \
extern int bpf_iter_ ## target(args); \
- int __init bpf_iter_ ## target(args) { return 0; }
+ int __init_bpf_preserve_type bpf_iter_ ## target(args) { return 0; }
struct bpf_iter_aux_info {
struct bpf_map *map;
next prev parent reply other threads:[~2020-11-10 10:35 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-11-09 18:57 [PATCHv5 bpf] bpf: Move iterator functions into special init section Jiri Olsa
2020-11-09 22:04 ` Daniel Borkmann
2020-11-10 10:35 ` Jiri Olsa [this message]
2020-11-10 23:30 ` 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=20201110103509.GD387652@krava \
--to=jolsa@redhat.com \
--cc=acme@kernel.org \
--cc=andrii@kernel.org \
--cc=andriin@fb.com \
--cc=ast@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=daniel@iogearbox.net \
--cc=john.fastabend@gmail.com \
--cc=jolsa@kernel.org \
--cc=kafai@fb.com \
--cc=kpsingh@chromium.org \
--cc=netdev@vger.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).