Re: [PATCH 0/5] x86/percpu semantics and fixes

From: Nadav Amit
Date: Wed Feb 27 2019 - 18:16:52 EST

> On Feb 27, 2019, at 2:12 AM, Peter Zijlstra <peterz@xxxxxxxxxxxxx> wrote:
> Hi all,
> This is a collection of x86/percpu changes that I had pending and got reminded
> of by Linus' comment yesterday about __this_cpu_xchg().
> This tidies up the x86/percpu primitives and fixes a bunch of 'fallout'.
> Built and boot tested with CONFIG_DEBUG_PREEMPT=y.

Overall this series affects 70 functions and shortens the code by 326 bytes.
_local_bh_enable() for example is shorten by 14 bytes (26%).

I must admit that I although I pointed some of these issues before, I am not
sure whether they are really important...

Recently, I tried to see how to make the compiler to generate âbetter codeâ
from Linux. I sprinkled âpureâ attribute on many common function (e.g.,
page_rmapping()), sg_next()); sprinkled const-attribute on some others
(e.g., jiffies_to_msecs()); created a const-alias variable so the compiler
would consider kaslr variables and sme_me_mask as constant after
initialization, and so on.

I was then looking at the changed code, and while some functions were
shorter and some longer, many common functions did look âbetterâ. The only
problem was that any benchmark that I did not show any measurable impact.

So perhaps it is a matter of measurement, but eventually right now there is
no clean win.