Received: by 2002:a05:6a10:a0d1:0:0:0:0 with SMTP id j17csp3240245pxa; Tue, 25 Aug 2020 15:48:29 -0700 (PDT) X-Google-Smtp-Source: ABdhPJybq6cVWcA5wMdlaYe4FwbEXQCXEs8J1FlPNATdaXbhcoM2mgtv2Depzc7xqPgVxuRJYrqq X-Received: by 2002:a17:906:4f8c:: with SMTP id o12mr13201890eju.69.1598395709000; Tue, 25 Aug 2020 15:48:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1598395708; cv=none; d=google.com; s=arc-20160816; b=q5kp8H7vbsW3rAMVRqZtyq3aX9zjQ7gsHYhL35lMWn1kjEB3khFNcp9M2/nR6UcZ2r O4AiyyR4lSamMntQjDh6C32QrQ+SNLwUC6/Z88nvkWgY2pJ4ar2bYM4ybpY8XfCUz6n8 DqT50XRqGYR70eUL82I/qGroLsYw+lKnX1OcpuyZuFyjjM30hJmxChO3vCX33ZH4NjHk FGxIvNIJiqinOwYlQmTDtv5kGvc7EY5XLkJ9qjziV/ii+r6UW4i41GCV+SoTJ8eEoPFT bgr/1PlRbXpvb/eriePi65R1SaVr1TA/Vv8JtBTrt2LFGu7ul4az4wuQeBC41awVTTLN WwMw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=lCOMEyRgRSwvt59dfkS7SB7QIanjWNqkuVUXG9Hrk1s=; b=dQ3fBxZNSs3awcU6xSbQEOKBx48wBgr0FRR15zbOshFBGkfmJSPyt6cF7l+zk6ShwO zrMfmvSwN4SA/VudZQoxpSYi+BXmRJVaRVA4QjnrsLsVmN6hs8r6W50IOJQvp9i0W+db duBRmsXEZV+WQ4QEvPu00MlrlS0pF1nXqUYhqxcKqaeMrCcdexBmhkpU41JE1VxwRioN JK2kIfSaTNd+pBpMHevfPSst1gEgJaRtCZngF770Uut7sx3HSB50Sh5YD3R0OMKZzuxr b3KVn5YWpLptU/1ile2WkNJjUxWAEboxOVtGEcyZ0HdfIZE9uUHQqIlZKX5CKuqgxwyb 9ojQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@joelfernandes.org header.s=google header.b=LkSY7dm+; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id be10si178470edb.574.2020.08.25.15.48.05; Tue, 25 Aug 2020 15:48:28 -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=@joelfernandes.org header.s=google header.b=LkSY7dm+; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726646AbgHYWr2 (ORCPT + 99 others); Tue, 25 Aug 2020 18:47:28 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54348 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726570AbgHYWrZ (ORCPT ); Tue, 25 Aug 2020 18:47:25 -0400 Received: from mail-qt1-x841.google.com (mail-qt1-x841.google.com [IPv6:2607:f8b0:4864:20::841]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BD369C061755 for ; Tue, 25 Aug 2020 15:47:25 -0700 (PDT) Received: by mail-qt1-x841.google.com with SMTP id p36so285426qtd.12 for ; Tue, 25 Aug 2020 15:47:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=joelfernandes.org; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=lCOMEyRgRSwvt59dfkS7SB7QIanjWNqkuVUXG9Hrk1s=; b=LkSY7dm+GJquyQ2aFOOspi9gf4IzwOKX8QtWMY8qrKiQuZYQaAAB1nz6G5pDu9w2Wp H6IL84OhwsjQbAXsT42VBpEDMiJq/OErETA7iJr8xl7R3T9ZAAT/Tvxq3iMDQgq6s9Vm 4sQBfzltT3NmrwUVKRQewC0SyG2IEgHcw4qgA= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=lCOMEyRgRSwvt59dfkS7SB7QIanjWNqkuVUXG9Hrk1s=; b=GuNJDclYeIZcpB5AnUsOfNxAZ4eEZf94XJuuTL6tKlS/jyZqnvRaxpTBfc5ovL2Qz4 ocxTT+M0E4W8ioJB3Ow3ZGiaim9ZUvnfQTr1OwxxJsB27llXCOCTRlKJwCPR4ryKgQkj 7XwYUo9hZOhY4vo0WhbxWaouQBcHd3/mImNA1OgYAeCnVLEFaIupUpLPD4gVncChF98r YTxjbo2xoUazD1qK1Kk1NatSIPLgVaQWZI4lW9Qx/G7D6P7jdgQHTj92da2jMknuppKY MzNBPegiBbgD3ZGEni1fqwp6UkUjUiG9vmdafxNZnd9wlRlgE9e8uvTBUzDGcNKKX9Xc l5Sw== X-Gm-Message-State: AOAM532YmVcqVI6Au1z7F0oGXitDDKb391eDgp8KpEBTsrFaTjz29ajX 8oQYI5NsVIhbbrQ1VyEz8JQygw== X-Received: by 2002:ac8:23a3:: with SMTP id q32mr3897181qtq.361.1598395644732; Tue, 25 Aug 2020 15:47:24 -0700 (PDT) Received: from localhost ([2620:15c:6:12:cad3:ffff:feb3:bd59]) by smtp.gmail.com with ESMTPSA id l13sm374104qth.77.2020.08.25.15.47.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 25 Aug 2020 15:47:24 -0700 (PDT) Date: Tue, 25 Aug 2020 18:47:23 -0400 From: Joel Fernandes To: "Paul E. McKenney" 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: <20200825224723.GB579506@google.com> References: <20200825024842.3408659-1-joel@joelfernandes.org> <20200825024842.3408659-2-joel@joelfernandes.org> <20200825200809.GW2855@paulmck-ThinkPad-P72> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200825200809.GW2855@paulmck-ThinkPad-P72> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Paul, On Tue, Aug 25, 2020 at 01:08:09PM -0700, Paul E. McKenney wrote: > 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. Ok will fix. > > 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. Are you referring to the cblist structures ->len? I know the segcblist's ->len field is what rcu_barrier() samples but I am not changing that behavior at all in this patch. This patch is only about the donecb's len (which is a cblist structure on the stack). > > 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? Good point, I will do that. > 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. Sorry, I did not understand. The rcu_cblist structure already has a length field. I do modify rcu_segcblist_extract_done_cbs() and rcu_segcblist_extract_pend_cbs() to carry the length already, in a later patch. Just to emphasize, this patch is just a small refactor to avoid an issue in later patches. It aims to keep current functionality unchanged. thanks, - Joel > > 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 > >