All of lore.kernel.org
 help / color / mirror / Atom feed
From: Bill Wendling <morbo@google.com>
To: Peter Zijlstra <peterz@infradead.org>
Cc: Kees Cook <keescook@google.com>, Jonathan Corbet <corbet@lwn.net>,
	Masahiro Yamada <masahiroy@kernel.org>,
	Linux Doc Mailing List <linux-doc@vger.kernel.org>,
	LKML <linux-kernel@vger.kernel.org>,
	Linux Kbuild mailing list <linux-kbuild@vger.kernel.org>,
	clang-built-linux <clang-built-linux@googlegroups.com>,
	Andrew Morton <akpm@linux-foundation.org>,
	Nathan Chancellor <natechancellor@gmail.com>,
	Nick Desaulniers <ndesaulniers@google.com>,
	Sami Tolvanen <samitolvanen@google.com>,
	Fangrui Song <maskray@google.com>,
	"maintainer:X86 ARCHITECTURE (32-BIT AND 64-BIT)"
	<x86@kernel.org>
Subject: Re: [PATCH v9] pgo: add clang's Profile Guided Optimization infrastructure
Date: Sat, 12 Jun 2021 12:10:03 -0700	[thread overview]
Message-ID: <CAGG=3QVHkkJ236mCJ8Jt_6JtgYtWHV9b4aVXnoj6ypc7GOnc0A@mail.gmail.com> (raw)
In-Reply-To: <YMT5xZsZMX0PpDKQ@hirez.programming.kicks-ass.net>

")On Sat, Jun 12, 2021 at 11:15 AM Peter Zijlstra <peterz@infradead.org> wrote:
>
> On Sat, Jun 12, 2021 at 10:25:57AM -0700, Bill Wendling wrote:
> > On Sat, Jun 12, 2021 at 9:59 AM Peter Zijlstra <peterz@infradead.org> wrote:
> > >
> > > On Wed, Apr 07, 2021 at 02:17:04PM -0700, Bill Wendling wrote:
> > > > From: Sami Tolvanen <samitolvanen@google.com>
> > > >
> > > > 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.
> > >
> > > *sigh*, and not a single x86 person on Cc, how nice :-/
> > >
> > This tool is generic and, despite the fact that it's first enabled for
> > x86, it contains no x86-specific code. The reason we're restricting it
> > to x86 is because it's the platform we tested on.
>
> You're modifying a lot of x86 files, you don't think it's good to let us
> know?  Worse, afaict this -fprofile-generate changes code generation,
> and we definitely want to know about that.
>
I got the list of people to add from the scripts/get_maintainer.pl.
The files you list below are mostly changes in Makefile, so it added
the kbuild maintainers and list. There's a small change to the linker
script to add the clang PGO data section, which is defined in
"include/asm-generic/vmlinux.lds.h". Using the "kernel/gcov" initial
implementation as a guildlline
(2521f2c228ad750701ba4702484e31d876dbc386), there's one intel people
CC'ed, but he didn't sign off on it. These patches were available for
review for months now, and posted to all of the lists and CC'ed to the
people from scripts/get_maintainers.pl. Perhaps that program should be
improved?

> > > >  arch/x86/Kconfig                      |   1 +
> > > >  arch/x86/boot/Makefile                |   1 +
> > > >  arch/x86/boot/compressed/Makefile     |   1 +
> > > >  arch/x86/crypto/Makefile              |   4 +
> > > >  arch/x86/entry/vdso/Makefile          |   1 +
> > > >  arch/x86/kernel/vmlinux.lds.S         |   2 +
> > > >  arch/x86/platform/efi/Makefile        |   1 +
> > > >  arch/x86/purgatory/Makefile           |   1 +
> > > >  arch/x86/realmode/rm/Makefile         |   1 +
> > > >  arch/x86/um/vdso/Makefile             |   1 +
>
>
> > > > +CFLAGS_PGO_CLANG := -fprofile-generate
> > > > +export CFLAGS_PGO_CLANG
>
> > > And which of the many flags in noinstr disables this?
> > >
> > These flags aren't used with PGO. So there's no need to disable them.
>
> Supposedly -fprofile-generate adds instrumentation to the generated
> code. noinstr *MUST* disable that. If not, this is a complete
> non-starter for x86.

"noinstr" has "notrace", which is defined as
"__attribute__((__no_instrument_function__))", which is honored by
both gcc and clang.

