Received: by 2002:a05:6358:11c7:b0:104:8066:f915 with SMTP id i7csp2090218rwl; Sat, 8 Apr 2023 07:36:18 -0700 (PDT) X-Google-Smtp-Source: AKy350aDxnspDyPZZ26xzf6of1vPwrs1g4ngpaxKwR3LkNdjWM9K6Wt6xn1MHEBFMdcntl9vlo9e X-Received: by 2002:a17:90a:fd83:b0:23a:66:1d3a with SMTP id cx3-20020a17090afd8300b0023a00661d3amr2867460pjb.45.1680964578579; Sat, 08 Apr 2023 07:36:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1680964578; cv=none; d=google.com; s=arc-20160816; b=TwjjfmVxqMOE5kEwRSyyZfvHRXCjZ1vKLXjT+7EHvEwViBmdjMHFoB0frFPFAJujEZ 7rmXyvVRVLgPdQbHzEgtwml9sai3FI436uWCLtRdwtCTglLWuTHWSFuPAODC51gnT1rG PeVPBPifdlSLQQgRD+IJCkNA/bQF5/SxdQ25o5TO1Bngk3iCreOenRiwoqI+U3R903qA 6ZeJ9edXmuEHCHVt1gGMGp9impI83JgnsjEI7TWnEJNWnaeD0RrVkRTGroAaDW5U7EK6 RkNoIm57tqZrPmi1v3OfHXb4OM+Wl4qUyrLTdDq8llVTNbFf7emzwDE3K4InRweZ6lY1 UTKQ== 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=lgQuBNF/zlYQKiyuhC6mg+eCs/QPhU39hJtSFyJBLB4=; b=BrHvXfO6KZmNGluepY4VuvdlXI3YWdxZVgWQRykj6/e3MgAaxOmKvXSIMIcglhRl8a kC4SL2zdkpwabUXXoBZ31J/hbdYyKIzJahcEz/NxZ8RaHKcKKG/c6VTTS8zUGW4Oau8G f6N3+CY/3p0g+EjJbJ6t2AJ3PbQ5r2GmnsCnbRiFmv6sCqlQiCKNX+dgQqhDL6PL1Ipf gAez2unR6nghdQRVZGFECu5W1+VX+qLQf7IieBcxbFUjecDFPMpBGHf/f+Nf8Vlg62aB Nf4lakqoAeUztceKEQgFS7gF+LAsPce3c3Jv3YyZDwbwjhz0kXByDoVDfEcmJ/0fAF7i g3yA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=h3cG+kBR; 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 n7-20020a6543c7000000b005032da21acasi5849987pgp.204.2023.04.08.07.36.05; Sat, 08 Apr 2023 07:36:18 -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=h3cG+kBR; 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 S229976AbjDHOYk (ORCPT + 99 others); Sat, 8 Apr 2023 10:24:40 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48300 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229756AbjDHOYj (ORCPT ); Sat, 8 Apr 2023 10:24:39 -0400 Received: from mga14.intel.com (mga14.intel.com [192.55.52.115]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 42F95C64A; Sat, 8 Apr 2023 07:24:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1680963878; x=1712499878; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=1/EFS4qTJgUjgKWW6wh9rSkbnbQnihJy1r+mSbHPrws=; b=h3cG+kBRw1/u2i4vwy2nE9rjhZVPBwAjLzWjmW4YjxLxPSxj1VpZI74G pcvQU3gJRt762vUNx2f7CvRcHgMuamsO1ZhcuTtQk3X0ZtdfancbVtz3k CZhuHgVLUPZ4Nx/qDrsSmptpFtKjwPj5J4K5rqL4FX4pMoHDTMRz/hogf aGtNT0mMqnxnzKTjmRYasz+LBo45OETDcrXAq/c4CLN08lsTY9f1W8X+y UuJf4lcIrqgaba+QFlMKMlRjF3x/vIyZh2xQcTV++M8gYQyw8763mVCxD QlvH5MZn8mCBanjCFRoNJ5oJfiBBIVlsCBuFsaZqHqbD0dJ38qBUeVjMn w==; X-IronPort-AV: E=McAfee;i="6600,9927,10674"; a="343147974" X-IronPort-AV: E=Sophos;i="5.98,329,1673942400"; d="scan'208";a="343147974" Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmsmga103.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 08 Apr 2023 07:24:37 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10674"; a="831461577" X-IronPort-AV: E=Sophos;i="5.98,329,1673942400"; d="scan'208";a="831461577" Received: from ubuntu.bj.intel.com ([10.238.155.108]) by fmsmga001.fm.intel.com with ESMTP; 08 Apr 2023 07:24:35 -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 v3] rcu/kvfree: Prevents cache growing when the backoff_page_cache_fill is set Date: Sat, 8 Apr 2023 22:25:17 +0800 Message-Id: <20230408142517.800549-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=-2.5 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE, SPF_NONE autolearn=unavailable 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 Currently, in kfree_rcu_shrink_scan(), the drain_page_cache() is executed before kfree_rcu_monitor() to drain page cache, if the bnode structure's->gp_snap has done, the kvfree_rcu_bulk() will fill the page cache again in kfree_rcu_monitor(), this commit add a check for krcp structure's->backoff_page_cache_fill in put_cached_bnode(), if the krcp structure's->backoff_page_cache_fill is set, prevent page cache growing and disable allocated page in fill_page_cache_func(). Signed-off-by: Zqiang --- kernel/rcu/tree.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/kernel/rcu/tree.c b/kernel/rcu/tree.c index cc34d13be181..9d9d3772cc45 100644 --- a/kernel/rcu/tree.c +++ b/kernel/rcu/tree.c @@ -2908,6 +2908,8 @@ static inline bool put_cached_bnode(struct kfree_rcu_cpu *krcp, struct kvfree_rcu_bulk_data *bnode) { + if (atomic_read(&krcp->backoff_page_cache_fill)) + return false; // Check the limit. if (krcp->nr_bkv_objs >= rcu_min_cached_objs) return false; @@ -3221,7 +3223,7 @@ static void fill_page_cache_func(struct work_struct *work) int i; nr_pages = atomic_read(&krcp->backoff_page_cache_fill) ? - 1 : rcu_min_cached_objs; + 0 : rcu_min_cached_objs; for (i = 0; i < nr_pages; i++) { bnode = (struct kvfree_rcu_bulk_data *) -- 2.32.0