Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755280AbbKCPgX (ORCPT ); Tue, 3 Nov 2015 10:36:23 -0500 Received: from e31.co.us.ibm.com ([32.97.110.149]:33791 "EHLO e31.co.us.ibm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932317AbbKCPWL (ORCPT ); Tue, 3 Nov 2015 10:22:11 -0500 X-IBM-Helo: d03dlp03.boulder.ibm.com X-IBM-MailFrom: paulmck@linux.vnet.ibm.com X-IBM-RcptTo: linux-kernel@vger.kernel.org Date: Tue, 3 Nov 2015 07:15:38 -0800 From: "Paul E. McKenney" To: Peter Zijlstra Cc: Yunhong Jiang , linux-kernel@vger.kernel.org, jiangshanlai@gmail.com Subject: Re: Can srcu_read_lock() be called from interrupt context? Message-ID: <20151103151538.GH29027@linux.vnet.ibm.com> Reply-To: paulmck@linux.vnet.ibm.com References: <20151103015656.GA10358@jnakajim-build> <20151103095539.GD29027@linux.vnet.ibm.com> <20151103144717.GC7520@twins.programming.kicks-ass.net> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20151103144717.GC7520@twins.programming.kicks-ass.net> User-Agent: Mutt/1.5.21 (2010-09-15) X-TM-AS-MML: disable X-Content-Scanned: Fidelis XPS MAILER x-cbid: 15110315-8236-0000-0000-000013409089 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1823 Lines: 42 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/