Message ID | 20240201-b4-zswap-invalidate-entry-v1-0-56ed496b6e55@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 C4692C4828D for <linux-mm@archiver.kernel.org>; Thu, 1 Feb 2024 15:50:20 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 4A3216B0098; Thu, 1 Feb 2024 10:50:20 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 41CA96B0099; Thu, 1 Feb 2024 10:50:20 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 2BD0C6B009A; Thu, 1 Feb 2024 10:50:20 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id 14F0A6B0098 for <linux-mm@kvack.org>; Thu, 1 Feb 2024 10:50:20 -0500 (EST) Received: from smtpin24.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id A1DC5140E11 for <linux-mm@kvack.org>; Thu, 1 Feb 2024 15:50:19 +0000 (UTC) X-FDA: 81743671758.24.6CD5EB6 Received: from out-172.mta1.migadu.com (out-172.mta1.migadu.com [95.215.58.172]) by imf26.hostedemail.com (Postfix) with ESMTP id B7105140023 for <linux-mm@kvack.org>; Thu, 1 Feb 2024 15:50:16 +0000 (UTC) Authentication-Results: imf26.hostedemail.com; dkim=none; dmarc=fail reason="SPF not aligned (relaxed), No valid DKIM" header.from=bytedance.com (policy=quarantine); spf=pass (imf26.hostedemail.com: domain of chengming.zhou@linux.dev designates 95.215.58.172 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=1706802617; 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=BOXSzkEYC68vAw698kd8n8eIYIrMz33UL2WgW/+0axE=; b=DqvPqKaJ8S+2eawz8bVgsglVX/JPs1AvA53hQB/qPAYS9rX6cRGWObpIn2hHCIKZOUmkXe plqr9Xd9tdHLxn7pnrVqf4bgRoRkXBuYbB5C7XMzKJvssuh9g2zcCOt+O5CvN9+F2FThUP s7gklK7MYTWOwaEF0sBkqWZYsB0H/ec= ARC-Authentication-Results: i=1; imf26.hostedemail.com; dkim=none; dmarc=fail reason="SPF not aligned (relaxed), No valid DKIM" header.from=bytedance.com (policy=quarantine); spf=pass (imf26.hostedemail.com: domain of chengming.zhou@linux.dev designates 95.215.58.172 as permitted sender) smtp.mailfrom=chengming.zhou@linux.dev ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1706802617; a=rsa-sha256; cv=none; b=Cfoo1hRu/tt5MF5LdhtQHlLePgaD2saSlSv0sJrGj63AjbjEkSbpGiT7EXoTbTMO5xOP+A +ukFYd3mlGwhH/ukx5H0kqzb5SiZzpUZFmGxJ+AhA7HzKky8S4QzkjIoK/2vCy0EVh5WIn YSIV4uBz7NXTVxUlhQc3/4S8HrNfhBU= Subject: [PATCH 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: H4sIAGy9u2UC/w3MTQqEMAxA4atI1gZqdabgbVIbxkCJ0viDinefLr/Few8YF2GDsXmg8CEmi1Z0bQ PTTPpjlFQN3vnBeddhHPC2k1YUPShLoo2RdSsXxhAS0ze43n+g9pGMMRbSaa4H3XN+3z91M6jccAAA AA== X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. From: Chengming Zhou <zhouchengming@bytedance.com> Date: Thu, 01 Feb 2024 15:49:00 +0000 Message-Id: <20240201-b4-zswap-invalidate-entry-v1-0-56ed496b6e55@bytedance.com> To: Nhat Pham <nphamcs@gmail.com>, Johannes Weiner <hannes@cmpxchg.org>, Andrew Morton <akpm@linux-foundation.org>, Yosry Ahmed <yosryahmed@google.com> Cc: linux-kernel@vger.kernel.org, Yosry Ahmed <yosryahmed@google.com>, Chengming Zhou <zhouchengming@bytedance.com>, Johannes Weiner <hannes@cmpxchg.org>, linux-mm@kvack.org X-Migadu-Flow: FLOW_OUT X-Rspam-User: X-Rspamd-Pre-Result: action=add header; module=dmarc; Action set by DMARC X-Stat-Signature: iiksekjoogtud4y63e6xdpcp71c5p97b X-Rspamd-Server: rspam07 X-Rspamd-Queue-Id: B7105140023 X-Rspam: Yes X-HE-Tag: 1706802616-981399 X-HE-Meta: U2FsdGVkX1/LcuKPaOM11bi6p7anW6FO+KcjSDFP3THZLrY+qDmucC38n63Qnc2wuvMuu1J6ZGiVHamcfNzhN94PdjZjk5WMpvNFPJ/4DUffc/Vs173FPwlqDp7Iz5wb3XOM+AlNeviMXt3vnox6CHPDFghUGhm/0FPJV97sJ8GULDF/hTXx25tWiAVjTdRTDlsj+lawHt0eTgKntz29bevH6RsCc90eMBiHbI4xz9mFiP4uQOY3PmR6jkf78WXYdkNlZ+rF/SPkChqXm53YmAD0zR0sMFi3wjxvWVhPEUsVlhFEFj0kehA1YOXK1/fGyDcvcvlWM/n/cTe8IaRlnumtZlYarf5LiiH11lai8BPycToBxf6jR9oT84us6YORo0kS2VSNY5U86VdBNt8D5hEaEMXxlGWQ0vCZEfs+5tbfWUHrLA0/xVqlvkB1wrCaEyJvz8+rbcIYMgVKtwRTp08A+0W31E3lSdNgoVZc43xTHJG+WNrYtuCL0/ANGkG78KN3tU0sjGl8efMJeiARext6eudujjD5TRA8hiQD7b9xsRB0k5LYo6WnP9WSPvJUdvCV3Vkve5W1tVm/HyW5GP43qbvY34szScP1S2CkiPsCJOnmIiBrWg1Kes9JuJYYhJ9upeHe1NIaCUoY5os+LbZh20AZzFsvVlJhTOedXApXFNkcqGmS73Y1gKCcvOWEfe469dAEC9cgptEqtN+2Ri7N/1ScHecogjovJpxQcNc9CiMeB5mN1JuxzhFBBp6OD0h6BQ6kCvpSZbb5t26JuSDM5djYadr96Fj70NYCSaE/whdzBig+pWkXT4XaF/JxE9t7lalmqrpmMUgNKPkUT1g7ZuB4p+hvXsD2MAQxnD4v42vudRGfE0a7QlfGwEDZK7kQyoBHuazAdvBrUvNyowymlhG3IEJz2LLLuHJGF4cRpBQizcUOZhbDGhel9neQ6Igf+TaCbaF+LHPn6fb wOvwEZuo WimzhXrGtxo6JL5V9zPON0roo7Xst3iGFQSGfYigyK74D2gGYtGUXFiu5fYpjMdVuHn0nWzMjbzY9EAvdQgrxH2iQUTrEPHPAckhkiceZ0TkSAInU4kgAT/gv54MYpsuf1LEt5rQ2/JsuXj5J1ZYwTZ8EGUAhwdoIzO1SEJEQe0jKlRv9LSdAKupsew/EetrvbWj3fxBdjtk4b8K7z/ZGblde8A2wBH1nWuuvgqCqNPGgkO+MpizVnrQg1ZNKo6M9//SrRPfXcPlcBLoeG+97M+rpqiNN1igT65Hr/YWFEt8ew5bImh1DyoHlgdagnwTEQ6Dw01irevNY1tLy98GNDl7xC3lZCXTokqXcYsccTSe7Dmo= 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
|
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. But it seems an unlikely case? I just send it out for discussion. Please see the commit for details. 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 | 1 + include/linux/zswap.h | 4 +- mm/Kconfig | 16 ------ mm/list_lru.c | 3 ++ mm/swap_slots.c | 2 + mm/swapfile.c | 1 - mm/zswap.c | 136 ++++++++++++++++------------------------------- 7 files changed, 54 insertions(+), 109 deletions(-) --- base-commit: 3a92c45e4ba694381c46994f3fde0d8544a2088b change-id: 20240201-b4-zswap-invalidate-entry-b77dea670325 Best regards,