From patchwork Thu Feb 1 15:49:04 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chengming Zhou X-Patchwork-Id: 13541310 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 BA8B9C4828D for ; Thu, 1 Feb 2024 15:50:36 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 530B16B009C; Thu, 1 Feb 2024 10:50:36 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 4B9056B009D; Thu, 1 Feb 2024 10:50:36 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 35A0E6B009E; Thu, 1 Feb 2024 10:50:36 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id 26D7E6B009C for ; Thu, 1 Feb 2024 10:50:36 -0500 (EST) Received: from smtpin18.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id DEC261205B9 for ; Thu, 1 Feb 2024 15:50:35 +0000 (UTC) X-FDA: 81743672430.18.02AD9C6 Received: from out-171.mta1.migadu.com (out-171.mta1.migadu.com [95.215.58.171]) by imf08.hostedemail.com (Postfix) with ESMTP id 06414160017 for ; Thu, 1 Feb 2024 15:50:33 +0000 (UTC) Authentication-Results: imf08.hostedemail.com; dkim=none; spf=pass (imf08.hostedemail.com: domain of chengming.zhou@linux.dev designates 95.215.58.171 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=1706802634; 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=I6+sO9JMMA3RtqRqlu5dPcLpUdnxswT8oHMiHI0DBBE=; b=bVGF4n/tg9uzSOMf6O4m6Ykcs8vmEKNkSGLjlckWWM/YAs7PeEf6B7q+ojwOFyaSvr6eYd kffpmypT/hLB99+up2ay9SGtfMT5SqdGP1uLWEAKForYJdFjketMYoPxkHM5kpWFpM9D8p /tgenjSTCOnr92U0/buXcN4RfSmCKOQ= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1706802634; a=rsa-sha256; cv=none; b=y4G7nJ5SW4yDlg6WeKgJYNY45YIQNt/1cWX7ghOVRCdcm3tlk6lc1/0GvLQBPLYWFGwSxO jJutRrqBVEo9qjghk47rRCVM15d0MVyriOE2cIPsiWr/yNFvkmkik5VUaO25vVI5oxTW8g GXN9draAh+3Jnfaq69sWxLyzdVtta64= ARC-Authentication-Results: i=1; imf08.hostedemail.com; dkim=none; spf=pass (imf08.hostedemail.com: domain of chengming.zhou@linux.dev designates 95.215.58.171 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) 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:04 +0000 Subject: [PATCH 4/6] mm/zswap: remove duplicate_entry debug value MIME-Version: 1.0 Message-Id: <20240201-b4-zswap-invalidate-entry-v1-4-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-Stat-Signature: ehq1x9i349tgopjo74j986iyian87d8u X-Rspamd-Server: rspam10 X-Rspamd-Queue-Id: 06414160017 X-Rspam-User: X-Rspamd-Pre-Result: action=add header; module=dmarc; Action set by DMARC X-Rspam: Yes X-HE-Tag: 1706802633-595577 X-HE-Meta: U2FsdGVkX19BOsRZ7m7NcRUey1GSYOZbYT80QKIw5vTKO0adityILdt5lY6fPU7EbzQYC4/fDGe+qBUZmdw7hl09Cgezm5EJUxgGKo2ciMsb4BiD9ukEzOfaUbtPlPBDPyEMYmytUDlo+Yb8su560v/4hFgJShVEMkPQlV6ivix4cr1/0H2gI2hY9TDCHgnmZHquOVSfMhQ9W4pYMD2ixSqksMilc6Mcnlu/IzSKefW67uFhPzsHM0yb19BAuVFeVFxoUVLkvDjydiz87OAl6T3EG54jGUsejGQdZ7+OAj64GoAPVAL5wfyIqHAGQLMPKe15/IP2tJr/Kx4AHA6eYmKX5e8ynOitEwD/A//H3ODG71CmQnzJHUpxiHK4A60ZB10T2X+2+f0HF0wTgyXqjTOYvOpBnl8JDEZriSwL5ppUi5E4i4vQcacz0ybHLOJVpYfklZWSFUhARkps29DLOIqgvg3kLAuQ5XpwdKgWEH1DEwK2WutKWS9EQg8NGc/SaTd8wByG7m2bgyCcfgvpZmPGdlJLA/HlFp05vKISoY/GD8FPHIQZcvftJFKJDc2+4nl9IEp9nTpKiq9gpR1Q13oPvNjOxGz5+cJSYDKNFxvd4E+2xWq/gJldSieyHjr7CZ0lzPVAT0NvWRL5nn4mT5tatoc2DUl2s3ln1653dgJnr/uDi3i2kUI5GCosU47O0SiJfRURkJyAAFVq/D+a1HUeDl4SSUHVhz2i3bx5KQOUp0wYoVBSZpm1DmYV0Ur2iykECceVh/BIS5fRoct4CD1YvzewWcRLxt1euvjkN+yihxYbX0QQYWZyuQhyRDeqW5tT3ltE53qyAf47+6wa9XGgXqH8VvwBAfOo64Jei6LEpMAjBlMGb6p6jSyLELZLge08Hd0BkPYlaJGLjkJJ3Ph2J1w6rKHvLDgDFQmQUKHTWhCG6/fAAV8mpt0kwFj0tgsBTp79KXHu7dI4Noz ++z4Zncs wnpDVcOdCge8FAIJxVDyl1Zbwx4KG8wLXR1EHzFgWKSQRVeEu/pam1I3H68gGcRARiteNlj6KKLD4tL/MMWajPz5Ee2FrREvr1xmBD4wrh6pqGW1W9G99knhSPxfFgrkm56c+WuxcfcI09cDbArSc5iayuTzvAqQ9h2xNOqxfHgjtkuzkdc2YFxHOLVP3j5+ldvhpNGASnB/XIRGt/mqatLpo7pVVvAOKfy4g8qe30hd45scfVFugJ/Rzt7E0GBM6/p0VphgRpE5wB8/hld/IZ4SeFXfZ3rm+UhglwZFgrpxOFkqmM20JIvC53+NLHbkVhs98t/bzqZMRdYldNfeHDIVOW89oEAZeGym77lm9zaGYSm2wg8S3VR67E0yEikaG03/nirQrrJwIDYeYKH17ejJsreYoJ+U5kFVq 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: cat /sys/kernel/debug/zswap/duplicate_entry 2086447 When testing, the duplicate_entry value is very high, but no warning message in the kernel log. From the comment of duplicate_entry "Duplicate store was encountered (rare)", it seems something goes wrong. Actually it's incremented in the beginning of zswap_store(), which found its zswap entry has already on the tree. And this is a normal case, since the folio could leave zswap entry on the tree after swapin, later it's dirtied and swapout/zswap_store again, found its original zswap entry. (Maybe we can reuse it instead of invalidating it?) So duplicate_entry should be only incremented in the real bug case, which already have "WARN_ON(1)", it looks redundant to count bug case, so this patch just remove it. Signed-off-by: Chengming Zhou Acked-by: Johannes Weiner Acked-by: Yosry Ahmed Reviewed-by: Nhat Pham --- mm/zswap.c | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/mm/zswap.c b/mm/zswap.c index 4381b7a2d4d6..3fbb7e2c8b8d 100644 --- a/mm/zswap.c +++ b/mm/zswap.c @@ -71,8 +71,6 @@ static u64 zswap_reject_compress_poor; static u64 zswap_reject_alloc_fail; /* Store failed because the entry metadata could not be allocated (rare) */ static u64 zswap_reject_kmemcache_fail; -/* Duplicate store was encountered (rare) */ -static u64 zswap_duplicate_entry; /* Shrinker work queue */ static struct workqueue_struct *shrink_wq; @@ -1571,10 +1569,8 @@ bool zswap_store(struct folio *folio) */ spin_lock(&tree->lock); entry = zswap_rb_search(&tree->rbroot, offset); - if (entry) { + if (entry) zswap_invalidate_entry(tree, entry); - zswap_duplicate_entry++; - } spin_unlock(&tree->lock); objcg = get_obj_cgroup_from_folio(folio); if (objcg && !obj_cgroup_may_zswap(objcg)) { @@ -1661,7 +1657,6 @@ bool zswap_store(struct folio *folio) */ while (zswap_rb_insert(&tree->rbroot, entry, &dupentry) == -EEXIST) { WARN_ON(1); - zswap_duplicate_entry++; zswap_invalidate_entry(tree, dupentry); } if (entry->length) { @@ -1822,8 +1817,6 @@ static int zswap_debugfs_init(void) zswap_debugfs_root, &zswap_reject_compress_poor); debugfs_create_u64("written_back_pages", 0444, zswap_debugfs_root, &zswap_written_back_pages); - debugfs_create_u64("duplicate_entry", 0444, - zswap_debugfs_root, &zswap_duplicate_entry); debugfs_create_u64("pool_total_size", 0444, zswap_debugfs_root, &zswap_pool_total_size); debugfs_create_atomic_t("stored_pages", 0444,