linux-toolchains.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* Re: [PATCH v9] pgo: add clang's Profile Guided Optimization infrastructure
       [not found]                 ` <CAGG=3QVPCuAx9UMTOzQp+8MJk8KVyOfaYeV0yehpVwbCaYMVpg@mail.gmail.com>
@ 2021-06-14 10:44                   ` Peter Zijlstra
  2021-06-14 11:41                     ` Bill Wendling
                                       ` (2 more replies)
  0 siblings, 3 replies; 11+ messages in thread
From: Peter Zijlstra @ 2021-06-14 10:44 UTC (permalink / raw)
  To: Bill Wendling
  Cc: Kees Cook, Jonathan Corbet, Masahiro Yamada,
	Linux Doc Mailing List, LKML, Linux Kbuild mailing list,
	clang-built-linux, Andrew Morton, Nathan Chancellor,
	Nick Desaulniers, Sami Tolvanen, Fangrui Song,
	maintainer:X86 ARCHITECTURE (32-BIT AND 64-BIT),
	andreyknvl, dvyukov, elver, johannes.berg, oberpar,
	linux-toolchains

On Mon, Jun 14, 2021 at 02:39:41AM -0700, Bill Wendling wrote:
> On Mon, Jun 14, 2021 at 2:01 AM Peter Zijlstra <peterz@infradead.org> wrote:

> > Because having GCOV, KCOV and PGO all do essentially the same thing
> > differently, makes heaps of sense?
> >
> It does when you're dealing with one toolchain without access to another.

Here's a sekrit, don't tell anyone, but you can get a free copy of GCC
right here:

  https://gcc.gnu.org/

We also have this linux-toolchains list (Cc'ed now) that contains folks
from both sides.

> > I understand that the compilers actually generates radically different
> > instrumentation for the various cases, but essentially they're all
> > collecting (function/branch) arcs.
> >
> That's true, but there's no one format for profiling data that's
> usable between all compilers. I'm not even sure there's a good way to
> translate between, say, gcov and llvm's format. To make matters more
> complicated, each compiler's format is tightly coupled to a specific
> version of that compiler. And depending on *how* the data is collected
> (e.g. sampling or instrumentation), it may not give us the full
> benefit of FDO/PGO.

I'm thinking that something simple like:

struct arc {
	u64	from;
	u64	to;
	u64	nr;
	u64	cntrs[0];
};

goes a very long way. Stick a header on that says how large cntrs[] is,
and some other data (like load offset and whatnot) and you should be
good.

Combine that with the executable image (say /proc/kcore) to recover
what's @from (call, jmp or conditional branch) and I'm thinking one
ought to be able to construct lots of useful data.

I've also been led to believe that the KCOV data format is not in fact
dependent on which toolchain is used.

> > I'm thinking it might be about time to build _one_ infrastructure for
> > that and define a kernel arc format and call it a day.
> >
> That may be nice, but it's a rather large request.

Given GCOV just died, perhaps you can look at what KCOV does and see if
that can be extended to do as you want. KCOV is actively used and
we actually tripped over all the fun little noinstr bugs at the time.

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH v9] pgo: add clang's Profile Guided Optimization infrastructure
  2021-06-14 10:44                   ` [PATCH v9] pgo: add clang's Profile Guided Optimization infrastructure Peter Zijlstra
@ 2021-06-14 11:41                     ` Bill Wendling
  2021-06-14 11:43                     ` Bill Wendling
  2021-06-14 14:16                     ` Marco Elver
  2 siblings, 0 replies; 11+ messages in thread
From: Bill Wendling @ 2021-06-14 11:41 UTC (permalink / raw)
  To: Peter Zijlstra
  Cc: Kees Cook, Jonathan Corbet, Masahiro Yamada,
	Linux Doc Mailing List, LKML, Linux Kbuild mailing list,
	clang-built-linux, Andrew Morton, Nathan Chancellor,
	Nick Desaulniers, Sami Tolvanen, Fangrui Song,
	maintainer:X86 ARCHITECTURE (32-BIT AND 64-BIT),
	andreyknvl, dvyukov, elver, johannes.berg, oberpar,
	linux-toolchains

