Re: plumbers session on profiling?

Paul E. McKenney
2022-07-01T16:28:48Z

On Fri, Jul 01, 2022 at 03:32:12PM +0000, Hongtao Yu wrote:
>
>
> ________________________________
> From: Paul E. McKenney <paulmck@kernel.org>
> Sent: Friday, July 1, 2022 6:50 AM
> To: Peter Zijlstra <peterz@infradead.org>
> Cc: Bill Wendling <morbo@google.com>; Jose E. Marchesi <jemarch@gnu.org>; Ruud van der Pas <ruud.vanderpas@oracle.com>; Nick Desaulniers <ndesaulniers@google.com>; Sami Tolvanen <samitolvanen@google.com>; Vladimir Mezentsev <vladimir.mezentsev@oracle.com>; clang-built-linux <llvm@lists.linux.dev>; LKML <linux-kernel@vger.kernel.org>; Yonghong Song <yhs@fb.com>; Wenlei He <wenlei@fb.com>; Hongtao Yu <hoy@fb.com>; Ingo Molnar <mingo@kernel.org>; linux-toolchains <linux-toolchains@vger.kernel.org>; elena.zannoni@oracle.com <elena.zannoni@oracle.com>
> Subject: Re: plumbers session on profiling?
>
> On Fri, Jul 01, 2022 at 01:49:06PM +0200, Peter Zijlstra wrote:
> > On Fri, Jul 01, 2022 at 03:17:54AM -0700, Bill Wendling wrote:
> > > On Fri, Jul 1, 2022 at 2:02 AM Peter Zijlstra <peterz@infradead.org> wrote:
> > > >
> > > > On Tue, Jun 28, 2022 at 07:08:48PM +0200, Jose E. Marchesi wrote:
> > > > >
> > > > > [Added linux-toolchains@vger in CC]
> > > > >
> > > > > It would be interesting to have some discussion in the Toolchains track
> > > > > on building the kernel with PGO/FDO. I have seen a raise on interest on
> > > > > the topic in several companies, but it would make very little sense if
> > > > > no kernel hacker is interested in participating... anybody?
> > > >
> > > > I know there's been a lot of work in this area, but none of it seems to
> > > > have trickled down to be easy enough for me to use it.
> > >
> > > We use an instrumented kernel to collect the data we need. It gives us
> > > the best payoff, because the profiling data is more fine-grained and
> > > accurate. (PGO does much more than make inlining decisions.)
> > >
> > > If I recall correctly, you previously suggested using sampling data.
> > > (Correct?) Is there a document or article that outlines that process?
> >
> > IIRC Google has LBR sample driven PGO somewhere as well. ISTR that being
> > the whole motivation for that gruesome Zen3 BRS hack.
> >
> > Google got me this: https://research.google.com/pubs/archive/45290.pdf
>
> > Whatever else, please refrain from using PGO and friends to drive
> data-value speculation!
>
> Is there a particular reason for this?

Yes, there is.

Doing so breaks many concurrent algorithms.

Sure, the hardware can get away with this sort of thing. But that is
only because it has access to cache and store-buffer state that allows it
to roll back and replay when needed. The compiler does not have access
to this state [1], so it needs to avoid playing this game.

Thanx, Paul