lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  PHC 
Open Source and information security mailing list archives
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:   Thu, 21 Jan 2021 17:29:40 -0800
From:   Nick Desaulniers <>
To:     Bill Wendling <>
Cc:     Jonathan Corbet <>,
        Masahiro Yamada <>,
        Linux Doc Mailing List <>,
        LKML <>,
        Linux Kbuild mailing list <>,
        clang-built-linux <>,
        Andrew Morton <>,
        Nathan Chancellor <>,
        Sami Tolvanen <>
Subject: Re: [PATCH v6] pgo: add clang's Profile Guided Optimization infrastructure

On Thu, Jan 21, 2021 at 12:24 AM Bill Wendling <> wrote:
> From: Sami Tolvanen <>
> Enable the use of clang's Profile-Guided Optimization[1]. To generate a
> profile, the kernel is instrumented with PGO counters, a representative
> workload is run, and the raw profile data is collected from
> /sys/kernel/debug/pgo/profraw.
> The raw profile data must be processed by clang's "llvm-profdata" tool
> before it can be used during recompilation:
>   $ cp /sys/kernel/debug/pgo/profraw vmlinux.profraw
>   $ llvm-profdata merge --output=vmlinux.profdata vmlinux.profraw
> Multiple raw profiles may be merged during this step.
> The data can now be used by the compiler:
>   $ make LLVM=1 KCFLAGS=-fprofile-use=vmlinux.profdata ...
> This initial submission is restricted to x86, as that's the platform we
> know works. This restriction can be lifted once other platforms have
> been verified to work with PGO.
> Note that this method of profiling the kernel is clang-native, unlike
> the clang support in kernel/gcov.
> [1]
> Signed-off-by: Sami Tolvanen <>
> Co-developed-by: Bill Wendling <>
> Signed-off-by: Bill Wendling <>
> Tested-by: Nick Desaulniers <>
> ---
> v2: - Added "__llvm_profile_instrument_memop" based on Nathan Chancellor's
>       testing.
>     - Corrected documentation, re PGO flags when using LTO, based on Fangrui
>       Song's comments.
> v3: - Added change log section based on Sedat Dilek's comments.
> v4: - Remove non-x86 Makfile changes and se "hweight64" instead of using our
>       own popcount implementation, based on Nick Desaulniers's comment.
> v5: - Correct padding calculation, discovered by Nathan Chancellor.
> v6: - Add better documentation about the locking scheme and other things.
>     - Rename macros to better match the same macros in LLVM's source code.

This is a major win for readability and comparing it against LLVM's
compiler-rt implementation! Thank you for doing that.  It looks like
it addresses most of my concerns.  I'm not against following up on
little details in subsequent patches on top.  However Sedat is right
about the small issue that v6 doesn't compile.  If you were to roll
his fixup into a v7 I'd be happy to sign off on it at this point.
~Nick Desaulniers

Powered by blists - more mailing lists