From patchwork Mon Feb 19 13:33:51 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chengming Zhou X-Patchwork-Id: 13562696 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 76A64C54764 for ; Mon, 19 Feb 2024 13:34:29 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id EF1D98D0001; Mon, 19 Feb 2024 08:34:28 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id EA27B6B007E; Mon, 19 Feb 2024 08:34:28 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id D41F08D0001; Mon, 19 Feb 2024 08:34:28 -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 C1A7D6B007D for ; Mon, 19 Feb 2024 08:34:28 -0500 (EST) Received: from smtpin25.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id 70A8EA03D3 for ; Mon, 19 Feb 2024 13:34:28 +0000 (UTC) X-FDA: 81808647816.25.64C6744 Received: from out-173.mta0.migadu.com (out-173.mta0.migadu.com [91.218.175.173]) by imf22.hostedemail.com (Postfix) with ESMTP id 9FAE1C0017 for ; Mon, 19 Feb 2024 13:34:25 +0000 (UTC) Authentication-Results: imf22.hostedemail.com; dkim=none; dmarc=fail reason="SPF not aligned (relaxed), No valid DKIM" header.from=bytedance.com (policy=quarantine); spf=pass (imf22.hostedemail.com: domain of chengming.zhou@linux.dev designates 91.218.175.173 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=1708349665; 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=ay0YbKxzCk9wsK3H/YNq28p1HPE723j9j853ir3WbuI=; b=e2dVb92j9BK4JZMMbceBCzPj8Q0pdyzqy5eEMccTw+EhfRCri1AgvzStB/WDZYuj0US+kf 0gIMg/nfVItTA8oHpkN5zZys8s8Y2PlhTnXbhWiergWTknVmB6QefOxUT06t3qULNlj5xK Ihuva1bDvYm4L9DEF6psFEJpv1WKAHg= ARC-Authentication-Results: i=1; imf22.hostedemail.com; dkim=none; dmarc=fail reason="SPF not aligned (relaxed), No valid DKIM" header.from=bytedance.com (policy=quarantine); spf=pass (imf22.hostedemail.com: domain of chengming.zhou@linux.dev designates 91.218.175.173 as permitted sender) smtp.mailfrom=chengming.zhou@linux.dev ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1708349665; a=rsa-sha256; cv=none; b=MR/FQZV+ri8jqR5EEkplrJ61rvb4nrFMcLJSCyqaGr8SFediFOLzgrHC35ZlRG64ALBDrI NK3PcRpFPZabRPDND2UAxjxZHk16DA1H1Dki7JmzS1uiriRJB4mK0KVYOI/DI4ZgJGd1X+ L6nqM7q4+kFBZ2y9VLEnF0ipGvDN/Xo= X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. From: Chengming Zhou Date: Mon, 19 Feb 2024 13:33:51 +0000 Subject: [PATCH 1/3] mm/zsmalloc: fix migrate_write_lock() when !CONFIG_COMPACTION MIME-Version: 1.0 Message-Id: <20240219-b4-szmalloc-migrate-v1-1-34cd49c6545b@bytedance.com> References: <20240219-b4-szmalloc-migrate-v1-0-34cd49c6545b@bytedance.com> In-Reply-To: <20240219-b4-szmalloc-migrate-v1-0-34cd49c6545b@bytedance.com> To: nphamcs@gmail.com, yosryahmed@google.com, Sergey Senozhatsky , Minchan Kim , Andrew Morton , hannes@cmpxchg.org Cc: linux-mm@kvack.org, Chengming Zhou , linux-kernel@vger.kernel.org X-Migadu-Flow: FLOW_OUT X-Rspamd-Queue-Id: 9FAE1C0017 X-Rspamd-Server: rspam02 X-Rspam-User: X-Stat-Signature: ksundozuxtfhuyjezqekgu6mxu5cyrer X-Rspamd-Pre-Result: action=add header; module=dmarc; Action set by DMARC X-Rspam: Yes X-HE-Tag: 1708349665-274307 X-HE-Meta: U2FsdGVkX1+No6ry/UpKdgdfao0WZo50qBslU8KPk9lPEQPRaHI0GadrQ7YRtvc97yjTqg2/Din8GE5KB/LISp5XNp8DN5Wpuj/1XytzwPz0hApwmYez0+PqE9DTHizsiM0JqSStQZ9yYqIc8q9b2ePQwg1IVBLWCEHm71WSFSN/PTrmrmBbKbT6qIvQEccmVpxc7pJDR9Migi6kfg2ddugYd/9kRQS6KYZCqhxHCSugZr3r7RLqBFyQnZLMQ4a9eC3m6fg9IAPn0tQ5csanwj9KQ21hHAHLEYem3QuFpXkzDl+7v6JxC/K9hGS88tLFznQRrMpdWlcUIOuw2LdQHaBnbrthFGxMC3fXXIZyAjvivz/LP+khznBKqeW9UBK0zkMZrUCXDFt4o702eD4ybQKEf1zNyRy5b0dEaiklwkktsenZavuVlhaYKfTJ0f9iXfhopvBD7xxX54Cq/fwqbltQf2l0mjHW1QzYxY/P77LQryvKZEb9ypwb22ATGtqKMErJHPDyfjssm9QuzaCZ1jH8RbtCdE4+ZWgMEJw3XVK8NEutqji+OrM2kb1+gAGBv62pD5NSTpWV/SPiAArERvMc4MWBzRncrhrt6q9r9jRbR0AAyX5Fxwrr2W3Od+Lqsn3xfUaTNbNgvVD9nAB1KH71u+IwbTu6byOvCOl1xz/y6JpdDs6t6Z3zfIdYT+Uni972Uk71wb1itvRpL09rckGcgLZKs/QyYlGMPKWjOKrfqtdq+xagApnb3eRnNSUnau4g58v2DD9fbxnCazcpqCEYLMXRrUo+3mLjXWYr/d8+JcoEuXj5honWusyW7Bj0f0eMS0Vf7S+SyAcMlCLSojOEQTvrG562CMHQoub7xeEvF3dtP3WsRgXbYL//gpetaA7HNPKm+fYUUOG6rEHQb9Y1j/2hu7AJL9k102C7M7Xnx476byMjQyA5y6Kfw60gMA8wo7AXO1wDqSBdNWS uBPnD2n1 pN3yZLNLpQtVC0CohuOoulgLteeu4zlajpVhfaGNf8Brze8GbojQGAvJgTxU46uS9vUZPC2ds74VbJbnMNoC2s5knd1pXxuT2RqpFfw8/wueC3TjZSN0nVnQZUPoPprmq+vxV39YCxjrB9UdSCzfhI2EwfDxXVVckTvRmMAr6QGo1FgFDVJoytgpb1WA4pWGU15EA/Kk2iNctcgczY4tyclh9rWqPOcYUlYkXJLx8m8MMxpJ0YMurS3POd8QEHrfJOMwuj/yZRkbVTAXrJRw9WVrT3ePIBBtqFTaxOe9tNGGe9cXn0BuPrh5NwDhZuke6UIvBPwL+QlaWubbDZ5Apdz5V2CQ8EzGyS1O3KBj2YEDtPZ8SKg+SUGkwUhP3L1zpfr1qvPyvuyIc0s3RR90kOC7rGAEk/sDG8lQ5 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: migrate_write_lock() is a empty function when !CONFIG_COMPACTION, in which case zs_compact() can be triggered from shrinker reclaim context. (Maybe it's better to rename it to zs_shrink()?) And zspage map object users rely on this migrate_read_lock() so object won't be migrated elsewhere. Fix it by always implementing the migrate_write_lock() related functions. Signed-off-by: Chengming Zhou --- mm/zsmalloc.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/mm/zsmalloc.c b/mm/zsmalloc.c index c937635e0ad1..64d5533fa5d8 100644 --- a/mm/zsmalloc.c +++ b/mm/zsmalloc.c @@ -278,18 +278,15 @@ static bool ZsHugePage(struct zspage *zspage) static void migrate_lock_init(struct zspage *zspage); static void migrate_read_lock(struct zspage *zspage); static void migrate_read_unlock(struct zspage *zspage); - -#ifdef CONFIG_COMPACTION static void migrate_write_lock(struct zspage *zspage); static void migrate_write_lock_nested(struct zspage *zspage); static void migrate_write_unlock(struct zspage *zspage); + +#ifdef CONFIG_COMPACTION static void kick_deferred_free(struct zs_pool *pool); static void init_deferred_free(struct zs_pool *pool); static void SetZsPageMovable(struct zs_pool *pool, struct zspage *zspage); #else -static void migrate_write_lock(struct zspage *zspage) {} -static void migrate_write_lock_nested(struct zspage *zspage) {} -static void migrate_write_unlock(struct zspage *zspage) {} static void kick_deferred_free(struct zs_pool *pool) {} static void init_deferred_free(struct zs_pool *pool) {} static void SetZsPageMovable(struct zs_pool *pool, struct zspage *zspage) {} @@ -1725,7 +1722,6 @@ static void migrate_read_unlock(struct zspage *zspage) __releases(&zspage->lock) read_unlock(&zspage->lock); } -#ifdef CONFIG_COMPACTION static void migrate_write_lock(struct zspage *zspage) { write_lock(&zspage->lock); @@ -1741,6 +1737,7 @@ static void migrate_write_unlock(struct zspage *zspage) write_unlock(&zspage->lock); } +#ifdef CONFIG_COMPACTION /* Number of isolated subpage for *page migration* in this zspage */ static void inc_zspage_isolation(struct zspage *zspage) { From patchwork Mon Feb 19 13:33:52 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chengming Zhou X-Patchwork-Id: 13562697 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 1B158C48BC3 for ; Mon, 19 Feb 2024 13:34:31 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 09B758D0003; Mon, 19 Feb 2024 08:34:30 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id E7A9E6B007E; Mon, 19 Feb 2024 08:34:29 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id D1E1F8D0003; Mon, 19 Feb 2024 08:34:29 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id C47066B007D for ; Mon, 19 Feb 2024 08:34:29 -0500 (EST) Received: from smtpin13.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id 8C17B803AA for ; Mon, 19 Feb 2024 13:34:29 +0000 (UTC) X-FDA: 81808647858.13.2496E56 Received: from out-187.mta0.migadu.com (out-187.mta0.migadu.com [91.218.175.187]) by imf02.hostedemail.com (Postfix) with ESMTP id 9F05780002 for ; Mon, 19 Feb 2024 13:34:27 +0000 (UTC) Authentication-Results: imf02.hostedemail.com; dkim=none; dmarc=fail reason="SPF not aligned (relaxed), No valid DKIM" header.from=bytedance.com (policy=quarantine); spf=pass (imf02.hostedemail.com: domain of chengming.zhou@linux.dev designates 91.218.175.187 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=1708349667; 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=HFxfZiBGJL+IWtJOH0RqN6bAv8R7z/wfJobmcJajs8E=; b=HuMUrzAQ55S5JlFq8543exw949ZBuKSgJF2FOTjTrd3nHQbXz8a/FYqHWk4DohOgWiDNe/ b1qzCEp9fAkUIdNMUaVodtnq0zw5EEAeFkvoKK4Di5DYEiTvpzbuOifOa7BMOcMl8Ul/Ki +eZHQAiB0W1+lHGJRRixGaeZ/6hKmSo= ARC-Authentication-Results: i=1; imf02.hostedemail.com; dkim=none; dmarc=fail reason="SPF not aligned (relaxed), No valid DKIM" header.from=bytedance.com (policy=quarantine); spf=pass (imf02.hostedemail.com: domain of chengming.zhou@linux.dev designates 91.218.175.187 as permitted sender) smtp.mailfrom=chengming.zhou@linux.dev ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1708349667; a=rsa-sha256; cv=none; b=h1tarnImDjJ9fkluY/3vTO1Pm/dgP9LqiLczMtxvppovQs/Pg63U6EV3hmD5FXRPfEOHGs ocN4yDh32L3JMJW007QICOwzq4E2V9mM5z0QQGseQDspmlg/nB3nVpe3aMpyzDyqiDfATe q6XmZ4cVF517gjyZYa8WEAY86lwMmQk= X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. From: Chengming Zhou Date: Mon, 19 Feb 2024 13:33:52 +0000 Subject: [PATCH 2/3] mm/zsmalloc: remove migrate_write_lock_nested() MIME-Version: 1.0 Message-Id: <20240219-b4-szmalloc-migrate-v1-2-34cd49c6545b@bytedance.com> References: <20240219-b4-szmalloc-migrate-v1-0-34cd49c6545b@bytedance.com> In-Reply-To: <20240219-b4-szmalloc-migrate-v1-0-34cd49c6545b@bytedance.com> To: nphamcs@gmail.com, yosryahmed@google.com, Sergey Senozhatsky , Minchan Kim , Andrew Morton , hannes@cmpxchg.org Cc: linux-mm@kvack.org, Chengming Zhou , linux-kernel@vger.kernel.org X-Migadu-Flow: FLOW_OUT X-Rspamd-Pre-Result: action=add header; module=dmarc; Action set by DMARC X-Rspam-User: X-Rspamd-Queue-Id: 9F05780002 X-Rspamd-Server: rspam05 X-Stat-Signature: dudusq9gi7z7h37dyds38agfsezakqko X-Rspam: Yes X-HE-Tag: 1708349667-141997 X-HE-Meta: U2FsdGVkX1/gUPYqyMCJtKFKu/U1L9eMSo32J1mhoP3vR/JtcR6ojU1m9TvRJiRyVzUTwOy1lKS24GqTL6unoZbiH8z61KTtdLdVTreROkWdquYsZ9GhYT8Hp7xnrfhXTFMXe/40vuK/PV3qv+BUfDi8ZnmXNQobjgHIXRYDPN1TbbkfLd+Zd5EuBpUeozanbpsRhC9w2AuC8o9aOA+oglCYmQ4NozY2FR114Lgpo81ZekCjGeuMk0U/sAfcZd5U+GtQrWI2ji6skdp3bfd/CjjK5cTSwgxE2okm+Mjmrz8E96HAF3i4uiKhE7O2GcEm4i6Am4md33nTXe0NxmKUs4om7KNEQvXpAzVYJUNdldDzq4o8W966XUYBJ4w5AOzk3rph6Lr7kmLvd9YgUuk8Ib1Nxsgt/7U/YRoLouSn2CcuyDkQ9pSRb06sMSYmhd1UCpby7mNzyR6NpwoLdEMR/tc0UcnMDyKEu5HCD7YGsfdEOzqTe8FiUOrCf7rV4WGuIaSDKFAHSMX+H1Cryra+an8yB7CipPnfYR7kDx0HMvrDq54Uvbf1QkQ3JtxnZcZkg2mjMP6A7VkrCKy7wvq7G/nqgkht2W6Ev7lL3rXrfAYS07TQCgLpLNg5O6Zt3ixAYA+dOCR9wq3MQ6WxITboJLuxRn+/Ido0ICnzchuAwxEmHPbaUr0AkNJCOb0AhLr88fsdaHb051v77KZipJh9S8iX5aIra31qvOHrsJZbi91tIZv8pGEGXglynH8jgoTnI45VFfg2U2OYb2sYW+pwJHOwRSNar/pgjr0he923BH12Sgpoy54GNVkKeZW8e/zs9B7Jf7KSlPetVQTLp8suBwISbTUNW0dwyDCcR7NRnyZ7W5aQI9KjGt35TLp/9XUAJxXBYvVUKUElrbNryUNiDT0wDpFyhj73RkEib0o20KLEfTVTbtA1frEP6xGBK35b1grJGudsv5zoRPMRepu zwbZrCgi tGEIYaULC6KzF4076qQw0iq40/QJqmgsrcZp353wA1zhL60Q06kH475Tr2T79WClf4pQnMdoJ+DETK8QjBDWVPciUgfkYapdwlR8dvaTC9n+Pnio1itIaKDR7WnyGcOR6yiVv9dUanSN5QeOlot7j3mWUs3EJ5ZRfegMwe1e/1SwRn4x5kS4Y2Exjweboyg/hyxUqm2a2gIIQSk60oVXGqPQ3Itl31kzHZfTqKw/Y2hi7VgPpJBa/MUxhAr3G6zkZ4waVjb7tdqtONWcxRKwpJg1mMEq6hHCv3v01o1HlwOAbRGqTG37Vs07wRgduLZBewJqlsOZZEDi8UUMJSbwjd0bYl58b3fx+Vo5XTf73MMEm7HpTnWazX/HKjw== 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: The migrate write lock is to protect the race between zspage migration and zspage objects' map users. We only need to lock out the map users of src zspage, not dst zspage, which is safe to map by users concurrently, since we only need to do obj_malloc() from dst zspage. So we can remove the migrate_write_lock_nested() use case. As we are here, cleanup the __zs_compact() by moving putback_zspage() outside of migrate_write_unlock since we hold pool lock, no malloc or free users can come in. Signed-off-by: Chengming Zhou --- mm/zsmalloc.c | 22 +++++----------------- 1 file changed, 5 insertions(+), 17 deletions(-) diff --git a/mm/zsmalloc.c b/mm/zsmalloc.c index 64d5533fa5d8..f2ae7d4c6f21 100644 --- a/mm/zsmalloc.c +++ b/mm/zsmalloc.c @@ -279,7 +279,6 @@ static void migrate_lock_init(struct zspage *zspage); static void migrate_read_lock(struct zspage *zspage); static void migrate_read_unlock(struct zspage *zspage); static void migrate_write_lock(struct zspage *zspage); -static void migrate_write_lock_nested(struct zspage *zspage); static void migrate_write_unlock(struct zspage *zspage); #ifdef CONFIG_COMPACTION @@ -1727,11 +1726,6 @@ static void migrate_write_lock(struct zspage *zspage) write_lock(&zspage->lock); } -static void migrate_write_lock_nested(struct zspage *zspage) -{ - write_lock_nested(&zspage->lock, SINGLE_DEPTH_NESTING); -} - static void migrate_write_unlock(struct zspage *zspage) { write_unlock(&zspage->lock); @@ -2003,19 +1997,17 @@ static unsigned long __zs_compact(struct zs_pool *pool, dst_zspage = isolate_dst_zspage(class); if (!dst_zspage) break; - migrate_write_lock(dst_zspage); } src_zspage = isolate_src_zspage(class); if (!src_zspage) break; - migrate_write_lock_nested(src_zspage); - + migrate_write_lock(src_zspage); migrate_zspage(pool, src_zspage, dst_zspage); - fg = putback_zspage(class, src_zspage); migrate_write_unlock(src_zspage); + fg = putback_zspage(class, src_zspage); if (fg == ZS_INUSE_RATIO_0) { free_zspage(pool, class, src_zspage); pages_freed += class->pages_per_zspage; @@ -2025,7 +2017,6 @@ static unsigned long __zs_compact(struct zs_pool *pool, if (get_fullness_group(class, dst_zspage) == ZS_INUSE_RATIO_100 || spin_is_contended(&pool->lock)) { putback_zspage(class, dst_zspage); - migrate_write_unlock(dst_zspage); dst_zspage = NULL; spin_unlock(&pool->lock); @@ -2034,15 +2025,12 @@ static unsigned long __zs_compact(struct zs_pool *pool, } } - if (src_zspage) { + if (src_zspage) putback_zspage(class, src_zspage); - migrate_write_unlock(src_zspage); - } - if (dst_zspage) { + if (dst_zspage) putback_zspage(class, dst_zspage); - migrate_write_unlock(dst_zspage); - } + spin_unlock(&pool->lock); return pages_freed; From patchwork Mon Feb 19 13:33:53 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chengming Zhou X-Patchwork-Id: 13562698 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 5405AC48BF8 for ; Mon, 19 Feb 2024 13:34:33 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id D92708D0005; Mon, 19 Feb 2024 08:34:31 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id D439D6B007E; Mon, 19 Feb 2024 08:34:31 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id AD28F8D0005; Mon, 19 Feb 2024 08:34:31 -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 99A2B6B007D for ; Mon, 19 Feb 2024 08:34:31 -0500 (EST) Received: from smtpin27.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id 68C46A03C4 for ; Mon, 19 Feb 2024 13:34:31 +0000 (UTC) X-FDA: 81808647942.27.DCFDB43 Received: from out-180.mta0.migadu.com (out-180.mta0.migadu.com [91.218.175.180]) by imf27.hostedemail.com (Postfix) with ESMTP id A08A840026 for ; Mon, 19 Feb 2024 13:34:29 +0000 (UTC) Authentication-Results: imf27.hostedemail.com; dkim=none; spf=pass (imf27.hostedemail.com: domain of chengming.zhou@linux.dev designates 91.218.175.180 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=1708349669; 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=FB3wHGJgRL5d+Axn88/lWUMH/HggPplS++B6a9lglMM=; b=EJFsZ0ukr6bxvgdhfEQgCusbvXssscTdk35x+QByuYbww27k1WaXxU37c6gUvkqN83P3IR eDu8FzzF32oRhYPTrhi6ePURviZ0ZrEcv8C5tuoXeqJ8DeXFWwWqnFWer14+5m9p+CAGBC Mrzh+acjfPcRlyTlPr9hn5ipozbrIoY= ARC-Authentication-Results: i=1; imf27.hostedemail.com; dkim=none; spf=pass (imf27.hostedemail.com: domain of chengming.zhou@linux.dev designates 91.218.175.180 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=1708349669; a=rsa-sha256; cv=none; b=WtTAsrab5JcUzFjFi4Y2MlVbczB0B/mowt7HsTzfv2ECcmLxuIyyNHT7+D7+42P8PloTqW pdNNvQ3PLd6P1TwKRIxNFFk+cNpHxtDaqedbYoIDiDYsXE+8SJ8Im5Wo8y8izhgfR4MgKZ SILafG3Q0bHkOrlJAC8EENjp008tQSo= X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. From: Chengming Zhou Date: Mon, 19 Feb 2024 13:33:53 +0000 Subject: [PATCH 3/3] mm/zsmalloc: remove unused zspage->isolated MIME-Version: 1.0 Message-Id: <20240219-b4-szmalloc-migrate-v1-3-34cd49c6545b@bytedance.com> References: <20240219-b4-szmalloc-migrate-v1-0-34cd49c6545b@bytedance.com> In-Reply-To: <20240219-b4-szmalloc-migrate-v1-0-34cd49c6545b@bytedance.com> To: nphamcs@gmail.com, yosryahmed@google.com, Sergey Senozhatsky , Minchan Kim , Andrew Morton , hannes@cmpxchg.org Cc: linux-mm@kvack.org, Chengming Zhou , linux-kernel@vger.kernel.org X-Migadu-Flow: FLOW_OUT X-Rspamd-Queue-Id: A08A840026 X-Rspamd-Pre-Result: action=add header; module=dmarc; Action set by DMARC X-Rspam-User: X-Stat-Signature: 9o5j9sxa1mqk97ge8zargjxffpo1yqgt X-Rspamd-Server: rspam01 X-Rspam: Yes X-HE-Tag: 1708349669-378582 X-HE-Meta: U2FsdGVkX1+Y2+URIxLg051cGmMEkTpMc63108CKqmt1SoOJE/OAGkbKccQi6MhRaRe1J8LB//NLykw5WCOstN11ZIuvTLsfm2Z0lsKLDZEQHe/zq9+tOX8sMSpVEVCBCUKgSAjD7eL2upDLFMzTeCb0439yXbQ9s2/ayDcr13LH0vSTV3kworni9ICWnApzhL6au1f1wQZ2w+rP+BUZiGTylsjpUOVKnXHLk9DueZ/KRYM5SThndqHMc546msvE3MbriYhFMjuxLJb/iN4/jqPafycddB22qpw4Mg/T441kvkLBCgv0yVboNzncucDgZtuf2Xa2AqnEnOHBYi2sXCE6jX+nRrnRnf40QSYhSmQRiQBnjCmMIFYKYnpWGY93/tRfv4ldJDjEexJXBdH56YmN8jlVf4NvYilTJdRIBYNL3/3nJGU/nkJmzYujYdmXzaxu/R9v74rtPoHBOAV96r58fAAugm1vNstV1C4z1I44xF2QBx7DZn38I/IHbyeKsqTqKhCJD/0PCM2ZNJnTMXfo7XmbAHc3f6vIh257HTPMpVadHARcaL431EPi/Vm6g8rIaw/dcq1PmyFJA83/iTmzMv/79p9PCpUCYvtOLGml0cxXmJWHWwsoKMZvPMuZ/CYWP6x9znr/6SHN1xXjWpCpM1ugby3PEnkfgLB4IyeIvQusGiVQMXJbZm2d5p/t89oQvVDzQ24wRM8zPFWVqFZmS9SpmJ8MwkJuYTtJG4GbkY9epQfOvHVtw2Y5XZ8wvqBEc2zWaQIoJYmI0gyCiI1+TeodJzxuDZjUuLtpHFH4mXXyKhE9Hs/VD2xNAiUP+/iG5tMz/z+9NCmhYnBLw6VRcsmhcQ4gO4ZegYVkfOjmwyZKO/ZUQ0umTieu3BKyE6sUSzNsOuN65QoqzcqNNdeX39ggCQ5aJ6Zo6NqUtYO9ew2xGa55fUmjWzcR6aZGBs58aLxxgUxZMaF9lAK 00OPhPAu SZX6fhUotP2R+Pwr3wMPD7ffUWIOxKdG21dU+YPNASm62KMlJqFqltoT/7ohWtgZj0XCuhu5If00Sv17aijrGSjcuwW0dvKZIorocb2pNlVsWyR1Uux6Yjx0weAyXubHZIv+JSUBFq3jegrrYIS3gZUDvbE68saNU4wNmmyvyZDCtWlc80Ik7L9pZrsyOQJw+zjdJQq2Z0mPknwG2FcS1UDP0AdPTLeoLsYvH7CObQCajwqNO4nle9v/xderuwdWtfstBLkHCDnoqOb70jenw6MSQjQdTD+yVFKKwrqvPUB/fdTtWahfiy+SSnchB3GXORFJErIawRC7wNuU= 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: The zspage->isolated is not used anywhere, we don't need to maintain it, which needs to hold the heavy pool lock to update it, so just remove it. Signed-off-by: Chengming Zhou --- mm/zsmalloc.c | 32 -------------------------------- 1 file changed, 32 deletions(-) diff --git a/mm/zsmalloc.c b/mm/zsmalloc.c index f2ae7d4c6f21..a48f4651d143 100644 --- a/mm/zsmalloc.c +++ b/mm/zsmalloc.c @@ -116,7 +116,6 @@ #define HUGE_BITS 1 #define FULLNESS_BITS 4 #define CLASS_BITS 8 -#define ISOLATED_BITS 5 #define MAGIC_VAL_BITS 8 #define MAX(a, b) ((a) >= (b) ? (a) : (b)) @@ -246,7 +245,6 @@ struct zspage { unsigned int huge:HUGE_BITS; unsigned int fullness:FULLNESS_BITS; unsigned int class:CLASS_BITS + 1; - unsigned int isolated:ISOLATED_BITS; unsigned int magic:MAGIC_VAL_BITS; }; unsigned int inuse; @@ -1732,17 +1730,6 @@ static void migrate_write_unlock(struct zspage *zspage) } #ifdef CONFIG_COMPACTION -/* Number of isolated subpage for *page migration* in this zspage */ -static void inc_zspage_isolation(struct zspage *zspage) -{ - zspage->isolated++; -} - -static void dec_zspage_isolation(struct zspage *zspage) -{ - VM_BUG_ON(zspage->isolated == 0); - zspage->isolated--; -} static const struct movable_operations zsmalloc_mops; @@ -1771,21 +1758,12 @@ static void replace_sub_page(struct size_class *class, struct zspage *zspage, static bool zs_page_isolate(struct page *page, isolate_mode_t mode) { - struct zs_pool *pool; - struct zspage *zspage; - /* * Page is locked so zspage couldn't be destroyed. For detail, look at * lock_zspage in free_zspage. */ VM_BUG_ON_PAGE(PageIsolated(page), page); - zspage = get_zspage(page); - pool = zspage->pool; - spin_lock(&pool->lock); - inc_zspage_isolation(zspage); - spin_unlock(&pool->lock); - return true; } @@ -1850,7 +1828,6 @@ static int zs_page_migrate(struct page *newpage, struct page *page, kunmap_atomic(s_addr); replace_sub_page(class, zspage, newpage, page); - dec_zspage_isolation(zspage); /* * Since we complete the data copy and set up new zspage structure, * it's okay to release the pool's lock. @@ -1872,16 +1849,7 @@ static int zs_page_migrate(struct page *newpage, struct page *page, static void zs_page_putback(struct page *page) { - struct zs_pool *pool; - struct zspage *zspage; - VM_BUG_ON_PAGE(!PageIsolated(page), page); - - zspage = get_zspage(page); - pool = zspage->pool; - spin_lock(&pool->lock); - dec_zspage_isolation(zspage); - spin_unlock(&pool->lock); } static const struct movable_operations zsmalloc_mops = {