From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933208AbdELUb7 (ORCPT ); Fri, 12 May 2017 16:31:59 -0400 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:34654 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932250AbdELUbu (ORCPT ); Fri, 12 May 2017 16:31:50 -0400 Date: Fri, 12 May 2017 13:31:45 -0700 From: "Paul E. McKenney" To: Steven Rostedt Cc: linux-kernel@vger.kernel.org, Thomas Gleixner , Peter Zijlstra , Ingo Molnar , Mathieu Desnoyers , Masami Hiramatsu Subject: Re: [RFC][PATCH 1/5] tracing: Make sure RCU is watching before calling a stack trace Reply-To: paulmck@linux.vnet.ibm.com References: <20170512171544.100715273@goodmis.org> <20170512172449.879684501@goodmis.org> <20170512182535.GZ3956@linux.vnet.ibm.com> <20170512143619.281db952@gandalf.local.home> <20170512185003.GC3956@linux.vnet.ibm.com> <20170512160532.4aacbffe@gandalf.local.home> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20170512160532.4aacbffe@gandalf.local.home> User-Agent: Mutt/1.5.21 (2010-09-15) X-TM-AS-GCONF: 00 x-cbid: 17051220-0056-0000-0000-000003625B1A X-IBM-SpamModules-Scores: X-IBM-SpamModules-Versions: BY=3.00007052; HX=3.00000241; KW=3.00000007; PH=3.00000004; SC=3.00000211; SDB=6.00859660; UDB=6.00426149; IPR=6.00639243; BA=6.00005345; NDR=6.00000001; ZLA=6.00000005; ZF=6.00000009; ZB=6.00000000; ZP=6.00000000; ZH=6.00000000; ZU=6.00000002; MB=3.00015432; XFM=3.00000015; UTC=2017-05-12 20:31:48 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 17051220-0057-0000-0000-000007988419 Message-Id: <20170512203145.GG3956@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:,, definitions=2017-05-12_11:,, signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 suspectscore=0 malwarescore=0 phishscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1703280000 definitions=main-1705120379 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, May 12, 2017 at 04:05:32PM -0400, Steven Rostedt wrote: > On Fri, 12 May 2017 11:50:03 -0700 > "Paul E. McKenney" wrote: > > > On Fri, May 12, 2017 at 02:36:19PM -0400, Steven Rostedt wrote: > > > On Fri, 12 May 2017 11:25:35 -0700 > > > "Paul E. McKenney" wrote: > > > > > > > On Fri, May 12, 2017 at 01:15:45PM -0400, Steven Rostedt wrote: > > > > > From: "Steven Rostedt (VMware)" > > > > > > > > > > As stack tracing now requires "rcu watching", force RCU to be watching when > > > > > recording a stack trace. > > > > > > > > > > Signed-off-by: Steven Rostedt (VMware) > > > > > > > > Assuming that you never get to __trace_stack() if in an NMI handler, > > > > this looks good to me! > > > > > > > > In contrast, if if __trace_stack() ever is called from an NMI handler, > > > > invoking rcu_irq_enter() can be fatal. > > > > > > Then someone may die. > > > > > > OK, what's the case of running this in nmi? How does perf do it? > > > > I have no idea. If it cannot happen, then it cannot happen and all > > is well, RCU is happy, and I am happy. ;-) > > > > > Do we just skip the check if it is in an nmi? > > > > > > if (!in_nmi()) { > > > if (unlikely(rcu_irq_enter_disabled())) > > > return; > > > rcu_irq_enter(); > > > } > > > > > > __ftrace_trace_stack(); > > > > > > if (!in_nmi()) > > > rcu_irq_exit(); > > > > > > ? > > > > If it -can- happen, bail out of the function without doing the > > Why? > > > __ftrace_trace_stack()? Or does that just cause other problems further > > down the road? Or BUG_ON(in_nmi())? > > Why? > > > But again if it cannot happen, no problem and no need for extra code. > > We can't call stack trace from nmi anymore? It calls rcu_read_lock() > which is why we need to make sure rcu is watching, otherwise lockdep > complains. Ah, finally got it! If we are in_nmi(), you are relying on the NMI handler's call to rcu_nmi_enter(), which works. The piece I was forgetting was that you also recently said in an unrelated LKML thread that all the functions called at the very beginings and ends of NMI handlers (which can see !in_nmi()) are marked notrace, so that should be covered as well. So never mind! (And thank you for the explanation.) Thanx, Paul