Re: Barrier before pushing desc_ring tail: was [PATCH v2 2/3] printk: add lockless buffer

2020-06-11 Thread John Ogness
On 2020-06-11, Petr Mladek wrote: > All this relies on the fact the the full barrier is called in > data_push_tail() and data_push_tail() is called right above. > But there are two situations where the barrier is not called. > It is when: > > 1. desc.text_blk_lpos.next already is behind data_rin

Re: redundant check in make_data_reusable(): was [PATCH v2 2/3] printk: add lockless buffer

2020-06-11 Thread John Ogness
On 2020-06-11, Petr Mladek wrote: >> --- /dev/null >> +++ b/kernel/printk/printk_ringbuffer.c >> +/* >> + * Given a data ring (text or dict), put the associated descriptor of >> each >> + * data block from @lpos_begin until @lpos_end into the reusable state. >> + * >>>

Re: redundant check in make_data_reusable(): was [PATCH v2 2/3] printk: add lockless buffer

2020-06-11 Thread John Ogness
On 2020-06-10, John Ogness wrote: >>> +static bool data_make_reusable(struct printk_ringbuffer *rb, >>> + struct prb_data_ring *data_ring, >>> + unsigned long lpos_begin, >>> + unsigned long lpos_end, >>> +

Re: redundant check in make_data_reusable(): was [PATCH v2 2/3] printk: add lockless buffer

2020-06-11 Thread Petr Mladek
On Wed 2020-06-10 12:24:01, John Ogness wrote: > On 2020-06-10, Petr Mladek wrote: > >> >> --- /dev/null > >> >> +++ b/kernel/printk/printk_ringbuffer.c > >> >> +/* > >> >> + * Given a data ring (text or dict), put the associated descriptor of > >> >> each > >> >> + * data block from @lpos_begin

Re: Barrier before pushing desc_ring tail: was [PATCH v2 2/3] printk: add lockless buffer

2020-06-11 Thread Petr Mladek
On Tue 2020-06-09 17:56:03, John Ogness wrote: > On 2020-06-09, Petr Mladek wrote: > >> --- /dev/null > >> +++ b/kernel/printk/printk_ringbuffer.c > >> +/* > >> + * Advance the desc ring tail. This function advances the tail by one > >> + * descriptor, thus invalidating the oldest descriptor. Befo

Re: redundant check in make_data_reusable(): was [PATCH v2 2/3] printk: add lockless buffer

2020-06-10 Thread John Ogness
On 2020-06-10, Petr Mladek wrote: >> +static bool data_make_reusable(struct printk_ringbuffer *rb, >> + struct prb_data_ring *data_ring, >> + unsigned long lpos_begin, >> + unsigned long lpos_end, >> +

Re: blk->id read race: was: [PATCH v2 2/3] printk: add lockless buffer

2020-06-10 Thread John Ogness
On 2020-06-10, Petr Mladek wrote: --- /dev/null +++ b/kernel/printk/printk_ringbuffer.c +/* + * Given a data ring (text or dict), put the associated descriptor of each + * data block from @lpos_begin until @lpos_end into the reusable state. + * + * If there is an

Re: redundant check in make_data_reusable(): was [PATCH v2 2/3] printk: add lockless buffer

2020-06-10 Thread John Ogness
On 2020-06-10, Petr Mladek wrote: >> >> --- /dev/null >> >> +++ b/kernel/printk/printk_ringbuffer.c >> >> +/* >> >> + * Given a data ring (text or dict), put the associated descriptor of >> >> each >> >> + * data block from @lpos_begin until @lpos_end into the reusable state. >> >> + * + * I

Re: redundant check in make_data_reusable(): was [PATCH v2 2/3] printk: add lockless buffer

2020-06-10 Thread Petr Mladek
On Tue 2020-06-09 16:48:30, John Ogness wrote: > On 2020-06-09, Petr Mladek wrote: > >> --- /dev/null > >> +++ b/kernel/printk/printk_ringbuffer.c > >> +/* > >> + * Given a data ring (text or dict), put the associated descriptor of each > >> + * data block from @lpos_begin until @lpos_end into the

Re: blk->id read race: was: [PATCH v2 2/3] printk: add lockless buffer

2020-06-10 Thread Petr Mladek
On Tue 2020-06-09 16:18:35, John Ogness wrote: > On 2020-06-09, Petr Mladek wrote: > >> --- /dev/null > >> +++ b/kernel/printk/printk_ringbuffer.c > >> +/* > >> + * Given a data ring (text or dict), put the associated descriptor of each > >> + * data block from @lpos_begin until @lpos_end into the

Re: data_ring head_lpos and tail_lpos synchronization: was [PATCH v2 2/3] printk: add lockless buffer

2020-06-10 Thread John Ogness
On 2020-06-09, Petr Mladek wrote: >> --- /dev/null >> +++ b/kernel/printk/printk_ringbuffer.c >> +/* >> + * Advance the data ring tail to at least @lpos. This function puts >> + * descriptors into the reusable state if the tail is pushed beyond >> + * their associated data block. >> + */ >> +stati

