Received: by 10.192.165.148 with SMTP id m20csp609120imm; Fri, 4 May 2018 16:22:23 -0700 (PDT) X-Google-Smtp-Source: AB8JxZrMJ+1sT6+8xQz/J/4B/Wnddby4EFFUKy6uuz45nD7wGVW2IFAthPr9swamMqFNvJWs4mcT X-Received: by 2002:a17:902:b216:: with SMTP id t22-v6mr7250568plr.105.1525476143899; Fri, 04 May 2018 16:22:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1525476143; cv=none; d=google.com; s=arc-20160816; b=oEDxz+3UEHzKHEOLO8EgM6C5g5RfV2kkfg4UK3jk5yMnVvL8lWlGZqrEEfGN7jjFl7 yEPuARdR5uWITLVY4XVR7Mb/vRSfeiUaSmMPDPTIzK62xPxldoSTbvH0Nu0AFt4dzsTv ruQFg9k+7ez+LKs/TaX6bouARSyjDSFG2K/CcHtg9NbDYbzDJ+dyp94ESwT3PYB4taqb WUy9WJ4TExxu196eeypFmNsNkWawiOb/NACyPq74phYnHVMEqJ/VGHdsW01yUdhuhEea Vnk/CIOOa4AGqN1atWjMU18A2IstZrJNo7AODjxtx6k+Cl9/GhJQPIZszYOAv/r4yAkO NH/g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:dkim-signature :arc-authentication-results; bh=6cPqdMy2p2kdKBlVx49LdCdF2xMupairrEyoGhHsJWE=; b=AG6Fo0vkEyJRROc/nAqTh+xatlttXcrqR4o6W09a9EBilMd6j7qCdOxutXjgpeluvJ +R1N1kBQenYTPpdEI5BxPGt+AFjlkWU+dNe7ifnoSYmtxNTMZ5dzFOgEOZUOtBkWu5Cn 422ljlVEJHX+XM3ezNYDTQjbf+0CRm5FLO3oXwiou0MR4tg+45b2bZgXaWaHuNDi7/fB JC1pmpXnG98vVSUGcexOIhZ8TzqzlIaWhyMEJ6UE3Ehl6lcdF5aG14/MMQUGfM8a7+4h 8qmzXuhoxtCFmqqmjvYtOlpvShDfvOOnHFe1+u7HRmndYhsXJ4dq45kwQv25GLewjAiI rDLQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=go0MDItv; 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=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id k62-v6si14284493pgc.170.2018.05.04.16.22.06; Fri, 04 May 2018 16:22:23 -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; dkim=pass header.i=@google.com header.s=20161025 header.b=go0MDItv; 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=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751748AbeEDXUp (ORCPT + 99 others); Fri, 4 May 2018 19:20:45 -0400 Received: from mail-pg0-f68.google.com ([74.125.83.68]:40266 "EHLO mail-pg0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751684AbeEDXUn (ORCPT ); Fri, 4 May 2018 19:20:43 -0400 Received: by mail-pg0-f68.google.com with SMTP id l2-v6so16387301pgc.7 for ; Fri, 04 May 2018 16:20:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=6cPqdMy2p2kdKBlVx49LdCdF2xMupairrEyoGhHsJWE=; b=go0MDItvIldQssOHQUlykaUydAa0nRp30Z9Jjz0ATVl05fNfRhEeBNSt12NUva+u53 5ecJ83WRmMlBrxGAMOIGUfUnflCiu64uLaymz+yKQGq/bTpt6dIM+VL4RhWwxR+faIgX SMgHtce7wnzqR7lfPnsYS7sjXj8Cz1voNf8Z99BedhCk38WyWCse/ay2A8LDPAe47/Wz kW8B73Ah5zWfTuRSRA5Miuvd4D/n3eIi6NLRjnp8vZSUvFD0Huxfsr94xKYp2PG2J/UP T++7ZcyQDnkh/AUR2k0iFFR920eNuah4a/DIHfbRNVXTsoNmsrwZBjPqCMEUnLQPoHSz AkxA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=6cPqdMy2p2kdKBlVx49LdCdF2xMupairrEyoGhHsJWE=; b=fc+mkLP6vajEkpupNuN1td9Dc8K9A4NJ+1VbJyYQSkSptpLwDXgHnZIQex/6MZzrV6 BSvBUs1P1XwFtwqM3A2Y4ZMHmpOe3gi+rBQ0eca1sveRXE6EbZzOvMF0TCZBC7lxFyr0 IvEBdbeR7h3F3RdcndMedNkejCoxlM5W+wZko2EpCR/tUdoKtDa1P4Xbqo+DSN43ySfB BtBgGSDNwAnrO9K2drAYO215TikBMT/WjvwKpFErNm/Bb906yewFPr2RZy64J9UEE9Ux zqW6sXYVDJik+PLYH7Vpp4Qc8lqk1z/QzvS/gy2MexSqjM3jcnVeyIOmHmg9EyuhWtIK W5gg== X-Gm-Message-State: ALQs6tBJfE6OO/y23GIZGi/2baA9bgmD0hHr3Gw4ktFvam4yfpI1oNDp mwGJegYI5uGjmueQGQMjtPNi4m1h0aA= X-Received: by 2002:a17:902:7b97:: with SMTP id w23-v6mr22354936pll.116.1525476042647; Fri, 04 May 2018 16:20:42 -0700 (PDT) Received: from joelaf.mtv.corp.google.com ([2620:0:1000:1600:3122:ea9c:d178:eb]) by smtp.gmail.com with ESMTPSA id j1-v6sm28150101pgn.69.2018.05.04.16.20.41 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 04 May 2018 16:20:41 -0700 (PDT) Subject: Re: rcu-bh design To: paulmck@linux.vnet.ibm.com Cc: "Joel Fernandes (Google)" , Steven Rostedt , Mathieu Desnoyers , LKML 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> From: Joel Fernandes Message-ID: <5ab0c23a-f98d-859f-593f-f32f6c470626@google.com> Date: Fri, 4 May 2018 16:20:41 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.6.0 MIME-Version: 1.0 In-Reply-To: <20180504224921.GE26088@linux.vnet.ibm.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-GB Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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). thanks, - Joel