On Mon, Jun 14, 2021 at 3:45 AM Peter Zijlstra <peterz@infradead.org> wrote:
> On Mon, Jun 14, 2021 at 02:39:41AM -0700, Bill Wendling wrote:
> > On Mon, Jun 14, 2021 at 2:01 AM Peter Zijlstra <peterz@infradead.org> wrote:
>
> > > Because having GCOV, KCOV and PGO all do essentially the same thing
> > > differently, makes heaps of sense?
> > >
> > It does when you're dealing with one toolchain without access to another.
>
> Here's a sekrit, don't tell anyone, but you can get a free copy of GCC
> right here:
>
>   https://gcc.gnu.org/
>
> We also have this linux-toolchains list (Cc'ed now) that contains folks
> from both sides.
>
Your sarcasm is not useful.

> > > I understand that the compilers actually generates radically different
> > > instrumentation for the various cases, but essentially they're all
> > > collecting (function/branch) arcs.
> > >
> > That's true, but there's no one format for profiling data that's
> > usable between all compilers. I'm not even sure there's a good way to
> > translate between, say, gcov and llvm's format. To make matters more
> > complicated, each compiler's format is tightly coupled to a specific
> > version of that compiler. And depending on *how* the data is collected
> > (e.g. sampling or instrumentation), it may not give us the full
> > benefit of FDO/PGO.
>
> I'm thinking that something simple like:
>
> struct arc {
>         u64     from;
>         u64     to;
>         u64     nr;
>         u64     cntrs[0];
> };
>
> goes a very long way. Stick a header on that says how large cntrs[] is,
> and some other data (like load offset and whatnot) and you should be
> good.
>
> Combine that with the executable image (say /proc/kcore) to recover
> what's @from (call, jmp or conditional branch) and I'm thinking one
> ought to be able to construct lots of useful data.
>
> I've also been led to believe that the KCOV data format is not in fact
> dependent on which toolchain is used.
>
> > > I'm thinking it might be about time to build _one_ infrastructure for
> > > that and define a kernel arc format and call it a day.
> > >
> > That may be nice, but it's a rather large request.
>
> Given GCOV just died, perhaps you can look at what KCOV does and see if
> that can be extended to do as you want. KCOV is actively used and
> we actually tripped over all the fun little noinstr bugs at the time.

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH v9] pgo: add clang's Profile Guided Optimization infrastructure
  2021-06-14 10:44                   ` [PATCH v9] pgo: add clang's Profile Guided Optimization infrastructure Peter Zijlstra
  2021-06-14 11:41                     ` Bill Wendling
@ 2021-06-14 11:43                     ` Bill Wendling
  2021-06-14 14:16                     ` Marco Elver
  2 siblings, 0 replies; 11+ messages in thread
From: Bill Wendling @ 2021-06-14 11:43 UTC (permalink / raw)
  To: Peter Zijlstra
  Cc: Kees Cook, Jonathan Corbet, Masahiro Yamada,
	Linux Doc Mailing List, LKML, Linux Kbuild mailing list,
	clang-built-linux, Andrew Morton, Nathan Chancellor,
	Nick Desaulniers, Sami Tolvanen, Fangrui Song,
	maintainer:X86 ARCHITECTURE (32-BIT AND 64-BIT),
	andreyknvl, dvyukov, elver, johannes.berg, oberpar,
	linux-toolchains

