Message ID | 20240201-b4-zswap-invalidate-entry-v2-0-99d4084260a0@bytedance.com (mailing list archive) |
---|---|
Headers | show
Return-Path: <owner-linux-mm@kvack.org> 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 49B2EC4828F for <linux-mm@archiver.kernel.org>; Sun, 4 Feb 2024 03:06:21 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id B02246B0072; Sat, 3 Feb 2024 22:06:20 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id AB22B6B0075; Sat, 3 Feb 2024 22:06:20 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 9A0846B0078; Sat, 3 Feb 2024 22:06:20 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id 8C2FA6B0072 for <linux-mm@kvack.org>; Sat, 3 Feb 2024 22:06:20 -0500 (EST) Received: from smtpin10.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id 8D0BC120581 for <linux-mm@kvack.org>; Sun, 4 Feb 2024 03:06:19 +0000 (UTC) X-FDA: 81752632878.10.2E3C5F8 Received: from out-171.mta1.migadu.com (out-171.mta1.migadu.com [95.215.58.171]) by imf10.hostedemail.com (Postfix) with ESMTP id 982B0C000C for <linux-mm@kvack.org>; Sun, 4 Feb 2024 03:06:16 +0000 (UTC) Authentication-Results: imf10.hostedemail.com; dkim=none; dmarc=fail reason="SPF not aligned (relaxed), No valid DKIM" header.from=bytedance.com (policy=quarantine); spf=pass (imf10.hostedemail.com: domain of chengming.zhou@linux.dev designates 95.215.58.171 as permitted sender) smtp.mailfrom=chengming.zhou@linux.dev ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1707015977; 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: references; bh=rOPoc7O8gKvqD/mSPVH46VlWQzQhw3kVLyTdS91cvpo=; b=BAndnfPhYSLOO8cAMaYWskH+3v8fQvnOMJOk8iQ8yR4GUAKthjOcHU2/F3xkAV5Qb6sF9X 3rXo9EYgAx7Y98x3sccMXy+S0IvKV9Cvl3JlolpcPReLLqIMXTMuEBn6uGChyQzoO76rkZ M0U7hqwJS5kJqSUq933Fkp3GeUrCU6c= ARC-Authentication-Results: i=1; imf10.hostedemail.com; dkim=none; dmarc=fail reason="SPF not aligned (relaxed), No valid DKIM" header.from=bytedance.com (policy=quarantine); spf=pass (imf10.hostedemail.com: domain of chengming.zhou@linux.dev designates 95.215.58.171 as permitted sender) smtp.mailfrom=chengming.zhou@linux.dev ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1707015977; a=rsa-sha256; cv=none; b=kVNXkwmXBN24vI4gazan6YQSkCvKkJGw9Ygd/Ua8mYFbZxWf3IL1jlBKYIdzwkmSaBrAL0 GI8ziPER1KBqW/Oon5LlTi3YBXBiUiXGKXG84AEHPlUKnTMUXNJlqzqjE6urwukMi/djQL XzOEcicmL3OoB6KTaywMShGo+1jvRPk= Subject: [PATCH v2 0/6] mm/zswap: optimize zswap lru list MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit X-b4-tracking: H4sIABb/vmUC/42NQQrCMBBFr1Jm7UgamxRd9R7iImkGO1BTSWKklt7dwRO4+rwP//0NMiWmDJdmg0 SVMy9RQB8aGCcX74QchEEr3SmtWvQdfvLbPZFjdTMHVwgplrSi7/tAzvbqpA3I3rtM6JOL4ySG+Jpn KSfOZUnr76+2Etd/1LVFhcZS6M7WWzJm8GuhIGo6jssDbvu+fwHL2bkYywAAAA== X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. From: Chengming Zhou <zhouchengming@bytedance.com> Date: Sun, 04 Feb 2024 03:05:58 +0000 Message-Id: <20240201-b4-zswap-invalidate-entry-v2-0-99d4084260a0@bytedance.com> To: Nhat Pham <nphamcs@gmail.com>, Yosry Ahmed <yosryahmed@google.com>, Andrew Morton <akpm@linux-foundation.org>, Johannes Weiner <hannes@cmpxchg.org> Cc: linux-mm@kvack.org, Nhat Pham <nphamcs@gmail.com>, Chengming Zhou <zhouchengming@bytedance.com>, linux-kernel@vger.kernel.org, Yosry Ahmed <yosryahmed@google.com>, Johannes Weiner <hannes@cmpxchg.org> X-Migadu-Flow: FLOW_OUT X-Rspam-User: X-Rspamd-Queue-Id: 982B0C000C X-Rspamd-Server: rspam12 X-Stat-Signature: 4bryf76mn6etpc1g8g8m3miobt6ndny7 X-Rspamd-Pre-Result: action=add header; module=dmarc; Action set by DMARC X-Rspam: Yes X-HE-Tag: 1707015976-673009 X-HE-Meta: U2FsdGVkX1+tozgUjH3SIuKMC1uBSVuY7+OZ9SRMmJUbjhOqDHrT5WazGQCnId9Lfzr2l5yOa1Ss2c0gjyCRRV2mfYiNnlZiq3ZmyF2gb2e6fWEjJNCLDI2v9ldTQrUiSZAr9KM8+BqEj2rm+Tk4XrVtXcmFfCn9m/tbe8MPkveGwVwssVQtcq1IINzCTr0ofdiOtMeEoHL6tolEWF/AfzWJkKgr8QmrHbuPrWb7MWxTYrdUlM0dZPqp0UKh9gankHQmCq+bd08pXafMB+YCheS/OyrAnX32ZpWkkbC28n9/Pzw4TEzPRXNu93kaRnSIeL2uC+iXVVR7viCy+eeiVyJFLjkwS85R+B4hmkzOQloE/7J2o85/M4uSFHw9TaqZ6GDIFJ2sLUAu1cpabqgf4Tz3AP6Wn5LMwSuSJQLqUcjSNfnboswGcfXeGolLP64NVorRDucLPFOxmG57bAj3K4DZTWch9eocM8TeMGumDd06bPpYJDnRFepYlNinM/K/GWazJRWtc/auAC2ZwryNirgjWu1wu5A3Vg9oxQefF9DnL32lMx5Shsm+sOwjJ6xXqRrwDEJ6qfPWv5tw1Tj66sp1PzCyx6fcYwBM07ZzW7sxnp+KYAueRcv+MQkG4ypWlUQa78vAQOmT5xTyBHhxNP7Iet7ZUikrkcZ52ILJfQR/lV2JdD1QXRKTIAsglYUZHQr7UWIlWrtqb2NBIbpmJxVKUd71pIEhie8yy9T81OYZ/7Bk/+4KnCgneAQaENHt4LG1Hegrozc3OUXKMcXLWCDXsA75M+/WtWPBOl75F2MMCIfCdZJ9Ts5tqloLWhO+2CtzEfmlpWUHs/pwIIVAroTJwYS+8oE0u+bCl6SZd0NXoGeyMAajXNYqU8mmtqeMod8TuiBii0tdX+eftd3Pfo4BLW0umOHUbFxaP74yMa36xm52WIGsOnjvWyz/20ZQ8K7BTFBnEsBm6otUcO4 dxJVRA83 VfpokiNLztNwcwKcjRUr6xeMKVA4fdQE8JPH5deExic/3F1MzsaAmAkWu6AehitMJcebPjcYM7AanzG6yVsk2yCFigLH01GRCZfupiUhy+UGQ0qCldOadiYdL9pbtBaGtp2Ba8Vs2ML1yxM+NO6sjajk3jS/4FlN9OmelAJYa0eYKrO2nKkhhcGtoexMNWjUCDjfP5S4Wmn40L+eL2DlDw8w6RsZpyJaVwPCy17y8//8XFbt6TYnGXsnPktSdrbu4016VaDtpNQytKOrmhRHCiooU2/6jhuwd6VSRaMSHPKQKlHyeTb+QTvBWZRfsgDWgSRCAdsBLtH5nN2sB95ESJ6XDz9HCT3JRVFZDzGQ4d0YZpWMtjo6PIiAaDz3pYu7cGbIYJeB6VPGUWpvETczKJMnXUCSimwo4j3x4bDd0GtTFbJY= 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: <linux-mm.kvack.org> List-Subscribe: <mailto:majordomo@kvack.org> List-Unsubscribe: <mailto:majordomo@kvack.org> |
Series |
mm/zswap: optimize zswap lru list
|
expand
|
Changes in v2: - Add comment above zswap_invalidate() to mention that large folio swap slot is not covered for now, per Yosry. - Add comment about locking behaviour of LRU_STOP, per Yosry. - Add the theory details and supportive testing results on why we choose the exclusive load as the default for zswap, per Johannes. - Collect tags. - Link to v1: https://lore.kernel.org/r/20240201-b4-zswap-invalidate-entry-v1-0-56ed496b6e55@bytedance.com Hi all, This series is motivated when observe the zswap lru list shrinking, noted there are some unexpected cases in zswap_writeback_entry(). bpftrace -e 'kr:zswap_writeback_entry {@[(int32)retval]=count()}' There are some -ENOMEM because when the swap entry is freed to per-cpu swap pool, it doesn't invalidate/drop zswap entry. Then the shrinker encounter these trashy zswap entries, it can't be reclaimed and return -ENOMEM. So moves the invalidation ahead to when swap entry freed to the per-cpu swap pool, since there is no any benefit to leave trashy zswap entries on the zswap tree and lru list. Another case is -EEXIST, which is seen more in the case of !zswap_exclusive_loads_enabled, in which case the swapin folio will leave compressed copy on the tree and lru list. And it can't be reclaimed until the folio is removed from swapcache. Changing to zswap_exclusive_loads_enabled mode will invalidate when folio swapin, which has its own drawback if that folio is still clean in swapcache and swapout again, we need to compress it again. Please see the commit for details on why we choose exclusive load as the default for zswap. Another optimization for -EEXIST is that we add LRU_STOP to support terminating the shrinking process to avoid evicting warmer region. Testing using kernel build in tmpfs, one 50GB swapfile and zswap shrinker_enabled, with memory.max set to 2GB. mm-unstable zswap-optimize real 63.90s 63.25s user 1064.05s 1063.40s sys 292.32s 270.94s The main optimization is in sys cpu, about 7% improvement. Thanks for review and comments! Signed-off-by: Chengming Zhou <zhouchengming@bytedance.com> --- Chengming Zhou (6): mm/zswap: add more comments in shrink_memcg_cb() mm/zswap: invalidate zswap entry when swap entry free mm/zswap: stop lru list shrinking when encounter warm region mm/zswap: remove duplicate_entry debug value mm/zswap: only support zswap_exclusive_loads_enabled mm/zswap: zswap entry doesn't need refcount anymore include/linux/list_lru.h | 2 + include/linux/zswap.h | 4 +- mm/Kconfig | 16 ------ mm/list_lru.c | 3 ++ mm/swap_slots.c | 3 ++ mm/swapfile.c | 1 - mm/zswap.c | 136 ++++++++++++++++------------------------------- 7 files changed, 56 insertions(+), 109 deletions(-) --- base-commit: 3a92c45e4ba694381c46994f3fde0d8544a2088b change-id: 20240201-b4-zswap-invalidate-entry-b77dea670325 Best regards,