All of lore.kernel.org
 help / color / mirror / Atom feed
From: Usama Arif <usama.arif@linux.dev>
To: Usama Arif <usama.arif@linux.dev>
Cc: Thomas Gleixner <tglx@kernel.org>,
	Dmitry Ilvokhin <d@ilvokhin.com>,
	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: Wed, 26 Aug 2026 08:22:48 -0700	[thread overview]
Message-ID: <20260826152249.1690870-1-usama.arif@linux.dev> (raw)
In-Reply-To: <0de32be8-7e19-4e8c-b9b9-0ed9a14b9eff@linux.dev>

On Thu, 20 Aug 2026 19:05:31 +0100 Usama Arif <usama.arif@linux.dev> wrote:

> 
> 
> On 20/08/2026 17:23, Thomas Gleixner wrote:
> > Usama!
> > 
> > On Thu, Aug 20 2026 at 16:19, Usama Arif wrote:
> >> On 14/08/2026 17:02, Thomas Gleixner wrote:
> >>> --- a/kernel/futex/waitwake.c
> >>> +++ b/kernel/futex/waitwake.c
> >>> @@ -857,7 +857,21 @@ int futex_wait_setup(u32 __user *uaddr,
> >>>  		CLASS(hbr, hbr)(&q->key);
> >>>  		auto hb = hbr.hb;
> >>>  
> >>> -		futex_q_lock(q, hb);
> >>> +		futex_hb_waiters_inc(hb);
> >>> +		q->lock_ptr = &hb->lock;
> >>> +
> >>> +		if (!spin_trylock(&hb->lock)) {
> >>> +			ret = get_user_inline(uval, uaddr);
> >>> +			if (ret) {
> >>> +				futex_hb_waiters_dec(hb);
> >>> +				return ret;
> >>> +			}
> >>> +			if (uval != val) {
> >>> +				futex_hb_waiters_dec(hb);
> >>> +				return -EWOULDBLOCK;
> >>> +			}
> >>> +			spin_lock(&hb->lock);
> >>> +		}
> >>>  
> >>>  		ret = futex_get_value_locked(&uval, uaddr);
> >>>
> >> I like this approach; it makes the trade-off much better than my patch.
> >> When spin_trylock() succeeds, the matching path performs only the existing 
> >> single user access, rather than the two accesses in my version.
> > 
> > Correct.
> > 
> >> Is it alright if I send v2 of the patch with your diff above? Or would you
> >> like to send it?
> > 
> > Go wild.
> > 
> 
> Thanks! I am going to try and run this in production workloads to gather data.
> Should be done in the next few days and send it early next week.

Just coming back on this, its taking more time than I would like to setup a
hosts with custom kernel on production traffic, I will update here once I have
something with this patch.

  reply	other threads:[~2026-08-26 15:22 UTC|newest]

Thread overview: 17+ 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
2026-08-14 16:01         ` Thomas Gleixner
2026-08-14 16:02           ` Thomas Gleixner
2026-08-20 15:19             ` Usama Arif
2026-08-20 16:23               ` Thomas Gleixner
2026-08-20 18:05                 ` Usama Arif
2026-08-26 15:22                   ` Usama Arif [this message]
2026-08-20 16:14             ` Dmitry Ilvokhin
2026-08-21 13:18               ` Thomas Gleixner
2026-08-25 16:48                 ` Thomas Gleixner
2026-08-08  9:19 ` Thomas Gleixner
2026-08-10 12:35   ` Usama Arif
2026-08-14 15:55     ` Thomas Gleixner

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=20260826152249.1690870-1-usama.arif@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.