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) {