From: Jarmo Tiitto <jarmo.tiitto@gmail.com>
To: Jessica Yu <jeyu@kernel.org>,
Nathan Chancellor <nathan@kernel.org>,
Nick Desaulniers <ndesaulniers@google.com>,
Kees Cook <keescook@chromium.org>,
Andrew Morton <akpm@linux-foundation.org>,
Sami Tolvanen <samitolvanen@google.com>,
Marco Elver <elver@google.com>,
Alexander Popov <alex.popov@linux.com>,
Masahiro Yamada <masahiroy@kernel.org>,
"Paul E. McKenney" <paulmck@kernel.org>,
Jarmo Tiitto <jarmo.tiitto@gmail.com>,
Dmitry Vyukov <dvyukov@google.com>, Arnd Bergmann <arnd@arndb.de>,
Alexei Starovoitov <ast@kernel.org>,
linux-kernel@vger.kernel.org, clang-built-linux@googlegroups.com
Cc: morbo@google.com,
Andy Shevchenko <andriy.shevchenko@linux.intel.com>,
Thomas Gleixner <tglx@linutronix.de>,
Chris Wilson <chris@chris-wilson.co.uk>
Subject: [RFC PATCH 1/5] pgo: Expose module sections for clang PGO instumentation.
Date: Sat, 12 Jun 2021 06:24:22 +0300 [thread overview]
Message-ID: <20210612032425.11425-2-jarmo.tiitto@gmail.com> (raw)
In-Reply-To: <20210612032425.11425-1-jarmo.tiitto@gmail.com>
Expose module sections for clang PGO:
In find_module_sections() add code to grab pointer and size
of __llvm_prf_{data,cnts,names,vnds} sections.
This data is used by pgo/instrument.c and pgo/fs.c
in following patches together with explicitly exposed
vmlinux's core __llvm_prf_xxx sections.
Signed-off-by: Jarmo Tiitto <jarmo.tiitto@gmail.com>
---
the reason of disabling profiling for module.c
is that instrumented kernel changes struct module layout,
and thus invalidates profile data collected from module.c
when optimized kernel it built.
More over the profile data from kernel/module.c
is probably not needed either way.
---
include/linux/module.h | 15 +++++++++++++++
kernel/Makefile | 6 ++++++
kernel/module.c | 7 +++++++
3 files changed, 28 insertions(+)
diff --git a/include/linux/module.h b/include/linux/module.h
index 8100bb477d86..7f557016e879 100644
--- a/include/linux/module.h
+++ b/include/linux/module.h
@@ -492,6 +492,21 @@ struct module {
unsigned long *kprobe_blacklist;
unsigned int num_kprobe_blacklist;
#endif
+#ifdef CONFIG_PGO_CLANG
+ /*
+ * Keep in sync with the PGO_CLANG_DATA sections
+ * in include/asm-generic/vmlinux.lds.h
+ * The prf_xxx_size is the section size in bytes.
+ */
+ void *prf_data; /* struct llvm_prf_data */
+ int prf_data_size;
+ void *prf_cnts;
+ int prf_cnts_size;
+ const void *prf_names;
+ int prf_names_size;
+ void *prf_vnds; /* struct llvm_prf_value_node */
+ int prf_vnds_size;
+#endif
#ifdef CONFIG_HAVE_STATIC_CALL_INLINE
int num_static_call_sites;
struct static_call_site *static_call_sites;
diff --git a/kernel/Makefile b/kernel/Makefile
index 6deef4effbdb..8657d67b771c 100644
--- a/kernel/Makefile
+++ b/kernel/Makefile
@@ -44,6 +44,12 @@ CFLAGS_kcov.o := $(call cc-option, -fno-conserve-stack) -fno-stack-protector
# Don't instrument error handlers
CFLAGS_REMOVE_cfi.o := $(CC_FLAGS_CFI)
+# Don't profile module.c:
+# CLANG_PGO changes the layout of struct module
+# for instrumented kernel so the profile data
+# will mismatch on final build.
+PGO_PROFILE_module.o := n
+
obj-y += sched/
obj-y += locking/
obj-y += power/
diff --git a/kernel/module.c b/kernel/module.c
index b5dd92e35b02..a2f65c247c41 100644
--- a/kernel/module.c
+++ b/kernel/module.c
@@ -3329,6 +3329,13 @@ static int find_module_sections(struct module *mod, struct load_info *info)
sizeof(*mod->static_call_sites),
&mod->num_static_call_sites);
#endif
+#ifdef CONFIG_PGO_CLANG
+ mod->prf_data = section_objs(info, "__llvm_prf_data", 1, &mod->prf_data_size);
+ mod->prf_cnts = section_objs(info, "__llvm_prf_cnts", 1, &mod->prf_cnts_size);
+ mod->prf_names = section_objs(info, "__llvm_prf_names", 1, &mod->prf_names_size);
+ mod->prf_vnds = section_objs(info, "__llvm_prf_vnds", 1, &mod->prf_vnds_size);
+#endif
+
mod->extable = section_objs(info, "__ex_table",
sizeof(*mod->extable), &mod->num_exentries);
base-commit: 0039303120c0065f3952698597e0c9916b76ebd5
--
2.32.0
next prev parent reply other threads:[~2021-06-12 3:36 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-06-12 3:24 [RFC PATCH 0/5] pgo: Add PGO support for module profile data Jarmo Tiitto
2021-06-12 3:24 ` Jarmo Tiitto [this message]
2021-06-12 3:24 ` [RFC PATCH 2/5] pgo: Make serializing functions to take prf_object Jarmo Tiitto
2021-06-12 3:24 ` [RFC PATCH 3/5] pgo: Wire up the new more generic code for modules Jarmo Tiitto
2021-06-14 15:55 ` Kees Cook
2021-06-14 19:08 ` jarmo.tiitto
2021-06-12 3:24 ` [RFC PATCH 4/5] pgo: Add module notifier machinery Jarmo Tiitto
2021-06-14 16:00 ` Kees Cook
2021-06-14 18:31 ` jarmo.tiitto
2021-06-12 3:24 ` [RFC PATCH 5/5] pgo: Cleanup code in pgo/fs.c Jarmo Tiitto
2021-06-14 15:50 ` Kees Cook
2021-06-14 16:05 ` [RFC PATCH 0/5] pgo: Add PGO support for module profile data Kees Cook
2021-06-14 21:57 ` Kees Cook
2021-06-14 22:27 ` jarmo.tiitto
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=20210612032425.11425-2-jarmo.tiitto@gmail.com \
--to=jarmo.tiitto@gmail.com \
--cc=akpm@linux-foundation.org \
--cc=alex.popov@linux.com \
--cc=andriy.shevchenko@linux.intel.com \
--cc=arnd@arndb.de \
--cc=ast@kernel.org \
--cc=chris@chris-wilson.co.uk \
--cc=clang-built-linux@googlegroups.com \
--cc=dvyukov@google.com \
--cc=elver@google.com \
--cc=jeyu@kernel.org \
--cc=keescook@chromium.org \
--cc=linux-kernel@vger.kernel.org \
--cc=masahiroy@kernel.org \
--cc=morbo@google.com \
--cc=nathan@kernel.org \
--cc=ndesaulniers@google.com \
--cc=paulmck@kernel.org \
--cc=samitolvanen@google.com \
--cc=tglx@linutronix.de \
/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