Re: [PATCH] printk/nbcon: Add assert that CPU migration is disabled when calling nbcon_context_try_acquire()

From: John Ogness
Date: Wed Sep 20 2023 - 09:00:28 EST


On 2023-09-20, Petr Mladek <pmladek@xxxxxxxx> wrote:
> The nbcon console is locked when the 'prio' and 'cpu' fields in
> console->nbcon_state stay the same. The locking algorithm would
> break when the locked context got migrated to another CPU.
>
> Add assert into nbcon_context_try_acquire(). It would warn when
> the function is called in a context where the CPU migration
> is possible.

static bool nbcon_context_try_acquire(struct nbcon_context *ctxt)
{
unsigned int cpu = smp_processor_id();

Doesn't smp_processor_id() already provide the necessary checking and
warning?

John