Received: by 2002:a05:6358:9144:b0:117:f937:c515 with SMTP id r4csp7631049rwr; Wed, 10 May 2023 10:28:47 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4xMIxotpip5sWNBTHt0xZiDAcbzydUVQ5muWI7FHBizFMJDbMgMR4FxLCw2GTMaRBo+hNY X-Received: by 2002:a17:90b:3a8e:b0:247:6ead:d0ed with SMTP id om14-20020a17090b3a8e00b002476eadd0edmr18697595pjb.28.1683739726891; Wed, 10 May 2023 10:28:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1683739726; cv=none; d=google.com; s=arc-20160816; b=z6Y3w1S3VZ/xIs0VJE9ECz6xMlrSUCx9WO0Y0kNsvKMztIMR5j5WXYzWPHA9Aezf4Q q/ZCpDJl1UKdTTC6gEt/7nMeKrGKpYo/Q+Njw4JuUDQ1teiESznVoIt8Wod7I6LpGU4/ atxbOW+tAmPBVVEtxLZypQ3a/0rO1uFSr3kDgpyrc30tUTfIkjdc7NSdcjbk6No3nwPO ozmz8WHfEdLIS+HsOWScupiFrV6ue7JuW1dEt9VidA7vw18Bp8nNc+S2IF8hPVvdljyo xVril49feVpu2spA0TJH1MwXp9eIzQbMowKqyQqgOEdF5n9XVzXKhWmgVmUx2vKAX1Se bkZA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=0cq1GfUIlQ7M8hYeXQ/3DrBjfoTPlJGs4UhfVTRvNC0=; b=j5ODiEWXo0tB077G6H+drIDE+euofgSUKG7vbWYZtrwJ1/CDQacBODEOy8iP2KSoDs S5WxCvVoy6ot/6wArK0SjoMtNScAuDnqaZr43b0b+bT3a2K3s0OEQgTKXbvrBUfo8SBr pcdoRgl0f/cQwlc1Vf/QwUeZspd2ZyoAGnwgSmGrx6Nd0LV2h9kusH+fqkA5sULOACFR Llv1XSryAKvICK6BbEXrtfNhWBwrp6U/TUGyPG3+iPllMWw0pfjrcOVrUdCWnBzsaXSs 8pPG+7O3p7ZOa3fo6Xt5sxnreAAzIEidxv1ykGtf5H3bK7TxOWFz+UPrGP+NOX67JSU4 4IsQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=uIJWv3bD; 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 l14-20020a17090ac58e00b00250bf29b6d6si3663604pjt.165.2023.05.10.10.28.32; Wed, 10 May 2023 10:28:46 -0700 (PDT) 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=uIJWv3bD; 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 S236327AbjEJRD3 (ORCPT + 99 others); Wed, 10 May 2023 13:03:29 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45846 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236138AbjEJRDZ (ORCPT ); Wed, 10 May 2023 13:03:25 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 11ECF5276; Wed, 10 May 2023 10:03:06 -0700 (PDT) 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 dfw.source.kernel.org (Postfix) with ESMTPS id C477964A2F; Wed, 10 May 2023 17:02:44 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 06901C433A1; Wed, 10 May 2023 17:02:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1683738164; bh=txQDJDLfcrk89uoEEXKL4LZWnIrpTUCXeBg768P6sLs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=uIJWv3bDn2hFfC3GAznQKTfEIn92fqAADGNsdFRt24u/29/slTTyOIBocfq0g6l4N hP16khOH4RVpTapoxN0aiNt7XqwJlLFn0PWuKJ5bjUL20abVXnDMsVnqchKpVDKJ0c juQ5Z09scxOuxTXQqSA69FuE5lnAabTg8vu5bf2MKygUgoYnJtfLXjpLRWUuitfIBz hJlvVmQlWVN3HLbX90MwIFkKtEjuHeUS4hvE6Go5C/HNmOAGoRNa2GPwkxfgIfdK/1 Hw/omcb7AF7rKOB1vdAdx/rN+pn3Y/DXCXDNN1tK0UYcCCPLsvmdpKuO93+/eXZLxp Fj6l3XJrDZUnQ== Received: by paulmck-ThinkPad-P17-Gen-1.home (Postfix, from userid 1000) id 5A4C3CE1348; Wed, 10 May 2023 10:02:43 -0700 (PDT) From: "Paul E. McKenney" To: rcu@vger.kernel.org Cc: linux-kernel@vger.kernel.org, kernel-team@meta.com, rostedt@goodmis.org, Zqiang , Uladzislau Rezki , "Paul E . McKenney" Subject: [PATCH rcu 7/8] rcu/kvfree: Make fill page cache start from krcp->nr_bkv_objs Date: Wed, 10 May 2023 10:02:41 -0700 Message-Id: <20230510170242.2187714-7-paulmck@kernel.org> X-Mailer: git-send-email 2.40.1 In-Reply-To: <1c01c38f-3783-44d7-8c11-7416cd5b849c@paulmck-laptop> References: <1c01c38f-3783-44d7-8c11-7416cd5b849c@paulmck-laptop> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE 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 From: Zqiang When the fill_page_cache_func() function is invoked, it assumes that the cache of pages is completely empty. However, there can be some time between triggering execution of this function and its actual invocation. During this time, kfree_rcu_work() might run, and might fill in part or all of this cache of pages, thus invalidating the fill_page_cache_func() function's assumption. This will not overfill the cache because put_cached_bnode() will reject the extra page. However, it will result in a needless allocation and freeing of one extra page, which might not be helpful under lowish-memory conditions. This commit therefore causes the fill_page_cache_func() to explicitly account for pages that have been placed into the cache shortly before it starts running. Signed-off-by: Zqiang Reviewed-by: Uladzislau Rezki (Sony) Signed-off-by: Paul E. McKenney --- kernel/rcu/tree.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kernel/rcu/tree.c b/kernel/rcu/tree.c index 18f592bf6dc6..98f2e833e217 100644 --- a/kernel/rcu/tree.c +++ b/kernel/rcu/tree.c @@ -3201,7 +3201,7 @@ static void fill_page_cache_func(struct work_struct *work) nr_pages = atomic_read(&krcp->backoff_page_cache_fill) ? 1 : rcu_min_cached_objs; - for (i = 0; i < nr_pages; i++) { + for (i = READ_ONCE(krcp->nr_bkv_objs); i < nr_pages; i++) { bnode = (struct kvfree_rcu_bulk_data *) __get_free_page(GFP_KERNEL | __GFP_NORETRY | __GFP_NOMEMALLOC | __GFP_NOWARN); -- 2.40.1