Received: by 2002:a05:6a10:a0d1:0:0:0:0 with SMTP id j17csp3160177pxa; Tue, 25 Aug 2020 13:09:35 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxh4M5OEddpcYYYdpIp0UgfWbDu6qEtG0owKjqxUrAW5IHUgh+maxFRPbfcq17iCvlDfTcR X-Received: by 2002:a50:fe17:: with SMTP id f23mr10401832edt.364.1598386175494; Tue, 25 Aug 2020 13:09:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1598386175; cv=none; d=google.com; s=arc-20160816; b=XUEdhzTP3ckk9bnHyFCGxlHf+vkx12h4w1V/7l1cJG0UQ1Q65eZmqqTEpd8lHA6WLB HkyfvSacP5N+iNUZP7NCuTo/GbZMoQzGiUcKQPYQMQmOZ0Wkwi6wf0VJp7DXhx9gCVmG IIWGO4r5IMx71vXBiP9YGebQtSFmrDzPumUnmKtkMHs7Xf6pAN7GMNx7uVZSvPMeS9hX ew3WC94e+6ynS8wlEEVNgzcV9JewU6mxUUgeX5rELTcEK9EZxb7BbsADPDv2BkHn8x28 8VrWKStTbW5TFmELDZEGPOuYGMkPSpAUspmFS8Gr7r1OQK/irnLQjTFS2y1VfVF5iIYe MFxA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:reply-to:message-id :subject:cc:to:from:date:dkim-signature; bh=SwX2u1nqi30ohZg99auIVBhFUpqCaHPptyI9zcKPWr8=; b=cpC9PNEnOG7OrLm5xIOYu+w0jIr39rFzvBIgmpw9DC3w9jq7JF+mLPTBi1y772r020 /nPkYegekclGeWNa1kQspUgh2Fh8eoTMFSgRRPZO4hf6KDBTf1l90gDRjmFqAukrDbdY pX6bToqBxqPDk6ADHGmMHKeY0sGO+eGM8t8qPuW0OiEowUPOP3oPnNcY624oAwIesJG9 DHASCQU2o/LsLi+KdqW8Sg4Q2j9zEnwJA3PADHC/ZIxcCoz91tnGxCmGsPWQN7brpDeF CYPDvqvIqgWhdRR7Hp/2MiPD6DNyH1qfEzsL0/1KWn9MMNYIAm89EOxdDD995xW4lVln orFg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=SHpORjOm; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id w21si54911eje.385.2020.08.25.13.09.11; Tue, 25 Aug 2020 13:09:35 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=SHpORjOm; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726570AbgHYUIL (ORCPT + 99 others); Tue, 25 Aug 2020 16:08:11 -0400 Received: from mail.kernel.org ([198.145.29.99]:48208 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726149AbgHYUIK (ORCPT ); Tue, 25 Aug 2020 16:08:10 -0400 Received: from paulmck-ThinkPad-P72.home (unknown [50.45.173.55]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 87D0120738; Tue, 25 Aug 2020 20:08:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1598386089; bh=XbmH07wbcFIV/RrfmMjndcKF+uq2nCiDV73youbhKi0=; h=Date:From:To:Cc:Subject:Reply-To:References:In-Reply-To:From; b=SHpORjOmnqVvwizcO3gjZq0AEb4cMvekHXt8sABBCTobZfILv4HATTqe2+/5o9UpV KXvUD3YtlLDPJM8IlTKIwdSD7T8KDTV5KXu7LG0tlv4BAmI6BXTufpInaqn00S+ryY 61B8pIM0cCRCFeT/h0+agOwNBkBaB86+xriKZCPk= Received: by paulmck-ThinkPad-P72.home (Postfix, from userid 1000) id 6B06F35226AE; Tue, 25 Aug 2020 13:08:09 -0700 (PDT) Date: Tue, 25 Aug 2020 13:08:09 -0700 From: "Paul E. McKenney" To: "Joel Fernandes (Google)" Cc: linux-kernel@vger.kernel.org, boqun.feng@gmail.com, dave@stgolabs.net, Ingo Molnar , Josh Triplett , Lai Jiangshan , Madhuparna Bhowmik , Mathieu Desnoyers , neeraj.iitr10@gmail.com, rcu@vger.kernel.org, Steven Rostedt , "Uladzislau Rezki (Sony)" , vineethrp@gmail.com Subject: Re: [PATCH v4 -rcu 1/4] rcu/segcblist: Do not depend on rcl->len to store the segcb len during merge Message-ID: <20200825200809.GW2855@paulmck-ThinkPad-P72> Reply-To: paulmck@kernel.org References: <20200825024842.3408659-1-joel@joelfernandes.org> <20200825024842.3408659-2-joel@joelfernandes.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200825024842.3408659-2-joel@joelfernandes.org> User-Agent: Mutt/1.9.4 (2018-02-28) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Aug 24, 2020 at 10:48:39PM -0400, Joel Fernandes (Google) wrote: > The donecbs's ->len field is used to store the total count of the segmented > callback list's length. This ->len field is then added to the destination segcb > list. > > However, this presents a problem for per-segment length counting which is added > in a future patch. This future patch sets the rcl->len field as we move > segments of callbacks between source and destination lists, thus becoming > incompatible with the donecb's ->len field. OK, I will bite. What is "rcl"? A placeholder for donecbs and pendcbs? If so, please just name them both. If not, please explain. > This commit therefore avoids depending on the ->len field in this way. IMHO, > this is also less error-prone and is more accurate - the donecb's ->len field > should be the length of the done segment and not just used as a temporarily > variable. Please also mention why ->len is handled specially at all, namely interactions between rcu_barrier() and callback invocation. This is the answer to "why not just make all this work like normal lists?" This might go well in the first paragraph. > Signed-off-by: Joel Fernandes (Google) > --- > kernel/rcu/rcu_segcblist.c | 8 ++++++-- > 1 file changed, 6 insertions(+), 2 deletions(-) > > diff --git a/kernel/rcu/rcu_segcblist.c b/kernel/rcu/rcu_segcblist.c > index 2d2a6b6b9dfb..b70d4154433c 100644 > --- a/kernel/rcu/rcu_segcblist.c > +++ b/kernel/rcu/rcu_segcblist.c > @@ -513,14 +513,18 @@ void rcu_segcblist_merge(struct rcu_segcblist *dst_rsclp, > { > struct rcu_cblist donecbs; > struct rcu_cblist pendcbs; > + long src_len; > > rcu_cblist_init(&donecbs); > rcu_cblist_init(&pendcbs); > - rcu_segcblist_extract_count(src_rsclp, &donecbs); > + > + src_len = rcu_segcblist_xchg_len(src_rsclp, 0); Given that both rcu_segcblist_xchg_len() and rcu_segcblist_extract_count() have only one callsite each, why not get rid of one of them? Or better yet, please see below, which should allow getting rid of both of them. > rcu_segcblist_extract_done_cbs(src_rsclp, &donecbs); > rcu_segcblist_extract_pend_cbs(src_rsclp, &pendcbs); > - rcu_segcblist_insert_count(dst_rsclp, &donecbs); > + > + rcu_segcblist_add_len(dst_rsclp, src_len); > rcu_segcblist_insert_done_cbs(dst_rsclp, &donecbs); > rcu_segcblist_insert_pend_cbs(dst_rsclp, &pendcbs); Rather than adding the blank lines, why not have the rcu_cblist structures carry the lengths? You are already adjusting one of the two call sites that care (rcu_do_batch()), and the other is srcu_invoke_callbacks(). That should shorten this function a bit more. And make callback handling much more approachable, I suspect. There would still be the callback-invocation need to be careful with ->cblist.len due to rcu_barrier() and srcu_barrier(). But both of those should be excluded by this code. (But don't take my word for it, ask KCSAN.) Thanx, Paul > + > rcu_segcblist_init(src_rsclp); > } > -- > 2.28.0.297.g1956fa8f8d-goog >