On Mon, Jun 14, 2021 at 3:45 AM Peter Zijlstra <peterz@infradead.org> wrote:
> On Mon, Jun 14, 2021 at 02:39:41AM -0700, Bill Wendling wrote:
> > On Mon, Jun 14, 2021 at 2:01 AM Peter Zijlstra <peterz@infradead.org> wrote:
> > > I understand that the compilers actually generates radically different
> > > instrumentation for the various cases, but essentially they're all
> > > collecting (function/branch) arcs.
> > >
> > That's true, but there's no one format for profiling data that's
> > usable between all compilers. I'm not even sure there's a good way to
> > translate between, say, gcov and llvm's format. To make matters more
> > complicated, each compiler's format is tightly coupled to a specific
> > version of that compiler. And depending on *how* the data is collected
> > (e.g. sampling or instrumentation), it may not give us the full
> > benefit of FDO/PGO.
>
> I'm thinking that something simple like:
>
> struct arc {
>         u64     from;
>         u64     to;
>         u64     nr;
>         u64     cntrs[0];
> };
>
> goes a very long way. Stick a header on that says how large cntrs[] is,
> and some other data (like load offset and whatnot) and you should be
> good.
>
> Combine that with the executable image (say /proc/kcore) to recover
> what's @from (call, jmp or conditional branch) and I'm thinking one
> ought to be able to construct lots of useful data.
>
> I've also been led to believe that the KCOV data format is not in fact
> dependent on which toolchain is used.
>
Awesome! I await your RFC on both the gcc and clang mailing lists.

-bw

> > > I'm thinking it might be about time to build _one_ infrastructure for
> > > that and define a kernel arc format and call it a day.
> > >
> > That may be nice, but it's a rather large request.
>
> Given GCOV just died, perhaps you can look at what KCOV does and see if
> that can be extended to do as you want. KCOV is actively used and
> we actually tripped over all the fun little noinstr bugs at the time.

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH v9] pgo: add clang's Profile Guided Optimization infrastructure
  2021-06-14 10:44                   ` [PATCH v9] pgo: add clang's Profile Guided Optimization infrastructure 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
  2 siblings, 1 reply; 11+ messages in thread
From: Marco Elver @ 2021-06-14 14:16 UTC (permalink / raw)
  To: Peter Zijlstra
  Cc: Bill Wendling, Kees Cook, Jonathan Corbet, Masahiro Yamada,
	Linux Doc Mailing List, LKML, Linux Kbuild mailing list,
	clang-built-linux, Andrew Morton, Nathan Chancellor,
	Nick Desaulniers, Sami Tolvanen, Fangrui Song,
	maintainer:X86 ARCHITECTURE (32-BIT AND 64-BIT),
	Andrey Konovalov, Dmitry Vyukov, johannes.berg, oberpar,
	linux-toolchains

On Mon, 14 Jun 2021 at 12:45, Peter Zijlstra <peterz@infradead.org> wrote:
[...]
> I've also been led to believe that the KCOV data format is not in fact
> dependent on which toolchain is used.

Correct, we use KCOV with both gcc and clang. Both gcc and clang emit
the same instrumentation for -fsanitize-coverage. Thus, the user-space
portion and interface is indeed identical:
https://www.kernel.org/doc/html/latest/dev-tools/kcov.html

> > > I'm thinking it might be about time to build _one_ infrastructure for
> > > that and define a kernel arc format and call it a day.
> > >
> > That may be nice, but it's a rather large request.
>
> Given GCOV just died, perhaps you can look at what KCOV does and see if
> that can be extended to do as you want. KCOV is actively used and
> we actually tripped over all the fun little noinstr bugs at the time.

There might be a subtle mismatch between coverage instrumentation for
testing/fuzzing and for profiling. (Disclaimer: I'm not too familiar
with Clang-PGO's requirements.) For example, while for testing/fuzzing
we may only require information if a code-path has been visited, for
profiling the "hotness" might be of interest. Therefore, the
user-space exported data format can make several trade-offs in
complexity.

In theory, I imagine there's a limit to how generic one could make
profiling information, because one compiler's optimizations are not
another compiler's optimizations. On the other hand, it may be doable
to collect unified profiling information for common stuff, but I guess
there's little motivation for figuring out the common ground given the
producer and consumer of the PGO data is the same compiler by design
(unlike coverage info for testing/fuzzing).

Therefore, if KCOV's exposed information does not match PGO's
requirements today, I'm not sure what realistically can be done
without turning KCOV into a monster. Because KCOV is optimized for
testing/fuzzing coverage, and I'm not sure how complex we can or want
to make it to cater to a new use-case.

My intuition is that the simpler design is to have 2 subsystems for
instrumentation-based coverage collection: one for testing/fuzzing,
and the other for profiling.

Alas, there's the problem of GCOV, which should be replaceable by KCOV
for most use cases. But it would be good to hear from a GCOV user if
there are some.

But as we learned GCOV is broken on x86 now, I see these options:

1. Remove GCOV, make KCOV the de-facto test-coverage collection
subsystem. Introduce PGO-instrumentation subsystem for profile
collection only, and make it _very_ clear that KCOV != PGO data as
hinted above. A pre-requisite is that compiler-support for PGO
instrumentation adds selective instrumentation support, likely just
making attribute no_instrument_function do the right thing.

2. Like (1) but also keep GCOV, given proper support for attribute
no_instrument_function would probably fix it (?).

3. Keep GCOV (and KCOV of course). Somehow extract PGO profiles from KCOV.

4. Somehow extract PGO profiles from GCOV, or modify kernel/gcov to do so.

Thanks.

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH v9] pgo: add clang's Profile Guided Optimization infrastructure
  2021-06-14 14:16                     ` Marco Elver
