* Can srcu_read_lock() be called from interrupt context? @ 2015-11-03 1:56 Yunhong Jiang 2015-11-03 9:55 ` Paul E. McKenney 0 siblings, 1 reply; 4+ messages in thread From: Yunhong Jiang @ 2015-11-03 1:56 UTC (permalink / raw) To: paulmck; +Cc: linux-kernel 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 ^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Can srcu_read_lock() be called from interrupt context? 2015-11-03 1:56 Can srcu_read_lock() be called from interrupt context? Yunhong Jiang @ 2015-11-03 9:55 ` Paul E. McKenney 2015-11-03 14:47 ` Peter Zijlstra 0 siblings, 1 reply; 4+ messages in thread From: Paul E. McKenney @ 2015-11-03 9:55 UTC (permalink / raw) To: Yunhong Jiang; +Cc: linux-kernel, jiangshanlai On Mon, Nov 02, 2015 at 05:56:56PM -0800, Yunhong Jiang wrote: > 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? 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 ^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Can srcu_read_lock() be called from interrupt context? 2015-11-03 9:55 ` Paul E. McKenney @ 2015-11-03 14:47 ` Peter Zijlstra 2015-11-03 15:15 ` Paul E. McKenney 0 siblings, 1 reply; 4+ messages in thread From: Peter Zijlstra @ 2015-11-03 14:47 UTC (permalink / raw) To: Paul E. McKenney; +Cc: Yunhong Jiang, linux-kernel, jiangshanlai On Tue, Nov 03, 2015 at 01:55:39AM -0800, Paul E. McKenney wrote: > On Mon, Nov 02, 2015 at 05:56:56PM -0800, Yunhong Jiang wrote: > > 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? > > 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.) 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. ^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Can srcu_read_lock() be called from interrupt context? 2015-11-03 14:47 ` Peter Zijlstra @ 2015-11-03 15:15 ` Paul E. McKenney 0 siblings, 0 replies; 4+ messages in thread From: Paul E. McKenney @ 2015-11-03 15:15 UTC (permalink / raw) To: Peter Zijlstra; +Cc: Yunhong Jiang, linux-kernel, jiangshanlai On Tue, Nov 03, 2015 at 03:47:17PM +0100, Peter Zijlstra wrote: > On Tue, Nov 03, 2015 at 01:55:39AM -0800, Paul E. McKenney wrote: > > On Mon, Nov 02, 2015 at 05:56:56PM -0800, Yunhong Jiang wrote: > > > 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? > > > > 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.) > > 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. > Even call_srcu() should be IRQ-safe. Looks plausible to me. Lai? Thanx, Paul ^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2015-11-03 15:36 UTC | newest] Thread overview: 4+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2015-11-03 1:56 Can srcu_read_lock() be called from interrupt context? Yunhong Jiang 2015-11-03 9:55 ` Paul E. McKenney 2015-11-03 14:47 ` Peter Zijlstra 2015-11-03 15:15 ` Paul E. McKenney
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox