Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1261155 > unrolled thread

Can srcu_read_lock() be called from interrupt context?

Started byYunhong Jiang <yunhong.jiang@linux.intel.com>
First post2015-11-03 03:10 +0100
Last post2015-11-03 16:40 +0100
Articles 4 — 3 participants

Back to article view | Back to linux.kernel


Contents

  Can srcu_read_lock() be called from interrupt context? Yunhong Jiang <yunhong.jiang@linux.intel.com> - 2015-11-03 03:10 +0100
    Re: Can srcu_read_lock() be called from interrupt context? "Paul E. McKenney" <paulmck@linux.vnet.ibm.com> - 2015-11-03 11:00 +0100
      Re: Can srcu_read_lock() be called from interrupt context? Peter Zijlstra <peterz@infradead.org> - 2015-11-03 15:50 +0100
        Re: Can srcu_read_lock() be called from interrupt context? "Paul E. McKenney" <paulmck@linux.vnet.ibm.com> - 2015-11-03 16:40 +0100

#1261155 — Can srcu_read_lock() be called from interrupt context?

FromYunhong Jiang <yunhong.jiang@linux.intel.com>
Date2015-11-03 03:10 +0100
SubjectCan srcu_read_lock() be called from interrupt context?
Message-ID<qqzcS-4Qb-13@gated-at.bofh.it>
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
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [next] | [standalone]


#1261352

From"Paul E. McKenney" <paulmck@linux.vnet.ibm.com>
Date2015-11-03 11:00 +0100
Message-ID<qqGxI-10C-9@gated-at.bofh.it>
In reply to#1261155
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

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [prev] | [next] | [standalone]


#1261551

FromPeter Zijlstra <peterz@infradead.org>
Date2015-11-03 15:50 +0100
Message-ID<qqL4m-3Y0-21@gated-at.bofh.it>
In reply to#1261352
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.
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [prev] | [next] | [standalone]


#1261628

From"Paul E. McKenney" <paulmck@linux.vnet.ibm.com>
Date2015-11-03 16:40 +0100
Message-ID<qqLQJ-4xa-13@gated-at.bofh.it>
In reply to#1261551
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

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web