Received: by 2002:a05:6358:11c7:b0:104:8066:f915 with SMTP id i7csp1043655rwl; Wed, 12 Apr 2023 07:34:34 -0700 (PDT) X-Google-Smtp-Source: AKy350bYNKjiqqXN86ivJ47JSieCy9ggV0w2rA7NeCyfWHU0BaxZGCZc8YGMoUzaw+dKeCY2g1AS X-Received: by 2002:aa7:ca53:0:b0:506:bdc:49c6 with SMTP id j19-20020aa7ca53000000b005060bdc49c6mr343716edt.23.1681310074051; Wed, 12 Apr 2023 07:34:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1681310074; cv=none; d=google.com; s=arc-20160816; b=Cceq9S+dUOFrdP8rVYdeX/H9NdbqO61jlriWP8FvhpdnbnL6zy9Qip1wb3Jx5akvq8 IOLjpNcV2C84iZOX6AoqIR4rXKRpsemArL2xGYISIm60OZ3xZvJFYBs9231U+B1XxQbO cH790oJDXZc1Jo2n7XZOx6MOnvvPygnIoQr5WI3ab7yDceHrkHB21V4dRzQJaY2BDsFm 9O0mns9jYdmlQHLyR0Zj6cI2Dfvj9I/rbJyo2I+fTszveEd1btmfboWgQbGc0Gu5XfC9 3wAPjnS5uWOrwLLBCE5g9CdWCik15sx51wLjHchic4pmcNHnsHoiRkd7dEedSrdg1bqX q89g== 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 :message-id:date:subject:cc:to:from:dkim-signature; bh=05wfHRFpSH3G6p2UQ407G4Jv88Y0zKmI41VsqtR+T0M=; b=ZEZRLkx5i8KvnhoTz6a7zygv4LnXFmHar114c30ewtNhzngqmsliKI2wAykWb/F8UW 6ljKqBGdjNOPlr5sH6CIx1leZ7fadQkaca0X5OBx0yqLg7p5vA2OTlSq5K4VafVsQuto YkWjyC0c4EHiFk35bZvrtInRTBigABfKLqZr+oC6qUiDEwA0q1xwcwsCtx/dJjDrkpW8 Qub5mFPdLbXLKNqCZNT/KoKJmT06fBy0obii9SlIbngu8LFsHpMDXhlZ5VuRBh6qcfHr E2UDTJBeYijvM5cc0Xa5rb2gJDd1jm8mfbF0KR1dQhJV7qX+8sGg6EQEvdQTallUAE1D OQcw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b="L/pe34kg"; 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=intel.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id l24-20020a056402125800b004c0e614f887si9919885edw.94.2023.04.12.07.34.08; Wed, 12 Apr 2023 07:34:34 -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=@intel.com header.s=Intel header.b="L/pe34kg"; 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=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230422AbjDLOa5 (ORCPT + 99 others); Wed, 12 Apr 2023 10:30:57 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57502 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229635AbjDLOax (ORCPT ); Wed, 12 Apr 2023 10:30:53 -0400 Received: from mga12.intel.com (mga12.intel.com [192.55.52.136]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E00716EAD; Wed, 12 Apr 2023 07:30:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1681309852; x=1712845852; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=MUukx+elsmvY2w1rcta7R5fVF5p3q8+K1K014A88sno=; b=L/pe34kgCBec6QV4EQerm1bvhXkppEHCDTtTVkHWq9V8gwZzsLaVP+PE yaLRhV9goW7YwAxhwyM7hDTuC1/6QtjN6i552TmtC85U/Z/Mwj0guWbBO qp7RpTmdiPQ5xmikuAnph4hWOoCeEqAE2jJtfE+Z75rAA99Q7d5AgL+Ug nRakgM3FAs3B6z5rLjtrmbBggXgGGcorJM6ZGlVSXP6qKz4T06RbE7LnD pv2TXXilBrB2OIbVPdjSDyOhhmjAIMZtnBiz5CIn4VOwOqpawr+zZe0m/ oWGxDtX8u9xM8aHzMCVSJcHjBD51oIDAkYSBE34uOFvP7kL5n72SRRDKI A==; X-IronPort-AV: E=McAfee;i="6600,9927,10678"; a="323537702" X-IronPort-AV: E=Sophos;i="5.98,339,1673942400"; d="scan'208";a="323537702" Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by fmsmga106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 Apr 2023 07:30:51 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10678"; a="778316338" X-IronPort-AV: E=Sophos;i="5.98,339,1673942400"; d="scan'208";a="778316338" Received: from ubuntu.bj.intel.com ([10.238.155.108]) by FMSMGA003.fm.intel.com with ESMTP; 12 Apr 2023 07:30:48 -0700 From: Zqiang To: urezki@gmail.com, paulmck@kernel.org, frederic@kernel.org, joel@joelfernandes.org, qiang1.zhang@intel.com Cc: qiang.zhang1211@gmail.com, rcu@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH] rcu/kvfree: Make fill page cache start from krcp->nr_bkv_objs Date: Wed, 12 Apr 2023 22:31:27 +0800 Message-Id: <20230412143127.1062367-1-qiang1.zhang@intel.com> X-Mailer: git-send-email 2.32.0 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_PASS,SPF_NONE,URIBL_BLOCKED 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 The fill_page_cache_func() is invoked and start from zero to allocate nr_pages of page, if the kfree_rcu_work() executes before the fill_page_cache_func(), the krcp->nr_bkv_objs is updated before enter for-loop and equal to nr_pages, since the page is allocated first, and then check the krcp->nr_bkv_objs in put_cached_bnode(), this produces a meaningless __get_free_page() call, this commit therefore make allocate page start from krcp->nr_bkv_objs and check krcp->nr_bkv_objs before allocate page. Signed-off-by: Zqiang --- 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 41daae3239b5..dcb86f9f2dd6 100644 --- a/kernel/rcu/tree.c +++ b/kernel/rcu/tree.c @@ -3223,7 +3223,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.32.0