From patchwork Tue Aug 6 02:21:42 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: 13754314 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 DA580C3DA4A for ; Tue, 6 Aug 2024 02:16:43 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 6E09F6B0088; Mon, 5 Aug 2024 22:16:43 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 691606B0089; Mon, 5 Aug 2024 22:16:43 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 5593B6B008C; Mon, 5 Aug 2024 22:16:43 -0400 (EDT) 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 372A06B0088 for ; Mon, 5 Aug 2024 22:16:43 -0400 (EDT) Received: from smtpin03.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id F043814051E for ; Tue, 6 Aug 2024 02:16:42 +0000 (UTC) X-FDA: 82420207044.03.6D49A12 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf12.hostedemail.com (Postfix) with ESMTP id 4F09F40014 for ; Tue, 6 Aug 2024 02:16:40 +0000 (UTC) Authentication-Results: imf12.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b="lMx4f/29"; spf=pass (imf12.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=1722910538; 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=4QKFa1vbmbzCmX4gVELLmb5iYGeWB2gX7ROj6JJouI0=; b=zzESuF1+HLafB4t0xD1W7/QzBAN7elAt3977XpCChbO93XwSKaVnrHrlr1gUuL5zsR9LUY 35pn4p3w1HCZp4M2Zj3hQs4ZdSiU89QKwyv5ZzxGIDQRCoJmyco7l4jH2u13yFugsadtSp klBktRNPZOEzn36NZSQqRwLtDuM9AAU= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1722910538; a=rsa-sha256; cv=none; b=G8cRjYpKZVAcP+eRMC/fM4MjzBoXxm+H1KkhcIVchVSoDuwyi0bWToWqPJIEkrrWQPyzM7 5RxwcVjZv2NOX6pcgnB8AP4sujz7ZLMxOiR5vOxyhvZkeXF+r3VhB8NWLdUjcGC5rLY1qE 9J6gw5SzaRqTh8Rj7fxlWXdSABwlewQ= ARC-Authentication-Results: i=1; imf12.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b="lMx4f/29"; spf=pass (imf12.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 1B10F60E00; Tue, 6 Aug 2024 02:16:39 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 9E4C8C32782; Tue, 6 Aug 2024 02:16:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1722910598; bh=yXVABbkmu8OTawq0fw52gNq7FEB6YnC9rfwX9dBxipE=; h=From:To:Cc:Subject:Date:From; b=lMx4f/29PRG68vAFR3Oy3tPjxk8B+tHttTZHU6R6Sj/cige+jkzrIUJyb7Hx0MHPg EHRFGdelRhCCFghYZ1SJ+NuPWT+R8Aru8lFou3iFyFQ2Ys7hRLo5ryhcsFnqj2uNFa LTYRtiQWPD7faB/98r0i2fmBHkcpBs9z7Wcv1HJycjLpJPtwvHIQVLiM99sK+yi5mU E4nHz8bXPtU7gAUhkUktGBmXFdlbcNLmlsH54g05FIgMWBbHPau2yjzsF0Di/vNh5N zLF0we9ScSmkLJJuj2YtN3aBmC3qxlx3Tf57zVJK0uL4bSBDoJ7Edbc2k1L1Hkkw1H RE5+LnwFldsoQ== 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 v5 00/21] mm/zsmalloc: add zpdesc memory descriptor for zswap.zpool Date: Tue, 6 Aug 2024 10:21:42 +0800 Message-ID: <20240806022143.3924396-1-alexs@kernel.org> X-Mailer: git-send-email 2.43.0 MIME-Version: 1.0 X-Rspam-User: X-Rspamd-Server: rspam04 X-Rspamd-Queue-Id: 4F09F40014 X-Stat-Signature: y5mc1bm6jr9n3bosunzeawg6ieh7qrxi X-HE-Tag: 1722910600-451686 X-HE-Meta: U2FsdGVkX19RYeGBU1J3iZXZPg5StBWFHWKs2Xc2xVRbUoDXHGzd1T0HqaS3qTXxD7WcLuZ3bl168NcCsTajP0MCPYlqbNU2HhO/pAuPwkWsgh4XZgQBntwmcUC+19PhEvNmrxVr1QQCQx2g0Jb3PeSBxsSpyzoSVBYpnEGUCD4InlMHjMALWK42rfwIhzJ3DTQ90kpmrQjhDSGowN/Nlhw7Z5Jt5kj2C1DpAq9mcw3W5efmq83KDF0dacOwnlI26zmYqvqc1duhsp0p27vdmTY1xvMMplKmyGAbgZ8+WxKKJGpmM1nbcvNYhpoe/XMEF9qX575WlCbPi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: 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. 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 --- v4->v5: - rebase on akpm/mm-unstable on Aug 4. - add a helper and update code comments accroding 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 | 146 +++++++++++++++ mm/zsmalloc.c | 482 +++++++++++++++++++++++++++----------------------- 2 files changed, 403 insertions(+), 225 deletions(-) create mode 100644 mm/zpdesc.h