Re: [RFC PATCH v1 02/25] printk-rb: add prb locking functions

2019-03-06 Thread Sergey Senozhatsky
On (02/12/19 15:29), John Ogness wrote: > +static bool __prb_trylock(struct prb_cpulock *cpu_lock, > + unsigned int *cpu_store) > +{ > + unsigned long *flags; > + unsigned int cpu; > + > + cpu = get_cpu(); > + > + *cpu_store = atomic_read(_lock->owner); > +

Re: [RFC PATCH v1 02/25] printk-rb: add prb locking functions

2019-02-15 Thread John Ogness
On 2019-02-15, Petr Mladek wrote: >>> void prb_lock(struct prb_cpulock *cpu_lock) >>> { >>> unsigned int flags; >>> int cpu; >> >> I added an explicit preempt_disable here: >> >> cpu = get_cpu(); > > It is superfluous. Preemption is not possible when interrupts > are disabled.

Re: [RFC PATCH v1 02/25] printk-rb: add prb locking functions

2019-02-15 Thread Petr Mladek
On Thu 2019-02-14 13:10:28, John Ogness wrote: > On 2019-02-14, Petr Mladek wrote: > >>> cpu_store looks like an implementation detail. The caller > >>> needs to remember it to handle the nesting properly. > >>> > >>> We could achieve the same with a recursion counter hidden > >>> in struct

Re: [RFC PATCH v1 02/25] printk-rb: add prb locking functions

2019-02-14 Thread John Ogness
On 2019-02-14, Petr Mladek wrote: >>> cpu_store looks like an implementation detail. The caller >>> needs to remember it to handle the nesting properly. >>> >>> We could achieve the same with a recursion counter hidden >>> in struct prb_lock. > > The atomic operations are tricky. I feel other

Re: [RFC PATCH v1 02/25] printk-rb: add prb locking functions

2019-02-14 Thread Petr Mladek
On Wed 2019-02-13 22:39:20, John Ogness wrote: > On 2019-02-13, Petr Mladek wrote: > >> +/* > >> + * prb_unlock: Perform a processor-reentrant spin unlock. > >> + * @cpu_lock: A pointer to the lock object. > >> + * @cpu_store: A "flags" object storing lock status information. > >> + * > >> + *

Re: [RFC PATCH v1 02/25] printk-rb: add prb locking functions

2019-02-13 Thread John Ogness
On 2019-02-13, Petr Mladek wrote: >> Add processor-reentrant spin locking functions. These allow >> restricting the number of possible contexts to 2, which can simplify >> implementing code that also supports NMI interruptions. >> >> prb_lock(); >> >> /* >> * This code is

Re: [RFC PATCH v1 02/25] printk-rb: add prb locking functions

2019-02-13 Thread Petr Mladek
On Tue 2019-02-12 15:29:40, John Ogness wrote: > Add processor-reentrant spin locking functions. These allow > restricting the number of possible contexts to 2, which can simplify > implementing code that also supports NMI interruptions. > > prb_lock(); > > /* > * This code is

[RFC PATCH v1 02/25] printk-rb: add prb locking functions

2019-02-12 Thread John Ogness
Add processor-reentrant spin locking functions. These allow restricting the number of possible contexts to 2, which can simplify implementing code that also supports NMI interruptions. prb_lock(); /* * This code is synchronized with all contexts * except an NMI on the same