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

From: Petr Mladek
Date: Tue Jun 01 2021 - 09:29:12 EST


On Tue 2021-06-01 09:37:08, John Ogness wrote:
> On 2021-06-01, John Ogness <john.ogness@xxxxxxxxxxxxx> wrote:
> >> 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.)
>
> The cpu lock implementation from dump_stack() also keeps preemption
> continually enabled while spinning.

I wonder if this might reduce some noise on the CPU cache lines
when disable_preemption()/enable_preemption() actually does something.
But the problem might be only with cmpxchg() in a busy loop.
Peter Zijlstra might know more.

> I used the cpu lock implementation from PREEMPT_RT. But for my v2
> I will adopt the same ordering from dump_stack(), as you are suggesting.

Anyway, please document any changes in the ordering if there are any.
The current commit message sounds like a code move without any
functional changes.

Best Regards,
Petr