[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <YEHtjioucovbxbRt@hirez.programming.kicks-ass.net>
Date: Fri, 5 Mar 2021 09:36:30 +0100
From: Peter Zijlstra <peterz@...radead.org>
To: Linus Torvalds <torvalds@...ux-foundation.org>
Cc: Ingo Molnar <mingo@...hat.com>,
Arnaldo Carvalho de Melo <acme@...nel.org>,
Mark Rutland <mark.rutland@....com>,
Alexander Shishkin <alexander.shishkin@...ux.intel.com>,
Jiri Olsa <jolsa@...hat.com>,
Namhyung Kim <namhyung@...nel.org>,
Linux Kernel Mailing List <linux-kernel@...r.kernel.org>
Subject: Re: "struct perf_sample_data" alignment
On Thu, Mar 04, 2021 at 07:45:44PM -0800, Linus Torvalds wrote:
> That ____cacheline_aligned goes back many years, this is not new, it
> seems to come from back in 2014: commit 2565711fb7d7 ("perf: Improve
> the perf_sample_data struct layout").
long time ago...
> But it really seems entirely and utterly bogus. That cacheline
> alignment makes things *worse*, when the variables are on the local
> stack. The local stack is already going to be dirty and in the cache,
> and aligning those things isn't going to - and I quote from the code
> in that commend in that commit - "minimize the cachelines touched".
>
> Quite the reverse. It's just going to make the stack frame use *more*
> memory, and make any cacheline usage _worse_.
IIRC there is more history here, but I can't seem to find references
just now.
What I remember is that since perf_sample_data is fairly large,
unconditionally initializing the whole thing is *slow* (and
-fauto-var-init=zero will hurt here).
So at some point I removed that full initialization and made sure we
only unconditionally touched the first few variables, which gave a
measurable speedup.
Then things got messy again and the commit 2565711fb7d7 referenced above
was cleanup, to get back to that initial state.
Now, you're right that __cacheline_aligned on on-stack (and this is
indeed mostly on-stack) is fairly tedious (there were a few patches
recently to reduce the amount of on-stack instances).
I'll put it on the todo list, along with that hotplug stuff (which I
tried to fix but ended up with an even bigger mess). I suppose we can
try and not have the alignment for the on-stack instances while
preserving it for the few off-stack ones.
Also; we're running on the NMI stack, and that's not typically hot.
Powered by blists - more mailing lists