@ 2021-06-14 15:26                       ` Kees Cook
  2021-06-14 15:35                         ` Peter Zijlstra
  2021-06-14 15:46                         ` Peter Zijlstra
  0 siblings, 2 replies; 11+ messages in thread
From: Kees Cook @ 2021-06-14 15:26 UTC (permalink / raw)
  To: Marco Elver
  Cc: Peter Zijlstra, Bill Wendling, Jonathan Corbet, Masahiro Yamada,
	Linux Doc Mailing List, LKML, Linux Kbuild mailing list,
	clang-built-linux, Andrew Morton, Nathan Chancellor,
	Nick Desaulniers, Sami Tolvanen, Fangrui Song,
	maintainer:X86 ARCHITECTURE (32-BIT AND 64-BIT),
	Andrey Konovalov, Dmitry Vyukov, johannes.berg, oberpar,
	linux-toolchains

On Mon, Jun 14, 2021 at 04:16:16PM +0200, 'Marco Elver' via Clang Built Linux wrote:
> On Mon, 14 Jun 2021 at 12:45, Peter Zijlstra <peterz@infradead.org> wrote:
> [...]
> > I've also been led to believe that the KCOV data format is not in fact
> > dependent on which toolchain is used.
> 
> Correct, we use KCOV with both gcc and clang. Both gcc and clang emit
> the same instrumentation for -fsanitize-coverage. Thus, the user-space
> portion and interface is indeed identical:
> https://www.kernel.org/doc/html/latest/dev-tools/kcov.html
> 
> > > > I'm thinking it might be about time to build _one_ infrastructure for
> > > > that and define a kernel arc format and call it a day.
> > > >
> > > That may be nice, but it's a rather large request.
> >
> > Given GCOV just died, perhaps you can look at what KCOV does and see if
> > that can be extended to do as you want. KCOV is actively used and
> > we actually tripped over all the fun little noinstr bugs at the time.
> 
> There might be a subtle mismatch between coverage instrumentation for
> testing/fuzzing and for profiling. (Disclaimer: I'm not too familiar
> with Clang-PGO's requirements.) For example, while for testing/fuzzing
> we may only require information if a code-path has been visited, for
> profiling the "hotness" might be of interest. Therefore, the
> user-space exported data format can make several trade-offs in
> complexity.

This has been my primary take-away: given that Clang's PGO is different
enough from the other things and provides more specific/actionable
results, I think it's justified to exist on its own separate from the
other parts.

> In theory, I imagine there's a limit to how generic one could make
> profiling information, because one compiler's optimizations are not
> another compiler's optimizations. On the other hand, it may be doable
> to collect unified profiling information for common stuff, but I guess
> there's little motivation for figuring out the common ground given the
> producer and consumer of the PGO data is the same compiler by design
> (unlike coverage info for testing/fuzzing).
> 
> Therefore, if KCOV's exposed information does not match PGO's
> requirements today, I'm not sure what realistically can be done
> without turning KCOV into a monster. Because KCOV is optimized for
> testing/fuzzing coverage, and I'm not sure how complex we can or want
> to make it to cater to a new use-case.
> 
> My intuition is that the simpler design is to have 2 subsystems for
> instrumentation-based coverage collection: one for testing/fuzzing,
> and the other for profiling.
> 
> Alas, there's the problem of GCOV, which should be replaceable by KCOV
> for most use cases. But it would be good to hear from a GCOV user if
> there are some.
> 
> But as we learned GCOV is broken on x86 now, I see these options:
> 
> 1. Remove GCOV, make KCOV the de-facto test-coverage collection
> subsystem. Introduce PGO-instrumentation subsystem for profile
> collection only, and make it _very_ clear that KCOV != PGO data as
> hinted above. A pre-requisite is that compiler-support for PGO
> instrumentation adds selective instrumentation support, likely just
> making attribute no_instrument_function do the right thing.

Right. I can't speak to GCOV, but KCOV certainly isn't PGO.

> 2. Like (1) but also keep GCOV, given proper support for attribute
> no_instrument_function would probably fix it (?).
> 
> 3. Keep GCOV (and KCOV of course). Somehow extract PGO profiles from KCOV.
> 
> 4. Somehow extract PGO profiles from GCOV, or modify kernel/gcov to do so.

If there *is* a way to "combine" these, I don't think it makes sense
to do it now. PGO has users (and is expanding[1]), and trying to
optimize the design before even landing the first version seems like a
needless obstruction, and to likely not address currently undiscovered
requirements.

So, AFAICT, the original blocking issue ("PGO does not respect noinstr")
is not actually an issue (noinstr contains notrace, which IS respected
by PGO[2]), I think this is fine to move forward.

-Kees

[1] https://lore.kernel.org/lkml/20210612032425.11425-1-jarmo.tiitto@gmail.com/
[2] https://lore.kernel.org/lkml/CAGG=3QVHkkJ236mCJ8Jt_6JtgYtWHV9b4aVXnoj6ypc7GOnc0A@mail.gmail.com/

-- 
Kees Cook

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH v9] pgo: add clang's Profile Guided Optimization infrastructure
  2021-06-14 15:26                       ` Kees Cook
