Re: [PATCH next v2 2/3] printk: change @clear_seq to atomic64_t
From: Sergey Senozhatsky
Date: Tue Dec 08 2020 - 15:35:49 EST
On (20/12/04 10:12), Petr Mladek wrote:
> On Tue 2020-12-01 21:59:40, John Ogness wrote:
> > Currently @clear_seq access is protected by @logbuf_lock. Once
> > @logbuf_lock is removed some other form of synchronization will be
> > required. Change the type of @clear_seq to atomic64_t to provide the
> > synchronization.
> >
> > diff --git a/kernel/printk/printk.c b/kernel/printk/printk.c
> > index fc5e3a7d6d89..e9018c4e1b66 100644
> > --- a/kernel/printk/printk.c
> > +++ b/kernel/printk/printk.c
> > @@ -3412,7 +3418,7 @@ EXPORT_SYMBOL_GPL(kmsg_dump_get_buffer);
> > */
> > void kmsg_dump_rewind_nolock(struct kmsg_dumper *dumper)
> > {
> > - dumper->cur_seq = clear_seq;
> > + dumper->cur_seq = atomic64_read(&clear_seq);
>
> Sigh, atomic64_read() uses a spin lock in the generic implementation
> that is used on some architectures.
Oh... So on those archs prb is not lockless in fact, it actually
takes the spin_lock each time we read the descriptor state?
desc_read()
atomic_long_read(state_var)
atomic64_read()
raw_spin_lock_irqsave(lock, flags)
<< NMI panic >>
Am I missing something?
-ss