Re: [PATCH] printk: Update @console_may_schedule in console_trylock_spinning()

From: John Ogness
Date: Mon Feb 26 2024 - 08:03:20 EST


On 2024-02-26, Mukesh Ojha <quic_mojha@xxxxxxxxxxx> wrote:
> what if console_trylock_spinning() gets the lock which makes
> console_may_schedule =1 and it is still schedulable ?

I am afraid I do not understand the question.

console_trylock_spinning() is only called from the printk caller
context. In this context, console_may_schedule is always set to 0.

Only if another context acquires the console lock per sleeping wait,
console_lock(), can console_may_schedule be set to 1.

Note that the value of console_may_schedule is only relevant for the
console lock owner when console_unlock() is called. That is why its
value is set when locking the console (or, with this patch, when
transferring console lock ownerhip).

John