From patchwork Tue Aug 13 08:45:46 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: 13761549 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 A8902C52D7C for ; Tue, 13 Aug 2024 08:41:11 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id F2BB96B008C; Tue, 13 Aug 2024 04:41:10 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id EB5196B0092; Tue, 13 Aug 2024 04:41:10 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id D2DFB6B0095; Tue, 13 Aug 2024 04:41:10 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id B299C6B008C for ; Tue, 13 Aug 2024 04:41:10 -0400 (EDT) Received: from smtpin26.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id 235F11C30DD for ; Tue, 13 Aug 2024 08:41:10 +0000 (UTC) X-FDA: 82446577500.26.BD96A7E Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf28.hostedemail.com (Postfix) with ESMTP id 8D32CC000E for ; Tue, 13 Aug 2024 08:41:07 +0000 (UTC) Authentication-Results: imf28.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=bWylMq9j; spf=pass (imf28.hostedemail.com: domain of alexs@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=alexs@kernel.org; dmarc=pass (policy=none) header.from=kernel.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1723538396; 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=cpA6ZHcMXgTJbk2MkH9J3zIffxpey2JVttw4n3QFgyw=; b=cMqDv7+MQyzaZeiKzj3lnh8gnyMNnPUO5UpvFcE789cgn4oDBD/VVWZsFV+chDw0iktKeY nWPTpo3QG+fVagnxUXJPlHqGlzZB+NgRcvvqrD7sfxRWmIHjRFVewfJlx0SnNIvOBblFOL qj1h7wyWRKRJWBbpF8O46HojNjfHuY4= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1723538396; a=rsa-sha256; cv=none; b=5U72v3B9m/HEPh7a9ZkieFYZaR6pUA7qFA+zR0p/Cx46z8zPEGFJmySAi6DdT52A6F33+E preebel91Wq3ZSivWFiop/S1b+uHB1azkbWIeztkk9RH5dPjfhgpoIrKUoRhsu4BcCijEM vLAOcnrmWjUwNiNL9X/dZejrz6iTQek= ARC-Authentication-Results: i=1; imf28.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=bWylMq9j; spf=pass (imf28.hostedemail.com: domain of alexs@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=alexs@kernel.org; dmarc=pass (policy=none) header.from=kernel.org Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id 6A14861057; Tue, 13 Aug 2024 08:41:06 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id B9E78C4AF0B; Tue, 13 Aug 2024 08:41:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1723538466; bh=Z/FMnC5lYBSOOCLhgveNnkuyOlHnMIIIL5Dx/+PVQLg=; h=From:To:Cc:Subject:Date:From; b=bWylMq9js9m3gA6VjYMC3dbDTYydIcdM74Gyq/SVS6zVmZHFqoKGA5fzN02HMhWLd 1iHWuBb7KuA3ydtm+97Myx/MEzJGyWE6Sjdlgzvy3qTYHHH5ewdcrYK39G7DgaN+te KB+hDssdx2Q1116Tsosg2VdNA/LWKl/puxWw3sswDPT5yUsoExpNnxVVfy4k3pAErZ /brk6jpXumPs/K7QJOpHliK7qXsH90PFH3zgZGnslcIgrwfUMLf/lCU4kELVjcvjjH iV56FIxwnYoEuhEkpTmwR4Ve+FMnd5RmqNwNMUM5ZBi6VPBvUmyY/EdVirUoz8Nt9W 1bzrd47Agv1TQ== 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 v6 00/21] mm/zsmalloc: add zpdesc memory descriptor for zswap.zpool Date: Tue, 13 Aug 2024 16:45:46 +0800 Message-ID: <20240813084611.4122571-1-alexs@kernel.org> X-Mailer: git-send-email 2.43.0 MIME-Version: 1.0 X-Stat-Signature: eaygaba987aby34z4qzommdq8zg8u8pq X-Rspamd-Queue-Id: 8D32CC000E X-Rspam-User: X-Rspamd-Server: rspam08 X-HE-Tag: 1723538467-752703 X-HE-Meta: U2FsdGVkX198VNwIr3scL17a2gJUEa9fV3iXdJwDYHEJBAiHhOPWkVIszyw4VjDH80tzIVUT2MS3R0vf3r0tm+kQyoUYQBcWaFa8Q5/G/g6E+c0ViIYNRUVfH95Uz7UnvI4x2fKyw+9v8sugAU+jCqmsTcWTdKMiL+LVFC8fxWaI0MYjRHTjs8Nf4fqpUKBQRyuHESV9dONv1s6YuWbCMZD/xgdAtNkYU7V70qGXq9Md/ZoLY1fYLIg5p+wu4Y6lizxYRrRok15NVQbsIReunNZ4hhIdRob2w7dhZ2yiWxHmMfdq+fSeTZ5OEZNfaUm/ZvsNmIMPi+D6WpuSWgyFMjNPIG7Q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V0/MHnE1ddN 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: 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. After this patchset, a possible way to memdesc is suggested here: https://marc.info/?l=linux-mm&m=172308822809560&w=2 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 could save about 122Kbytes zsmalloc.o size. Thanks a lot for comments and suggestion from Yosry, Yoo, Sergey, Willy and Vishal! Thanks Alex --- v5->v6: - rebase on akpm/mm-unstable on Aug 4 - recover 2 helpers and update code comments according to Vishal's comments on patch 1 and 6. v4->v5: - rebase on akpm/mm-unstable on Aug 8 + Stephen Rothwell's build fix. - add a helper and update code comments according to Sergey's comments - fold patch 20/21, remove 3 helpers functions according to Vishal's comments v3->v4: - rebase on akpm/mm-unstable Jul 21 - fixed a build warning reported by LKP - Add a comment update for struct page to zpdesc change v2->v3: - Fix LKP reported build issue - Update the Usage of struct zpdesc fields. - Rebase onto latest mm-unstable commit 2073cda629a4 v1->v2: - Take Yosry and Yoo's suggestion to add more members in zpdesc, - Rebase on latest mm-unstable commit 31334cf98dbd Alex Shi (10): 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: convert get/set_first_obj_offset() to take zpdesc mm/zsmalloc: introduce __zpdesc_clear_movable mm/zsmalloc: introduce __zpdesc_clear/set_zsmalloc() mm/zsmalloc: introduce zpdesc_clear_first() helper mm/zsmalloc: update comments for page->zpdesc changes Hyeonggon Yoo (11): 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/zpdesc.h | 147 +++++++++++++++ mm/zsmalloc.c | 496 +++++++++++++++++++++++++++----------------------- 2 files changed, 418 insertions(+), 225 deletions(-) create mode 100644 mm/zpdesc.h