Received: by 2002:a05:6359:c8b:b0:c7:702f:21d4 with SMTP id go11csp180295rwb; Mon, 26 Sep 2022 16:56:33 -0700 (PDT) X-Google-Smtp-Source: AMsMyM7Wl1hsJv7xTwTIsCkSLfawXuUCxUqEbIinYSFJZWqpJyjRCj5L+bm8w84/p/2vTllM2kKf X-Received: by 2002:aa7:ce0b:0:b0:456:f7f8:50c2 with SMTP id d11-20020aa7ce0b000000b00456f7f850c2mr14540013edv.111.1664236593434; Mon, 26 Sep 2022 16:56:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1664236593; cv=none; d=google.com; s=arc-20160816; b=eTn9jls/kx16FHQUQaBw3GXCM1ppg7J+2vEwiZCoaaZPq2P9X5sWSBttmYHlBCM5O6 sepDQOIaVO8r0N5qQNjF9nLpEbmhziWHWujXVcgFTPaMUSz+w+0FXWj9o+Ar6WId4zZn gRQjP1aAF4NNTvx26FCNz7k2JMVvGTorN4U5kBuLCmGHRj2ycb1tFkAD2u58MJFHFVi8 lI5Fcr4NUv53fSvkWo+abSxjf7x4RLj6fnc/AMx4b59lKcPQMxpFK4Xs06EvRseS1qpN LNLGVye+uNlSA7zKLA4PLKJdLzclykwgTlVnWwb6EkBBOEIrncU42bdyLXOYYMTACcYj bRMg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:to:in-reply-to:cc:references:message-id:date :subject:mime-version:from:content-transfer-encoding:dkim-signature; bh=g1wLBAvnQ8SzjlNR0NcnJNCPTuqcD1TxoST+iFzU5DU=; b=t+mam+Sjqg/2zibzpHmsedUq1IR1VDA67vXxP+5oQplyNcYnmKrh8KdmKZRx9xr65n /HZPRmKCTfeEbMuMoBuQgumAHr3lcIYDRnrGkyyNTPJDIodPx3a7PeGeV1StOnXmbfg1 KD3dSjG6YkWguGknRQpEc5ij3cx6hdiW3WESxoW/R/NUfsNitQxEYIskc6viOOPqYS0v QQApvX4omp3cEbKRbV6/2Q17+mQHLlEh+PHbv8ewme68MMijvjeNndK1wmLh/R+mk9Us LZfnR5kn6KvJBVdPjB0LB7sosMQYOCCJFpgwRWtrSrpYwznBeFBFrJuwHwcvLU6ebj2F 2XCg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@joelfernandes.org header.s=google header.b=TPtmNCxR; 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 a29-20020a50c31d000000b00456efe7cbd9si24856edb.591.2022.09.26.16.56.04; Mon, 26 Sep 2022 16:56:33 -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=TPtmNCxR; 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 S229459AbiIZXda (ORCPT + 99 others); Mon, 26 Sep 2022 19:33:30 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43200 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231292AbiIZXdW (ORCPT ); Mon, 26 Sep 2022 19:33:22 -0400 Received: from mail-qv1-xf30.google.com (mail-qv1-xf30.google.com [IPv6:2607:f8b0:4864:20::f30]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 80C2F7B782 for ; Mon, 26 Sep 2022 16:33:19 -0700 (PDT) Received: by mail-qv1-xf30.google.com with SMTP id l14so5285134qvq.8 for ; Mon, 26 Sep 2022 16:33:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=joelfernandes.org; s=google; h=to:in-reply-to:cc:references:message-id:date:subject:mime-version :from:content-transfer-encoding:from:to:cc:subject:date; bh=g1wLBAvnQ8SzjlNR0NcnJNCPTuqcD1TxoST+iFzU5DU=; b=TPtmNCxRdqwoGgun2c+N57orO9Thu5oxdH9XRQCtiekHggtCaEF4mWFRlIZhPp7rR3 T8ZSY5slsDiczjGUJqHtXxRmDg9KvvyD/Pj+a04YmwF1Z2uL74F2fDm9dSzQoH1L1O1x y6yTrikL7h19tF3NFAyo0jx9bgCKOjhczDkyY= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=to:in-reply-to:cc:references:message-id:date:subject:mime-version :from:content-transfer-encoding:x-gm-message-state:from:to:cc :subject:date; bh=g1wLBAvnQ8SzjlNR0NcnJNCPTuqcD1TxoST+iFzU5DU=; b=2RDcMfHFwJiFOMsOAkIn+HdqMa4uXDc3mo0GsgGB3tQQBRBwdVzSrhdOdG7rnrjUFu 3Am3skOc1pjTeizb64hSsxXzzx5v1zyiBTv9S+/YY6rRHLL8PCk6KwLcwRXJJfgZfGJv 0qLBHWFhDioXvxEIayFVEofMSTfuExvrjs5ap+5LhMQV0C33beMMmw93Lkbo40DxSbfG oeDQ30Gr7lnKy4J07LkQ10wk4IYnsLQHpQtt9ZOz0jNXgBQzIFelj/BcJYeVSjXyBuRW XR3HB0naR93jUi1oPDRUrFU0dWLM/z5jeiZRFOis5xpJN6tLtO0ycM7RQyfol4aQbr+r +fIg== X-Gm-Message-State: ACrzQf0TMuKsuMwEmsMWnQfdoYyQwk4PREWwWaIPx1JEnRjfAyUrk8bY R6JzSfQ06PJRJRZLwW10VH99YGzM2FPY3x28 X-Received: by 2002:a0c:b20b:0:b0:4ad:c33:8ad with SMTP id x11-20020a0cb20b000000b004ad0c3308admr19599545qvd.129.1664235198434; Mon, 26 Sep 2022 16:33:18 -0700 (PDT) Received: from smtpclient.apple ([2600:1003:b132:37f:2047:987d:1b5f:cf31]) by smtp.gmail.com with ESMTPSA id x1-20020a05620a14a100b006ced196a73fsm12500071qkj.135.2022.09.26.16.33.18 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 26 Sep 2022 16:33:18 -0700 (PDT) Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable From: Joel Fernandes Mime-Version: 1.0 (1.0) Subject: Re: [PATCH v6 1/4] rcu: Make call_rcu() lazy to save power Date: Mon, 26 Sep 2022 19:33:17 -0400 Message-Id: References: <20220926223751.GZ4196@paulmck-ThinkPad-P17-Gen-1> Cc: rcu@vger.kernel.org, linux-kernel@vger.kernel.org, rushikesh.s.kadam@intel.com, urezki@gmail.com, neeraj.iitr10@gmail.com, frederic@kernel.org, rostedt@goodmis.org In-Reply-To: <20220926223751.GZ4196@paulmck-ThinkPad-P17-Gen-1> To: paulmck@kernel.org X-Mailer: iPhone Mail (19G82) 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 Sep 26, 2022, at 6:37 PM, Paul E. McKenney wrote: >=20 > =EF=BB=BFOn Mon, Sep 26, 2022 at 09:07:12PM +0000, Joel Fernandes wrote: >> Hi Paul, >>=20 >> On Mon, Sep 26, 2022 at 10:42:40AM -0700, Paul E. McKenney wrote: >> [..] >>>>>>>> + WRITE_ONCE(rdp->lazy_len, 0); >>>>>>>> + } else { >>>>>>>> + rcu_cblist_flush_enqueue(&rcl, &rdp->nocb_bypass, rhp); >>>>>>>> + WRITE_ONCE(rdp->lazy_len, 0); >>>>>>>=20 >>>>>>> This WRITE_ONCE() can be dropped out of the "if" statement, correct?= >>>>>>=20 >>>>>> Yes will update. >>>>>=20 >>>>> Thank you! >>>>>=20 >>>>>>> If so, this could be an "if" statement with two statements in its "t= hen" >>>>>>> clause, no "else" clause, and two statements following the "if" stat= ement. >>>>>>=20 >>>>>> I don=E2=80=99t think we can get rid of the else part but I=E2=80=99l= l see what it looks like. >>>>>=20 >>>>> In the function header, s/rhp/rhp_in/, then: >>>>>=20 >>>>> struct rcu_head *rhp =3D rhp_in; >>>>>=20 >>>>> And then: >>>>>=20 >>>>> if (lazy && rhp) { >>>>> rcu_cblist_enqueue(&rdp->nocb_bypass, rhp); >>>>> rhp =3D NULL; >>>>=20 >>>> This enqueues on to the bypass list, where as if lazy && rhp, I want to= queue >>>> the new rhp on to the main cblist. So the pseudo code in my patch is: >>>>=20 >>>> if (lazy and rhp) then >>>> 1. flush bypass CBs on to main list. >>>> 2. queue new CB on to main list. >>>=20 >>> And the difference is here, correct? I enqueue to the bypass list, >>> which is then flushed (in order) to the main list. In contrast, you >>> flush the bypass list, then enqueue to the main list. Either way, >>> the callback referenced by rhp ends up at the end of ->cblist. >>>=20 >>> Or am I on the wrong branch of this "if" statement? >>=20 >> But we have to flush first, and then queue the new one. Otherwise wouldn'= t >> the callbacks be invoked out of order? Or did I miss something? >=20 > I don't think so... >=20 > We want the new callback to be last, right? One way to do that is to > flush the bypass, then queue the new callback onto ->cblist. Another way > to do that is to enqueue the new callback onto the end of the bypass, > then flush the bypass. Why wouldn't these result in the same order? Yes you are right, sorry. I was fixated on the main list. Both your snippet a= nd my patch will be equivalent then. However I find your snippet a bit confu= sing, as in it is not immediately obvious - why would we queue something on t= o a list, if we were about to flush it. But any way, it does make it a cleve= r piece of code in some sense and I am ok with doing it this way ;-) Thanks, - Joel >=20 >>>> else >>>> 1. flush bypass CBs on to main list >>>> 2. queue new CB on to bypass list. >>>>=20 >>>>> } >>>>> rcu_cblist_flush_enqueue(&rcl, &rdp->nocb_bypass, rhp); >>>>> WRITE_ONCE(rdp->lazy_len, 0); >>>>>=20 >>>>> Or did I mess something up? >>>>=20 >>>> So the rcu_cblist_flush_enqueue() has to happen before the >>>> rcu_cblist_enqueue() to preserve the ordering of flushing into the main= list, >>>> and queuing on to the main list for the "if". Where as in your snip, th= e >>>> order is reversed. >>>=20 >>> Did I pick the correct branch of the "if" statement above? Or were you >>> instead talking about the "else" clause? >>>=20 >>> I would have been more worried about getting cblist->len right. >>=20 >> Hmm, I think my concern was more the ordering of callbacks, and moving th= e >> write to length should be Ok. >=20 > OK, sounds good to me! ;-) >=20 >>>> If I consolidate it then, it looks like the following. However, it is a= bit >>>> more unreadable. I could instead just take the WRITE_ONCE out of both i= f/else >>>> and move it to after the if/else, that would be cleanest. Does that sou= nd >>>> good to you? Thanks! >>>=20 >>> Let's first figure out whether or not we are talking past one another. ;= -) >>=20 >> Haha yeah :-) >=20 > So were we? ;-) >=20 > Thanx, Paul