@ 2021-06-14 15:35                         ` Peter Zijlstra
  2021-06-14 16:22                           ` Kees Cook
  2021-06-14 15:46                         ` Peter Zijlstra
  1 sibling, 1 reply; 11+ messages in thread
From: Peter Zijlstra @ 2021-06-14 15:35 UTC (permalink / raw)
  To: Kees Cook
  Cc: Marco Elver, Bill Wendling, Jonathan Corbet, Masahiro Yamada,
	Linux Doc Mailing List, LKML, Linux Kbuild mailing list,
	clang-built-linux, Andrew Morton, Nathan Chancellor,
	Nick Desaulniers, Sami Tolvanen, Fangrui Song,
	maintainer:X86 ARCHITECTURE (32-BIT AND 64-BIT),
	Andrey Konovalov, Dmitry Vyukov, johannes.berg, oberpar,
	linux-toolchains

On Mon, Jun 14, 2021 at 08:26:01AM -0700, Kees Cook wrote:
> So, AFAICT, the original blocking issue ("PGO does not respect noinstr")
> is not actually an issue (noinstr contains notrace, which IS respected
> by PGO[2]), I think this is fine to move forward.

It is *NOT*: https://godbolt.org/z/9c7xdvGd9

Look at how both compilers generate instrumentation in the no_instr()
function.

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH v9] pgo: add clang's Profile Guided Optimization infrastructure
  2021-06-14 15:26                       ` Kees Cook
  2021-06-14 15:35                         ` Peter Zijlstra
@ 2021-06-14 15:46                         ` Peter Zijlstra
  2021-06-14 16:03                           ` Nick Desaulniers
  1 sibling, 1 reply; 11+ messages in thread
From: Peter Zijlstra @ 2021-06-14 15:46 UTC (permalink / raw)
  To: Kees Cook
  Cc: Marco Elver, Bill Wendling, Jonathan Corbet, Masahiro Yamada,
	Linux Doc Mailing List, LKML, Linux Kbuild mailing list,
	clang-built-linux, Andrew Morton, Nathan Chancellor,
	Nick Desaulniers, Sami Tolvanen, Fangrui Song,
	maintainer:X86 ARCHITECTURE (32-BIT AND 64-BIT),
	Andrey Konovalov, Dmitry Vyukov, johannes.berg, oberpar,
	linux-toolchains

On Mon, Jun 14, 2021 at 08:26:01AM -0700, Kees Cook wrote:
> > 2. Like (1) but also keep GCOV, given proper support for attribute
> > no_instrument_function would probably fix it (?).
> > 
> > 3. Keep GCOV (and KCOV of course). Somehow extract PGO profiles from KCOV.
> > 
> > 4. Somehow extract PGO profiles from GCOV, or modify kernel/gcov to do so.
> 
> If there *is* a way to "combine" these, I don't think it makes sense
> to do it now. PGO has users (and is expanding[1]), and trying to
> optimize the design before even landing the first version seems like a
> needless obstruction, and to likely not address currently undiscovered
> requirements.

Even if that were so (and I'm not yet convinced), the current proposal
is wedded to llvm-pgo, there is no way gcc-pgo could reuse any of this
code afaict, which then means they have to create yet another variant.

Sorting this *before* the first version is exactly the right time.

Since when are we merging code when the requirements are not clear?

Just to clarify:

Nacked-by: Peter Zijlstra (Intel) <peterz@infradead.org>

For all this PGO crud.

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH v9] pgo: add clang's Profile Guided Optimization infrastructure
  2021-06-14 15:46                         ` Peter Zijlstra
