[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20251023135316.1ZRx0UU5@linutronix.de>
Date: Thu, 23 Oct 2025 15:53:16 +0200
From: Sebastian Andrzej Siewior <bigeasy@...utronix.de>
To: Oleg Nesterov <oleg@...hat.com>
Cc: "Luis Claudio R. Goncalves" <lgoncalv@...hat.com>,
Peter Zijlstra <peterz@...radead.org>,
Clark Williams <clrkwllms@...nel.org>,
Steven Rostedt <rostedt@...dmis.org>, Tejun Heo <tj@...nel.org>,
David Vernet <dvernet@...a.com>, Barret Rhoden <brho@...gle.com>,
Josh Don <joshdon@...gle.com>, Crystal Wood <crwood@...hat.com>,
linux-kernel@...r.kernel.org, linux-rt-devel@...ts.linux.dev,
Juri Lelli <juri.lelli@...hat.com>, Ben Segall <bsegall@...gle.com>,
Dietmar Eggemann <dietmar.eggemann@....com>,
Ingo Molnar <mingo@...hat.com>, Mel Gorman <mgorman@...e.de>,
Valentin Schneider <vschneid@...hat.com>,
Vincent Guittot <vincent.guittot@...aro.org>,
Thomas Gleixner <tglx@...utronix.de>,
Wander Lairson Costa <wander@...hat.com>
Subject: Re: usage of DEFINE_WAIT_OVERRIDE_MAP(LD_WAIT_SLEEP)
On 2025-10-20 16:53:10 [+0200], Oleg Nesterov wrote:
> Hi Sebastian,
Hi,
> > You are correct Oleg. I've been just verifying it and yes: LD_WAIT_SLEEP
> > suppresses also mutex while the intention is to only suppress
> > spinlock_t.
> > We have four users in tree, based on quick check all four should use
> > CONFIG, three of them do use SLEEP.
>
> No ;)
>
> I was going to send the patch which does s/SLEEP/CONFIG/, but this
> would be wrong. printk_legacy_map can use LD_WAIT_CONFIG, but lets
> look at debug_objects_fill_pool()
>
> if (!IS_ENABLED(CONFIG_PREEMPT_RT) || preemptible()) {
> /*
> * Annotate away the spinlock_t inside raw_spinlock_t warning
> * by temporarily raising the wait-type to WAIT_SLEEP, matching
> * the preemptible() condition above.
> */
> static DEFINE_WAIT_OVERRIDE_MAP(fill_pool_map, LD_WAIT_SLEEP);
> lock_map_acquire_try(&fill_pool_map);
> fill_pool();
> lock_map_release(&fill_pool_map);
> }
>
> If CONFIG_PREEMPT_RT=y and preemptible() is true, LD_WAIT_CONFIG won't work.
> lockdep will complain if fill_pool() takes a spinlock_t, spinlock is
> LD_WAIT_SLEEP on RT.
Where is this? This is then wrong then because _SLEEP is for MUTEX and
those things that sleep-sleep and pretend to sleep.
spinlock_t should be LD_WAIT_CONFIG. This is used in
include/linux/spinlock_types.h via SPIN_DEP_MAP_INIT which is only
defined once as LD_WAIT_CONFIG.
rt_mutex is defined as LD_WAIT_SLEEP but this one is not the one we use
for spinlock_t.
What you want to have working in the end is the following scenario:
|static DEFINE_SPINLOCK(lock_spinlock);
|static DEFINE_RAW_SPINLOCK(lock_raw_spinlock);
|static DEFINE_RAW_SPINLOCK(lock_raw_spinlock2);
|
|static void lockdep_test(void)
|{
| static DEFINE_WAIT_OVERRIDE_MAP(put_task_map, LD_WAIT_CONFIG);
|
| raw_spin_lock(&lock_raw_spinlock);
| lock_map_acquire_try(&put_task_map);
|
| spin_lock(&lock_spinlock);
| spin_unlock(&lock_spinlock);
|
| raw_spin_lock(&lock_raw_spinlock2);
| raw_spin_unlock(&lock_raw_spinlock2);
|
| lock_map_release(&put_task_map);
| raw_spin_unlock(&lock_raw_spinlock);
|}
This will work. On RT as well but is wrong and will not happen due to
the preemptible() check. On !RT it will so you want lockdep to be quiet.
>
> Oleg.
Sebastian
Powered by blists - more mailing lists