Received: by 2002:a05:6a10:6744:0:0:0:0 with SMTP id w4csp348338pxu; Thu, 15 Oct 2020 05:40:46 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyuPEhP73tUs2DUN1Hb3dIhOqJfOevT/yZeeNQWG5p9tqvpz60QWeDdkaJjcFn7RkbkUwKD X-Received: by 2002:a17:906:7f8d:: with SMTP id f13mr4466540ejr.540.1602765646280; Thu, 15 Oct 2020 05:40:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1602765646; cv=none; d=google.com; s=arc-20160816; b=z1TPXljxCQgimYk1M2RZF6dx3XsIJjyDedLF9W2if3k2psbHgYbet4D4RQRQ4KS/X3 QDFdTGKIy+ntqipF6CIcRvh4Qoy01eCUkNJom06wHME+FgObOHC/n/hn/njJG0pahXzx G+8mW7nPxUiAUDJ4cAW+5oAQ4sbgAmF51cbWJ7Ag/1U8ZT3OiKaFku/AYZhw10HA434k Aky9gQCZcCHla/T+7DkqGwbuKvRf6Id1aVVb4DPXNL+PCS4OuYXYlWwu8THqnpAWczoE ZLiYIEn8OAshnMRM9sMzHA3w0hNhSXP5OAmApfFvU1OC9HAg3xAndHRSn8ttxdrwcf0N IoIQ== 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=syX8GmVW2XIVAd9gEhOxfENmmOkSVpydsLLe+7yNgbU=; b=CRqBvLq6ITqmoVp6TkECvwTxmUZoIPSortjnkYGv8mRbA73Lh3MFIbupyLSirbz+rb 9qvbbR86Kyxxm+VWqW1an1xJxYYkE0YXIM86Rludg+FdJFk8dmedZJ4nMVUokJ6cr9QU UlZJ0rAJkcJDzqCpYCQEOv8N5kAoiVDDkty6+8J24vlha5O9JBnP9Rh+6eKq590kHjOf ISSF7ZxaeRF+lpYCP2T/1GvTVvTlPpxc/HSZKmu1yp1Ow9pdIg0Q5OhL2UvVVScFsim2 pMkr/r9AQHdwNSI9H6qS1ubb+iJ8qR1eLBlGJh1bvxE6BvuTSi+brxjXj7pCgOe0o+p7 NDlQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=Pa85ZkyC; 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 ly6si1987054ejb.594.2020.10.15.05.40.16; Thu, 15 Oct 2020 05:40:46 -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=Pa85ZkyC; 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 S1727717AbgJOMWC (ORCPT + 99 others); Thu, 15 Oct 2020 08:22:02 -0400 Received: from mail.kernel.org ([198.145.29.99]:45338 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727074AbgJOMWC (ORCPT ); Thu, 15 Oct 2020 08:22:02 -0400 Received: from localhost (unknown [176.167.119.22]) (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 961CD2223F; Thu, 15 Oct 2020 12:22:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1602764521; bh=FJ5bTk8vf5rV2RhefNs+cKOPow5fLZ9ShzXDYcMU0Dg=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=Pa85ZkyCCX2heoe3Z8r5WFhi7yQI3+LAHzaKfoDL/lPCiYqPZseTMb4XKnVZ3AK1r Zf38As7NK4Cx5huWyhs3N9wARTPiQEBpc8W0iPCZMAhxBhns6tvZLaGzWlfMge5OuZ BXNaIGaF4/AWKru938FF6+b2WOaTgDf45PUsov4E= Date: Thu, 15 Oct 2020 14:21:58 +0200 From: Frederic Weisbecker To: "Joel Fernandes (Google)" Cc: linux-kernel@vger.kernel.org, Ingo Molnar , Josh Triplett , Lai Jiangshan , Marco Elver , Mathieu Desnoyers , "Paul E. McKenney" , rcu@vger.kernel.org, Steven Rostedt , "Uladzislau Rezki (Sony)" , fweisbec@gmail.com, neeraj.iitr10@gmail.com Subject: Re: [PATCH v7 2/6] rcu/segcblist: Add counters to segcblist datastructure Message-ID: <20201015122158.GA127222@lothringen> References: <20201015002301.101830-1-joel@joelfernandes.org> <20201015002301.101830-3-joel@joelfernandes.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20201015002301.101830-3-joel@joelfernandes.org> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Oct 14, 2020 at 08:22:57PM -0400, Joel Fernandes (Google) wrote: > Add counting of segment lengths of segmented callback list. > > This will be useful for a number of things such as knowing how big the > ready-to-execute segment have gotten. The immediate benefit is ability > to trace how the callbacks in the segmented callback list change. > > Also this patch remove hacks related to using donecbs's ->len field as a > temporary variable to save the segmented callback list's length. This cannot be > done anymore and is not needed. > > Signed-off-by: Joel Fernandes (Google) > --- > include/linux/rcu_segcblist.h | 2 + > kernel/rcu/rcu_segcblist.c | 133 +++++++++++++++++++++++----------- > kernel/rcu/rcu_segcblist.h | 2 - > 3 files changed, 92 insertions(+), 45 deletions(-) > > diff --git a/include/linux/rcu_segcblist.h b/include/linux/rcu_segcblist.h > index b36afe7b22c9..d462ae5e340a 100644 > --- a/include/linux/rcu_segcblist.h > +++ b/include/linux/rcu_segcblist.h > @@ -69,8 +69,10 @@ struct rcu_segcblist { > unsigned long gp_seq[RCU_CBLIST_NSEGS]; > #ifdef CONFIG_RCU_NOCB_CPU > atomic_long_t len; > + atomic_long_t seglen[RCU_CBLIST_NSEGS]; Also does it really need to be atomic? > @@ -245,7 +280,7 @@ void rcu_segcblist_enqueue(struct rcu_segcblist *rsclp, > struct rcu_head *rhp) > { > rcu_segcblist_inc_len(rsclp); > - smp_mb(); /* Ensure counts are updated before callback is enqueued. */ That's a significant change that shouldn't be hidden and unexplained in an unrelated patch or it may be easily missed. I'd suggest to move this line together in "rcu/tree: Remove redundant smp_mb() in rcu_do_batch" (with the title updated perhaps) and maybe put it in the beginning of the series? > + rcu_segcblist_inc_seglen(rsclp, RCU_NEXT_TAIL); > rhp->next = NULL; > WRITE_ONCE(*rsclp->tails[RCU_NEXT_TAIL], rhp); > WRITE_ONCE(rsclp->tails[RCU_NEXT_TAIL], &rhp->next); [...] > @@ -330,11 +353,16 @@ void rcu_segcblist_extract_pend_cbs(struct rcu_segcblist *rsclp, > > if (!rcu_segcblist_pend_cbs(rsclp)) > return; /* Nothing to do. */ > + rclp->len = rcu_segcblist_get_seglen(rsclp, RCU_WAIT_TAIL) + > + rcu_segcblist_get_seglen(rsclp, RCU_NEXT_READY_TAIL) + > + rcu_segcblist_get_seglen(rsclp, RCU_NEXT_TAIL); > *rclp->tail = *rsclp->tails[RCU_DONE_TAIL]; > rclp->tail = rsclp->tails[RCU_NEXT_TAIL]; > WRITE_ONCE(*rsclp->tails[RCU_DONE_TAIL], NULL); > - for (i = RCU_DONE_TAIL + 1; i < RCU_CBLIST_NSEGS; i++) > + for (i = RCU_DONE_TAIL + 1; i < RCU_CBLIST_NSEGS; i++) { > WRITE_ONCE(rsclp->tails[i], rsclp->tails[RCU_DONE_TAIL]); > + rcu_segcblist_set_seglen(rsclp, i, 0); > + } So, that's probably just a matter of personal preference, so feel free to ignore but I'd rather do: rclp->len += rcu_segcblist_get_seglen(rsclp, i); rcu_segcblist_set_seglen(rsclp, i, 0); instead of the big addition above. That way, if a new index ever gets added/renamed to the segcblist, we'll take it into account. Also that spares a few lines. Thanks.