@ 2021-06-14 16:03                           ` Nick Desaulniers
  0 siblings, 0 replies; 11+ messages in thread
From: Nick Desaulniers @ 2021-06-14 16:03 UTC (permalink / raw)
  To: Peter Zijlstra
  Cc: Kees Cook, Marco Elver, Bill Wendling, Jonathan Corbet,
	Masahiro Yamada, Linux Doc Mailing List, LKML,
	Linux Kbuild mailing list, clang-built-linux, Andrew Morton,
	Nathan Chancellor, Sami Tolvanen, Fangrui Song,
	maintainer:X86 ARCHITECTURE (32-BIT AND 64-BIT),
	Andrey Konovalov, Dmitry Vyukov, Johannes Berg, oberpar,
	linux-toolchains

On Mon, Jun 14, 2021 at 8:46 AM Peter Zijlstra <peterz@infradead.org> wrote:
>
> On Mon, Jun 14, 2021 at 08:26:01AM -0700, Kees Cook wrote:
> > > 2. Like (1) but also keep GCOV, given proper support for attribute
> > > no_instrument_function would probably fix it (?).
> > >
> > > 3. Keep GCOV (and KCOV of course). Somehow extract PGO profiles from KCOV.
> > >
> > > 4. Somehow extract PGO profiles from GCOV, or modify kernel/gcov to do so.
> >
> > If there *is* a way to "combine" these, I don't think it makes sense
> > to do it now. PGO has users (and is expanding[1]), and trying to
> > optimize the design before even landing the first version seems like a
> > needless obstruction, and to likely not address currently undiscovered
> > requirements.
>
> Even if that were so (and I'm not yet convinced), the current proposal
> is wedded to llvm-pgo, there is no way gcc-pgo could reuse any of this
> code afaict, which then means they have to create yet another variant.

Similar to GCOV, the runtime support for exporting such data is
heavily compiler (and compiler version) specific, as is the data
format for compilers to consume.  We were able to reuse most of the
runtime code between GCC and Clang support in GCOV; I don't see why we
couldn't do a similar factoring of the runtime code being added to the
kernel here, should anyone care to pursue implementing PGO with GCC.
Having an implementation is a great starting point for folks looking
to extend support or to understand how to support PGO in such a bare
metal environment (one that doesn't dynamically link against
traditional compiler runtimes).
-- 
Thanks,
~Nick Desaulniers

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH v9] pgo: add clang's Profile Guided Optimization infrastructure
  2021-06-14 15:35                         ` Peter Zijlstra
