Received: by 10.192.165.148 with SMTP id m20csp622509imm; Fri, 4 May 2018 16:44:04 -0700 (PDT) X-Google-Smtp-Source: AB8JxZplxYxZEvVQg9fZHNiwlmCM9hQ+RNuWyQafexsMQqFcK3w0oO/4yZaPaUXnMiwUUR07/nJw X-Received: by 2002:a63:705d:: with SMTP id a29-v6mr23965767pgn.202.1525477444742; Fri, 04 May 2018 16:44:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1525477444; cv=none; d=google.com; s=arc-20160816; b=XdiK39QjRAD/K7ha/qDJ6p13ES4s16j1/PBFOBF+08y8qdGfdFTLbc5Rz0xAiJNI3E QgUabjI0RkNsedSE15PY2vglBY7tSQUjT/KN69ktKYP+/33p8p1y2PHfo7CN6w+ZXDKS chrRwCILClJOCQFFXhAMTLilUgoh/ar2kmfSmWYmMMzeSV7hT5zuH0jiehfV8QAMVBTN 4ge8cLP9b28pnOItAZBhoUBUWwT1L0v5gXncLmELNlKX0cfPvxDZEHHClJeeRqp5ZCxL tGTetSTImcMUns4XkSH+51/nx4DXxysHVqdLiFtmGMHJwFVjMV/KDP7g8JrXgBctcVan ++VQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:user-agent:in-reply-to :content-disposition:mime-version:references:reply-to:subject:cc:to :from:date:arc-authentication-results; bh=nk0EeBwaYBSBGVPeml3xUkAx4wbAHSSMC9F1CqT/f2g=; b=ISqV7J+OjaWu6FMCIKj3DJAzj8mc99Qxk/Ko5TdL7NEPdxQCxDr9L4cQHQy1TbAcPQ sh30gvRePVSNEufqq+PisGi/wla7FEZss0x1M6UgwFrepOdEqQj+oeFyeLNmUaSO/mWB ZvHPJMufgmx4c0RlP97tyVbQtzDtS5gkK10j+71dJ72DqSJE+kTgjBctEIfGy7Soal4y QQjFgJjbbeqwqleODqTPeWMlT3c+g52eOlaQX7vpPSJt7jDtbJKndqNYDgpd3DlYIIv9 wsnU1scD7/esVetz0W79GfXozLU/Hh08XOaHPmF8tP+LuuX+Rhj0TjYA2c1GpE2GHRm1 HMYQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=ibm.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 21si17610969pfy.293.2018.05.04.16.43.50; Fri, 04 May 2018 16:44:04 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=ibm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751812AbeEDXm0 (ORCPT + 99 others); Fri, 4 May 2018 19:42:26 -0400 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:53468 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751771AbeEDXmZ (ORCPT ); Fri, 4 May 2018 19:42:25 -0400 Received: from pps.filterd (m0098394.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.22/8.16.0.22) with SMTP id w44NdZaw069108 for ; Fri, 4 May 2018 19:42:25 -0400 Received: from e18.ny.us.ibm.com (e18.ny.us.ibm.com [129.33.205.208]) by mx0a-001b2d01.pphosted.com with ESMTP id 2hry2gmmc3-1 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=NOT) for ; Fri, 04 May 2018 19:42:24 -0400 Received: from localhost by e18.ny.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Fri, 4 May 2018 19:42:23 -0400 Received: from b01cxnp23032.gho.pok.ibm.com (9.57.198.27) by e18.ny.us.ibm.com (146.89.104.205) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Fri, 4 May 2018 19:42:20 -0400 Received: from b01ledav003.gho.pok.ibm.com (b01ledav003.gho.pok.ibm.com [9.57.199.108]) by b01cxnp23032.gho.pok.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id w44NgKcs47644708; Fri, 4 May 2018 23:42:20 GMT Received: from b01ledav003.gho.pok.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 27A9DB204E; Fri, 4 May 2018 20:44:20 -0400 (EDT) Received: from paulmck-ThinkPad-W541 (unknown [9.70.82.108]) by b01ledav003.gho.pok.ibm.com (Postfix) with ESMTP id D2B27B2046; Fri, 4 May 2018 20:44:19 -0400 (EDT) Received: by paulmck-ThinkPad-W541 (Postfix, from userid 1000) id ED24F16C1ED4; Fri, 4 May 2018 16:43:42 -0700 (PDT) Date: Fri, 4 May 2018 16:43:42 -0700 From: "Paul E. McKenney" To: Joel Fernandes Cc: "Joel Fernandes (Google)" , Steven Rostedt , Mathieu Desnoyers , LKML Subject: Re: rcu-bh design Reply-To: paulmck@linux.vnet.ibm.com References: <20180504123050.2841f80d@gandalf.local.home> <20180504174330.GS26088@linux.vnet.ibm.com> <20180504184951.GU26088@linux.vnet.ibm.com> <20180504201129.GX26088@linux.vnet.ibm.com> <20180504224921.GE26088@linux.vnet.ibm.com> <5ab0c23a-f98d-859f-593f-f32f6c470626@google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <5ab0c23a-f98d-859f-593f-f32f6c470626@google.com> User-Agent: Mutt/1.5.21 (2010-09-15) X-TM-AS-GCONF: 00 x-cbid: 18050423-0044-0000-0000-0000040FD6A9 X-IBM-SpamModules-Scores: X-IBM-SpamModules-Versions: BY=3.00008971; HX=3.00000241; KW=3.00000007; PH=3.00000004; SC=3.00000258; SDB=6.01027588; UDB=6.00524918; IPR=6.00806722; MB=3.00020934; MTD=3.00000008; XFM=3.00000015; UTC=2018-05-04 23:42:22 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 18050423-0045-0000-0000-00000841E09B Message-Id: <20180504234342.GJ26088@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:,, definitions=2018-05-04_09:,, signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 malwarescore=0 suspectscore=2 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 impostorscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1709140000 definitions=main-1805040211 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, May 04, 2018 at 04:20:41PM -0700, Joel Fernandes wrote: > > > On 05/04/2018 03:49 PM, Paul E. McKenney wrote: > >>Yes just one more ;-). I am trying to write a 'probetorture' test inspired > >>by RCU torture that whacks the tracepoints in various scenarios. One of the > >>things I want to do is verify the RCU callbacks are queued and secondly, > >>they are executed. Just to verify that the garbage collect was done and > >>we're not leaking the function probe table (not that I don't have > >>confidence in the chained callback technique which you mentioned, but it > >>would be nice to assure this mechanism is working for tracepoints). > >> > >>Is there a way to detect this given a reference to srcu_struct? Mathieu and > >>we were chatting about srcu_barrier which is cool but that just tells me > >>that if there was a callback queued, it would have executed after the > >>readers were done. But not whether something was queued. > > > >Suppose that you are queuing an RCU callback that in turn queues an SRCU > >callback on my_srcu_struct, like this: > > > > void my_rcu_callback(struct rcu_head *rhp) > > { > > p = container_of(rhp, struct my_struct, my_rcu_head); > > > > free_it_up_or_down(p); > > } > > > > void my_srcu_callback(struct rcu_head *rhp) > > { > > call_rcu(rhp, my_rcu_callback); > > } > > > > call_srcu(&my_srcu_struct, &p->my_rcu_head, my_srcu_callback); > > > >Then to make sure that any previously submitted callback has been fully > >processed, you do this: > > > > rcu_barrier(); > > srcu_barrier(&my_srcu_struct); > > > >Of course if you queue in the opposite order, like this: > > > > void my_srcu_callback(struct rcu_head *rhp) > > { > > p = container_of(rhp, struct my_struct, my_rcu_head); > > > > free_it_up_or_down(p); > > } > > > > void my_rcu_callback(struct rcu_head *rhp) > > { > > call_srcu(&my_srcu_struct, &p->my_rcu_head, my_srcu_callback); > > } > > > > call_rcu(rhp, my_rcu_callback); > > > >Then you must wait in the opposite order: > > > > rcu_barrier(); > > srcu_barrier(&my_srcu_struct); > > > >Either way, the trick is that the first *_barrier() call cannot return > >until after all previous callbacks have executed, which means that by that > >time the callback is enqueued for the other flavor of {S,}RCU. So the > >second *_barrier() call must wait for the callback to be completely done, > >through both flavors of {S,}RCU. > > > >So after executing the pair of *_barrier() calls, you know that the > >callback is no longer queued. > > > >Does that cover it, or am I missing a turn in here somewhere? > > Yes, that covers some of it. Thanks a lot. Btw, I was also thinking > I want to check that srcu received a callback queuing request as > well (not just completion but also queuing). > > Say that the tracepoint code is buggy and for some reason a > call_srcu wasn't done. For example, say the hypothetical bug I'm > taking about is in tracepoint_remove_func which called the > rcu_assign_pointer, but didn't call release_probes: > > diff --git a/kernel/tracepoint.c b/kernel/tracepoint.c > index d0639d917899..f54cb358f451 100644 > --- a/kernel/tracepoint.c > +++ b/kernel/tracepoint.c > @@ -216,7 +216,6 @@ static int tracepoint_add_func(struct tracepoint *tp, > rcu_assign_pointer(tp->funcs, tp_funcs); > if (!static_key_enabled(&tp->key)) > static_key_slow_inc(&tp->key); > - release_probes(old); > return 0; > } > --- > I want to catching this from the test code. If I did the following, > it would be insufficient then: > > trace_probe_register(...); > srcu_barrier(&my_srcu_struct); // only tells me any queued calls > // are done but not that something > // was queued > > I was seeing if I could use my_srcu_struct::completed for that. but > I'm not sure if that'll work (or that its legal to access it > directly - but hey this is just test code! :P). This is a bit ugly to do programmatically in the kernel. The callbacks are on per-CPU queues that cannot be safely accessed except by that CPU. Plus they are on singly linked lists that can be quite long, so it could be insanely slow as well. But given that this is test code, why not leverage event tracing? There are some relevant events in include/trace/events/rcu.h, starting with the rcu_callback trace event. Thanx, Paul