Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp2872963rwb; Wed, 30 Nov 2022 12:04:49 -0800 (PST) X-Google-Smtp-Source: AA0mqf51YEbxug5dTD8VWFM0hCeaw3MaNOVBPR8SbwrKWlkRYQInfnEDI+FJlRCYEnEVEYffuGGo X-Received: by 2002:aa7:980c:0:b0:574:80b6:5706 with SMTP id e12-20020aa7980c000000b0057480b65706mr33701222pfl.30.1669838689615; Wed, 30 Nov 2022 12:04:49 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669838689; cv=none; d=google.com; s=arc-20160816; b=Pax00FxKsh9ONSlknTLOx92EjHauAgBq9m3JJuciMfYS/+wKqis88hSoAZjpH6hNO0 Hzie+PKx7eNkhp+HVfBfdsAZwVsM+md+3TdL87HzSC+ifE+2VTQb/+mQ8FRVe8MXppyy W0zOOOe2t+L7dvvPbCBckMP69uyRVCNj1q+0r3F/Gdntw56ldIDZKYkTmLA9IvD/sl7J VZx440O/p5AtLo7j6INihZKSIKm5kKn6V+hMUJ6BN0M2a5O4UCnwjkkVh+nVa0vs7+OK CqXU1Y1z/cqgsCyBGHlSX5xqGBKjZP15gIsxZsJcbnPirRTax08fTsYqX4jQJkcxt9OO 7qaQ== 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:sender:dkim-signature; bh=pUBcXV7nQy/1r0o6E64fUR2RwhClmxU+dP9giO6hLmY=; b=zR/sK0PIOfTGHh2sZzpkLngkiyebstbhcwVjyme6qG3jT60x2RXJF2H1bXnR56NBtk hODO5RmGeMB7YQg5BIcZcHkHVTGu0zxoAY3AQ0pBJl95/EKnhLfJYalPdUDnKXi7wcXZ Mx5Nk5FCFGmq8lt/Ex4FtMBc8Z29J+YGlTat1ckGI7xGjPAJ5upvwrwNyML9VR0qdrQ+ BraBek1QQtqJqyXtdgsPW8ypMdxI4wRxkcgvk7+gkwo4jgNzgfvzEWcWY2gAsF+sdP1m XGyh0UiXWA1sN6exesen4NXAwtXL2z+E0+zY/axLDzTT98dYCcTP8fuaay1Anz43q3DE 1DWA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=fBZVpztZ; 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 v3-20020a056a00148300b0056de69b0c76si2616950pfu.283.2022.11.30.12.04.38; Wed, 30 Nov 2022 12:04:49 -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=@gmail.com header.s=20210112 header.b=fBZVpztZ; 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 S229750AbiK3TnS (ORCPT + 83 others); Wed, 30 Nov 2022 14:43:18 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53646 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229726AbiK3TnR (ORCPT ); Wed, 30 Nov 2022 14:43:17 -0500 Received: from mail-pl1-x629.google.com (mail-pl1-x629.google.com [IPv6:2607:f8b0:4864:20::629]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CDE3226132; Wed, 30 Nov 2022 11:43:15 -0800 (PST) Received: by mail-pl1-x629.google.com with SMTP id jl24so229863plb.8; Wed, 30 Nov 2022 11:43:15 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:sender:from:to:cc:subject:date:message-id :reply-to; bh=pUBcXV7nQy/1r0o6E64fUR2RwhClmxU+dP9giO6hLmY=; b=fBZVpztZLS4scqkNd2KK5kBSJaDFwKbZkCD7lBloMLPUm1TxERP3E6+Awn4UyBRiws RrFEP2bcgV6oWYpuTKP35X1NhRHLIYuBvf0xnaG3Ta1so5bYMBsei779ZlT8fR38icqX FmHpKdrR40GVytaMY/oF09SOnM/LTlZ2UoPLI8AdPREHGPMtmLVvAP2+QXWOx2pmwjrT nO+pRilq6WETWtwL3w78XpSiy8noae+/SPNfJiiFpGXlPALaPVuLB9hV4gKs6uv+5uuI 8UiAqE7kZlf8C1yGFtWc+r4Hox3xWYsLg2j4KLUtiLPDj48BtDEc9mvupGhQAUDLIvFa Jf9g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:sender:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=pUBcXV7nQy/1r0o6E64fUR2RwhClmxU+dP9giO6hLmY=; b=hLYsEEpxIZ+WutNQ2ZeRQq947vbAWXXwpbUzMknHVTaLr8n5C3b2xHmnn3QGz8ZbYb lTvmsPbC7p0KujgfP6HuXmSJhwVm7unpTn4Q0OhRHrYaHM48/b59FmTeE8a54RWV4MM+ 0wwbHadNPBHfo4QoOE3RcDS0xB+ajpgbLzhnvZQtGsvD91xtj+PH6IqCGpM4bTA7+dEG umZBYS5mlrH9OR0sGo2trA5TujElvO057vw/7QK3x/BZNwDOmmA14yufD1nA8NH+uMnD 4k/X99jV76I9PQhzjmJijO80AGOCib+cCWiT9dMI8EzEYAJLOmIRE4Qpk+8hWSiA54Nh 0nIg== X-Gm-Message-State: ANoB5pmImhYYqmAKWx9HcarR91NvgDwHqUWwNGFXyFo6tEel5lh0N7xq 8X95KKRuZKM9pQJmypVpIvM= X-Received: by 2002:a17:902:8548:b0:186:8398:350 with SMTP id d8-20020a170902854800b0018683980350mr43130061plo.6.1669837395109; Wed, 30 Nov 2022 11:43:15 -0800 (PST) Received: from localhost (2603-800c-1a02-1bae-a7fa-157f-969a-4cde.res6.spectrum.com. [2603:800c:1a02:1bae:a7fa:157f:969a:4cde]) by smtp.gmail.com with ESMTPSA id k1-20020a170902c40100b00188fc33e96dsm1870452plk.198.2022.11.30.11.43.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 30 Nov 2022 11:43:14 -0800 (PST) Sender: Tejun Heo Date: Wed, 30 Nov 2022 09:43:13 -1000 From: Tejun Heo To: "Paul E. McKenney" Cc: rcu@vger.kernel.org, linux-kernel@vger.kernel.org, kernel-team@meta.com, rostedt@goodmis.org, Uladzislau Rezki , Joel Fernandes , Lai Jiangshan Subject: Re: [PATCH rcu 13/16] workqueue: Make queue_rcu_work() use call_rcu_hurry() Message-ID: References: <20221130181316.GA1012431@paulmck-ThinkPad-P17-Gen-1> <20221130181325.1012760-13-paulmck@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20221130181325.1012760-13-paulmck@kernel.org> X-Spam-Status: No, score=-1.7 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_EF,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE, SPF_PASS autolearn=no 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 Wed, Nov 30, 2022 at 10:13:22AM -0800, Paul E. McKenney wrote: > From: Uladzislau Rezki > > Earlier commits in this series allow battery-powered systems to build > their kernels with the default-disabled CONFIG_RCU_LAZY=y Kconfig option. > This Kconfig option causes call_rcu() to delay its callbacks in order > to batch them. This means that a given RCU grace period covers more > callbacks, thus reducing the number of grace periods, in turn reducing > the amount of energy consumed, which increases battery lifetime which > can be a very good thing. This is not a subtle effect: In some important > use cases, the battery lifetime is increased by more than 10%. > > This CONFIG_RCU_LAZY=y option is available only for CPUs that offload > callbacks, for example, CPUs mentioned in the rcu_nocbs kernel boot > parameter passed to kernels built with CONFIG_RCU_NOCB_CPU=y. > > Delaying callbacks is normally not a problem because most callbacks do > nothing but free memory. If the system is short on memory, a shrinker > will kick all currently queued lazy callbacks out of their laziness, > thus freeing their memory in short order. Similarly, the rcu_barrier() > function, which blocks until all currently queued callbacks are invoked, > will also kick lazy callbacks, thus enabling rcu_barrier() to complete > in a timely manner. > > However, there are some cases where laziness is not a good option. > For example, synchronize_rcu() invokes call_rcu(), and blocks until > the newly queued callback is invoked. It would not be a good for > synchronize_rcu() to block for ten seconds, even on an idle system. > Therefore, synchronize_rcu() invokes call_rcu_hurry() instead of > call_rcu(). The arrival of a non-lazy call_rcu_hurry() callback on a > given CPU kicks any lazy callbacks that might be already queued on that > CPU. After all, if there is going to be a grace period, all callbacks > might as well get full benefit from it. > > Yes, this could be done the other way around by creating a > call_rcu_lazy(), but earlier experience with this approach and > feedback at the 2022 Linux Plumbers Conference shifted the approach > to call_rcu() being lazy with call_rcu_hurry() for the few places > where laziness is inappropriate. > > And another call_rcu() instance that cannot be lazy is the one > in queue_rcu_work(), given that callers to queue_rcu_work() are > not necessarily OK with long delays. > > Therefore, make queue_rcu_work() use call_rcu_hurry() in order to revert > to the old behavior. > > [ paulmck: Apply s/call_rcu_flush/call_rcu_hurry/ feedback from Tejun Heo. ] > > Signed-off-by: Uladzislau Rezki > Signed-off-by: Joel Fernandes (Google) > Cc: Tejun Heo > Cc: Lai Jiangshan > Signed-off-by: Paul E. McKenney Acked-by: Tejun Heo Thanks. -- tejun