Can srcu_read_lock() be called from interrupt context?
Hi, Paul
I have a question to the srcu_read_lock(). Can it be invoked on
interrupt context? According to
http://lxr.free-electrons.com/source/kernel/rcu/srcu.c#L292 it can only be called from process context, but according to
http://lxr.free-electrons.com/source/include/linux/srcu.h#L213 seems it's ok from irq context only if it matches with the srcu_read_unlock. Can you please give some hints?
Thanks
--jyh
Quoted 8 lines · Yunhong Jiang
Hi, Paul
I have a question to thesrcu_read_lock(). Can it be invoked on
interrupt context? According to
http://lxr.free-electrons.com/source/kernel/rcu/srcu.c#L292 it can only be called from process context, but according to
http://lxr.free-electrons.com/source/include/linux/srcu.h#L213 seems it's ok from irq context only if it matches with thesrcu_read_unlock. Can you please give some hints?
Adding Lai Jianshan for his thoughts.
I believe that srcu.h is correct, at least assuming that interrupts do not nest too deeply. (If they were to nest four billion deep, then the ->seq[] counter could overflow, defeating the checks, but the CPU stack would have overflowed long before.)
Lai, am I missing anything here?
Thanx, Paul
Quoted 10 lines · Paul E. McKenney
Quoted 8 lines · Yunhong Jiang
Hi, Paul
I have a question to thesrcu_read_lock(). Can it be invoked on
interrupt context? According to
http://lxr.free-electrons.com/source/kernel/rcu/srcu.c#L292 it can only be called from process context, but according to
http://lxr.free-electrons.com/source/include/linux/srcu.h#L213 seems it's ok from irq context only if it matches with thesrcu_read_unlock. Can you please give some hints?
Quoted 6 lines
Adding Lai Jianshan for his thoughts.
I believe that
srcu.his correct, at least assuming that interrupts do not nest too deeply. (If they were to nest four billion deep, then the ->seq[] counter could overflow, defeating the checks, but the CPU stack would have overflowed long before.)
It seems like a strange constraint to me; not being able to use srcu_read_lock() from IRQ (or even NMI) context. And looking at the various implementations of it nothing ever prohibited this.
While srcu _allows_ for sleeping while holding the read side primitives, it is not required at all.
So I would suggest amending the comment and RCU/checklist.txt.
Even call_srcu() should be IRQ-safe.
Quoted 18 lines · Peter Zijlstra
Quoted 10 lines · Paul E. McKenney
Quoted 8 lines · Yunhong Jiang
Hi, Paul
I have a question to thesrcu_read_lock(). Can it be invoked on
interrupt context? According to
http://lxr.free-electrons.com/source/kernel/rcu/srcu.c#L292 it can only be called from process context, but according to
http://lxr.free-electrons.com/source/include/linux/srcu.h#L213 seems it's ok from irq context only if it matches with thesrcu_read_unlock. Can you please give some hints?Quoted 6 lines
Adding Lai Jianshan for his thoughts.
I believe that
srcu.his correct, at least assuming that interrupts do not nest too deeply. (If they were to nest four billion deep, then the ->seq[] counter could overflow, defeating the checks, but the CPU stack would have overflowed long before.)
Quoted 8 lines
It seems like a strange constraint to me; not being able to use
srcu_read_lock()from IRQ (or even NMI) context. And looking at the various implementations of it nothing ever prohibited this.While srcu _allows_ for sleeping while holding the read side primitives, it is not required at all.
So I would suggest amending the comment and
RCU/checklist.txt.
We need to hear from Lai. I -think- that it is OK for one srcu_read_lock() to interrupt another, but I could easily be missing something.
Quoted 1 line
Even
call_srcu()should be IRQ-safe.
Looks plausible to me. Lai?
Thanx, Paul