> > > Also, and I don't see this answered *anywhere*, why are you not using
> > > perf for this? Your link even mentions Sampling Profilers (and I happen
> > > to know there's been significant effort to make perf output work as
> > > input for the PGO passes of the various compilers).
> > >
> > Instruction-based (non-sampling) profiling gives us a better
> > context-sensitive profile, making PGO more impactful. It's also useful
> > for coverage whereas sampling profiles cannot.
>
> We've got KCOV and GCOV support already. Coverage is also not an
> argument mentioned anywhere else. Coverage can go pound sand, we really
> don't need a third means of getting that.
>
Those aren't useful for clang-based implementations. And I like to
look forward to potential improvements.

> Do you have actual numbers that back up the sampling vs instrumented
> argument? Having the instrumentation will affect performance which can
> scew the profile just the same.
>
Instrumentation counts the number of times a branch is taken. Sampling
is at a gross level, where if the sampling time is fine enough, you
can get an idea of where the hot spots are, but it won't give you the
fine-grained information that clang finds useful. Essentially, while
sampling can "capture the hot spots very well", relying solely on
sampling is basically leaving optimization on the floor.

Our optimizations experts here have determined, through data of
course, that instrumentation is the best option for PGO.

> Also, sampling tends to capture the hot spots very well.


-bw

  reply	other threads:[~2021-06-12 19:11 UTC|newest]

