mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Thomas Gleixner <tglx@kernel.org>
To: Usama Arif <usama.arif@linux.dev>,
	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
Cc: shakeel.butt@linux.dev, hannes@cmpxchg.org, riel@surriel.com,
	d@ilvokhin.com, kernel-team@meta.com
Subject: Re: [PATCH] futex: Avoid hash-bucket locking for mismatched waits
Date: Fri, 14 Aug 2026 17:55:58 +0200	[thread overview]
Message-ID: <87zeyolmr5.ffs@fw13> (raw)
In-Reply-To: <f5459ad9-6fab-4924-a06e-c7c4f30c2667@linux.dev>

On Mon, Aug 10 2026 at 13:35, Usama Arif wrote:
> On 08/08/2026 10:19, Thomas Gleixner wrote:
>> On Fri, Jul 31 2026 at 12:26, Usama Arif wrote:
>>>  
>>> +	/*
>>> +	 * A mismatch here refuses the wait without locating the hash bucket;
>>> +	 * a match is rechecked under the lock below before queueing.
>>> +	 *
>>> +	 * get_futex_key() runs get_user_pages_fast() only for shared futexes,
>>> +	 * so their page is resident and the non-faulting read suffices, with
>>> +	 * the locked path recovering if it does not.  A private futex may
>> 
>> That's a fairy tale:
>> 
>>        get_futex_key()
>>           ...
>>           // shared
>>           get_user_pages_fast();        // gets a page reference
>>           ...
>>           folio = page_folio(page);
>>           ...
>> 
>>        out:
>>           folio_put(folio);	       // drops the page reference
>>           
>> Thanks,
>> 
>>         tglx
>
> I will fix the comment if the discussion in the other thread hopefully
> works out and there is a v2. folio_put() does not immediately evict the
> page; however as you point out it removes the guarantee that it stays
> available.
>
> get_futex_key() has just resolved the shared page, so a non-faulting
> read is "very likely" to succeed. If it doesn't, we get -EFAULT and will
> then reach the existing locked check and continues to do what is done
> without the patch.

What's the point of that exercise?

If the user access fails and it can fail with a page fault because
it's preemptible context, then the operation is done and returns -EFAULT
to user space.

This special handling of private futexes does not buy any value at all,
actually it adds a pointless conditional and makes the code
incomprehensible no matter how much effort you put into a comment.

Thanks,

        tglx



      reply	other threads:[~2026-08-14 15:56 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-31 19:26 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-08  9:19 ` Thomas Gleixner
2026-08-10 12:35   ` Usama Arif
2026-08-14 15:55     ` Thomas Gleixner [this message]

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=87zeyolmr5.ffs@fw13 \
    --to=tglx@kernel.org \
    --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=usama.arif@linux.dev \
    /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

all inboxes | Powered by JetHome®