Re: [PATCH -tip] x86/locking/atomic: Use asm_inline for atomic locking insns

From: Uros Bizjak
Date: Wed Mar 05 2025 - 15:13:45 EST


On Wed, Mar 5, 2025 at 8:55 PM Ingo Molnar <mingo@xxxxxxxxxx> wrote:
>
>
> * Uros Bizjak <ubizjak@xxxxxxxxx> wrote:
>
> > On Sat, Mar 1, 2025 at 1:38 PM Borislav Petkov <bp@xxxxxxxxx> wrote:
> > >
> > > On Sat, Mar 01, 2025 at 10:05:56AM +0100, Uros Bizjak wrote:
> > > > OTOH, -Os, where different code size/performance heuristics are used, now
> > > > performs better w.r.t code size.
> > >
> > > Did anything change since:
> > >
> > > 281dc5c5ec0f ("Give up on pushing CC_OPTIMIZE_FOR_SIZE")
> > > 3a55fb0d9fe8 ("Tell the world we gave up on pushing CC_OPTIMIZE_FOR_SIZE")
> > >
> > > wrt -Os?
> > >
> > > Because if not, we still don't love -Os and you can drop the -Os argument.
> >
> > The -Os argument was to show the effect of the patch when the compiler
> > is instructed to take care of the overall size. Giving the compiler
> > -O2 and then looking at the overall size of the produced binary is
> > just wrong.
> >
> > > And without any perf data showing any improvement, this patch does nothing but
> > > enlarge -O2 size...
> >
> > Even to my surprise, the patch has some noticeable effects on the
> > performance, please see the attachment in [1] for LMBench data or [2]
> > for some excerpts from the data. So, I think the patch has potential
> > to improve the performance.
> >
> > [1] https://lore.kernel.org/lkml/CAFULd4YBcG45bigHBox2pu+To+Y5BzbRxG+pUr42AVOWSnfKsg@xxxxxxxxxxxxxx/
> > [2] https://lore.kernel.org/lkml/CAFULd4ZsSKwJ4Dz3cCAgaVsa4ypbb0e2savO-3_Ltbs=1wzgKQ@xxxxxxxxxxxxxx/
>
> If you are measuring micro-costs, please make sure you pin the workload
> to a single CPU (via 'taskset' for example) and run 'perf stat --null
> --repeat 5' or so to measure the run-over-run noise of the benchmark.

I simply run the lmbench command, where the benchmark was obtained as
.rpm for Fedora 41 [1], assuming that the benchmark itself sets the
benchmarked system to the correct state and does enough repetitions to
obtain a meaningful result [2].

[1] https://fedora.pkgs.org/41/rpm-sphere-x86_64/lmbench-3.0-0.a9.3.x86_64.rpm.html
[2] https://www.usenix.org/legacy/publications/library/proceedings/sd96/full_papers/mcvoy.pdf

Thanks,
Uros.