@ 2021-06-14 16:22                           ` Kees Cook
  2021-06-14 18:07                             ` Nick Desaulniers
  0 siblings, 1 reply; 11+ messages in thread
From: Kees Cook @ 2021-06-14 16:22 UTC (permalink / raw)
  To: Peter Zijlstra
  Cc: Marco Elver, Bill Wendling, Jonathan Corbet, Masahiro Yamada,
	Linux Doc Mailing List, LKML, Linux Kbuild mailing list,
	clang-built-linux, Andrew Morton, Nathan Chancellor,
	Nick Desaulniers, Sami Tolvanen, Fangrui Song,
	maintainer:X86 ARCHITECTURE (32-BIT AND 64-BIT),
	Andrey Konovalov, Dmitry Vyukov, johannes.berg, oberpar,
	linux-toolchains

On Mon, Jun 14, 2021 at 05:35:45PM +0200, Peter Zijlstra wrote:
> On Mon, Jun 14, 2021 at 08:26:01AM -0700, Kees Cook wrote:
> > So, AFAICT, the original blocking issue ("PGO does not respect noinstr")
> > is not actually an issue (noinstr contains notrace, which IS respected
> > by PGO[2]), I think this is fine to move forward.
> 
> It is *NOT*: https://godbolt.org/z/9c7xdvGd9
> 
> Look at how both compilers generate instrumentation in the no_instr()
> function.

Well that's disappointing. I'll put this on hold until Clang can grow an
appropriate attribute (or similar work-around). Thanks for catching
that.

-- 
Kees Cook

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH v9] pgo: add clang's Profile Guided Optimization infrastructure
  2021-06-14 16:22                           ` Kees Cook
@ 2021-06-14 18:07                             ` Nick Desaulniers
  2021-06-14 20:49                               ` Nick Desaulniers
  0 siblings, 1 reply; 11+ messages in thread
From: Nick Desaulniers @ 2021-06-14 18:07 UTC (permalink / raw)
  To: Kees Cook
  Cc: Peter Zijlstra, Marco Elver, Bill Wendling, Jonathan Corbet,
	Masahiro Yamada, Linux Doc Mailing List, LKML,
	Linux Kbuild mailing list, clang-built-linux, Andrew Morton,
	Nathan Chancellor, Sami Tolvanen, Fangrui Song,
	maintainer:X86 ARCHITECTURE (32-BIT AND 64-BIT),
	Andrey Konovalov, Dmitry Vyukov, Johannes Berg, oberpar,
	linux-toolchains

On Mon, Jun 14, 2021 at 9:23 AM Kees Cook <keescook@chromium.org> wrote:
>
> On Mon, Jun 14, 2021 at 05:35:45PM +0200, Peter Zijlstra wrote:
> > On Mon, Jun 14, 2021 at 08:26:01AM -0700, Kees Cook wrote:
> > > So, AFAICT, the original blocking issue ("PGO does not respect noinstr")
> > > is not actually an issue (noinstr contains notrace, which IS respected
> > > by PGO[2]), I think this is fine to move forward.
> >
> > It is *NOT*: https://godbolt.org/z/9c7xdvGd9
> >
> > Look at how both compilers generate instrumentation in the no_instr()
> > function.
>
> Well that's disappointing. I'll put this on hold until Clang can grow an
> appropriate attribute (or similar work-around). Thanks for catching
> that.

Cross referencing since these two threads are related.
https://lore.kernel.org/lkml/CAKwvOdmPTi93n2L0_yQkrzLdmpxzrOR7zggSzonyaw2PGshApw@mail.gmail.com/
-- 
Thanks,
~Nick Desaulniers

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH v9] pgo: add clang's Profile Guided Optimization infrastructure
  2021-06-14 18:07                             ` Nick Desaulniers