Thread overview: 124+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-01-11  8:18 [PATCH] pgo: add clang's Profile Guided Optimization infrastructure Bill Wendling
2021-01-11  8:39 ` Sedat Dilek
2021-01-11  8:42   ` Sedat Dilek
2021-01-11  9:17   ` Bill Wendling
2021-01-11  9:57     ` Sedat Dilek
2021-01-11 18:28       ` Nathan Chancellor
2021-01-11 20:12 ` Fangrui Song
2021-01-11 20:23   ` Bill Wendling
2021-01-11 20:31     ` Fangrui Song
2021-01-12  0:37       ` Bill Wendling
2021-01-12  0:44         ` Fāng-ruì Sòng
2021-01-11 21:04 ` Nathan Chancellor
2021-01-11 21:17   ` Nick Desaulniers
2021-01-11 21:32     ` Bill Wendling
2021-01-12  5:14 ` [PATCH v2] " Bill Wendling
2021-01-12  5:17   ` Sedat Dilek
2021-01-12  5:31   ` [PATCH v3] " Bill Wendling
2021-01-12  9:10     ` kernel test robot
2021-01-12  9:10       ` kernel test robot
2021-01-12 17:22       ` Nathan Chancellor
2021-01-13  6:19     ` [PATCH v4] " Bill Wendling
2021-01-13 20:55       ` Nathan Chancellor
2021-01-13 21:59         ` Bill Wendling
2021-01-14  4:07         ` Nick Desaulniers
2021-01-16  0:01           ` Nick Desaulniers
2021-01-16  0:13             ` Nick Desaulniers
2021-01-16  4:30               ` Sedat Dilek
2021-01-16  5:07               ` Sedat Dilek
2021-01-16  5:18                 ` Sedat Dilek
2021-01-18  0:57               ` Sedat Dilek
2021-01-13 23:01       ` Nick Desaulniers
2021-01-16  9:43       ` [PATCH v5] " Bill Wendling
2021-01-16 17:38         ` Sedat Dilek
2021-01-16 18:36           ` Sedat Dilek
2021-01-16 20:23           ` Bill Wendling
2021-01-17 10:44             ` Sedat Dilek
2021-01-17 10:53               ` Sedat Dilek
2021-01-17 11:23                 ` Sedat Dilek
2021-01-17 11:42                   ` Sedat Dilek
2021-01-17 11:58                     ` Sedat Dilek
2021-01-17 12:05                       ` Sedat Dilek
2021-01-17 17:42                         ` Sedat Dilek
2021-01-17 20:34                           ` Bill Wendling
2021-01-17 23:33                             ` Sedat Dilek
2021-01-18  0:26                               ` Sedat Dilek
2021-01-18  2:32                                 ` Bill Wendling
2021-01-18 12:39                                   ` Sedat Dilek
2021-01-18 17:26                                     ` Sedat Dilek
2021-01-18 21:56                                       ` Bill Wendling
2021-01-18 23:29                                         ` Sedat Dilek
2021-01-21  2:03                                         ` Sedat Dilek
2021-01-21 22:44                                           ` Sedat Dilek
2021-01-22  1:42                                           ` Nick Desaulniers
2021-01-22  1:49                                             ` Sedat Dilek
2021-01-22  1:52                                               ` Nick Desaulniers
2021-01-22  1:54                                                 ` Sedat Dilek
2021-01-20  1:02         ` Nick Desaulniers
2021-01-21  0:51         ` Nick Desaulniers
2021-01-21  8:24           ` Bill Wendling
2021-01-21  8:24         ` [PATCH v6] " Bill Wendling
2021-01-21 10:34           ` Sedat Dilek
2021-01-22  1:44             ` Nick Desaulniers
2021-01-22  1:51               ` Sedat Dilek
2021-01-22  0:14           ` Sedat Dilek
2021-01-22  0:58             ` Sedat Dilek
2021-01-22  1:29           ` Nick Desaulniers
2021-01-22 10:11           ` [PATCH v7] " Bill Wendling
2021-01-22 11:31             ` Sedat Dilek
2021-01-22 18:41             ` Nick Desaulniers
2021-01-28 20:46               ` Sedat Dilek
2021-01-28 21:12                 ` Nick Desaulniers
2021-01-28 21:19                   ` Sedat Dilek
2021-01-28 21:24                     ` Nick Desaulniers
2021-01-28 21:39                       ` Sedat Dilek
2021-01-29  7:43               ` Sedat Dilek
2021-01-29 21:48                 ` Nick Desaulniers
2021-02-10 23:25             ` Bill Wendling
2021-02-22 21:52               ` Bill Wendling
2021-02-26 22:20             ` [PATCH v8] " Bill Wendling
2021-02-26 22:55               ` Bill Wendling
2021-02-28 18:52               ` Fangrui Song
2021-02-28 21:50                 ` Fangrui Song
2021-01-12 17:37   ` [PATCH v2] " Nick Desaulniers
2021-01-12 17:45     ` Fāng-ruì Sòng
2021-01-21  2:21 ` [PATCH] " Sedat Dilek
2021-01-22  1:34   ` Nick Desaulniers
2021-01-22  1:43     ` Sedat Dilek
2021-04-07 21:17 ` [PATCH v9] " Bill Wendling
2021-04-07 21:22   ` Kees Cook
2021-04-07 21:44     ` Fāng-ruì Sòng
2021-04-07 21:47   ` Nathan Chancellor
2021-04-07 21:58     ` Bill Wendling
2021-05-19 21:37   ` Kees Cook
2021-05-22 23:51     ` Bill Wendling
2021-05-31 21:12     ` Nathan Chancellor
2021-06-01 17:31       ` Nick Desaulniers
2021-06-12 16:59   ` Peter Zijlstra
2021-06-12 17:25     ` Bill Wendling
2021-06-12 18:15       ` Peter Zijlstra
2021-06-12 19:10         ` Bill Wendling [this message]
2021-06-12 19:28           ` Bill Wendling
2021-06-12 20:25           ` Peter Zijlstra
2021-06-12 20:56             ` Bill Wendling
2021-06-12 22:47               ` Bill Wendling
2021-06-13 18:07                 ` Bill Wendling
2021-06-14  9:43                   ` Peter Zijlstra
2021-06-14 10:18                     ` Peter Zijlstra
2021-06-14  7:51               ` Peter Zijlstra
2021-06-14  9:01               ` Peter Zijlstra
2021-06-14  9:39                 ` Bill Wendling
2021-06-14 10:44                   ` Peter Zijlstra
2021-06-14 11:41                     ` Bill Wendling
2021-06-14 11:43                     ` Bill Wendling
2021-06-14 14:16                     ` Marco Elver
2021-06-14 15:26                       ` Kees Cook
2021-06-14 15:35                         ` Peter Zijlstra
2021-06-14 16:22                           ` Kees Cook
2021-06-14 18:07                             ` Nick Desaulniers
2021-06-14 20:49                               ` Nick Desaulniers
2021-06-14 15:46                         ` Peter Zijlstra
2021-06-14 16:03                           ` Nick Desaulniers
2021-06-12 20:20         ` Fangrui Song
2021-06-12 20:31           ` Peter Zijlstra
2021-06-01 18:53 Kees Cook

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='CAGG=3QVHkkJ236mCJ8Jt_6JtgYtWHV9b4aVXnoj6ypc7GOnc0A@mail.gmail.com' \
    --to=morbo@google.com \
    --cc=akpm@linux-foundation.org \
    --cc=clang-built-linux@googlegroups.com \
    --cc=corbet@lwn.net \
    --cc=keescook@google.com \
    --cc=linux-doc@vger.kernel.org \
    --cc=linux-kbuild@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=masahiroy@kernel.org \
    --cc=maskray@google.com \
    --cc=natechancellor@gmail.com \
    --cc=ndesaulniers@google.com \
    --cc=peterz@infradead.org \
    --cc=samitolvanen@google.com \
    --cc=x86@kernel.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.