From patchwork Thu Feb 1 15:49:03 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chengming Zhou X-Patchwork-Id: 13541309 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4AC42C4828D for ; Thu, 1 Feb 2024 15:50:31 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id C0E306B009B; Thu, 1 Feb 2024 10:50:30 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id B96D76B009C; Thu, 1 Feb 2024 10:50:30 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id A379F6B009D; Thu, 1 Feb 2024 10:50:30 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id 8E9E36B009B for ; Thu, 1 Feb 2024 10:50:30 -0500 (EST) Received: from smtpin19.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id 240E9A1B7E for ; Thu, 1 Feb 2024 15:50:30 +0000 (UTC) X-FDA: 81743672220.19.8A80932 Received: from out-182.mta1.migadu.com (out-182.mta1.migadu.com [95.215.58.182]) by imf27.hostedemail.com (Postfix) with ESMTP id 408814000F for ; Thu, 1 Feb 2024 15:50:28 +0000 (UTC) Authentication-Results: imf27.hostedemail.com; dkim=none; spf=pass (imf27.hostedemail.com: domain of chengming.zhou@linux.dev designates 95.215.58.182 as permitted sender) smtp.mailfrom=chengming.zhou@linux.dev; dmarc=fail reason="SPF not aligned (relaxed), No valid DKIM" header.from=bytedance.com (policy=quarantine) ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1706802628; a=rsa-sha256; cv=none; b=VJrWKffzmfgIYjMYqn8Wai+2W4Eg3BwwC+Qzf/hjSryeu/Www7NrUvBJm4n6ILUwVZSOWb 27qYNlshM9e5A3lbHG7S/gD/DqBYdFtE7jGb07rwjQcBsvUMaamx2s2jfE8gEGQQYyB1VI WPtNdd5aF1yaWdW3mr4aheO1iymOC5A= ARC-Authentication-Results: i=1; imf27.hostedemail.com; dkim=none; spf=pass (imf27.hostedemail.com: domain of chengming.zhou@linux.dev designates 95.215.58.182 as permitted sender) smtp.mailfrom=chengming.zhou@linux.dev; dmarc=fail reason="SPF not aligned (relaxed), No valid DKIM" header.from=bytedance.com (policy=quarantine) ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1706802628; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=ChF6yAyrxR93Q+ibVPgtMoofnZ58v2EsFurbhlA0kyE=; b=W1M61InrmgsFWCiuRIsTJMRLsLlgJsmakKa+TsMfgA2Zug34fkdFvNljDMVy0CkdkYAc+s yjqu77nX+FOoKoiwyC+w/fOZcpUF8wlZXd2V3V2SgvmKgEKTG+ukmdj8h70E5i3xemJ5YU qIKovwgr6kuWoY/wAEw9ne8YxipOH5s= X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. From: Chengming Zhou Date: Thu, 01 Feb 2024 15:49:03 +0000 Subject: [PATCH 3/6] mm/zswap: stop lru list shrinking when encounter warm region MIME-Version: 1.0 Message-Id: <20240201-b4-zswap-invalidate-entry-v1-3-56ed496b6e55@bytedance.com> References: <20240201-b4-zswap-invalidate-entry-v1-0-56ed496b6e55@bytedance.com> In-Reply-To: <20240201-b4-zswap-invalidate-entry-v1-0-56ed496b6e55@bytedance.com> To: Nhat Pham , Johannes Weiner , Andrew Morton , Yosry Ahmed Cc: linux-kernel@vger.kernel.org, Yosry Ahmed , Chengming Zhou , Johannes Weiner , linux-mm@kvack.org X-Migadu-Flow: FLOW_OUT X-Rspam-User: X-Rspamd-Server: rspam06 X-Rspamd-Queue-Id: 408814000F X-Stat-Signature: wqjwuc4w6hed4t1yz51gmu9xp57nx5oc X-Rspamd-Pre-Result: action=add header; module=dmarc; Action set by DMARC X-Rspam: Yes X-HE-Tag: 1706802628-805623 X-HE-Meta: U2FsdGVkX19r0efKgd9MEtr2HhoqSDZZ3uqKIUcnx4abEjWYMx4NPoQayR1YLO4J44Z2QllhVM0siO/TFDBwpDKHaZUREBCj7xhlUIbdk5BhZl+h2Is5LQzv7gicecd/SnqxKj+IGOpQVz10sq7NhMI67lZBVfZZOId7Rst/4ZzaH1Rcn7w7ucs+sL106eHxcNDz3XzQjrsL2DRrsUyxqmtamvykFh3hWhar0HOYPH/wrBTJhCPa3Yp6X7/WKwokY51WPfYVKowfIwD1Ey3h+RZmpXeKN0Z5mwVSCxIRt2/riuQEzaD5SksjT74jX+7dgrQI+mnu6AzrJdwLfE4gupIKkTjzt75YdreABolSEhxXELdMH3fUDcNLBD0Gabo8Pe7uUNNSd4y9H0L+tgIVv9BUlcFx3/5buJmyD6a6NAQGeT+KXUpUCBP/fj9Gi0Nj37Rq6uByzi0nzS3tML99Z6TVBfE7qemvGIAN0gWrJl0UFRivmgh1GLwCeZGEqvEC0Hj5Aos+Tw/Vi8osBlbSSotDZ5q8a8bIvzRdCIZDuM1voOtCP3sWwinmTuIp20yO/+Aw305am4APXTxoIGScqQgEkMYgwVprDOizHimv9LgKV/58dq7a82jI9LhB/DKDEXhyR3UYksehk1VRyA+CCtDWqzz+bfxfYvP/SOmRG1EWJ95a2VgMsffVP+HWjzcZLbBE9MfmiNXO0uY4cnR2OqxKtd+e3UQTC6M23Gqm2k32eoBLUt0vZgKBR9hDVB2r4F+xxxFChoh3XbicpvBh4BT9hcBdROtUd4yOy/+MqUxn6SScXRxV7YdP5h3PlzjTrLf3X4ncNSLxSUIo32SCSNPImozNLOPAiH2QczVMdo28klrN12tH+6ePAICifc6VTMqhT9/xyMckkS1Y7hHUMw0Y3gpiFPNguCkIKpX+Xvkub1TW5ybi3fRVyH79iR90WWalOJgd3lk88GmPjsE WSU/LAvG XLTCQ6i/59kJ1Ti8WNuqbj6iV27gnHNiUErcFY4/WwcIcZzcADR36ZDTHkVtwIFyI8AXWWnShUVrKOIYKK2waILBtMGkVkuupKcoeWuVJijjPNILvvgmSQvDouJOKaEHeyawc7OZnhFgckhadZelQTkkcangJegwlje3PFvtvN5Fz9LH6GsuFT976LHYdDTK3O5eTgmcP3ZVXVbuaso//Uz3Bavuyv5qLy/mS1IW3hp8S54ec6KW/MNg5o5vX7MGQKxmGnt0TvtKBKziIU3hdRUgPa4Cm2PDy46C9Gtgi1mXuuTFollB5rGCeWWA0q1EN60JFk0P0N/sb+x6spx4ry2sn/tUgH3DisDms X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: When the shrinker encounter an existing folio in swap cache, it means we are shrinking into the warmer region. We should terminate shrinking if we're in the dynamic shrinker context. This patch add LRU_STOP to support this, to avoid overshrinking. Signed-off-by: Chengming Zhou Acked-by: Johannes Weiner Acked-by: Nhat Pham Reviewed-by: Yosry Ahmed --- include/linux/list_lru.h | 1 + mm/list_lru.c | 3 +++ mm/zswap.c | 4 +++- 3 files changed, 7 insertions(+), 1 deletion(-) diff --git a/include/linux/list_lru.h b/include/linux/list_lru.h index f2882a820690..5633e970144b 100644 --- a/include/linux/list_lru.h +++ b/include/linux/list_lru.h @@ -24,6 +24,7 @@ enum lru_status { LRU_SKIP, /* item cannot be locked, skip */ LRU_RETRY, /* item not freeable. May drop the lock internally, but has to return locked. */ + LRU_STOP, /* stop lru list walking */ }; struct list_lru_one { diff --git a/mm/list_lru.c b/mm/list_lru.c index 61f3b6b1134f..3fd64736bc45 100644 --- a/mm/list_lru.c +++ b/mm/list_lru.c @@ -243,6 +243,9 @@ __list_lru_walk_one(struct list_lru *lru, int nid, int memcg_idx, */ assert_spin_locked(&nlru->lock); goto restart; + case LRU_STOP: + assert_spin_locked(&nlru->lock); + goto out; default: BUG(); } diff --git a/mm/zswap.c b/mm/zswap.c index d8bb0e06e2b0..4381b7a2d4d6 100644 --- a/mm/zswap.c +++ b/mm/zswap.c @@ -1315,8 +1315,10 @@ static enum lru_status shrink_memcg_cb(struct list_head *item, struct list_lru_o * into the warmer region. We should terminate shrinking (if we're in the dynamic * shrinker context). */ - if (writeback_result == -EEXIST && encountered_page_in_swapcache) + if (writeback_result == -EEXIST && encountered_page_in_swapcache) { + ret = LRU_STOP; *encountered_page_in_swapcache = true; + } } else { zswap_written_back_pages++; }