Received: by 2002:a05:6358:16cc:b0:ea:6187:17c9 with SMTP id r12csp6997061rwl; Mon, 9 Jan 2023 16:23:08 -0800 (PST) X-Google-Smtp-Source: AMrXdXs7GNeYwxMPcrivJHXgnHWRkJJ5cHVT2SsYKOeSZ712ePW08y4qaV8A42fbnbwT6EqNXG/n X-Received: by 2002:a05:6402:2409:b0:493:597e:2192 with SMTP id t9-20020a056402240900b00493597e2192mr15861952eda.38.1673310187849; Mon, 09 Jan 2023 16:23:07 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1673310187; cv=none; d=google.com; s=arc-20160816; b=oCbDIekqI9dxSWlo6HEGy9qwL6fPLs0HmSQdHN1mH5Qye7Cxv0PnOaLZq7x1dPuE5K vBuO1TC0E6iujs0A2iWr2s5PHdX+I81cOGWYl9/LM8/t8XKtmzJt3X53naUWIpg61sfa FOYown0wEKAZ6hIvXdxQGMmSH4Etm32RqYxjHWFWl34977QWV05Z7zVhgZqw/pfsk/Fv KRBdC+3KVNfG8EkwU5m/db4Ep5tGo8XyAJ0jr09d9ou97f4K1zU7LXOpKK1dSfaL22xj 8ywf2+MkvB70kMwGUhSdsux59LzBXUKgzzBkOT66hyeJaACLv+o6qENm9XpgPX9gF5a+ ZRtg== 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-transfer-encoding :content-disposition:mime-version:references:reply-to:message-id :subject:cc:to:from:date:dkim-signature; bh=vsBEfs8g0+guYP1RCYXXHEfroV8PUamlfN/yJQTEhkk=; b=l1NgdRuS9fzici/g5HV3lelMq0juTkGvoztqyZ522Ms02vFCdS7C/1x05wkY8XTL0o zp3dle60xaFjvJofGIoyMo/G+hY/EPhrK5YnXQB6rnYkcUQGW9N5yAIJyrU9qMfm8bMU n9ztE0dfFAN1LFMLo6zjK24l/7UU72WSH5IHdoJFyRmH9bO7Zo40XUF+psycD9TWnKxN Ywt2MmSSN2HmRkWiMfqZcTWrOao3EQ0cwkkziCd9Rvl+pocN+C335ySAv0ebAplJetxE eIQRvXVjNuxdAmJW5G+U8SKWJmt3EnYbVh30egVvfIJZMtkGLNE+I686z8Ax1PdJMA// nMYg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=AGJHpzHI; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id h9-20020a05640250c900b0046abe52aca7si11205254edb.486.2023.01.09.16.22.55; Mon, 09 Jan 2023 16:23:07 -0800 (PST) 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=@kernel.org header.s=k20201202 header.b=AGJHpzHI; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230312AbjAIXzi (ORCPT + 53 others); Mon, 9 Jan 2023 18:55:38 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45454 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231150AbjAIXzg (ORCPT ); Mon, 9 Jan 2023 18:55:36 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B1420DFCC; Mon, 9 Jan 2023 15:55:34 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 6FF78B810B3; Mon, 9 Jan 2023 23:55:33 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 1A568C433D2; Mon, 9 Jan 2023 23:55:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1673308532; bh=36W9a7c+G0nl1lcdbIJ/BM2s765cqvTrYCaVHIqcPAw=; h=Date:From:To:Cc:Subject:Reply-To:References:In-Reply-To:From; b=AGJHpzHIodkO9gpRBSXl7RpPj7usJlj3xJUsQrbHFxdtqdjGkP/TW0gVpduI7/7Cf Y/c9f8MZcYjp5J0i/DctlG4fADgwgACCXuGMElDYHz3kX7MC9zC6vtUrUS8JwIG0Bb 6qAgFj5mzu+MBqTq4bueZoQ/3pWYA4laHY7Grf5ujxm+6WvOv/gadUUHIxA3glzFHf z2qNMWTxrV9rnLImWeIw2MM7VvIx9sdjAR8c6RL5Yy5yLFLmcNshJ3MNsS4lvrVcZw gkSoj6LCV3nTbgI9j/NV4fEU5HZDf2bM9Ue3FoTbduKPhzfUgDnhXT5QdkmZkhalPi StwTZEHy7YlHA== Received: by paulmck-ThinkPad-P17-Gen-1.home (Postfix, from userid 1000) id B3C985C0623; Mon, 9 Jan 2023 15:55:31 -0800 (PST) Date: Mon, 9 Jan 2023 15:55:31 -0800 From: "Paul E. McKenney" To: Joel Fernandes Cc: linux-kernel@vger.kernel.org, Josh Triplett , Lai Jiangshan , Mathieu Desnoyers , rcu@vger.kernel.org, Steven Rostedt , foo@bar.com Subject: Re: [PATCH -rcu] rcu: Disable lazy if call_rcu() called when GPs expedited Message-ID: <20230109235531.GB4028633@paulmck-ThinkPad-P17-Gen-1> Reply-To: paulmck@kernel.org References: <20230109231416.GA4028633@paulmck-ThinkPad-P17-Gen-1> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS autolearn=ham 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 Mon, Jan 09, 2023 at 06:20:55PM -0500, Joel Fernandes wrote: > > > > On Jan 9, 2023, at 6:14 PM, Paul E. McKenney wrote: > > > > On Mon, Jan 09, 2023 at 10:17:56PM +0000, Joel Fernandes (Google) wrote: > >> During suspend, we see failures to suspend 1 in 300-500 suspends. > >> Looking closer, it appears that we are queuing lazy callbacks even > >> though rcu_gp_is_expedited(). These delays appear to not be very welcome > >> by the suspend/resume code as evidenced by these occasional suspend > >> failures. > >> > >> This commit therefore checks if rcu_gp_is_expedited() and ignores the > >> lazy hint if so. > >> > >> Ignoring the lazy hint if rcu_gp_is_expedited() makes the 3000 > >> suspend/resume cycles pass reliably on a 12th gen 12-core Intel CPU. > > > > Yow!!! ;-) > > :-D > > >> Fixes: 3cb278e73be5 ("rcu: Make call_rcu() lazy to save power") > >> Signed-off-by: Joel Fernandes (Google) > >> --- > >> Paul, could we take this for 6.2 -rc cycle? Thanks. > >> > >> kernel/rcu/tree.c | 5 +++-- > >> 1 file changed, 3 insertions(+), 2 deletions(-) > >> > >> diff --git a/kernel/rcu/tree.c b/kernel/rcu/tree.c > >> index 63545d79da51..93eb03f8ed99 100644 > >> --- a/kernel/rcu/tree.c > >> +++ b/kernel/rcu/tree.c > >> @@ -2594,12 +2594,12 @@ static void check_cb_ovld(struct rcu_data *rdp) > >> } > >> > >> static void > >> -__call_rcu_common(struct rcu_head *head, rcu_callback_t func, bool lazy) > >> +__call_rcu_common(struct rcu_head *head, rcu_callback_t func, bool lazy_in) > >> { > >> static atomic_t doublefrees; > >> unsigned long flags; > >> struct rcu_data *rdp; > >> - bool was_alldone; > >> + bool was_alldone, lazy; > > > > Please put "lazy" in alpha order. Except that... > > Ah sure. > > > > >> /* Misaligned rcu_head! */ > >> WARN_ON_ONCE((unsigned long)head & (sizeof(void *) - 1)); > >> @@ -2622,6 +2622,7 @@ __call_rcu_common(struct rcu_head *head, rcu_callback_t func, bool lazy) > >> kasan_record_aux_stack_noalloc(head); > >> local_irq_save(flags); > >> rdp = this_cpu_ptr(&rcu_data); > >> + lazy = lazy_in && !rcu_gp_is_expedited(); > > > > Doesn't this completely disable laziness on Android? > > Good point, I am not sure but it could be. Maybe it is safer that I add > a new suspend-indicator then, with corresponding > suspend entry/exit calls like we do for expedited. > > That way anyone doing it this way will not disable > lazy fully. > > Thoughts? Makes sense to me! Just so you know, there is an overlapping patch series in flight here: https://lore.kernel.org/all/20221219202910.3063036-1-elliott@hpe.com/ Thanx, Paul