From patchwork Wed Jul 3 04:05:50 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: alexs@kernel.org X-Patchwork-Id: 13721070 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 46443C2BD09 for ; Wed, 3 Jul 2024 04:01:16 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 9B2B26B007B; Wed, 3 Jul 2024 00:01:15 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 93BE76B0082; Wed, 3 Jul 2024 00:01:15 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 766B06B0085; Wed, 3 Jul 2024 00:01:15 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id 54E2B6B007B for ; Wed, 3 Jul 2024 00:01:15 -0400 (EDT) Received: from smtpin02.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id B33AE120706 for ; Wed, 3 Jul 2024 04:01:14 +0000 (UTC) X-FDA: 82297091268.02.3C290E0 Received: from sin.source.kernel.org (sin.source.kernel.org [145.40.73.55]) by imf11.hostedemail.com (Postfix) with ESMTP id 79DAC4000C for ; Wed, 3 Jul 2024 04:01:12 +0000 (UTC) Authentication-Results: imf11.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=UE0z8PvQ; dmarc=pass (policy=none) header.from=kernel.org; spf=pass (imf11.hostedemail.com: domain of alexs@kernel.org designates 145.40.73.55 as permitted sender) smtp.mailfrom=alexs@kernel.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1719979255; a=rsa-sha256; cv=none; b=YXHkPX+0foSshdTP6IX/NpaFuax2dYEC81dvh8DTpuJJVdIk59hiahQaA9DhSORSVAqOOR dr1zww2csXCq11tLtoDW8enCjgaQ35s330FgAzKLhhhQ+W2xeRDnTaw7jBOpyEyJ9VIINU kmTTGtQJgaDIfyHzde0pAwrbOts436k= ARC-Authentication-Results: i=1; imf11.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=UE0z8PvQ; dmarc=pass (policy=none) header.from=kernel.org; spf=pass (imf11.hostedemail.com: domain of alexs@kernel.org designates 145.40.73.55 as permitted sender) smtp.mailfrom=alexs@kernel.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1719979255; 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-transfer-encoding:content-transfer-encoding: in-reply-to:references:dkim-signature; bh=d25GD/2V0m60WLMKaj5tJuQIC+WdokgMhKpBAN8hbGE=; b=8odBlcyuB02uRtVrNZp/062R/4fRJ1NDY6QmYLDISwqriI2evu2+Md+Rj4GeaGt50sX2qw XHnoKuU5xIhHdj4IzMm4PkjdhFuIL7sv7E7PxMklWm7LpLc5YE5HcFl/FaLT95Nf/xywaN jlV8tsUcPtsIctyCq5GiFXIOf9iRKJk= Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by sin.source.kernel.org (Postfix) with ESMTP id 8E5FFCE21CB; Wed, 3 Jul 2024 04:01:08 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8F287C32781; Wed, 3 Jul 2024 04:01:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1719979267; bh=R8PbHDxHItRnttRsVyzAQLI+0I52W3YmlMnrM72F+NA=; h=From:To:Cc:Subject:Date:From; b=UE0z8PvQpR6RnbkYegJYZzdXzv+2CWrilJnJyjlsjCdwp4aOkDW6MDpYs2vBNMFkg UYNN4qHib4hSrIbrhN6wg0kAew4dGju/9Xy1oIVTMnefdZAUu4OgpFIcRcFnvUKjl+ ZtFuzTWDE6mvwt1vkb3fyBhKAJdXgnXO53Mu7wmJFB+D3iYk/2wLuKDtuB3j0A/zzv O+d7VBrCjrvnMX4ijxbfXDvqavPMRFRJ8xS5PeTBDn8wFa7Q+7biX0v47Gem5BZggm sDLmwUwxvgLlwgyqvemK8cc5jk4f4FXYUil4cJuJKtYQBw3041LXGy8nRhCzBM75h+ nkYgJ7Ob7EqgQ== From: alexs@kernel.org To: Vitaly Wool , Miaohe Lin , Andrew Morton , linux-kernel@vger.kernel.org, linux-mm@kvack.org, minchan@kernel.org, willy@infradead.org, senozhatsky@chromium.org, david@redhat.com, 42.hyeyoo@gmail.com, Yosry Ahmed , nphamcs@gmail.com Cc: Alex Shi Subject: [PATCH v2 00/20] mm/zsmalloc: add zpdesc memory descriptor for zswap.zpool Date: Wed, 3 Jul 2024 12:05:50 +0800 Message-ID: <20240703040613.681396-1-alexs@kernel.org> X-Mailer: git-send-email 2.43.0 MIME-Version: 1.0 X-Rspamd-Queue-Id: 79DAC4000C X-Rspam-User: X-Rspamd-Server: rspam05 X-Stat-Signature: f1q146mtfoywb9m1s6hqb4yzm7qtw7sp X-HE-Tag: 1719979272-342356 X-HE-Meta: U2FsdGVkX19C9vXyLKHLWA9XRkHFG+uDc8Jfrr0zs+jKdSrbN0w2yL1IBi72kXy7nvhO+Yi+tekNPngds72SXNgyMAhqoAMczkNzMRo1ayENIPoLa7tCClu98cRdamsn2Mi+Dull4vpw7MO7IH4Pw/IheRy6wdX7uSJy6+BZhnSIiQHNYtbVEj3cIBr/3DX0zVFbmwK0Zvm6GuH8xS3CdYX1lhzJ/5r0wQ9U7p1fFJbtjYFPU9ZD2DmFMAdn5dU/BRKSGePpNEHijtBNDHj0xJ6YJ5Yd+1Oqk8ngxDWIP1ARHSEc7i7Txw1eM+nnN2f+b04CthEAUnqKs0Ij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@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: From: Alex Shi According to Metthew's plan, the page descriptor will be replace by a 8 bytes mem_desc on destination purpose. https://lore.kernel.org/lkml/YvV1KTyzZ+Jrtj9x@casper.infradead.org/ Here is a implement on zsmalloc to replace page descriptor by 'zpdesc', which is still overlay on struct page now. but it's a step move forward above destination. To name the struct zpdesc instead of zsdesc, since there are still 3 zpools under zswap: zbud, z3fold, zsmalloc for now(z3fold maybe removed soon), and we could easyly extend it to other zswap.zpool in needs. For all zswap.zpools, they are all using single page since often used under memory pressure. So the conversion via folio series helper is better than page's for compound_head check saving. For now, all zpools are using some page struct members, like page.flags for PG_private/PG_locked. and list_head lru, page.mapping for page migration. This patachset does not increase the descriptor size nor introduce any functional changes, and it could save about 123Kbytes zsmalloc.o size. Thanks Alex --- v1->v2: - Take Yosry and Yoo's suggestion to add more members in zpdesc, - Rebase on latest mm-unstable commit 31334cf98dbd --- Alex Shi (8): mm/zsmalloc: add zpdesc memory descriptor for zswap.zpool mm/zsmalloc: use zpdesc in trylock_zspage/lock_zspage mm/zsmalloc: convert create_page_chain() and its users to use zpdesc mm/zsmalloc: rename reset_page to reset_zpdesc and use zpdesc in it mm/zsmalloc: convert SetZsPageMovable and remove unused funcs mm/zsmalloc: introduce __zpdesc_clear_movable mm/zsmalloc: introduce __zpdesc_clear_zsmalloc mm/zsmalloc: introduce __zpdesc_set_zsmalloc() Hyeonggon Yoo (12): mm/zsmalloc: convert __zs_map_object/__zs_unmap_object to use zpdesc mm/zsmalloc: add and use pfn/zpdesc seeking funcs mm/zsmalloc: convert obj_malloc() to use zpdesc mm/zsmalloc: convert obj_allocated() and related helpers to use zpdesc mm/zsmalloc: convert init_zspage() to use zpdesc mm/zsmalloc: convert obj_to_page() and zs_free() to use zpdesc mm/zsmalloc: add zpdesc_is_isolated/zpdesc_zone helper for zs_page_migrate mm/zsmalloc: convert __free_zspage() to use zdsesc mm/zsmalloc: convert location_to_obj() to take zpdesc mm/zsmalloc: convert migrate_zspage() to use zpdesc mm/zsmalloc: convert get_zspage() to take zpdesc mm/zsmalloc: convert get/set_first_obj_offset() to take zpdesc mm/zpdesc.h | 143 ++++++++++++++++ mm/zsmalloc.c | 456 +++++++++++++++++++++++++++----------------------- 2 files changed, 393 insertions(+), 206 deletions(-) create mode 100644 mm/zpdesc.h