Messages in this thread | | | From | John Ogness <> | Subject | Re: [RFC PATCH v1 07/25] printk-rb: add functionality required by printk | Date | Wed, 13 Feb 2019 10:20:07 +0100 |
| |
On 2019-02-12, Linus Torvalds <torvalds@linux-foundation.org> wrote: > On Tue, Feb 12, 2019 at 6:30 AM John Ogness <john.ogness@linutronix.de> wrote: >> >> + while (atomic_long_read(&rb->lost)) { >> + atomic_long_dec(&rb->lost); >> + rb->seq++; >> + } > > This looks like crazy garbage. It's neither atomic nor sane.
It works because because only 1 context on a single CPU can hit that loop. But yes, it is crazy.
> Why isn't it something like > > if (atomic_long_read(&rb->lost)) { > long lost = atomic_xchg(&rb->lost, 0); > rb->seq += lost; > } > > instead?
Yes, it should be like you suggest. Thanks.
John Ogness
| |