Re: [PATCH next v2 2/3] printk: change @clear_seq to atomic64_t

2020-12-09 Thread Peter Zijlstra
On Wed, Dec 09, 2020 at 08:28:52PM +0900, Sergey Senozhatsky wrote: > On (20/12/09 12:00), Peter Zijlstra wrote: > > > So another potential re-entry path is > > > > > > atomic_foo() > > >spin_lock_irqsave(ATOMIC_HASH(v), flags) > > > printk() > > > prb() > > > atomic_foo() > >

Re: [PATCH next v2 2/3] printk: change @clear_seq to atomic64_t

2020-12-09 Thread Sergey Senozhatsky
On (20/12/09 12:00), Peter Zijlstra wrote: > > So another potential re-entry path is > > > > atomic_foo() > > spin_lock_irqsave(ATOMIC_HASH(v), flags) > > printk() > >prb() > > atomic_foo() > > spin_lock_irqsave(ATOMIC_HASH(v), flags) > > > > which can dead

Re: [PATCH next v2 2/3] printk: change @clear_seq to atomic64_t

2020-12-09 Thread Peter Zijlstra
On Wed, Dec 09, 2020 at 07:46:13PM +0900, Sergey Senozhatsky wrote: > On (20/12/09 18:22), Sergey Senozhatsky wrote: > > > > > > Please put on your eye cancer gear and inspect the atomic implementation > > > of PA-RISC, Sparc32, feh, I forgot who else. > > > > > > Those SMP capable architectures

Re: [PATCH next v2 2/3] printk: change @clear_seq to atomic64_t

2020-12-09 Thread Sergey Senozhatsky
On (20/12/09 18:22), Sergey Senozhatsky wrote: > > > > Please put on your eye cancer gear and inspect the atomic implementation > > of PA-RISC, Sparc32, feh, I forgot who else. > > > > Those SMP capable architectures are gifted with just one XCHG like > > atomic instruction :/ Anyway, as said in

Re: [PATCH next v2 2/3] printk: change @clear_seq to atomic64_t

2020-12-09 Thread Sergey Senozhatsky
On (20/12/09 09:16), Peter Zijlstra wrote: > On Tue, Dec 08, 2020 at 11:36:44PM +0106, John Ogness wrote: > > For the state variable we chose atomic_long_t instead of atomic64_t for > > this reason. atomic_long_t operations are available atomically on all > > architectures. > > Please put on your

Re: [PATCH next v2 2/3] printk: change @clear_seq to atomic64_t

2020-12-09 Thread Peter Zijlstra
On Tue, Dec 08, 2020 at 11:36:44PM +0106, John Ogness wrote: > For the state variable we chose atomic_long_t instead of atomic64_t for > this reason. atomic_long_t operations are available atomically on all > architectures. Please put on your eye cancer gear and inspect the atomic implementation o

Re: [PATCH next v2 2/3] printk: change @clear_seq to atomic64_t

2020-12-09 Thread Peter Zijlstra
On Wed, Dec 09, 2020 at 05:34:19AM +0900, Sergey Senozhatsky wrote: > 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

Re: [PATCH next v2 2/3] printk: change @clear_seq to atomic64_t

2020-12-08 Thread Sergey Senozhatsky
On (20/12/08 23:36), John Ogness wrote: > On 2020-12-09, Sergey Senozhatsky wrote: > >> 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 eac

Re: [PATCH next v2 2/3] printk: change @clear_seq to atomic64_t

2020-12-08 Thread John Ogness
On 2020-12-09, Sergey Senozhatsky wrote: >> 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_

Re: [PATCH next v2 2/3] printk: change @clear_seq to atomic64_t

2020-12-08 Thread Sergey Senozhatsky
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

RE: [PATCH next v2 2/3] printk: change @clear_seq to atomic64_t

2020-12-07 Thread David Laight
From: John Ogness > Sent: 07 December 2020 10:04 > > On 2020-12-07, Peter Zijlstra wrote: > >> Yes, and it is read-only access. Perhaps atomic64_t is the wrong thing > >> to use here. We could use a seqcount_latch and a shadow variable so that > >> if a writer has been preempted, we can use the p

Re: [PATCH next v2 2/3] printk: change @clear_seq to atomic64_t

2020-12-07 Thread Petr Mladek
On Mon 2020-12-07 11:09:39, John Ogness wrote: > On 2020-12-07, Peter Zijlstra wrote: > >> Yes, and it is read-only access. Perhaps atomic64_t is the wrong thing > >> to use here. We could use a seqcount_latch and a shadow variable so that > >> if a writer has been preempted, we can use the previo

Re: [PATCH next v2 2/3] printk: change @clear_seq to atomic64_t

2020-12-07 Thread Peter Zijlstra
On Mon, Dec 07, 2020 at 11:09:39AM +0106, John Ogness wrote: > That will not work. We are talking about a situation where the writer is > preempted. So seq will never equal seq_copy in that situation. I expect > that the seqcount_latch is necessary. Interrupted rather, I would think, specifically

Re: [PATCH next v2 2/3] printk: change @clear_seq to atomic64_t

2020-12-07 Thread John Ogness
On 2020-12-07, Peter Zijlstra wrote: >> Yes, and it is read-only access. Perhaps atomic64_t is the wrong thing >> to use here. We could use a seqcount_latch and a shadow variable so that >> if a writer has been preempted, we can use the previous value. (Only >> kmsg_dump would need to use the lock

Re: [PATCH next v2 2/3] printk: change @clear_seq to atomic64_t

2020-12-07 Thread Peter Zijlstra
On Sun, Dec 06, 2020 at 09:29:59PM +0106, John Ogness wrote: > Yes, and it is read-only access. Perhaps atomic64_t is the wrong thing > to use here. We could use a seqcount_latch and a shadow variable so that > if a writer has been preempted, we can use the previous value. (Only > kmsg_dump would n

Re: [PATCH next v2 2/3] printk: change @clear_seq to atomic64_t

2020-12-06 Thread John Ogness
On 2020-12-04, 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 >> sync

Re: [PATCH next v2 2/3] printk: change @clear_seq to atomic64_t

2020-12-04 Thread Petr Mladek
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/pri

[PATCH next v2 2/3] printk: change @clear_seq to atomic64_t

2020-12-01 Thread John Ogness
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. Signed-off-by: John Ogness --- kernel/printk/printk.c | 22 ++---