Re: [RFC PATCH 0/5] pgo: Add PGO support for module profile data
From: Kees Cook
Date: Mon Jun 14 2021 - 12:06:44 EST
[oops, I failed to CC correctly -- resending]
On Sat, Jun 12, 2021 at 06:24:21AM +0300, Jarmo Tiitto wrote:
> This patch series intends to extend the current Clang PGO code to
> support profile data from modules. Note that current PGO can and *does*
> instrument all kernel code, including modules, but this profile data
> is inaccessible.
>
> This patch series adds pgo/<module>.profraw files from what
> per loaded module profile data can be read.
>
> The final profile can be generated by merging all these profile files:
> llvm-profdata merge --output=vmlinux.profdata vmlinux.profraw ...
> and then building the optimized kernel.
>
> This v2 patch series is still an bit of RFC so I'd like feedback how
> to do things better still.
This looks pretty good; thank you! I sent some notes, which are mostly
just clean-ups and patch hunk moves.
> The patches itself are based on Kees/for-next/clang/features tree
> where I have two of my bug fix patches already in. :-)
>
> I have done some initial testing:
> * Booted the instrumented kernel on qemu *and* bare hardware.
> * Module un/loading via test_module in QEMU.
> * Built optimized kernel using the new profile data.
If you haven't already, can you also test this with lock testing
enabled? i.e. these configs:
# Detect potential deadlocks.
CONFIG_PROVE_LOCKING=y
# Detect sleep-while-atomic.
CONFIG_DEBUG_ATOMIC_SLEEP=y
Thanks!
-Kees
>
> Jarmo Tiitto (5):
> pgo: Expose module sections for clang PGO instumentation.
> pgo: Make serializing functions to take prf_object
> pgo: Wire up the new more generic code for modules
> pgo: Add module notifier machinery
> pgo: Cleanup code in pgo/fs.c
>
> include/linux/module.h | 15 +++
> kernel/Makefile | 6 +
> kernel/module.c | 7 ++
> kernel/pgo/fs.c | 241 ++++++++++++++++++++++++++++++++++------
> kernel/pgo/instrument.c | 57 +++++++---
> kernel/pgo/pgo.h | 85 ++++++++++----
> 6 files changed, 342 insertions(+), 69 deletions(-)
>
>
> base-commit: 0039303120c0065f3952698597e0c9916b76ebd5
> --
> 2.32.0
>
--
Kees Cook