@ 2021-06-14 20:49                               ` Nick Desaulniers
  0 siblings, 0 replies; 11+ messages in thread
From: Nick Desaulniers @ 2021-06-14 20:49 UTC (permalink / raw)
  To: Kees Cook, Peter Zijlstra, Borislav Petkov
  Cc: Marco Elver, Bill Wendling, Jonathan Corbet, Masahiro Yamada,
	Linux Doc Mailing List, LKML, Linux Kbuild mailing list,
	clang-built-linux, Andrew Morton, Nathan Chancellor,
	Sami Tolvanen, Fangrui Song,
	maintainer:X86 ARCHITECTURE (32-BIT AND 64-BIT),
	Andrey Konovalov, Dmitry Vyukov, Johannes Berg, oberpar,
	linux-toolchains, Borislav Petkov

On Mon, Jun 14, 2021 at 11:07 AM Nick Desaulniers
<ndesaulniers@google.com> wrote:
>
> On Mon, Jun 14, 2021 at 9:23 AM Kees Cook <keescook@chromium.org> wrote:
> >
> > On Mon, Jun 14, 2021 at 05:35:45PM +0200, Peter Zijlstra wrote:
> > > On Mon, Jun 14, 2021 at 08:26:01AM -0700, Kees Cook wrote:
> > > > So, AFAICT, the original blocking issue ("PGO does not respect noinstr")
> > > > is not actually an issue (noinstr contains notrace, which IS respected
> > > > by PGO[2]), I think this is fine to move forward.
> > >
> > > It is *NOT*: https://godbolt.org/z/9c7xdvGd9
> > >
> > > Look at how both compilers generate instrumentation in the no_instr()
> > > function.
> >
> > Well that's disappointing. I'll put this on hold until Clang can grow an
> > appropriate attribute (or similar work-around). Thanks for catching
> > that.
>
> Cross referencing since these two threads are related.
> https://lore.kernel.org/lkml/CAKwvOdmPTi93n2L0_yQkrzLdmpxzrOR7zggSzonyaw2PGshApw@mail.gmail.com/

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=80223 looked appropriate
to me, so I commented on it.
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=80223#c6

Patches for:
PGO: https://reviews.llvm.org/D104253
GCOV: https://reviews.llvm.org/D104257
--
Thanks,
~Nick Desaulniers

^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2021-06-14 20:49 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <20210111081821.3041587-1-morbo@google.com>
     [not found] ` <20210407211704.367039-1-morbo@google.com>
     [not found]   ` <YMTn9yjuemKFLbws@hirez.programming.kicks-ass.net>
     [not found]     ` <CAGG=3QXjD1DQjACu=CQQSP=whue-14Pw8FcNcXrJZfLC_E+y9w@mail.gmail.com>
     [not found]       ` <YMT5xZsZMX0PpDKQ@hirez.programming.kicks-ass.net>
     [not found]         ` <CAGG=3QVHkkJ236mCJ8Jt_6JtgYtWHV9b4aVXnoj6ypc7GOnc0A@mail.gmail.com>
     [not found]           ` <20210612202505.GG68208@worktop.programming.kicks-ass.net>
     [not found]             ` <CAGG=3QUZ9tXGNLhbOr+AFDTJABDujZuaG1mYaLKdTcJZguEDWw@mail.gmail.com>
     [not found]               ` <YMca2aa+t+3VrpN9@hirez.programming.kicks-ass.net>
     [not found]                 ` <CAGG=3QVPCuAx9UMTOzQp+8MJk8KVyOfaYeV0yehpVwbCaYMVpg@mail.gmail.com>
2021-06-14 10:44                   ` [PATCH v9] pgo: add clang's Profile Guided Optimization infrastructure 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

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).