Re: Barrier before pushing desc_ring tail: was [PATCH v2 2/3] printk: add lockless buffer

2020-06-09 Thread John Ogness
On 2020-06-09, Petr Mladek wrote: >> --- /dev/null >> +++ b/kernel/printk/printk_ringbuffer.c >> +/* >> + * Advance the desc ring tail. This function advances the tail by one >> + * descriptor, thus invalidating the oldest descriptor. Before advancing >> + * the tail, the tail descriptor is made r

Re: Full barrier in data_push_tail(): was [PATCH v2 2/3] printk: add lockless buffer

2020-06-09 Thread John Ogness
On 2020-06-09, Petr Mladek wrote: >> --- /dev/null >> +++ b/kernel/printk/printk_ringbuffer.c >> +static bool data_push_tail(struct printk_ringbuffer *rb, >> + struct prb_data_ring *data_ring, >> + unsigned long lpos) >> +{ >> ... >> + >> +/*

Re: redundant check in make_data_reusable(): was [PATCH v2 2/3] printk: add lockless buffer

2020-06-09 Thread John Ogness
On 2020-06-09, Petr Mladek wrote: >> --- /dev/null >> +++ b/kernel/printk/printk_ringbuffer.c >> +/* >> + * Given a data ring (text or dict), put the associated descriptor of each >> + * data block from @lpos_begin until @lpos_end into the reusable state. >> + * >> + * If there is any problem maki

data_ring head_lpos and tail_lpos synchronization: was [PATCH v2 2/3] printk: add lockless buffer

2020-06-09 Thread Petr Mladek
On Fri 2020-05-01 11:46:09, John Ogness wrote: > Introduce a multi-reader multi-writer lockless ringbuffer for storing > the kernel log messages. Readers and writers may use their API from > any context (including scheduler and NMI). This ringbuffer will make > it possible to decouple printk() call

Re: blk->id read race: was: [PATCH v2 2/3] printk: add lockless buffer

2020-06-09 Thread John Ogness
On 2020-06-09, Petr Mladek wrote: >> --- /dev/null >> +++ b/kernel/printk/printk_ringbuffer.c >> +/* >> + * Given a data ring (text or dict), put the associated descriptor of each >> + * data block from @lpos_begin until @lpos_end into the reusable state. >> + * >> + * If there is any problem maki

Barrier before pushing desc_ring tail: was [PATCH v2 2/3] printk: add lockless buffer

2020-06-09 Thread Petr Mladek
On Fri 2020-05-01 11:46:09, John Ogness wrote: > Introduce a multi-reader multi-writer lockless ringbuffer for storing > the kernel log messages. Readers and writers may use their API from > any context (including scheduler and NMI). This ringbuffer will make > it possible to decouple printk() call

Full barrier in data_push_tail(): was [PATCH v2 2/3] printk: add lockless buffer

2020-06-09 Thread Petr Mladek
On Fri 2020-05-01 11:46:09, John Ogness wrote: > Introduce a multi-reader multi-writer lockless ringbuffer for storing > the kernel log messages. Readers and writers may use their API from > any context (including scheduler and NMI). This ringbuffer will make > it possible to decouple printk() call

redundant check in make_data_reusable(): was [PATCH v2 2/3] printk: add lockless buffer

2020-06-09 Thread Petr Mladek
On Fri 2020-05-01 11:46:09, John Ogness wrote: > Introduce a multi-reader multi-writer lockless ringbuffer for storing > the kernel log messages. Readers and writers may use their API from > any context (including scheduler and NMI). This ringbuffer will make > it possible to decouple printk() call

blk->id read race: was: [PATCH v2 2/3] printk: add lockless buffer

2020-06-09 Thread Petr Mladek
On Fri 2020-05-01 11:46:09, John Ogness wrote: > Introduce a multi-reader multi-writer lockless ringbuffer for storing > the kernel log messages. Readers and writers may use their API from > any context (including scheduler and NMI). This ringbuffer will make > it possible to decouple printk() call

Re: [PATCH v2 2/3] printk: add lockless buffer

2020-05-19 Thread John Ogness
On 2020-05-18, Linus Torvalds wrote: >> smp_mb(); /* LMM(data_push_tail:C) */ >> >> + if (atomic_long_try_cmpxchg_relaxed(&data_ring->tail_lpos, >> + &tail_lpos, >> + next_lpos)) { /* LMM(data_push_tail:D) */

Re: [PATCH v2 2/3] printk: add lockless buffer

2020-05-18 Thread Linus Torvalds
On Mon, May 18, 2020 at 6:04 AM John Ogness wrote: > > The cmpxchg() needs to be moved out of the while condition so that a > continue can be used as intended. Patch below. This seems pointless and wrong (patch edited to remove the '-' lines so that you see the end result): > smp

[PATCH v2 2/3] printk: add lockless buffer

2020-05-01 Thread John Ogness
Introduce a multi-reader multi-writer lockless ringbuffer for storing the kernel log messages. Readers and writers may use their API from any context (including scheduler and NMI). This ringbuffer will make it possible to decouple printk() callers from any context, locking, or console constraints.