Re: [PATCH next v1 1/2] dump_stack: move cpu lock to printk.c

From: John Ogness
Date: Tue Jun 01 2021 - 02:58:59 EST


On 2021-06-01, Sergey Senozhatsky <senozhatsky@xxxxxxxxxxxx> wrote:
> On (21/05/31 18:20), John Ogness wrote:
>> +void printk_cpu_lock(unsigned int *cpu_store, unsigned long *flags)
>> +{
>> + unsigned int cpu;
>> +
>> + for (;;) {
>> + cpu = get_cpu();
>> +
>> + *cpu_store = atomic_read(&printk_cpulock_owner);
>> +
>> + if (*cpu_store == -1) {
>> + local_irq_save(*flags);
>
> Is there any particular reason this does
>
> preempt_disable();
> cpu = smp_processor_id();
> local_irq_safe();
>
> instead of
>
> local_irq_safe();
> cpu = raw_smp_processor_id();
>
> ?

If the lock is owned by another CPU, there is no need to disable
interrupts for this CPU. (The local_irq_save() is conditional.)

John Ogness