Received: by 2002:a05:6358:489b:b0:bb:da1:e618 with SMTP id x27csp72293rwn; Fri, 16 Sep 2022 15:37:02 -0700 (PDT) X-Google-Smtp-Source: AMsMyM5ta/31kw4W5tTb3wyRHLw6ebAlfn6ix2ytaFUhfwzZT9aIBDCKMXyqr4euGUZfTCL5aDzj X-Received: by 2002:a17:90b:3ec7:b0:202:b984:8436 with SMTP id rm7-20020a17090b3ec700b00202b9848436mr7827886pjb.4.1663367822417; Fri, 16 Sep 2022 15:37:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1663367822; cv=none; d=google.com; s=arc-20160816; b=QPmVoQg2T2NS7eyijcdS3cQr+aBFpzm0ZAN1umlajejhNRSZb/zT74o7/SImHgTqPS ctZEn6pgaEdbAKpNraikw+dyqXWnkNcneH/XUYrjqydRK+ssF1Knk97cdrbnEoGSM39f vrT0G8y6Y5FbVgG6g+uV3mjoCGTCMqO9XK/XhxpxA+T9M0uF+1leAA2K1wFI/APeP0Bc /hJEuCvMEp8AsN607MIORVszaC0oGY+gOvdok/dRG3ufxEXnl8jMk9v8SC4C66me6lb3 1rmpps5RXyZNC64mQiDL9cqjPvyOc+DKY66vWHZcd5rbytu+HnTvhMnD1F3YT+72HqSq mgQA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=/Z4HioIHNMXZQnpDiGaKlQH+R1i37jGb7DQ/+FG9DY4=; b=H+IzXomol02QNeD9DdIH8BslYW8hBQXxxj0x5FwgjIyVrwhSdgbr1DvxHKIehs1Hfh Shl/DOcQUKK1EMAXpTUBShiw2MIsKIgKNqf+MumVdbxoKuCnANI6J9K2IO9PQqWmBigu sgMs/qjiagDQURbAHSfmch+uPoAFAxn5p33LV1TzMGnbc9h4rheOglkHGmx7K6QxYEFC VODUWoH/WsS16jFdrUFQ9u+ZuW6+dnMEY8alkBSRabTvnlHFkT8i8RcyFcG2pBTMxm1M qh9EjRVaLDT3PvU0qTVwBRElXs12CHROUqRh90kws/4M6hu108OCpsBPevWvpV+Z06Y0 X95w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@joelfernandes.org header.s=google header.b=oUVC0QCl; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id r3-20020a635143000000b00439398fcb63si13832315pgl.24.2022.09.16.15.36.51; Fri, 16 Sep 2022 15:37:02 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@joelfernandes.org header.s=google header.b=oUVC0QCl; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229487AbiIPWV6 (ORCPT + 99 others); Fri, 16 Sep 2022 18:21:58 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56860 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229436AbiIPWVz (ORCPT ); Fri, 16 Sep 2022 18:21:55 -0400 Received: from mail-qt1-x834.google.com (mail-qt1-x834.google.com [IPv6:2607:f8b0:4864:20::834]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A64AAA024A for ; Fri, 16 Sep 2022 15:21:54 -0700 (PDT) Received: by mail-qt1-x834.google.com with SMTP id y2so17038729qtv.5 for ; Fri, 16 Sep 2022 15:21:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=joelfernandes.org; s=google; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date; bh=/Z4HioIHNMXZQnpDiGaKlQH+R1i37jGb7DQ/+FG9DY4=; b=oUVC0QClHNlhxYz78lza87f+pSlzjYsLRu3OF8G6xytxs7gvHTGh7Y7rmJF3PEBsYj oAxNiqG1254EaTVfzSZWle42RZCslH+C0vjsPJYAmVvAg14jTeDKKfpIoQARQ0zX/oke VJIugZnJFWHS1CWs4KhMzTfBp5XFl+ngOAcuQ= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date; bh=/Z4HioIHNMXZQnpDiGaKlQH+R1i37jGb7DQ/+FG9DY4=; b=7997VfiveLNG2TTDIcA+mNgTECe05UXwttoWhSPmcige4fAySVvEcsWXKuqGiSdxen iqgegFFz5bLgfE2pOoTYsnl5xoQKur9wZc1KujaXvWC8TKIyB77bylc/id+mPfbUiVq8 hXiCLEoo7pDFq3m5b2QclLw0p+UVPbvwB1R+fJK0RB8Z8CGmL/N6mFzW4GTOttHxqmnf JyXcg9xd6ht7oaQYGz6ryVig0tb+e7sAl35Dmuu8PUCoPOMLO93ICX7C0oECqLja3Vo4 ZGwIOCePGXDE5PCdKHtIruhjvQBskEeSQoVR8iPzouNl3oUGKNn5ph3ZKv3tYF0eD99Z 6qVw== X-Gm-Message-State: ACrzQf0f0RIrrhKEBOD6nFM1TD1SgVuOhUyDy+dA+UbhBOq3LExJ9Fxa gGF6leHRb8nkyGA7IYCmPxj19Q== X-Received: by 2002:a05:622a:1492:b0:35c:b7e6:12ef with SMTP id t18-20020a05622a149200b0035cb7e612efmr6481356qtx.94.1663366913808; Fri, 16 Sep 2022 15:21:53 -0700 (PDT) Received: from localhost (228.221.150.34.bc.googleusercontent.com. [34.150.221.228]) by smtp.gmail.com with ESMTPSA id l20-20020a05620a28d400b006ce1bfbd603sm7386322qkp.124.2022.09.16.15.21.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 16 Sep 2022 15:21:53 -0700 (PDT) Date: Fri, 16 Sep 2022 22:21:53 +0000 From: Joel Fernandes To: Frederic Weisbecker Cc: linux-kernel@vger.kernel.org, Josh Triplett , Lai Jiangshan , Mathieu Desnoyers , Neeraj Upadhyay , "Paul E. McKenney" , rcu@vger.kernel.org, Steven Rostedt Subject: Re: [PATCH rcu/next 2/3] rcu: Move trace_rcu_callback() before bypassing Message-ID: References: <20220915001419.55617-1-joel@joelfernandes.org> <20220915001419.55617-3-joel@joelfernandes.org> <20220916110949.GB25456@lothringen> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Spam-Status: No, score=-0.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS,URIBL_BLACK autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Sep 16, 2022 at 10:19:14PM +0000, Joel Fernandes wrote: [...] > >> + if (rcu_nocb_try_bypass(rdp, head, &was_alldone, flags)) > >> + return; // Enqueued onto ->nocb_bypass, so just leave. > >> + // If no-CBs CPU gets here, rcu_nocb_try_bypass() acquired > >> ->nocb_lock. > >> + rcu_segcblist_enqueue(&rdp->cblist, head); > >> + > >> trace_rcu_segcb_stats(&rdp->cblist, TPS("SegCBQueued")); > >> > >> /* Go handle any RCU core processing required. */ > > > > Two subtle changes induced here: > > > > * rcu_segcblist_n_cbs() is now read lockless. It's just tracing so no huge > > deal > > but still, if this races with callbacks invocation, we may on some rare > > occasion > > read stale numbers on traces while enqueuing (think about rcu_top for > > example) > > Actually I disagree with this point now. Changes to the number of callbacks > in the main ->cblist can be lockless. It uses atomic on CONFIG_RCU_NOCB. On > non CONFIG_RCU_NOCB, CB cannot be queued as interrupts will be disabled. > > Also, in rcu_do_batch(), the count is manipulated after calling > rcu_nocb_lock_irqsave(rdp, flags); > > > * trace_rcu_callback() will now show the number of callbacks _before_ > > enqueuing > > instead of _after_. Not sure if it matters, but sometimes tools rely on > > trace > > events. > > Yeah this is fixable and good point. So how about the below? > > ---8<----------------------- > > From: "Joel Fernandes (Google)" > Subject: [PATCH] rcu: Call trace_rcu_callback() also for bypass queuing > > If any CB is queued into the bypass list, then trace_rcu_callback() does > not show it. This makes it not clear when a callback was actually > queued, as you only end up getting a trace_rcu_invoke_callback() trace. > Fix it by calling the tracing function even for bypass queue. > > Also, while at it, optimize the tracing so that rcu_state is not > accessed here if tracing is disabled, because that's useless if we are > not tracing. A quick inspection of the generated assembler shows that > rcu_state is accessed even if the jump label for the tracepoint is > disabled. > > __trace_rcu_callback: > movq 8(%rdi), %rcx > movq rcu_state+3640(%rip), %rax > movq %rdi, %rdx > cmpq $4095, %rcx > ja .L3100 > movq 192(%rsi), %r8 > 1:jmp .L3101 # objtool NOPs this > .pushsection __jump_table, "aw" > .balign 8 > .long 1b - . > .long .L3101 - . > .quad __tracepoint_rcu_kvfree_callback+8 + 2 - . > .popsection > > With this change, the jump label check which is NOOPed is moved to the > beginning of the function. > > Signed-off-by: Joel Fernandes (Google) > --- > kernel/rcu/tree.c | 31 +++++++++++++++++++++++-------- > 1 file changed, 23 insertions(+), 8 deletions(-) > > diff --git a/kernel/rcu/tree.c b/kernel/rcu/tree.c > index 5ec97e3f7468..b64df55f7f55 100644 > --- a/kernel/rcu/tree.c > +++ b/kernel/rcu/tree.c > @@ -2728,6 +2728,23 @@ static void check_cb_ovld(struct rcu_data *rdp) > raw_spin_unlock_rcu_node(rnp); > } > > +/* > + * Trace RCU callback helper, call after enqueuing callback. > + * The ->cblist must be locked when called. Also sorry for the spam, this comment is stale now so will delete this line.