From patchwork Mon Jul 8 06:33:21 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: 13726188 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 58CB7C3271E for ; Mon, 8 Jul 2024 06:28:45 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id E98266B0093; Mon, 8 Jul 2024 02:28:44 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id E47D86B0095; Mon, 8 Jul 2024 02:28:44 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id D39706B0096; Mon, 8 Jul 2024 02:28:44 -0400 (EDT) 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 B5EDA6B0093 for ; Mon, 8 Jul 2024 02:28:44 -0400 (EDT) Received: from smtpin28.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id 38583A1151 for ; Mon, 8 Jul 2024 06:28:44 +0000 (UTC) X-FDA: 82315606968.28.2C11E76 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf21.hostedemail.com (Postfix) with ESMTP id AC3D21C0018 for ; Mon, 8 Jul 2024 06:28:42 +0000 (UTC) Authentication-Results: imf21.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=cfPlvnzf; dmarc=pass (policy=none) header.from=kernel.org; spf=pass (imf21.hostedemail.com: domain of alexs@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=alexs@kernel.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1720420101; a=rsa-sha256; cv=none; b=rRotaEBaJL8J0fiaqInVsRxjR4OL1/tW/+wTkzh7D4dZxdbTCuq3zNRfPGjcABPLVjuLL8 tdS+5d5Fq+gKZerbQDz+kDjZARiEfz77ACDgq7GMPPqsT3pLo1QlLpbdlBqdo8Q14fI5aQ +rza7LeakYngNylIeynLkF4D38LafzQ= ARC-Authentication-Results: i=1; imf21.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=cfPlvnzf; dmarc=pass (policy=none) header.from=kernel.org; spf=pass (imf21.hostedemail.com: domain of alexs@kernel.org designates 139.178.84.217 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=1720420101; 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=fnvABIJYhl47LJnMbYInSapruimd2y7uPHa0zGzzCxI=; b=FpXqcMgOKI4Lh5HUFJBkYgyz6lFyhUX8bCjhswvZ8lferYdl6x6/5mZvgUOjevHczXSt0P FQmiOa4EBtxcJgiXzn5xG3WegZ6I0i5a3uCOmbxAXFKeBEbP4y4gOG0JJtqZfaqi4pqAQe StCkcvV6OVQlpAESTB4tlBjHUIXqLdo= Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id CDAAA60A4A; Mon, 8 Jul 2024 06:28:41 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 90A95C116B1; Mon, 8 Jul 2024 06:28:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1720420121; bh=PygjdzSV6SpcBpLpxkEt0f2pdR/RuCc/C0kYkbdkhs0=; h=From:To:Cc:Subject:Date:From; b=cfPlvnzfcKFaWjdjjnAmZ2m7n+TdCgGEfSAB+HvrSbcNZkj71mTAAQTqCpgVnpYlg UcbjJZU5jAJVOd1rBPNbncXnj3hT2/kjjFlXOmivBNbBhE316jitv3xlJkS6v8CbwN xdt+TxYPjg286s/ke13z/uypE48Cy1Qvpx6Ux9T0MoQ0y9TJp9vCrFIMGfFYsCqpoU 8Uz7xTj+jaBkX3cw7wDKb0YX8q4mdP7mZP1orDqaDR06QVTRdwfnfmJjNKrtR+iNCf BePIs5y81HMDegsGP//PKKF9cKhFsmDmDq5PryvaapCYIbuE+KMhhd5lV1n5kQUFbH QkLyK0gjan05g== 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 v3 00/20] mm/zsmalloc: add zpdesc memory descriptor for zswap.zpool Date: Mon, 8 Jul 2024 14:33:21 +0800 Message-ID: <20240708063344.1096626-1-alexs@kernel.org> X-Mailer: git-send-email 2.43.0 MIME-Version: 1.0 X-Rspamd-Queue-Id: AC3D21C0018 X-Rspam-User: X-Rspamd-Server: rspam05 X-Stat-Signature: nwpdnr4ddodhfha79gt3861g5a3yba1g X-HE-Tag: 1720420122-626184 X-HE-Meta: U2FsdGVkX1/xjj5NZ4jtcOzDXqUQExD0rfpmBW5BArWN3fK8wRRuNM0944HpGoEnsyhZKx03iMLG2OqfAtHcJAjF4Po8Nspa+nBEjDK7SLrdHdpcEmBZ0frFG4kcCJuUV9RzkLUmjAKsaPqtbAZ1B9B1YE2BkhDLTZtFOh/vB8ofkSaRWHaFkIgJKLtkqQccAQvENVe1g5F9gqffTFAq5sQ3/Ky5vCTrVAPMiomuTJDrk5elrOkTcb/06+uAdJfsJ6vVEd1vrO/wHdygFYIGSbSAN0ZsSR1ulMmF1niIJ1KR9DNo2zOP60jU/j56spBrg8a3490QSsADS4BFDOApJWLl9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org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: From: Alex Shi (Tencent) 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 Alex --- v3->v2: - 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 (Tencent) (9): 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_zsmalloc mm/zsmalloc: introduce __zpdesc_set_zsmalloc() 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 | 460 +++++++++++++++++++++++++++----------------------- 2 files changed, 398 insertions(+), 208 deletions(-) create mode 100644 mm/zpdesc.h