mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: K Prateek Nayak <kprateek.nayak@amd.com>
To: Suleiman Souhlal <suleiman@google.com>
Cc: "Peter Zijlstra" <peterz@infradead.org>,
	linux-kernel@vger.kernel.org, "Thomas Gleixner" <tglx@kernel.org>,
	"Ingo Molnar" <mingo@redhat.com>,
	"Darren Hart" <dvhart@infradead.org>,
	"Davidlohr Bueso" <dave@stgolabs.net>,
	"André Almeida" <andrealmeid@igalia.com>,
	"Juri Lelli" <juri.lelli@redhat.com>,
	"Vincent Guittot" <vincent.guittot@linaro.org>,
	"Dietmar Eggemann" <dietmar.eggemann@arm.com>,
	"Steven Rostedt" <rostedt@goodmis.org>,
	"Ben Segall" <bsegall@google.com>, "Mel Gorman" <mgorman@suse.de>,
	"Valentin Schneider" <vschneid@redhat.com>,
	"zhidao su" <soolaugust@gmail.com>,
	"John Stultz" <jstultz@google.com>,
	"Qais Yousef" <qyousef@google.com>,
	ssouhlal@freebsd.org
Subject: Re: [RFC PATCH 02/12] futex: Switch PI futex to use p->pi_futex_lock instead of p->pi_lock.
Date: Fri, 16 Oct 2026 13:45:50 +0530	[thread overview]
Message-ID: <067742df-adf5-43dc-b939-ef5530001614@amd.com> (raw)
In-Reply-To: <CABCjUKB9ntxrEzJQcd45j8dUde+91i--MCSW49RWR2Zr40QTCg@mail.gmail.com>

Hello Suleiman,

