Linux Kernel Selftest development
 help / color / mirror / Atom feed
From: Usama Arif <usama.arif@linux.dev>
To: Thomas Gleixner <tglx@kernel.org>, Dmitry Ilvokhin <d@ilvokhin.com>
Cc: peterz@infradead.org, andrealmeid@igalia.com, dave@stgolabs.net,
	dvhart@infradead.org, linux-kernel@vger.kernel.org,
	linux-kselftest@vger.kernel.org, mingo@redhat.com,
	shuah@kernel.org, shakeel.butt@linux.dev, hannes@cmpxchg.org,
	riel@surriel.com, kernel-team@meta.com
Subject: Re: [PATCH] futex: Avoid hash-bucket locking for mismatched waits
Date: Mon, 10 Aug 2026 13:17:34 +0100	[thread overview]
Message-ID: <f4eaec7c-39f7-4040-b668-946de9c70941@linux.dev> (raw)
In-Reply-To: <87jyq2dji5.ffs@fw13>



On 07/08/2026 16:42, Thomas Gleixner wrote:
> On Wed, Aug 05 2026 at 06:28, Usama Arif wrote:
>> On Tue, 4 Aug 2026 17:07:59 +0000 Dmitry Ilvokhin <d@ilvokhin.com> wrote:
>> The above data shows the significance of the patch.
>> It provides a very meaningful improvement (22.4% of time spent in futex_q_lock()
>> will be significantly optimized and will also deliver second-order effects)
>> and has no measurable impact on latency in the matching path.
>> IMHO, this patch is a free lunch.
> 
> Not really free. The user space access is not exactly cheap either
> because CLAC/STAC are memory fencing to meet the SMAP guarantees.
> 


My understanding from 86e6b1547b3d is that STAC/CLAC “end up serializing
execution on older Zen,” while Zen 5’s AC renaming “improves performance
of STAC/CLAC a lot a lot.”  Architecturally, they only change the AC bit.
They are not memory-ordering instructions like LFENCE. I am currently
testing on Zen5 which could be why I didn't see any wall-time regression
in futex_wait_timeout.c from [1].

> I've tried that lockless read/test before and gave up when a
> multi-waiter real world test case degraded by 5-10% depending on micro
> architecture.
> 


futex_wait_timeout.c [1] deliberately makes every call take the two-read path
and doesnt show any wall-time regression. The extra userspace read ofcourse
introduces additional instructions, but it is not showing up in any metric what
I thought would be the worst case in real world metrics.

The precheck adds no work while hb->lock is held, so it won't cause any more
contention.

I have been trying to coming up with some example userspace program that
would be negatively impacted by this patch and can't. I am not sure how
multi-waiter case that you described can result in 5-10% degradation
as the extra read is not showing up in wall clock time and we are not
adding more work under lock. I am currently testing on a Zen5 system.
Could you share the reproducer, thread topology, measured metric, and CPU
model on which you saw the 5–10% regression?

[1] https://lore.kernel.org/all/20260805132831.2852771-1-usama.arif@linux.dev/

  reply	other threads:[~2026-08-10 12:17 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-31 19:26 [PATCH] futex: Avoid hash-bucket locking for mismatched waits Usama Arif
2026-08-04 17:07 ` Dmitry Ilvokhin
2026-08-05 13:28   ` Usama Arif
2026-08-07 15:42     ` Thomas Gleixner
2026-08-10 12:17       ` Usama Arif [this message]
2026-08-08  9:19 ` Thomas Gleixner
2026-08-10 12:35   ` Usama Arif

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=f4eaec7c-39f7-4040-b668-946de9c70941@linux.dev \
    --to=usama.arif@linux.dev \
    --cc=andrealmeid@igalia.com \
    --cc=d@ilvokhin.com \
    --cc=dave@stgolabs.net \
    --cc=dvhart@infradead.org \
    --cc=hannes@cmpxchg.org \
    --cc=kernel-team@meta.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-kselftest@vger.kernel.org \
    --cc=mingo@redhat.com \
    --cc=peterz@infradead.org \
    --cc=riel@surriel.com \
    --cc=shakeel.butt@linux.dev \
    --cc=shuah@kernel.org \
    --cc=tglx@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox