Received: by 2002:a05:6a10:16a7:0:0:0:0 with SMTP id gp39csp161241pxb; Wed, 18 Nov 2020 19:59:55 -0800 (PST) X-Google-Smtp-Source: ABdhPJwT2Qw0H5K9x5BvxRWdvpbCM6vnldpVvfEguCbW0o7GyGPFPyywgqBLugclEBRzR5XrVTKe X-Received: by 2002:aa7:d5d7:: with SMTP id d23mr29294028eds.203.1605758395362; Wed, 18 Nov 2020 19:59:55 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1605758395; cv=none; d=google.com; s=arc-20160816; b=gMGtdaX83PFdcUWmOfJTjufop2Yt9JT5w2/1Ty1rgm+ibeAX/RYTvDZoAoL7XYlhbU zRCzNobsDFrOXrqa6UEkHNOrtMQTX4dWydxI41ICVTiPXYEEGmruVifek1NohnWlzVdk gEbQ+yPTOvDJjoci8+rMkjAUEcuFgzX+RM+AlxyV8kxjizU3QRq58Zmvh9SJhbRzqWaY vU7D6VGe2mauZevzT7XTZf2JlbYsn9yKkugtSw8RuiT6EFjiSEzYKzg7FXai9bnL0uE2 WXFlhHDB3utmA+GYwWTmeLvG9ROYdT/ZzfDGavLSWhVp+mW9mnJgNNfODSgo+dYrKLCK C+ew== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:user-agent:in-reply-to:content-disposition :mime-version:references:reply-to:message-id:subject:cc:to:from:date :dkim-signature; bh=xcJGpxDhMTHk5N5Fq+HBaDTuIi8GxwQvScJTKnZ05gs=; b=tmmMzQ9oqHqX+Lwq7dujmPhNDK3KBnvmMq2B2VzxW6dhANDv1aVV7hRSWfTGIw5Ne+ yTdGucg1Rt9+McEtL750Bvy67mk8y5Qurs5qm9CY2QCof5RV0pwVNsv1ZwcUqTn/Tevv DTs1e5kztz3RibM9yQUwygH/LBYml0niTUk/Wl+Ye3MKcC2G/SBsgym8VY1l2nqXNxMg f2sE28Yqvvof7M3mDpFjR3mZY85kfKcsDiITu+A84rc+rv9g3zRecUdjzVduIvAwThbl st9daNnoTMUq/TQ6xmGYMTkPU5iOgPDN9e+iMLmx94gUjI20sxwZQ42dgVX8CSfeJ0SW SVIg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=P79BGE06; 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 ec3si173946ejb.731.2020.11.18.19.59.33; Wed, 18 Nov 2020 19:59:55 -0800 (PST) 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=P79BGE06; 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 S1726530AbgKSD4P (ORCPT + 99 others); Wed, 18 Nov 2020 22:56:15 -0500 Received: from mail.kernel.org ([198.145.29.99]:50736 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726219AbgKSD4O (ORCPT ); Wed, 18 Nov 2020 22:56:14 -0500 Received: from paulmck-ThinkPad-P72.home (50-39-104-11.bvtn.or.frontiernet.net [50.39.104.11]) (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 AEB5C246B0; Thu, 19 Nov 2020 03:56:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1605758173; bh=O1jqm1mU4En+Yq4IQvbC+oEAUUqMUvdf56rbkAebN3Y=; h=Date:From:To:Cc:Subject:Reply-To:References:In-Reply-To:From; b=P79BGE06EkMUPgBsxphK7GKHa2IdWGjW5wmuLJ6jMs0Tk4JvrkMJ7vF/ChJhUdxDc hHOfhcOxZWIii5uXxBaFaT9FnglWXD4Dp0SyOSqqTsKHIqKUj5ltHn0bq5ziBWQgkw 19C24SQ6vH55cpgTCPYp4EQw+cuoJMHLhy4fohTs= Received: by paulmck-ThinkPad-P72.home (Postfix, from userid 1000) id 1679235227BD; Wed, 18 Nov 2020 19:56:13 -0800 (PST) Date: Wed, 18 Nov 2020 19:56:13 -0800 From: "Paul E. McKenney" To: "Joel Fernandes (Google)" Cc: linux-kernel@vger.kernel.org, Josh Triplett , Lai Jiangshan , Mathieu Desnoyers , rcu@vger.kernel.org, Steven Rostedt Subject: Re: [PATCH v2] rcu/segcblist: Add debug checks for segment lengths Message-ID: <20201119035613.GA18816@paulmck-ThinkPad-P72> Reply-To: paulmck@kernel.org References: <20201118161541.3844924-1-joel@joelfernandes.org> <20201118201335.GR1437@paulmck-ThinkPad-P72> <20201119035222.GA18458@paulmck-ThinkPad-P72> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20201119035222.GA18458@paulmck-ThinkPad-P72> User-Agent: Mutt/1.9.4 (2018-02-28) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Nov 18, 2020 at 07:52:23PM -0800, Paul E. McKenney wrote: > On Wed, Nov 18, 2020 at 12:13:35PM -0800, Paul E. McKenney wrote: > > On Wed, Nov 18, 2020 at 11:15:41AM -0500, Joel Fernandes (Google) wrote: > > > After rcu_do_batch(), add a check for whether the seglen counts went to > > > zero if the list was indeed empty. > > > > > > Signed-off-by: Joel Fernandes (Google) > > > > Queued for testing and further review, thank you! > > FYI, the second of the two checks triggered in all four one-hour runs of > TREE01, all four one-hour runs of TREE04, and one of the four one-hour > runs of TREE07. This one: > > WARN_ON_ONCE(count != 0 && rcu_segcblist_n_segment_cbs(&rdp->cblist) == 0); > > That is, there are callbacks in the list, but the sum of the segment > counts is nevertheless zero. The ->nocb_lock is held. > > Thoughts? FWIW, TREE01 reproduces it very quickly compared to the other two scenarios, on all four run, within five minutes. Thanx, Paul > > > --- > > > v1->v2: Added more debug checks. > > > > > > kernel/rcu/rcu_segcblist.c | 12 ++++++++++++ > > > kernel/rcu/rcu_segcblist.h | 3 +++ > > > kernel/rcu/tree.c | 2 ++ > > > 3 files changed, 17 insertions(+) > > > > > > diff --git a/kernel/rcu/rcu_segcblist.c b/kernel/rcu/rcu_segcblist.c > > > index 5059b6102afe..6e98bb3804f0 100644 > > > --- a/kernel/rcu/rcu_segcblist.c > > > +++ b/kernel/rcu/rcu_segcblist.c > > > @@ -94,6 +94,18 @@ static long rcu_segcblist_get_seglen(struct rcu_segcblist *rsclp, int seg) > > > return READ_ONCE(rsclp->seglen[seg]); > > > } > > > > > > +/* Return number of callbacks in segmented callback list by totalling seglen. */ > > > +long rcu_segcblist_n_segment_cbs(struct rcu_segcblist *rsclp) > > > +{ > > > + long len = 0; > > > + int i; > > > + > > > + for (i = RCU_DONE_TAIL; i < RCU_CBLIST_NSEGS; i++) > > > + len += rcu_segcblist_get_seglen(rsclp, i); > > > + > > > + return len; > > > +} > > > + > > > /* Set the length of a segment of the rcu_segcblist structure. */ > > > static void rcu_segcblist_set_seglen(struct rcu_segcblist *rsclp, int seg, long v) > > > { > > > diff --git a/kernel/rcu/rcu_segcblist.h b/kernel/rcu/rcu_segcblist.h > > > index cd35c9faaf51..46a42d77f7e1 100644 > > > --- a/kernel/rcu/rcu_segcblist.h > > > +++ b/kernel/rcu/rcu_segcblist.h > > > @@ -15,6 +15,9 @@ static inline long rcu_cblist_n_cbs(struct rcu_cblist *rclp) > > > return READ_ONCE(rclp->len); > > > } > > > > > > +/* Return number of callbacks in segmented callback list by totalling seglen. */ > > > +long rcu_segcblist_n_segment_cbs(struct rcu_segcblist *rsclp); > > > + > > > void rcu_cblist_init(struct rcu_cblist *rclp); > > > void rcu_cblist_enqueue(struct rcu_cblist *rclp, struct rcu_head *rhp); > > > void rcu_cblist_flush_enqueue(struct rcu_cblist *drclp, > > > diff --git a/kernel/rcu/tree.c b/kernel/rcu/tree.c > > > index f5b61e10f1de..91e35b521e51 100644 > > > --- a/kernel/rcu/tree.c > > > +++ b/kernel/rcu/tree.c > > > @@ -2553,6 +2553,8 @@ static void rcu_do_batch(struct rcu_data *rdp) > > > WARN_ON_ONCE(count == 0 && !rcu_segcblist_empty(&rdp->cblist)); > > > WARN_ON_ONCE(!IS_ENABLED(CONFIG_RCU_NOCB_CPU) && > > > count != 0 && rcu_segcblist_empty(&rdp->cblist)); > > > + WARN_ON_ONCE(count == 0 && rcu_segcblist_n_segment_cbs(&rdp->cblist) != 0); > > > + WARN_ON_ONCE(count != 0 && rcu_segcblist_n_segment_cbs(&rdp->cblist) == 0); > > > > > > rcu_nocb_unlock_irqrestore(rdp, flags); > > > > > > -- > > > 2.29.2.299.gdc1121823c-goog