mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
To: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Cc: peterz@infradead.org, tglx@kernel.org, mingo@redhat.com,
	linux-kernel@vger.kernel.org, will@kernel.org, boqun@kernel.org,
	longman@redhat.com, rostedt@goodmis.org, clrkwllms@kernel.org,
	dvhart@infradead.org, dave@stgolabs.net, andrealmeid@igalia.com,
	shuah@kernel.org, juri.lelli@redhat.com,
	linux-rt-devel@lists.linux.dev, linux-kselftest@vger.kernel.org,
	stable@vger.kernel.org
Subject: Re: [PATCH v2 2/5] locking/rtmutex: Initialize the ww_mutex context of a waiter
Date: Wed, 18 Nov 2026 12:28:54 -0500	[thread overview]
Message-ID: <56ded99b-9390-46c1-9466-0be0cbb9ee95@efficios.com> (raw)
In-Reply-To: <20261118144006.ms1fvDv1@linutronix.de>

Hi Sebastian,

> The deference _shouldn't_ happen because those two a different. However,
> we could have a mix of those two and which point it becomes relevant.

Agreed. It needs a chain that mixes both. I dropped that paragraph.

> I would strip that paragraph because *I* think it is more important to
> mention the FUTEX case which no longer does proper chainwalk regardless
> of PREEMPT_RT.

One point. The two tests of ww_ctx in rt_mutex_adjust_prio_chain() are
under IS_ENABLED(CONFIG_PREEMPT_RT). Without PREEMPT_RT,
futex_lock_pi_inherit gets EDEADLK in both cases, with or without this
patch. So I kept the PREEMPT_RT condition in the message. Did you have
another path in mind?

With your changes, the message reads:

    rt_mutex_init_waiter() does not set rt_mutex_waiter::ww_ctx. Only
    __rt_mutex_slowlock_locked() sets it. So the waiters of PI futexes
    and rtlocks keep the 0x11 poison of CONFIG_DEBUG_RT_MUTEXES, or
    random garbage without that option.

    The futex code for FUTEX_LOCK_PI performs a RT_MUTEX_FULL_CHAINWALK
    during locking:

      futex_lock_pi()
        rt_mutex_init_waiter()
        __rt_mutex_start_proxy_lock()
          task_blocks_on_rt_mutex()
            rt_mutex_adjust_prio_chain()

    With PREEMPT_RT, rt_mutex_adjust_prio_chain() then wrongly assumes
    that it is a ww_mutex, due to the garbage in rt_mutex_waiter::ww_ctx.
    It does not report a deadlock, but expects the caller to handle it.
    Two threads that each block on a PI futex the other holds then sleep
    forever. Without PREEMPT_RT, the second one gets EDEADLK.
    FUTEX_LOCK_PI also blocks on a chain deeper than max_lock_depth,
    instead of returning EDEADLK.

    Fix this by clearing rt_mutex_waiter::ww_ctx in
    rt_mutex_init_waiter().

    With this patch, FUTEX_LOCK_PI returns EDEADLK in both cases. The
    futex_lock_pi_inherit selftest added later in this series found
    this, with PREEMPT_RT and CONFIG_DEBUG_RT_MUTEXES. Its deadlock and
    max_lock_depth cases cover it.

> This, Fixes: and
>
> Reviewed-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>

Thanks!

Mathieu


-- 
Mathieu Desnoyers
EfficiOS Inc.
https://www.efficios.com

  reply	other threads:[~2026-11-18 17:28 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-08 14:13 [PATCH v2 0/5] locking/rtmutex: priority inheritance fixes and tests Mathieu Desnoyers
2026-11-08 14:13 ` [PATCH v2 1/5] locking/rtmutex: Stop spinning on the owner when the waiter is woken Mathieu Desnoyers
2026-11-16 12:06   ` Sebastian Andrzej Siewior
2026-11-16 18:36     ` Mathieu Desnoyers
2026-11-18 14:19       ` Sebastian Andrzej Siewior
2026-11-18 17:27         ` Mathieu Desnoyers
2026-11-18 18:51           ` Sebastian Andrzej Siewior
2026-11-08 14:13 ` [PATCH v2 2/5] locking/rtmutex: Initialize the ww_mutex context of a waiter Mathieu Desnoyers
2026-11-16 13:58   ` Sebastian Andrzej Siewior
2026-11-16 18:37     ` Mathieu Desnoyers
2026-11-18 14:40       ` Sebastian Andrzej Siewior
2026-11-18 17:28         ` Mathieu Desnoyers [this message]
2026-11-18 18:49           ` Sebastian Andrzej Siewior
2026-11-08 14:13 ` [PATCH v2 3/5] locking/rtmutex: Clone the sort keys in rt_mutex_enqueue_pi() Mathieu Desnoyers
2026-11-16 15:11   ` Sebastian Andrzej Siewior
2026-11-16 18:35     ` Mathieu Desnoyers
2026-11-08 14:13 ` [PATCH v2 4/5] selftests/futex: Test priority inheritance on PI futexes Mathieu Desnoyers
2026-11-16 16:56   ` Sebastian Andrzej Siewior
2026-11-16 18:48     ` Mathieu Desnoyers
2026-11-08 14:13 ` [PATCH v2 5/5] locking/ww_mutex/test: Time an ABBA with both owners running Mathieu Desnoyers
2026-11-18 16:38   ` Sebastian Andrzej Siewior
2026-11-18 17:29     ` Mathieu Desnoyers
2026-11-18 18:45       ` Sebastian Andrzej Siewior

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=56ded99b-9390-46c1-9466-0be0cbb9ee95@efficios.com \
    --to=mathieu.desnoyers@efficios.com \
    --cc=andrealmeid@igalia.com \
    --cc=bigeasy@linutronix.de \
    --cc=boqun@kernel.org \
    --cc=clrkwllms@kernel.org \
    --cc=dave@stgolabs.net \
    --cc=dvhart@infradead.org \
    --cc=juri.lelli@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-kselftest@vger.kernel.org \
    --cc=linux-rt-devel@lists.linux.dev \
    --cc=longman@redhat.com \
    --cc=mingo@redhat.com \
    --cc=peterz@infradead.org \
    --cc=rostedt@goodmis.org \
    --cc=shuah@kernel.org \
    --cc=stable@vger.kernel.org \
    --cc=tglx@kernel.org \
    --cc=will@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

all inboxes | Powered by JetHome®