[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20241202-vertigo-dreamboat-4bf6b61a4ef6@spud>
Date: Mon, 2 Dec 2024 11:22:02 +0000
From: Conor Dooley <conor@...nel.org>
To: guoren@...nel.org
Cc: paul.walmsley@...ive.com, palmer@...belt.com, bjorn@...osinc.com,
leobras@...hat.com, peterz@...radead.org, parri.andrea@...il.com,
will@...nel.org, longman@...hat.com, boqun.feng@...il.com,
arnd@...db.de, alexghiti@...osinc.com,
linux-riscv@...ts.infradead.org, linux-kernel@...r.kernel.org,
Guo Ren <guoren@...ux.alibaba.com>
Subject: Re: [RESEND PATCH] riscv: Fixup boot failure when
CONFIG_DEBUG_RT_MUTEXES=y
On Sat, Nov 30, 2024 at 10:33:10AM -0500, guoren@...nel.org wrote:
> From: Guo Ren <guoren@...ux.alibaba.com>
>
> When CONFIG_DEBUG_RT_MUTEXES=y, mutex_lock->rt_mutex_try_acquire
> would change from rt_mutex_cmpxchg_acquire to
> rt_mutex_slowtrylock():
> raw_spin_lock_irqsave(&lock->wait_lock, flags);
> ret = __rt_mutex_slowtrylock(lock);
> raw_spin_unlock_irqrestore(&lock->wait_lock, flags);
>
> Because queued_spin_#ops to ticket_#ops is changed one by one by
> jump_label, raw_spin_lock/unlock would cause a deadlock during the
> changing.
>
> That means in arch/riscv/kernel/jump_label.c:
> 1.
> arch_jump_label_transform_queue() ->
> mutex_lock(&text_mutex); +-> raw_spin_lock -> queued_spin_lock
> |-> raw_spin_unlock -> queued_spin_unlock
> patch_insn_write -> change the raw_spin_lock to ticket_lock
> mutex_unlock(&text_mutex);
> ...
>
> 2. /* Dirty the lock value */
> arch_jump_label_transform_queue() ->
> mutex_lock(&text_mutex); +-> raw_spin_lock -> *ticket_lock*
> |-> raw_spin_unlock -> *queued_spin_unlock*
> /* BUG: ticket_lock with queued_spin_unlock */
> patch_insn_write -> change the raw_spin_unlock to ticket_unlock
> mutex_unlock(&text_mutex);
> ...
>
> 3. /* Dead lock */
> arch_jump_label_transform_queue() ->
> mutex_lock(&text_mutex); +-> raw_spin_lock -> ticket_lock /* deadlock! */
> |-> raw_spin_unlock -> ticket_unlock
> patch_insn_write -> change other raw_spin_#op -> ticket_#op
> mutex_unlock(&text_mutex);
>
> So, the solution is to disable mutex usage of
> arch_jump_label_transform_queue() during early_boot_irqs_disabled, just
> like we have done for stop_machine.
>
> Reported-by: Conor Dooley <conor@...nel.org>
Tested-by: Conor Dooley <conor.dooley@...rochip.com>
Thanks,
Conor.
Download attachment "signature.asc" of type "application/pgp-signature" (229 bytes)
Powered by blists - more mailing lists