On 10/16/2026 11:29 AM, Suleiman Souhlal wrote:
>>> I suppose the alternatives would be to either figure out how to
>>> un-nest pi_lock from wait_lock in futex code or un-nesting the
>>> blocked_on lock from pi_lock in the scheduler.
>>
>> So the only time we try to grab pi_lock + blocked_lock is during
>> wakeup so I think doing that should be (theoretically) possible.
>>
>> The ttwu_runnable() handling is extremely painful unless we block
>> the delayed task fully. Since we have he new p->is_blocked state,
>> we can safely retain the p->blocked_on while running the task -
>> it is either cleared during unlock by previosu owner or will be
>> same as the lock on which the task blocked on.
>>
>>
>> Based on John's tree at commit 06ac43db4d8e ("[ANNOTATION] ===
>> Needs confirmation of functionality past this point ===") on
>> proxy-exec-v31-7.2-rc4 branch:
> 
> Sorry for the slow reply and thanks for the very quick patch.
> 
> Unfortunately, it doesn't seem like this approach works in the end,
> because there is still a pi_lock -> rq lock -> blocked_lock transitive
> relationship, which deadlocks when trying to get the pi_lock while
> holding the blocked_lock (when fixing up the pi_state owner in the
> futex code). :-(

Ah! So what you are saying is, since we have:

  p->pi_lock
    rq_lock /* ttwu_runnable() */

and

  rq_lock
   blocked_lock /* find_proxy_task() */

relations, doing a:

  blocked_lock
    p->pi_lock

would cause a deadlock via rq_lock. True that.

> 
> On the other hand, Peter's suggestion of moving the scheduler's use of
> pi_lock to a new lock, p->sched_lock, seems to work in my testing, but
> is kind of a scary change to me.
> 
> Maybe an acceptable alternative would be for the new futex to use a
> new lock (similarly to what the original patch does), but keep regular
> PI futexes using pi_lock, at least as long as they are still based on
> rtmutexes.

I guess that should do too, yes.

On a different note, why do we need the p->pi_lock/p->pi_futex_lock to
modify the ping_state->owner in ping_state_update_owner()? Isn't
ping_state->ping_mutex.wait_lock + owner->blocked_on locks enough?

Note: I'm still wrapping my head around the PING implementation so it
might take me a while to appreciate the need for the pi_futex_lock.
I'm using proxy-exec-v32-7.3-rc-tip-sched-core from John's tree at the
moment to jump around.

-- 
Thanks and Regards,
Prateek


  reply	other threads:[~2026-10-16  8:16 UTC|newest]

Thread overview: 31+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-17  4:33 [RFC PATCH 00/12] FUTEX_PING: A stealable futex using Proxy Execution Suleiman Souhlal
2026-09-17  4:33 ` [RFC PATCH 01/12] sched: Abstract task_struct->blocked_on by locking primitive Suleiman Souhlal
2026-09-17  4:33 ` [RFC PATCH 02/12] futex: Switch PI futex to use p->pi_futex_lock instead of p->pi_lock Suleiman Souhlal
2026-09-17 15:38   ` Peter Zijlstra
2026-09-18  7:11     ` Suleiman Souhlal
2026-09-18 10:07       ` K Prateek Nayak
2026-10-16  5:59         ` Suleiman Souhlal
2026-10-16  8:15           ` K Prateek Nayak [this message]
2026-09-18 12:06       ` Peter Zijlstra
2026-09-17  4:33 ` [RFC PATCH 03/12] futex: Add "ping" parameter to pi_state management functions and export them Suleiman Souhlal
2026-09-17  4:33 ` [RFC PATCH 04/12] futex: Introduce stealable PI futex, FUTEX_*_PING Suleiman Souhlal
2026-09-17  4:33 ` [RFC PATCH 05/12] futex: Implement exit_ping_state_list() Suleiman Souhlal
2026-09-17  4:33 ` [RFC PATCH 06/12] futex: Address aborting from futex_lock_ping() while owning ping_state Suleiman Souhlal
2026-09-17  4:33 ` [RFC PATCH 07/12] futex: Make FUTEX_*_PING use Proxy Execution Suleiman Souhlal
2026-09-17 13:18   ` Jihan LIN
2026-09-17 14:39     ` K Prateek Nayak
2026-09-17 15:36       ` Peter Zijlstra
2026-09-21  4:51         ` K Prateek Nayak
2026-09-23 14:04           ` Jihan LIN
2026-09-17  4:33 ` [RFC PATCH 08/12] futex: Implement PING futex handoff Suleiman Souhlal
2026-09-17  4:33 ` [RFC PATCH 09/12] futex: Wake up donor in PING futex unlock Suleiman Souhlal
2026-09-17  4:33 ` [RFC PATCH 10/12] futex: Optimistic spinning for PING futexes Suleiman Souhlal
2026-09-17  4:33 ` [RFC PATCH 11/12] futex: Allow userspace stealing " Suleiman Souhlal
2026-09-17  4:33 ` [RFC PATCH 12/12] tools/testing/futex: Add ping_bench, a tool for benchmarking futexes Suleiman Souhlal
2026-09-17  8:58 ` [RFC PATCH 00/12] FUTEX_PING: A stealable futex using Proxy Execution Peter Zijlstra
2026-09-17 17:53   ` John Stultz
2026-09-17 18:51     ` Steven Rostedt
2026-09-18  6:30       ` Suleiman Souhlal
2026-09-18  8:25     ` Peter Zijlstra
2026-09-18  6:07   ` Suleiman Souhlal
2026-09-18  8:07     ` Peter Zijlstra

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=067742df-adf5-43dc-b939-ef5530001614@amd.com \
    --to=kprateek.nayak@amd.com \
    --cc=andrealmeid@igalia.com \
    --cc=bsegall@google.com \
    --cc=dave@stgolabs.net \
    --cc=dietmar.eggemann@arm.com \
    --cc=dvhart@infradead.org \
    --cc=jstultz@google.com \
    --cc=juri.lelli@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mgorman@suse.de \
    --cc=mingo@redhat.com \
    --cc=peterz@infradead.org \
    --cc=qyousef@google.com \
    --cc=rostedt@goodmis.org \
    --cc=soolaugust@gmail.com \
    --cc=ssouhlal@freebsd.org \
    --cc=suleiman@google.com \
    --cc=tglx@kernel.org \
    --cc=vincent.guittot@linaro.org \
    --cc=vschneid@redhat.com \
    /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®