From patchwork Mon Sep 2 07:21:11 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: 13786824 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 8A542CD13CF for ; Mon, 2 Sep 2024 07:16:37 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 066028D0083; Mon, 2 Sep 2024 03:16:37 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id F2EDD8D002D; Mon, 2 Sep 2024 03:16:36 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id DA86C8D0083; Mon, 2 Sep 2024 03:16:36 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id BC13F8D002D for ; Mon, 2 Sep 2024 03:16:36 -0400 (EDT) Received: from smtpin26.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id 669C71C6417 for ; Mon, 2 Sep 2024 07:16:36 +0000 (UTC) X-FDA: 82518940392.26.7B0E8AC Received: from nyc.source.kernel.org (nyc.source.kernel.org [147.75.193.91]) by imf10.hostedemail.com (Postfix) with ESMTP id D4AB3C0018 for ; Mon, 2 Sep 2024 07:16:33 +0000 (UTC) Authentication-Results: imf10.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=RmzGMWRd; dmarc=pass (policy=quarantine) header.from=kernel.org; spf=pass (imf10.hostedemail.com: domain of alexs@kernel.org designates 147.75.193.91 as permitted sender) smtp.mailfrom=alexs@kernel.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1725261325; a=rsa-sha256; cv=none; b=A3Ri60EbhGazNONTuVC7SJ/nQtUuEv2s7xotuQhjHf1NGslaTXLCgyq/soxmngX2Kcbm4o cPl8iZIeRuGtYojAxA6LicMnlC0DGUz1HiFJc4AHmxkfu+Ppuhnkw4WuOYKs41mndQzcFn ktkCjzsMJcLYlOCYQBDPDNM+f9hAPSI= ARC-Authentication-Results: i=1; imf10.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=RmzGMWRd; dmarc=pass (policy=quarantine) header.from=kernel.org; spf=pass (imf10.hostedemail.com: domain of alexs@kernel.org designates 147.75.193.91 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=1725261325; 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=29ep1TuiqlJTvfUC2pfP3tDHh0V6ddmU8pid9ppQpUc=; b=mEjGLP+E2FiO2qhRB9iZQ5M4sC/V7OXnuIdQe81tZ0Fs2x7NIfS4p0nEkN9a3WbcIkNwtI Gf6IEDsoiq0V21Vp9tAmkyereegYCQ1TOQfLqg6l9gI2LShA/sxGP21/8EB/BA0kKufFC9 M52aGrG2l5lQIN9CWTH2pMqrwr5HDtY= Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by nyc.source.kernel.org (Postfix) with ESMTP id ED274A41355; Mon, 2 Sep 2024 07:16:25 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id B4FC7C4CEC2; Mon, 2 Sep 2024 07:16:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1725261392; bh=C+PQyPVCIVbmT/BZwf3yjRAH5H4AzFwbepsfC3VtwYo=; h=From:To:Cc:Subject:Date:From; b=RmzGMWRdeLlM97okxY0Sw/YVpluQR5yVs86w+rYSGxhsrJ0twKF8C6XMJhCcOJrhN zeVnZMGaBxB0b+iOU9YkLfSjwrHuYFJuB7Anp8tPnaJBYLQkX6bveW+uogzC3eFbSM drf2NyTvM+LOatVbNyY4gk4VvlYICfui+UJPNUnD7pyQPkzzXsQ7dG6b3UxRXXhdMq YnnO5RpdJ2HHpz20DV51q+gnlCRr9saSCrsso2KtMLEaokS9O4+VuSysrY6hNyjmEN vx653RNcY+1986hKlndc2S1jorh1E1kyF7GspGOsYRLQKcGwKcs3FbG64vas3yd6Nn fLOvh0LxtqWfg== 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 v7 00/21] mm/zsmalloc: add zpdesc memory descriptor for zswap.zpool Date: Mon, 2 Sep 2024 15:21:11 +0800 Message-ID: <20240902072136.578720-1-alexs@kernel.org> X-Mailer: git-send-email 2.46.0 MIME-Version: 1.0 X-Rspamd-Queue-Id: D4AB3C0018 X-Rspam-User: X-Rspamd-Server: rspam05 X-Stat-Signature: 8ewjj6hsscbzi3c3q6nemo39ue9cy9hp X-HE-Tag: 1725261393-304729 X-HE-Meta: U2FsdGVkX19yX84I+pY6yMTt1regi8mH5QYsFlesWN9/peA49KfXsbUxWztMPjFw22TZ+AfcUrrZewavyVH+v0DYAq3VwAW6jjLc3gEIl5MBDpDD1oHenF2DfzzHLDYDLNg4EYK06xMMOaj61kaJ1D8oYaKlYikKpmbfzi+anAEsxUlsY/Guo4J7qcIIZSkRXRoj9sVC2qJQAGSb2F2dA0Y/eA6ySNGKEkPlQ/8yc+cOy8XednKSg+h2i7ZXczR86Bb8Fmk/OJqjr3aOEHDH/A1cvk10flPmNptEOH/4wt48SOeUVayRz7tQvmukg6shdYX2GzA9/DvFk9Mm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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/ This patchset abstracts the memory descriptor used in zsmalloc by zswap/zram. The descriptor still overlays the struct page; nothing has changed in that regard. What this patchset accomplishes is the use of folios in to save some code size, and the introduction of a new concept, zpdesc. This patchset is just an initial step; it does not bias the potential changes to kmem_alloc or larger zspage modifications. 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 --- v6->v7: - rebase on akpm/mm-unstable on Aug 30 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 | 490 +++++++++++++++++++++++++++----------------------- 2 files changed, 414 insertions(+), 223 deletions(-) create mode 100644 mm/zpdesc.h