Re: [PATCH v2] locking/mutex: remove redundant argument from __mutex_lock_common()

From: Ingo Molnar
Date: Mon Sep 04 2023 - 15:08:16 EST



* Peter Zijlstra <peterz@xxxxxxxxxxxxx> wrote:

> On Sun, Sep 03, 2023 at 12:33:19AM +0200, Michał Mirosław wrote:
> > use_ww_ctx is equivalent to ww_ctx != NULL. The one case where
> > use_ww_ctx was true but ww_ctx == NULL leads to the same
> > __mutex_add_waiter() call via __ww_mutex_add_waiter().
> >
> > Since now __ww_mutex_add_waiter() is called only with ww_ctx != NULL
> > (from both regular and PREEMPT_RT implementations), remove the
> > branch there.
> >
>
> There were compilers that failed to constant propagate the ww_ctx==NULL
> thing properly and generated crap code, the use_ww_ctx thing fixed that.
>
> I can't remember which compilers that were (my brain is saying <gcc-6 or
> something, but I could be totally wrong) and if we still care about
> people using them (probably not).

The changelog of the patch should probably include before/after generated
code comparison & analysis - or at minimum a '/bin/size' comparison to
quantify the changes to generated code.

Thanks,

Ingo