From nobody Tue Dec 16 19:40:58 2025 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B364F13CFB8 for ; Fri, 21 Jun 2024 05:42:07 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718948527; cv=none; b=rJP5ulq/IrLohKdfbK2JMBN7HIp0m3GaJfsE3NIkoFNfVEiLpWeRCv/BVQRefeBO7Fkh1DP5WVTpZjom1irzpp74RB5ruqgsAoAK+Zv3S8h3Ac47eARcZtL/uoH8J+OXyEPwJZ3VNjB45WVelkbeLuwrvfMwgYKP2Dsg8ouHbE0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718948527; c=relaxed/simple; bh=nrW0QvxLKLlDHZUd0Xa2UXqPdoTHBMmkz4AnWaU+jyY=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=bRZL2NKDkAMWefoDI+gIBYVA6LDB1ijF6bHiwe8db5QYzA3vKbCi5DEC8DB1E+LTtTbkuOYyzQfC5/hdbQyCVL2CDQOlnC4OFSlPQMPxspQwzHFeDMLr8ADywi9rhU73ZL/YXXGxj77eYJZH/N1RLrR4P4H3rJrlo8Vd1lbsj6E= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=KRbg5wZp; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="KRbg5wZp" Received: by smtp.kernel.org (Postfix) with ESMTPSA id C3DADC4AF0A; Fri, 21 Jun 2024 05:42:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1718948527; bh=nrW0QvxLKLlDHZUd0Xa2UXqPdoTHBMmkz4AnWaU+jyY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=KRbg5wZpEC9mSEW33Mg+dxiP8pUoi07ZZ/5F/960HRxTGr8p88LrW+F7XECclmEQl c9eBg3G/dL2KRKCuhTn6ckQKH5geiK9dUhWc66Uvkf44QjZrkLszJJPW+rbg92AKJI sTIqfeF4GpOYKmdvdQY2sR4qJ1T9QBF3O9ZfqtwKW6DK1B8NpGP2pJZuN8C3EJwbjq fKzlvXmy0auuOFcFNp8iZeqNUXgq2lGT0nSv62pFsCeLR73b0y/mgXvSQAPlpq8wjA H0WmCMVCCZFAt1sLB4fTlXvI51DjEhP819kD3TdnzWezEAuF7mgPHBhTs9d6p7IhXN u46tfDHGJD5lA== 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 Cc: Alex Shi Subject: [PATCH 01/15] mm/z3fold: add zpdesc struct and helper and use them in z3fold_page_isolate Date: Fri, 21 Jun 2024 13:46:41 +0800 Message-ID: <20240621054658.1220796-2-alexs@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240621054658.1220796-1-alexs@kernel.org> References: <20240621054658.1220796-1-alexs@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Alex Shi The 1st patch here, we introduce some helper functions along with struct zpdesc, like zpdesc_page/zpdesc_folio/page_zpdesc and zpdesc_address similar with folio_address, and convert page to zpdesc in func z3fold_page_isolate. z3fold_page_isolate() hooked to page_isolate that the reason we could not fully remove page from its parameter for now. Originally-by: Hyeonggon Yoo <42.hyeyoo@gmail.com> Suggested-by: David Hildenbrand Signed-off-by: Alex Shi --- mm/z3fold.c | 14 ++++++++------ mm/zpdesc.h | 51 +++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 59 insertions(+), 6 deletions(-) create mode 100644 mm/zpdesc.h diff --git a/mm/z3fold.c b/mm/z3fold.c index 2ebfed32871b..b1229c0520f1 100644 --- a/mm/z3fold.c +++ b/mm/z3fold.c @@ -40,6 +40,7 @@ #include #include #include +#include "zpdesc.h" =20 /* * NCHUNKS_ORDER determines the internal allocation granularity, effective= ly @@ -1251,22 +1252,23 @@ static bool z3fold_page_isolate(struct page *page, = isolate_mode_t mode) { struct z3fold_header *zhdr; struct z3fold_pool *pool; + struct zpdesc *zpdesc =3D page_zpdesc(page); =20 - VM_BUG_ON_PAGE(PageIsolated(page), page); + VM_BUG_ON_PAGE(PageIsolated(zpdesc_page(zpdesc)), zpdesc_page(zpdesc)); =20 - if (test_bit(PAGE_HEADLESS, &page->private)) + if (test_bit(PAGE_HEADLESS, &zpdesc->zppage_flag)) return false; =20 - zhdr =3D page_address(page); + zhdr =3D zpdesc_address(zpdesc); z3fold_page_lock(zhdr); - if (test_bit(NEEDS_COMPACTING, &page->private) || - test_bit(PAGE_STALE, &page->private)) + if (test_bit(NEEDS_COMPACTING, &zpdesc->zppage_flag) || + test_bit(PAGE_STALE, &zpdesc->zppage_flag)) goto out; =20 if (zhdr->mapped_count !=3D 0 || zhdr->foreign_handles !=3D 0) goto out; =20 - if (test_and_set_bit(PAGE_CLAIMED, &page->private)) + if (test_and_set_bit(PAGE_CLAIMED, &zpdesc->zppage_flag)) goto out; pool =3D zhdr_to_pool(zhdr); spin_lock(&pool->lock); diff --git a/mm/zpdesc.h b/mm/zpdesc.h new file mode 100644 index 000000000000..d51785863596 --- /dev/null +++ b/mm/zpdesc.h @@ -0,0 +1,51 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* zpdesc.h: zswap.zpool memory descriptor + * + * Written by Alex Shi (Tencent) + */ +#ifndef __MM_ZPDESC_H__ +#define __MM_ZPDESC_H__ + +/* + * struct zpdesc - Memory descriptor for z3fold memory + * @flags: Page flags, PG_locked for headless z3fold memory + * @lru: Indirected used by page migration + * @zppage_flag: z3fold memory flags + * + * This struct overlays struct page for now. Do not modify without a good + * understanding of the issues. + */ +struct zpdesc { + unsigned long flags; + struct list_head lru; + unsigned long _zp_pad_1; + unsigned long _zp_pad_2; + unsigned long zppage_flag; +}; +#define ZPDESC_MATCH(pg, zp) \ + static_assert(offsetof(struct page, pg) =3D=3D offsetof(struct zpdesc, zp= )) + +ZPDESC_MATCH(flags, flags); +ZPDESC_MATCH(lru, lru); +ZPDESC_MATCH(private, zppage_flag); +#undef ZPDESC_MATCH +static_assert(sizeof(struct zpdesc) <=3D sizeof(struct page)); + +#define zpdesc_page(zp) (_Generic((zp), \ + const struct zpdesc *: (const struct page *)(zp), \ + struct zpdesc *: (struct page *)(zp))) + +#define zpdesc_folio(zp) (_Generic((zp), \ + const struct zpdesc *: (const struct folio *)(zp), \ + struct zpdesc *: (struct folio *)(zp))) + +#define page_zpdesc(p) (_Generic((p), \ + const struct page *: (const struct zpdesc *)(p), \ + struct page *: (struct zpdesc *)(p))) + +static inline void *zpdesc_address(const struct zpdesc *zpdesc) +{ + return folio_address(zpdesc_folio(zpdesc)); +} + +#endif --=20 2.43.0 From nobody Tue Dec 16 19:40:58 2025 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 0A25713CFB8 for ; Fri, 21 Jun 2024 05:42:10 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718948531; cv=none; b=XR466pUzHkM/83DWg81157AQZLJS5CN5sG+m71lnLvjQj0c1IeK0HAodYrrTX0c63NV8DkKtN/Yh70a1q5pYigziUgIAyFtXJPeCqnRJz0CPUebG/ManxsO42lF3zhXoBiXBd8QoEZFj4ZEGBYNWhTK3GY4hvWUCmnHs+mRnjXo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718948531; c=relaxed/simple; bh=lFp9hPza5pPU6dl5Bp6oDNXPAe1FxKDcyrPF29XpEYA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=UKq+mzpv3GQpwkbO2nGIe+B0t7qAmusI6Q6nHG/RjcipJ4nzWNB+qblu1OB/sRCutC5tJAJH89lOQfkIoBMtDMVT6R7djyQqYx9Yy6XqkNZsp+Ai9nzeJq95HWqqIj4CRGP8P8kQHYkDDVCBs62zq2FmMU+RneW1CHzCBwRkgcU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=YFwfQUXj; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="YFwfQUXj" Received: by smtp.kernel.org (Postfix) with ESMTPSA id E15D1C4AF07; Fri, 21 Jun 2024 05:42:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1718948530; bh=lFp9hPza5pPU6dl5Bp6oDNXPAe1FxKDcyrPF29XpEYA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=YFwfQUXjaoVLS24SUVu4YvOrADDzlqMCpnmBV2Rt9lcarvqJAYcoeVvBBvZyEFcSG KGp68SU8RbPtBYJ0klurNhr77ppUHrZZJoq6fEbsZSRQ46nP4EpcSXTNWC0Zj4P8jv 7VnR4u6r0N7uF+UzuFsJGa4F019JtVvNXMbiibkCiDuyt+A3TtkgePnKr8f8sbXfea 79oztsDbLI2MuKg2Bmquh568/GbNejiYViESoUfL7kBDMZTEpPDLSwh6n7xrYyYJPr qovChvVpaBRXEMqycHMZRrIDiyieHrI5RQLwOEPxF45O2eupXrulXqajYm/UeTflAW 2vOA+yRTrYNNA== 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 Cc: Alex Shi Subject: [PATCH 02/15] mm/z3fold: use zpdesc in z3fold_page_migrate Date: Fri, 21 Jun 2024 13:46:42 +0800 Message-ID: <20240621054658.1220796-3-alexs@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240621054658.1220796-1-alexs@kernel.org> References: <20240621054658.1220796-1-alexs@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Alex Shi Convert page to zpdesc in z3fold_page_migrate. And introduce zpdesc_get/put base on folio_get/put helpers, since z3fold only deal with single pages. This patch could save about 12Kbytes. Signed-off-by: Alex Shi --- mm/z3fold.c | 30 ++++++++++++++++-------------- mm/zpdesc.h | 10 ++++++++++ 2 files changed, 26 insertions(+), 14 deletions(-) diff --git a/mm/z3fold.c b/mm/z3fold.c index b1229c0520f1..b7f86c1b57a3 100644 --- a/mm/z3fold.c +++ b/mm/z3fold.c @@ -1290,18 +1290,20 @@ static int z3fold_page_migrate(struct page *newpage= , struct page *page, { struct z3fold_header *zhdr, *new_zhdr; struct z3fold_pool *pool; + struct zpdesc *zpdesc =3D page_zpdesc(page); + struct zpdesc *newzpdesc =3D page_zpdesc(newpage); =20 - VM_BUG_ON_PAGE(!PageIsolated(page), page); - VM_BUG_ON_PAGE(!test_bit(PAGE_CLAIMED, &page->private), page); - VM_BUG_ON_PAGE(!PageLocked(newpage), newpage); + VM_BUG_ON_PAGE(!PageIsolated(zpdesc_page(zpdesc)), zpdesc_page(zpdesc)); + VM_BUG_ON_PAGE(!test_bit(PAGE_CLAIMED, &zpdesc->zppage_flag), zpdesc_page= (zpdesc)); + VM_BUG_ON_PAGE(!PageLocked(zpdesc_page(newzpdesc)), zpdesc_page(newzpdesc= )); =20 - zhdr =3D page_address(page); + zhdr =3D zpdesc_address(zpdesc); pool =3D zhdr_to_pool(zhdr); =20 if (!z3fold_page_trylock(zhdr)) return -EAGAIN; if (zhdr->mapped_count !=3D 0 || zhdr->foreign_handles !=3D 0) { - clear_bit(PAGE_CLAIMED, &page->private); + clear_bit(PAGE_CLAIMED, &zpdesc->zppage_flag); z3fold_page_unlock(zhdr); return -EBUSY; } @@ -1309,10 +1311,10 @@ static int z3fold_page_migrate(struct page *newpage= , struct page *page, z3fold_page_unlock(zhdr); return -EAGAIN; } - new_zhdr =3D page_address(newpage); + new_zhdr =3D zpdesc_address(newzpdesc); memcpy(new_zhdr, zhdr, PAGE_SIZE); - newpage->private =3D page->private; - set_bit(PAGE_MIGRATED, &page->private); + newzpdesc->zppage_flag =3D zpdesc->zppage_flag; + set_bit(PAGE_MIGRATED, &zpdesc->zppage_flag); z3fold_page_unlock(zhdr); spin_lock_init(&new_zhdr->page_lock); INIT_WORK(&new_zhdr->work, compact_page_work); @@ -1321,9 +1323,9 @@ static int z3fold_page_migrate(struct page *newpage, = struct page *page, * so we only have to reinitialize it. */ INIT_LIST_HEAD(&new_zhdr->buddy); - __ClearPageMovable(page); + __ClearPageMovable(zpdesc_page(zpdesc)); =20 - get_page(newpage); + zpdesc_get(newzpdesc); z3fold_page_lock(new_zhdr); if (new_zhdr->first_chunks) encode_handle(new_zhdr, FIRST); @@ -1331,16 +1333,16 @@ static int z3fold_page_migrate(struct page *newpage= , struct page *page, encode_handle(new_zhdr, LAST); if (new_zhdr->middle_chunks) encode_handle(new_zhdr, MIDDLE); - set_bit(NEEDS_COMPACTING, &newpage->private); + set_bit(NEEDS_COMPACTING, &newzpdesc->zppage_flag); new_zhdr->cpu =3D smp_processor_id(); - __SetPageMovable(newpage, &z3fold_mops); + __SetPageMovable(zpdesc_page(newzpdesc), &z3fold_mops); z3fold_page_unlock(new_zhdr); =20 queue_work_on(new_zhdr->cpu, pool->compact_wq, &new_zhdr->work); =20 /* PAGE_CLAIMED and PAGE_MIGRATED are cleared now. */ - page->private =3D 0; - put_page(page); + zpdesc->zppage_flag =3D 0; + zpdesc_put(zpdesc); return 0; } =20 diff --git a/mm/zpdesc.h b/mm/zpdesc.h index d51785863596..7fde29645331 100644 --- a/mm/zpdesc.h +++ b/mm/zpdesc.h @@ -48,4 +48,14 @@ static inline void *zpdesc_address(const struct zpdesc *= zpdesc) return folio_address(zpdesc_folio(zpdesc)); } =20 +static inline void zpdesc_get(struct zpdesc *zpdesc) +{ + folio_get(zpdesc_folio(zpdesc)); +} + +static inline void zpdesc_put(struct zpdesc *zpdesc) +{ + folio_put(zpdesc_folio(zpdesc)); +} + #endif --=20 2.43.0 From nobody Tue Dec 16 19:40:58 2025 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 0F71D155A52 for ; Fri, 21 Jun 2024 05:42:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718948534; cv=none; b=dDILCgnO2c5nJIjPJ19259XgFErGoar0hvPIyj4ZaGb3VeK3rrQq8prGyMRq5pq/8Bol5ixJ0IQ6m/72MC3Zoq/FE5K5yBNk3rsXnylhgjXh4xtYXhU4LRcl7b41qh5LGo8Ahx4KXgjgYxvpQiGf5r1R6tnw6BtN7kqZ7WGmhk8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718948534; c=relaxed/simple; bh=dd2siZgce72Js9rHx7j82fOPcgkDkcIWKh0L5w1zff0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=bIgZx9vUUwApT3uxB3UbGgufnXWfaMo11JJWsNSxLbPJdr7059A0FouUttOFUokMP3AAqSjS9GamqE4VflDTHz0Q+0AqfvgLJ+UMocU4Z1O1VMdf4+2NTm4wOURuYYfkJA71mTEoJ3bWzaN/yOEERQWSJz4KexPazuwoL09e8Xs= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=H8XjtS0m; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="H8XjtS0m" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 0A606C4AF0A; Fri, 21 Jun 2024 05:42:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1718948533; bh=dd2siZgce72Js9rHx7j82fOPcgkDkcIWKh0L5w1zff0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=H8XjtS0m/7b+Fl85MJhkqBpvIGisLhL2bxGmCQxv2/ny81+Fq+AeD8U9d5RFc0ya4 S2TcuJm+gq+e9lJNLM8l9DgeOhGkYTTLL+S174+ntE4pAv6fK6kU3ELimUhyYCzSzo ZCIG+yI3q4l/Mu7uLRo8kAeYWwWUCZBqfvyC+i791Um2NAbykq+FsKHkvzxo/JY3bU 62T0zsgRdnWgftCddh08lv2ApsH/JcLvdqoZBzbWQHvrZDRSdjjWFJypgPs+95Altm ASoDaRp5K5LT9x51YgLFcUZ3D4Hks6T5n0LWikFXdOKm74gG9w+rt71Qb2vmxRA3PL hTWBId8cGCb0w== 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 Cc: Alex Shi Subject: [PATCH 03/15] mm/z3fold: use zpdesc in z3fold_page_putback Date: Fri, 21 Jun 2024 13:46:43 +0800 Message-ID: <20240621054658.1220796-4-alexs@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240621054658.1220796-1-alexs@kernel.org> References: <20240621054658.1220796-1-alexs@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Alex Shi Convert page to zpdesc in z3fold_page_putback function, and keep the 'page' parameter since the function hooks to page_putback, which is used by other users. Signed-off-by: Alex Shi --- mm/z3fold.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/mm/z3fold.c b/mm/z3fold.c index b7f86c1b57a3..5cb156fc03be 100644 --- a/mm/z3fold.c +++ b/mm/z3fold.c @@ -1350,8 +1350,9 @@ static void z3fold_page_putback(struct page *page) { struct z3fold_header *zhdr; struct z3fold_pool *pool; + struct zpdesc *zpdesc =3D page_zpdesc(page); =20 - zhdr =3D page_address(page); + zhdr =3D zpdesc_address(zpdesc); pool =3D zhdr_to_pool(zhdr); =20 z3fold_page_lock(zhdr); @@ -1362,7 +1363,7 @@ static void z3fold_page_putback(struct page *page) return; if (list_empty(&zhdr->buddy)) add_to_unbuddied(pool, zhdr); - clear_bit(PAGE_CLAIMED, &page->private); + clear_bit(PAGE_CLAIMED, &zpdesc->zppage_flag); z3fold_page_unlock(zhdr); } =20 --=20 2.43.0 From nobody Tue Dec 16 19:40:58 2025 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C768616727F for ; Fri, 21 Jun 2024 05:42:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718948536; cv=none; b=AUV/BQ/ogk8ZCl51qkdNDVb5vdICFleVCAiDfnvDno0DKDR+D3129QZmbBiMhnpl6VMT6vD3srp2Zf1YOs4DmzmvsHvSePYLBp4TXd2bVfmiuKCFQAtJcCwDZRRnNC9TNEUDApKoXDbu7MLPd1/1aTGMiiJRJtWdsaf34VCapE4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718948536; c=relaxed/simple; bh=qXj63AgP40NUpl4XlwRzrIm8KuNAVcRpUKRIp23PaNE=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=QfgAMXefj4733Fqwi3VMxxebydmI6HxU3ohv+BmINLHxRDyF5rCWElJUnW0Zcj/dR7yQcrZtYe2dEJl6iCxDM3Rsn+Z8E2OC9RRf6O1/slMDvxtWYwWcfbSveUlZeDLatyEPfebQkX7yVAFt/NlUm7aUUQQHBZ/bTfJjAqcdNlk= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=egYyPlAu; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="egYyPlAu" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 26DE5C4AF0C; Fri, 21 Jun 2024 05:42:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1718948536; bh=qXj63AgP40NUpl4XlwRzrIm8KuNAVcRpUKRIp23PaNE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=egYyPlAu2juH8SLzVU+rYnNIQS1jHZS8wx2DLqMXQyz3DVD45Y0KyAZE+CzBDrV3J bwGHV0nFL+UoZwbljfBrDLCxvQVfsP8kxb3DOscMi+QicjSb6hN4Sbsh5mjGQjQPlC IGbnFyZdDdnFh7j+9fKhGIL6PRo2weH7KoUYwkE2E2yS4qkG5EInsDTDLngIyrIhNZ agfViVHiyJfvSZhd15I14UKzVJa8mcs7JrIdj36iq1chQ8uZKYJj97w2Kw3k/2GzJ0 FDnQOknl6afuuRG4a+UsSji+sd8oWb+N4YgVkRCYbRo53xU4iI4+0RIBUR8SSXfBkQ oOwZQ+7+xJkXw== 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 Cc: Alex Shi Subject: [PATCH 04/15] mm/z3fold: use zpdesc in get/put_z3fold_header funcs Date: Fri, 21 Jun 2024 13:46:44 +0800 Message-ID: <20240621054658.1220796-5-alexs@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240621054658.1220796-1-alexs@kernel.org> References: <20240621054658.1220796-1-alexs@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Alex Shi Convert the get/put_z3fold_header funcs pair to use zpdesc. Signed-off-by: Alex Shi --- mm/z3fold.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/mm/z3fold.c b/mm/z3fold.c index 5cb156fc03be..bfbc9f9fdfd4 100644 --- a/mm/z3fold.c +++ b/mm/z3fold.c @@ -254,9 +254,9 @@ static inline struct z3fold_header *get_z3fold_header(u= nsigned long handle) locked =3D z3fold_page_trylock(zhdr); read_unlock(&slots->lock); if (locked) { - struct page *page =3D virt_to_page(zhdr); + struct zpdesc *zpdesc =3D page_zpdesc(virt_to_page(zhdr)); =20 - if (!test_bit(PAGE_MIGRATED, &page->private)) + if (!test_bit(PAGE_MIGRATED, &zpdesc->zppage_flag)) break; z3fold_page_unlock(zhdr); } @@ -271,9 +271,9 @@ static inline struct z3fold_header *get_z3fold_header(u= nsigned long handle) =20 static inline void put_z3fold_header(struct z3fold_header *zhdr) { - struct page *page =3D virt_to_page(zhdr); + struct zpdesc *zpdesc =3D page_zpdesc(virt_to_page(zhdr)); =20 - if (!test_bit(PAGE_HEADLESS, &page->private)) + if (!test_bit(PAGE_HEADLESS, &zpdesc->zppage_flag)) z3fold_page_unlock(zhdr); } =20 --=20 2.43.0 From nobody Tue Dec 16 19:40:58 2025 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 2E117169AD5 for ; Fri, 21 Jun 2024 05:42:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718948540; cv=none; b=YYBhqeC7876xv0Dpu/CNkNMbn2u1nt9zhvwh0Nu8YFCZIpitY4/mrwML2BroIQ9YI1aMSLzVqgHeaIWJ1LXypb1I+E2rJdJXUS6fsK1SsO7nICtKd3St1xqOBcJ+j85Df5v+JqVRnv6720FKvh7uX8vq+hmj2SICWePFOdEPjuQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718948540; c=relaxed/simple; bh=7oNANOKMLtbJmXb9loH6eu8JvLufwYd8JIWVLHAnqL4=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=jCNGK1jzYW59TAYmdfoGFNOvLuLh+gVtVriCiJGQBMC8VJ/5Vhpmb/0zciXRBGTotMkhgcq3U+7RRAJkf645kb9iUz17YqVynUcFuOGP6bSvkZvAKj4zJEjKqu2bAgL5k2zYBQ/MLi1BVPdpZybQX2Pcbx/2/YDw68FHcAFF21c= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=W0DztK0m; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="W0DztK0m" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 42E17C4AF0C; Fri, 21 Jun 2024 05:42:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1718948539; bh=7oNANOKMLtbJmXb9loH6eu8JvLufwYd8JIWVLHAnqL4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=W0DztK0mpdQ9nkPkrX3G1oWV0jN9zXYYkkUwaQaFTDd67I4LtFfWlibpmLHOlupgI fhD0/PVR2FYJypn+aJNV4ow0mh2vjIkqlRg422SSynLyEIcXd0OlZaduQT3rZspgXd 3E1i0RdBtY85TaTN9qr53ckrhhhujmCzCJl1xwVpx8oSDk2TjMhMOUT2c/X6Q3eB8S mlEJ0J7m5GK2sYQysRObCsWJ9mVN4J9eOmtHjMliJCIAxwyjjZpyo8sdQmxwapATuH 8ZJe6SmS/Ggk9WqVdazQppwtz7I8E37R//PDGAQjg8ANUSTaA88AaDMcKKB/cz01b0 /QVqN8dKtEuRA== 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 Cc: Alex Shi Subject: [PATCH 05/15] mm/z3fold: use zpdesc in init_z3fold_page Date: Fri, 21 Jun 2024 13:46:45 +0800 Message-ID: <20240621054658.1220796-6-alexs@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240621054658.1220796-1-alexs@kernel.org> References: <20240621054658.1220796-1-alexs@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Alex Shi The func only uses page.private member, now use zpdesc.zppage_flag to replace it. Signed-off-by: Alex Shi --- mm/z3fold.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/mm/z3fold.c b/mm/z3fold.c index bfbc9f9fdfd4..cd1332243c62 100644 --- a/mm/z3fold.c +++ b/mm/z3fold.c @@ -320,15 +320,16 @@ static inline void free_handle(unsigned long handle, = struct z3fold_header *zhdr) static struct z3fold_header *init_z3fold_page(struct page *page, bool head= less, struct z3fold_pool *pool, gfp_t gfp) { - struct z3fold_header *zhdr =3D page_address(page); + struct zpdesc *zpdesc =3D page_zpdesc(page); + struct z3fold_header *zhdr =3D zpdesc_address(zpdesc); struct z3fold_buddy_slots *slots; =20 - clear_bit(PAGE_HEADLESS, &page->private); - clear_bit(MIDDLE_CHUNK_MAPPED, &page->private); - clear_bit(NEEDS_COMPACTING, &page->private); - clear_bit(PAGE_STALE, &page->private); - clear_bit(PAGE_CLAIMED, &page->private); - clear_bit(PAGE_MIGRATED, &page->private); + clear_bit(PAGE_HEADLESS, &zpdesc->zppage_flag); + clear_bit(MIDDLE_CHUNK_MAPPED, &zpdesc->zppage_flag); + clear_bit(NEEDS_COMPACTING, &zpdesc->zppage_flag); + clear_bit(PAGE_STALE, &zpdesc->zppage_flag); + clear_bit(PAGE_CLAIMED, &zpdesc->zppage_flag); + clear_bit(PAGE_MIGRATED, &zpdesc->zppage_flag); if (headless) return zhdr; =20 --=20 2.43.0 From nobody Tue Dec 16 19:40:58 2025 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 2C4BB16B732 for ; Fri, 21 Jun 2024 05:42:23 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718948543; cv=none; b=GrWi8cQIc+HBpsTLbTt9JzSATEEAgSxUxYVbo8gPWmHNCptY8bpfqpk0tcSpNNg+KiwjuqLmelmGm80JW1943UkY5pFGeDxAtxr3Hlt/wQ/dlpjjiTSZThEMoK19A924M3Ag643VrfMsSKFH6Z0TpSvwx4pvr09zPER4musDg90= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718948543; c=relaxed/simple; bh=Aj59HBvyuIXaYaW1di/3HOtWKFIv4GVuFVxywiNiDA0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=clXw2LsGJTNKDlEq7kJTP8JF43mbInAMXcZ1MBeDQDzOJObkkcQ5MUEXv3wJmPPitsxCDKOx9yBNzMrhQ2pYb4mrqFtIC2+VLRh1H1X/EHL4K5pqdq5KAH3lSC7ezalKMezNBGHgsUTWMz22O5teTxj5xM0RLDTzeUPRVCfBgNI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=EsKyTF1/; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="EsKyTF1/" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 5FEAEC4AF07; Fri, 21 Jun 2024 05:42:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1718948542; bh=Aj59HBvyuIXaYaW1di/3HOtWKFIv4GVuFVxywiNiDA0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=EsKyTF1/bKjYshawlayijtDnP8TUPAZKDtD/Mh/KT6Qq+EEO2S0IMoRSTTzJEp6WC rP1rbJdiN/rO43GsAOREos0OE0VzeKq9mxgnIr9xFw7ZVhj7pzSyzr6JDu7wmazDBE m8dwTE+C2Jn8TGnK9a1VrQHMluBY35EUgoAJKifG2p8UTdMFjLU4NvH4v9LT+ayQoK G0nwEdswmMNrjjmAz/ob2PsABybafsKanTwqe6OWhN6IkJQvNEl02+twpanS7M8zRm 6Y4lxyxLowIGC/YcvclDu1cpRRheNG0WyDbEusaKHHJU/rHddJ0Vu17098evnuFyRQ t5biyiMG26RoA== 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 Cc: Alex Shi Subject: [PATCH 06/15] mm/z3fold: use zpdesc in free_z3fold_page Date: Fri, 21 Jun 2024 13:46:46 +0800 Message-ID: <20240621054658.1220796-7-alexs@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240621054658.1220796-1-alexs@kernel.org> References: <20240621054658.1220796-1-alexs@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Alex Shi Convert page to zpdesc in free_z3fold_page and introduce new helper zpdesc_lock/unlock. this patch could saves about 10kbytes on object file size. Signed-off-by: Alex Shi --- mm/z3fold.c | 10 ++++++---- mm/zpdesc.h | 10 ++++++++++ 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/mm/z3fold.c b/mm/z3fold.c index cd1332243c62..c3c740b42052 100644 --- a/mm/z3fold.c +++ b/mm/z3fold.c @@ -351,12 +351,14 @@ static struct z3fold_header *init_z3fold_page(struct = page *page, bool headless, /* Resets the struct page fields and frees the page */ static void free_z3fold_page(struct page *page, bool headless) { + struct zpdesc *zpdesc =3D page_zpdesc(page); + if (!headless) { - lock_page(page); - __ClearPageMovable(page); - unlock_page(page); + zpdesc_lock(zpdesc); + __ClearPageMovable(zpdesc_page(zpdesc)); + zpdesc_unlock(zpdesc); } - __free_page(page); + __free_page(zpdesc_page(zpdesc)); } =20 /* Helper function to build the index */ diff --git a/mm/zpdesc.h b/mm/zpdesc.h index 7fde29645331..06cfd33de330 100644 --- a/mm/zpdesc.h +++ b/mm/zpdesc.h @@ -58,4 +58,14 @@ static inline void zpdesc_put(struct zpdesc *zpdesc) folio_put(zpdesc_folio(zpdesc)); } =20 +static inline void zpdesc_lock(struct zpdesc *zpdesc) +{ + folio_lock(zpdesc_folio(zpdesc)); +} + +static inline void zpdesc_unlock(struct zpdesc *zpdesc) +{ + folio_unlock(zpdesc_folio(zpdesc)); +} + #endif --=20 2.43.0 From nobody Tue Dec 16 19:40:58 2025 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5DEB2152500 for ; Fri, 21 Jun 2024 05:42:25 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718948546; cv=none; b=Aorms2TjSN+R5uygxdo1A1FbKdRoboihE63AWYRTTtefrlg+12XaXXzqpnhASAF6Y/LIV3S5ZRvYG+Dop/sNXs1zJLSR8RYbMKONox2xSMBLuKS27b00ZPPfYceHs89pGWY9C20DTLrmVYKhLBjJJvspDE9EkFx1Q2YCfCC1mKc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718948546; c=relaxed/simple; bh=HH8XUbwE54a8Ffun41cCB2IdbyAXONYKrrqycjR2+TA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=JQzvwTcqPw3VOt+Yp5ukp/jaNtbri8CL2V8M+cg2nZbKUcAtNmjLJ94WRcS7u0FS7yQNUbhT1abuFDIjyCndxSPkQBiUbo5frwB8/oJp1BTxtIWgcW+OD6FWmvQdUOEy6hAWpkiuHliYnUOLILhDonZNcn1cDYE1YPnLdeAA10Y= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=pMsgGw2f; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="pMsgGw2f" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 7C3E8C4AF09; Fri, 21 Jun 2024 05:42:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1718948545; bh=HH8XUbwE54a8Ffun41cCB2IdbyAXONYKrrqycjR2+TA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=pMsgGw2faeC2vry7ZfObRdqPniifc1PywteXa6fKyQZYs70YWl/TsVQxmuZoesIEw TaQze64JKDMRSAWcfynF7PkpSTcd/3wsLqNQTQhm2t1EJ5Vd2V0qb3z9oXhnvIGpUn 5QCBfWdYoIGz7WXdJ58DpOID9+bOjQ6yL+C84N7J6ri+uSjnhEwxGAgZCh0n0PyOw+ zT8S+Xy5If/MnxW9+63qKKT6ypsQe+hmbyJgImhAjzy4nrmUrjCUUjodTol/lVTA6i cZupBvuMYNV6/g/N+p4Nhd2AkuPrgu2adPHto/Tma6Up2WQS+tMICgF44Z+INGUrEE 15rT8lv4wMCBQ== 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 Cc: Alex Shi Subject: [PATCH 07/15] mm/z3fold: convert page to zpdesc in __release_z3fold_page Date: Fri, 21 Jun 2024 13:46:47 +0800 Message-ID: <20240621054658.1220796-8-alexs@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240621054658.1220796-1-alexs@kernel.org> References: <20240621054658.1220796-1-alexs@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Alex Shi The main purpose is converting page->private to zpdesc->zppage_flag. Signed-off-by: Alex Shi --- mm/z3fold.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/mm/z3fold.c b/mm/z3fold.c index c3c740b42052..afdf21024f83 100644 --- a/mm/z3fold.c +++ b/mm/z3fold.c @@ -441,12 +441,12 @@ static inline struct z3fold_pool *zhdr_to_pool(struct= z3fold_header *zhdr) =20 static void __release_z3fold_page(struct z3fold_header *zhdr, bool locked) { - struct page *page =3D virt_to_page(zhdr); + struct zpdesc *zpdesc =3D page_zpdesc(virt_to_page(zhdr)); struct z3fold_pool *pool =3D zhdr_to_pool(zhdr); =20 WARN_ON(!list_empty(&zhdr->buddy)); - set_bit(PAGE_STALE, &page->private); - clear_bit(NEEDS_COMPACTING, &page->private); + set_bit(PAGE_STALE, &zpdesc->zppage_flag); + clear_bit(NEEDS_COMPACTING, &zpdesc->zppage_flag); spin_lock(&pool->lock); spin_unlock(&pool->lock); =20 --=20 2.43.0 From nobody Tue Dec 16 19:40:58 2025 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 636B316B72E for ; Fri, 21 Jun 2024 05:42:28 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718948549; cv=none; b=gqIbArw4N88xL2mgxYVZiyWKDSXdYXmxSzEB4CcJjhQGA1AxNOZ1PjakWbQw8cBSO6akUstlHbAyBg4VRvTJn4JDVQ4jUtwez+iNmBgHoPDEkllG7dJdxj7JPqsiS/yVMw2Uz5otpzDxQ9n2FeorDlS4bpIv36K+8Cibur4zIwA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718948549; c=relaxed/simple; bh=i+6jvijEvKznYbydl9yTcQyvtnhbHNyQpu93+PKwok0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=MjVzylb5P+GI7B1xj5Ir3FTcviedtNsiZ+UAdxA1RRBKdqvoJ74pkEpzKk1NO3lzozanI19NEdzlw6oW0cHAHZl782k/kgQsF9cs25LGQ1XWNdCBO4us8cvKlaEUjO4ApysJRjdMb4zn5zzpFx2e09F0jzlMaDMaiN+j6bVljtA= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=czXMYM0b; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="czXMYM0b" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 745EDC2BBFC; Fri, 21 Jun 2024 05:42:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1718948548; bh=i+6jvijEvKznYbydl9yTcQyvtnhbHNyQpu93+PKwok0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=czXMYM0bXh8jZ8xftE+0j1b7rkSL/jCrtw8ckNbHOZmFLB7ysjWJPl9eILFV6RiCa ajtcXwIb12ZQn7bD+gnfFGeceJkDl10HMKqJzwtZZL4O8OMOIaeY3jdEaHqwbtjUpr SvQrsXs6MAxl0on05DNGeHGaIr8bj2CwOHFmZC1A18rOD/+mipzobyJ6T5Bdccpi8S 5NpmdOV4Lmf8teIpRLA9Siiu/VXDGNVCUsFKEx3ZokuJIq6o+P4FuuRn/6ZtdGwHgs VgaY11vZfsiMnM9acjeemBSsxFoFDT9cd1v+/atG/tK28kDz64lYZmxxdlFoHXY+Es vb6yS7x9hDVdw== 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 Cc: Alex Shi Subject: [PATCH 08/15] mm/z3fold: use zpdesc free_pages_work Date: Fri, 21 Jun 2024 13:46:48 +0800 Message-ID: <20240621054658.1220796-9-alexs@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240621054658.1220796-1-alexs@kernel.org> References: <20240621054658.1220796-1-alexs@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Alex Shi The main purpose is converting page->private to zpdesc->zppage_flag. Signed-off-by: Alex Shi --- mm/z3fold.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/mm/z3fold.c b/mm/z3fold.c index afdf21024f83..97580e2224c2 100644 --- a/mm/z3fold.c +++ b/mm/z3fold.c @@ -501,14 +501,14 @@ static void free_pages_work(struct work_struct *w) while (!list_empty(&pool->stale)) { struct z3fold_header *zhdr =3D list_first_entry(&pool->stale, struct z3fold_header, buddy); - struct page *page =3D virt_to_page(zhdr); + struct zpdesc *zpdesc =3D page_zpdesc(virt_to_page(zhdr)); =20 list_del(&zhdr->buddy); - if (WARN_ON(!test_bit(PAGE_STALE, &page->private))) + if (WARN_ON(!test_bit(PAGE_STALE, &zpdesc->zppage_flag))) continue; spin_unlock(&pool->stale_lock); cancel_work_sync(&zhdr->work); - free_z3fold_page(page, false); + free_z3fold_page(zpdesc_page(zpdesc), false); cond_resched(); spin_lock(&pool->stale_lock); } --=20 2.43.0 From nobody Tue Dec 16 19:40:58 2025 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 100E216C444 for ; Fri, 21 Jun 2024 05:42:32 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718948552; cv=none; b=XgpvVacXVnIx6shTgoFjrWWRNa2rjWLFtMg7HxXRX3PDm6pxb7Ypie8bbItYVk8SfkEdg68bHlDbPTE78zDQyIxlm2703h1MperQaSODJTmun/+5d00D072WBOtzZ8dvy0xqcNuXvFgUDOG9rTsLcLi7gBSjLqSD/jD12isnpbk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718948552; c=relaxed/simple; bh=y6KoeLhtvm8xPFObZNaibmIhv/1vXuAoQWjifV7MAf4=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=pfWQs9GrkA6z+p9p+QtEn5MXMek4AYZ7WxeQQHxBqYytcBKVZ/EE5ddHpeH1dK3zifRewSxr8+uWZHcuPzGcz4vgnAkP1pf4yTc1U2MeZT2RimOiYbqQDkVVZryMMMDrLW4WCnZQX80s2toxREqnVgW+t9OziKlrcnEdq6IRtsQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=ghaTGi+U; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="ghaTGi+U" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 6DA2EC4AF0A; Fri, 21 Jun 2024 05:42:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1718948551; bh=y6KoeLhtvm8xPFObZNaibmIhv/1vXuAoQWjifV7MAf4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ghaTGi+UM7rTyHmBOXsg4g/Q87Fxag1B+8BTmn51DnnCTFVZEYWtdlc1Bq6m3a9OI rQmyMjlhsXeMSLdsf0OBDkZ1iiUBcbohmeGSHet9Zbf7odS2O+5sYO1rxn7TGCFPwB 7nWzR442GxYjaomeWTuFa/aYTj8j5EeBGaln1+26V2j470pWPmGx2LJEwONvA9SvRT e0BhQPgYEahIKbmo0CW1nY82aDZg1EpHbZQQ1YQgHfehQwIA20edDZL8ekXeXcPzUa /paqNPM9jXw3gMc1gIQbA8PPVvb3zcgJ6xvaBNXvzos35sn6ju19wMc/BEc7n5v5x5 nRmPjpjlYopSQ== 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 Cc: Alex Shi Subject: [PATCH 09/15] mm/z3fold: use zpdesc in z3fold_compact_page and do_compact_page Date: Fri, 21 Jun 2024 13:46:49 +0800 Message-ID: <20240621054658.1220796-10-alexs@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240621054658.1220796-1-alexs@kernel.org> References: <20240621054658.1220796-1-alexs@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Alex Shi The main purpose is converting page->private to zpdesc->zppage_flag too. Signed-off-by: Alex Shi --- mm/z3fold.c | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/mm/z3fold.c b/mm/z3fold.c index 97580e2224c2..3d36448885c9 100644 --- a/mm/z3fold.c +++ b/mm/z3fold.c @@ -691,12 +691,12 @@ static struct z3fold_header *compact_single_buddy(str= uct z3fold_header *zhdr) /* Has to be called with lock held */ static int z3fold_compact_page(struct z3fold_header *zhdr) { - struct page *page =3D virt_to_page(zhdr); + struct zpdesc *zpdesc =3D page_zpdesc(virt_to_page(zhdr)); =20 - if (test_bit(MIDDLE_CHUNK_MAPPED, &page->private)) + if (test_bit(MIDDLE_CHUNK_MAPPED, &zpdesc->zppage_flag)) return 0; /* can't move middle chunk, it's used */ =20 - if (unlikely(PageIsolated(page))) + if (unlikely(PageIsolated(zpdesc_page(zpdesc)))) return 0; =20 if (zhdr->middle_chunks =3D=3D 0) @@ -739,14 +739,13 @@ static int z3fold_compact_page(struct z3fold_header *= zhdr) static void do_compact_page(struct z3fold_header *zhdr, bool locked) { struct z3fold_pool *pool =3D zhdr_to_pool(zhdr); - struct page *page; + struct zpdesc *zpdesc =3D page_zpdesc(virt_to_page(zhdr)); =20 - page =3D virt_to_page(zhdr); if (locked) WARN_ON(z3fold_page_trylock(zhdr)); else z3fold_page_lock(zhdr); - if (WARN_ON(!test_and_clear_bit(NEEDS_COMPACTING, &page->private))) { + if (WARN_ON(!test_and_clear_bit(NEEDS_COMPACTING, &zpdesc->zppage_flag)))= { z3fold_page_unlock(zhdr); return; } @@ -757,8 +756,8 @@ static void do_compact_page(struct z3fold_header *zhdr,= bool locked) if (put_z3fold_locked(zhdr)) return; =20 - if (test_bit(PAGE_STALE, &page->private) || - test_and_set_bit(PAGE_CLAIMED, &page->private)) { + if (test_bit(PAGE_STALE, &zpdesc->zppage_flag) || + test_and_set_bit(PAGE_CLAIMED, &zpdesc->zppage_flag)) { z3fold_page_unlock(zhdr); return; } @@ -766,7 +765,7 @@ static void do_compact_page(struct z3fold_header *zhdr,= bool locked) if (!zhdr->foreign_handles && buddy_single(zhdr) && zhdr->mapped_count =3D=3D 0 && compact_single_buddy(zhdr)) { if (!put_z3fold_locked(zhdr)) { - clear_bit(PAGE_CLAIMED, &page->private); + clear_bit(PAGE_CLAIMED, &zpdesc->zppage_flag); z3fold_page_unlock(zhdr); } return; @@ -774,7 +773,7 @@ static void do_compact_page(struct z3fold_header *zhdr,= bool locked) =20 z3fold_compact_page(zhdr); add_to_unbuddied(pool, zhdr); - clear_bit(PAGE_CLAIMED, &page->private); + clear_bit(PAGE_CLAIMED, &zpdesc->zppage_flag); z3fold_page_unlock(zhdr); } =20 --=20 2.43.0 From nobody Tue Dec 16 19:40:58 2025 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 93FDF16C6A6 for ; Fri, 21 Jun 2024 05:42:35 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718948555; cv=none; b=Zzgy/1sjvRLLB48AsNJReWTXtoC8k7i02DbnMde4hBWHfT2nIZMHdJEDu1jWekfu0IbECkn4rr8koOTCHqZ+vU9wUmgfYoxCkG13tS3xzQosN1evU2b6nVWmBZCge7mroIC+Nx8WSZyffYAFPUdEj/PydlVm89Y5TSzJnlx+JVA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718948555; c=relaxed/simple; bh=Sd2Phg+JvwLSFmEURLUSKjCDab85FD2bJliNqmZmxJc=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=b4DP9M5TdhxsUGGeeUmyNyxgQKuvfaKl9CcYs4w1mahtdRGtar3ZED/1stasGdTWfPm2Nq9YoxriKcI1NIg3BIRRh/8S//xPEtJE9uL2h+10NICsjZh3VfjeIHgp589CQWLFmtu5/tqopVToLlWmHR3hPKrdNdA09cNiO4tdfFY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=IsjvEN5G; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="IsjvEN5G" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 89007C2BBFC; Fri, 21 Jun 2024 05:42:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1718948555; bh=Sd2Phg+JvwLSFmEURLUSKjCDab85FD2bJliNqmZmxJc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=IsjvEN5G5UtwH5nf6m44K+yulQm1RsG8bHkIVkguFk1JvLe7qVG7hIdWTy4Kjs6Pe VAiFIQIHfPdS+46prNFdVC42cOugMQXDmwTViUO66+hLNc28yBDx172D/Esdp9mqyB tQ1rxcUrko5b+IiC101fBhNBvOcgzADOF/MTa6NS7Rq1aJXjNLgi6RyfKTiNUEPIzd ItWxesPk2knISOhVPZf1M8Z5+JvBXQG1WaNJki8upVSP04V1DDxv5DypiOBa1t7nE9 XTTxK9Nqj8U8AH8xM38UDDCQ6j1EQihjMZ6aEueUdq74JdFqt5WsYVwfBssqvfzOKK 2igffWYGHyERg== 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 Cc: Alex Shi Subject: [PATCH 10/15] mm/z3fold: use zpdesc in __z3fold_alloc Date: Fri, 21 Jun 2024 13:46:50 +0800 Message-ID: <20240621054658.1220796-11-alexs@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240621054658.1220796-1-alexs@kernel.org> References: <20240621054658.1220796-1-alexs@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Alex Shi The main purpose is converting page->private to zpdesc->zppage_flag. Signed-off-by: Alex Shi --- mm/z3fold.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/mm/z3fold.c b/mm/z3fold.c index 3d36448885c9..f164eb4e1139 100644 --- a/mm/z3fold.c +++ b/mm/z3fold.c @@ -790,7 +790,7 @@ static inline struct z3fold_header *__z3fold_alloc(stru= ct z3fold_pool *pool, size_t size, bool can_sleep) { struct z3fold_header *zhdr =3D NULL; - struct page *page; + struct zpdesc *zpdesc; struct list_head *unbuddied; int chunks =3D size_to_chunks(size), i; =20 @@ -823,9 +823,9 @@ static inline struct z3fold_header *__z3fold_alloc(stru= ct z3fold_pool *pool, zhdr->cpu =3D -1; spin_unlock(&pool->lock); =20 - page =3D virt_to_page(zhdr); - if (test_bit(NEEDS_COMPACTING, &page->private) || - test_bit(PAGE_CLAIMED, &page->private)) { + zpdesc =3D page_zpdesc(virt_to_page(zhdr)); + if (test_bit(NEEDS_COMPACTING, &zpdesc->zppage_flag) || + test_bit(PAGE_CLAIMED, &zpdesc->zppage_flag)) { z3fold_page_unlock(zhdr); zhdr =3D NULL; migrate_enable(); @@ -868,9 +868,9 @@ static inline struct z3fold_header *__z3fold_alloc(stru= ct z3fold_pool *pool, zhdr->cpu =3D -1; spin_unlock(&pool->lock); =20 - page =3D virt_to_page(zhdr); - if (test_bit(NEEDS_COMPACTING, &page->private) || - test_bit(PAGE_CLAIMED, &page->private)) { + zpdesc =3D page_zpdesc(virt_to_page(zhdr)); + if (test_bit(NEEDS_COMPACTING, &zpdesc->zppage_flag) || + test_bit(PAGE_CLAIMED, &zpdesc->zppage_flag)) { z3fold_page_unlock(zhdr); zhdr =3D NULL; if (can_sleep) --=20 2.43.0 From nobody Tue Dec 16 19:40:58 2025 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 4FD9616C841 for ; Fri, 21 Jun 2024 05:42:38 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718948558; cv=none; b=d3gqd2x+/KGde7nDrq3gn2F4VduD7As/miHATwYze8hMip44c616fcIyMNyOAXD3ZVCx3C+9/iPJJijtOinuKUdog1X0O6ZhrshuXiCqoeQXLLUZ+oNWS+2zSGMbFY1aoaIBM9Dt/UrLoI0bSd/XP0neoYBeYMpQUpKPPZR+ves= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718948558; c=relaxed/simple; bh=dBoIzS7885VeKezN+gY+kbZ+dCan8vwvmHD8Z0kpVt0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=hB+eiyQJtLFFCTNzPgsK0uOMck8uRoI/+Aq4Qi5XRsPBl/XfgVhDUxzyFGXMybiConfZUJTg68FHv1JoTTCuKV1Ul33dFmFJbWBGGP49vKzD6VPcZnmXFEpWfZ5lOQCFWSh0NJXg5MDGhcFm5sVKSZ2XXI7J1SrS4MRVeAGLPBg= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=Dhhurl3c; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="Dhhurl3c" Received: by smtp.kernel.org (Postfix) with ESMTPSA id AD57CC4AF07; Fri, 21 Jun 2024 05:42:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1718948558; bh=dBoIzS7885VeKezN+gY+kbZ+dCan8vwvmHD8Z0kpVt0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Dhhurl3cF4nteYiqCwSt1qwbQI2OTdrwgXN3j6ATVB1DNAHIvWS+c7hY4e16dlN6l SxH+V4eiObBiqu3OQvjRDh3meSyWpVloR2DvITcgYW+xDaMzNhg4rPpvk8Z2qbUtb4 vq49YEJnL3gz6HL0yp/KvMpG+g0VlAPTdP7HpqIZQ0OD8X2JBdQtTe/NNaH7aI1jwx GJ6nWcnMBWe+rPxVnrWnC14CZ2CwSkeieja++9ODBJyzCVkpw1/9l3W8N0Y8nViDHj yMR1NaxKkFHtVdXydX5qGU06OsQZdVfO/0FgcSjo+HzwyZVOdr5jm050B9WkbdxTCy Sq5KFiKIWilwA== 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 Cc: Alex Shi Subject: [PATCH 11/15] mm/z3fold: use zpdesc in z3fold_alloc Date: Fri, 21 Jun 2024 13:46:51 +0800 Message-ID: <20240621054658.1220796-12-alexs@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240621054658.1220796-1-alexs@kernel.org> References: <20240621054658.1220796-1-alexs@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Alex Shi Convert page to zpdesc in z3fold_alloc func. Since both func use zpdesc now, we can pass zpdesc to init_z3fold_page(). And introduce zpdesc_trylock helper. This patch could save about 12KB object file size. Originally-by: Hyeonggon Yoo <42.hyeyoo@gmail.com> Signed-off-by: Alex Shi --- mm/z3fold.c | 29 ++++++++++++++--------------- mm/zpdesc.h | 5 +++++ 2 files changed, 19 insertions(+), 15 deletions(-) diff --git a/mm/z3fold.c b/mm/z3fold.c index f164eb4e1139..e780143982c6 100644 --- a/mm/z3fold.c +++ b/mm/z3fold.c @@ -317,10 +317,9 @@ static inline void free_handle(unsigned long handle, s= truct z3fold_header *zhdr) } =20 /* Initializes the z3fold header of a newly allocated z3fold page */ -static struct z3fold_header *init_z3fold_page(struct page *page, bool head= less, +static struct z3fold_header *init_z3fold_page(struct zpdesc *zpdesc, bool = headless, struct z3fold_pool *pool, gfp_t gfp) { - struct zpdesc *zpdesc =3D page_zpdesc(page); struct z3fold_header *zhdr =3D zpdesc_address(zpdesc); struct z3fold_buddy_slots *slots; =20 @@ -1006,7 +1005,7 @@ static int z3fold_alloc(struct z3fold_pool *pool, siz= e_t size, gfp_t gfp, { int chunks =3D size_to_chunks(size); struct z3fold_header *zhdr =3D NULL; - struct page *page =3D NULL; + struct zpdesc *zpdesc =3D NULL; enum buddy bud; bool can_sleep =3D gfpflags_allow_blocking(gfp); =20 @@ -1030,35 +1029,35 @@ static int z3fold_alloc(struct z3fold_pool *pool, s= ize_t size, gfp_t gfp, WARN_ON(1); goto retry; } - page =3D virt_to_page(zhdr); + zpdesc =3D page_zpdesc(virt_to_page(zhdr)); goto found; } bud =3D FIRST; } =20 - page =3D alloc_page(gfp); - if (!page) + zpdesc =3D page_zpdesc(alloc_page(gfp)); + if (!zpdesc) return -ENOMEM; =20 - zhdr =3D init_z3fold_page(page, bud =3D=3D HEADLESS, pool, gfp); + zhdr =3D init_z3fold_page(zpdesc, bud =3D=3D HEADLESS, pool, gfp); if (!zhdr) { - __free_page(page); + __free_page(zpdesc_page(zpdesc)); return -ENOMEM; } atomic64_inc(&pool->pages_nr); =20 if (bud =3D=3D HEADLESS) { - set_bit(PAGE_HEADLESS, &page->private); + set_bit(PAGE_HEADLESS, &zpdesc->zppage_flag); goto headless; } if (can_sleep) { - lock_page(page); - __SetPageMovable(page, &z3fold_mops); - unlock_page(page); + zpdesc_lock(zpdesc); + __SetPageMovable(zpdesc_page(zpdesc), &z3fold_mops); + zpdesc_unlock(zpdesc); } else { - WARN_ON(!trylock_page(page)); - __SetPageMovable(page, &z3fold_mops); - unlock_page(page); + WARN_ON(!zpdesc_trylock(zpdesc)); + __SetPageMovable(zpdesc_page(zpdesc), &z3fold_mops); + zpdesc_unlock(zpdesc); } z3fold_page_lock(zhdr); =20 diff --git a/mm/zpdesc.h b/mm/zpdesc.h index 06cfd33de330..9ead7a452f2a 100644 --- a/mm/zpdesc.h +++ b/mm/zpdesc.h @@ -63,6 +63,11 @@ static inline void zpdesc_lock(struct zpdesc *zpdesc) folio_lock(zpdesc_folio(zpdesc)); } =20 +static inline bool zpdesc_trylock(struct zpdesc *zpdesc) +{ + return folio_trylock(zpdesc_folio(zpdesc)); +} + static inline void zpdesc_unlock(struct zpdesc *zpdesc) { folio_unlock(zpdesc_folio(zpdesc)); --=20 2.43.0 From nobody Tue Dec 16 19:40:58 2025 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 6A2C816C863 for ; Fri, 21 Jun 2024 05:42:41 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718948561; cv=none; b=eE9wWnDGZerlUQ6dTmr8fO6LKG2d8iBhYN2j4c28HOWO4SStDqjTbKWLQYri2blcYsWltWMMvYQv3mtm6FNs1xVZGd2H++Md0TPdilkDbJWrYYtEwBcjnxdZ1Jf8jYzYKsvDYN+rCCO/T5AvMoXPaQLK9r3JIwqz5jz8RSi2xcc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718948561; c=relaxed/simple; bh=iUFkTemSK3oMLsI1l/U6UgPholZKLkeww8XRyVLS3YQ=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=aKo+RfKIE31JxlcNbQrcPygh6WXMFt87sROSRtjkOLOLILEUMH9UlBBxSyhdmUwnLOYiWSdqAFC2c6R3CthmdOwljJoVzcYcLh7a3XRpPPRBldhwTsIYS2NQSAepaZCnJzu52YRe4S3W2j+HNVFOKjtq3zURO54Dzuy1uI5Wpuc= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=H4G9h9IY; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="H4G9h9IY" Received: by smtp.kernel.org (Postfix) with ESMTPSA id C7E36C4AF0C; Fri, 21 Jun 2024 05:42:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1718948561; bh=iUFkTemSK3oMLsI1l/U6UgPholZKLkeww8XRyVLS3YQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=H4G9h9IYgL6A+XLLiKLsHlkZMWM8Y9URN+Jrim9l0215wGO1ZYme7D9n+vqXl9EN6 oqO7g8axPVPUtW3TSyt5NGMoL4B1OKHE39rXL55GNZTTKfMDZe26DCFXp5qUtogvY7 CsT1ieKYR27q6/Z/PjoIv3EestKY3vwZ/8GhzGH39WuwZWauB+SRJHD5KjaojXIJhQ NDJcDxv31lxeL3ysuF6lseIq9ogCnBRYKidgBPlU68L2BTbks1c/rgFD/76b+4Z6Lo eCK4vIu6+ZRcfwnjRu4feZIpSAn1jppqehkqwRuQ0iHMq5t23ZDdAlitNKAMGTgTCF iiOkZLvINvdoA== 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 Cc: Alex Shi Subject: [PATCH 12/15] mm/z3fold: use zpdesc in free_z3fold_page and z3fold_free Date: Fri, 21 Jun 2024 13:46:52 +0800 Message-ID: <20240621054658.1220796-13-alexs@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240621054658.1220796-1-alexs@kernel.org> References: <20240621054658.1220796-1-alexs@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Alex Shi Convert page to zpdesc in free_z3fold_page and its caller z3fold_free, it could save 430bytes. Signed-off-by: Alex Shi --- mm/z3fold.c | 26 ++++++++++++-------------- 1 file changed, 12 insertions(+), 14 deletions(-) diff --git a/mm/z3fold.c b/mm/z3fold.c index e780143982c6..6283f90d1c22 100644 --- a/mm/z3fold.c +++ b/mm/z3fold.c @@ -347,11 +347,9 @@ static struct z3fold_header *init_z3fold_page(struct z= pdesc *zpdesc, bool headle return zhdr; } =20 -/* Resets the struct page fields and frees the page */ -static void free_z3fold_page(struct page *page, bool headless) +/* Resets the struct zpdesc fields and frees the page */ +static void free_z3fold_page(struct zpdesc *zpdesc, bool headless) { - struct zpdesc *zpdesc =3D page_zpdesc(page); - if (!headless) { zpdesc_lock(zpdesc); __ClearPageMovable(zpdesc_page(zpdesc)); @@ -507,7 +505,7 @@ static void free_pages_work(struct work_struct *w) continue; spin_unlock(&pool->stale_lock); cancel_work_sync(&zhdr->work); - free_z3fold_page(zpdesc_page(zpdesc), false); + free_z3fold_page(zpdesc, false); cond_resched(); spin_lock(&pool->stale_lock); } @@ -1095,15 +1093,15 @@ static int z3fold_alloc(struct z3fold_pool *pool, s= ize_t size, gfp_t gfp, static void z3fold_free(struct z3fold_pool *pool, unsigned long handle) { struct z3fold_header *zhdr; - struct page *page; + struct zpdesc *zpdesc; enum buddy bud; bool page_claimed; =20 zhdr =3D get_z3fold_header(handle); - page =3D virt_to_page(zhdr); - page_claimed =3D test_and_set_bit(PAGE_CLAIMED, &page->private); + zpdesc =3D page_zpdesc(virt_to_page(zhdr)); + page_claimed =3D test_and_set_bit(PAGE_CLAIMED, &zpdesc->zppage_flag); =20 - if (test_bit(PAGE_HEADLESS, &page->private)) { + if (test_bit(PAGE_HEADLESS, &zpdesc->zppage_flag)) { /* if a headless page is under reclaim, just leave. * NB: we use test_and_set_bit for a reason: if the bit * has not been set before, we release this page @@ -1111,7 +1109,7 @@ static void z3fold_free(struct z3fold_pool *pool, uns= igned long handle) */ if (!page_claimed) { put_z3fold_header(zhdr); - free_z3fold_page(page, true); + free_z3fold_page(zpdesc, true); atomic64_dec(&pool->pages_nr); } return; @@ -1146,20 +1144,20 @@ static void z3fold_free(struct z3fold_pool *pool, u= nsigned long handle) put_z3fold_header(zhdr); return; } - if (test_and_set_bit(NEEDS_COMPACTING, &page->private)) { - clear_bit(PAGE_CLAIMED, &page->private); + if (test_and_set_bit(NEEDS_COMPACTING, &zpdesc->zppage_flag)) { + clear_bit(PAGE_CLAIMED, &zpdesc->zppage_flag); put_z3fold_header(zhdr); return; } if (zhdr->cpu < 0 || !cpu_online(zhdr->cpu)) { zhdr->cpu =3D -1; kref_get(&zhdr->refcount); - clear_bit(PAGE_CLAIMED, &page->private); + clear_bit(PAGE_CLAIMED, &zpdesc->zppage_flag); do_compact_page(zhdr, true); return; } kref_get(&zhdr->refcount); - clear_bit(PAGE_CLAIMED, &page->private); + clear_bit(PAGE_CLAIMED, &zpdesc->zppage_flag); queue_work_on(zhdr->cpu, pool->compact_wq, &zhdr->work); put_z3fold_header(zhdr); } --=20 2.43.0 From nobody Tue Dec 16 19:40:58 2025 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 679BA16D321 for ; Fri, 21 Jun 2024 05:42:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718948564; cv=none; b=ntAKgtANPFWixWMbXcYwg9gwhr/JQV4Rwpp4pbI8dxsraJaD5nYMuvwYUqzkDQIJ75Rje1uiDq6VTY/036cEV5ufLArKlZ5ZwtoAPejo9Ov4+fURoJM7XxULIEkrQeSq3mZiThV/+6skfT8xdpCqdvSRXx23YrZPb66WfGuUvX0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718948564; c=relaxed/simple; bh=bi1YiTpFhUFGRvPbUZHBdhkxL3sPin4zELQjsCTT+98=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=RoXm8iQzecQZ2d/pKjB2CPV75v0haEBGzjz9kVmKhGWmS0iPiBw44mHMbFyTuZiR5YvyIjZzmkd/T6hpHTWUGubn2c/SvHNVrB4CwIpm0LSqCewlGeAYQJ7xgYYCNae9io/Z6OjJpT61tVwXz53ToJh6PVseH7cwiZCU2KabSmo= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=Zt2liuts; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="Zt2liuts" Received: by smtp.kernel.org (Postfix) with ESMTPSA id E2B65C2BBFC; Fri, 21 Jun 2024 05:42:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1718948564; bh=bi1YiTpFhUFGRvPbUZHBdhkxL3sPin4zELQjsCTT+98=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Zt2liutsK7oexaFQKqUKy8TRoTda3rT7B1LKbaH/xbtnFL/JUig3qUzjaQk64nmTg PE2cpP3SiIOO9DqQehRhtVEbJrvnAKHGFA7kLjug6WlCc81GkT0O/+xWu+LngXcIkN Zhf/+phnJpHf8VFV55ycxsk6RSqieF+MvbbIkKoRdn7zGLAzUlFNmTtBnVOP7DPQha obEjXax3WVszHrEXSNat4nsfockOXEriYwLhkmu/04gFt554Q/iEarrqhvqDcQBPK5 v/YIgnYIEZT3L0xDJxF7bGLOLgDUN5ufC6Yavx+16hzKVpXPPPtG0dMjttpfCbAxc8 wIqnnJDrjcRsg== 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 Cc: Alex Shi Subject: [PATCH 13/15] mm/z3fold: use zpdesc in z3fold_map/z3fold_unmap Date: Fri, 21 Jun 2024 13:46:53 +0800 Message-ID: <20240621054658.1220796-14-alexs@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240621054658.1220796-1-alexs@kernel.org> References: <20240621054658.1220796-1-alexs@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Alex Shi Convert page to zpdesc in z3fold_map/z3fold_unmap pair, the main purpose is doing page->private to zpdesc->zppage_flag conversion. Signed-off-by: Alex Shi --- mm/z3fold.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/mm/z3fold.c b/mm/z3fold.c index 6283f90d1c22..7d95c0293664 100644 --- a/mm/z3fold.c +++ b/mm/z3fold.c @@ -1175,15 +1175,15 @@ static void z3fold_free(struct z3fold_pool *pool, u= nsigned long handle) static void *z3fold_map(struct z3fold_pool *pool, unsigned long handle) { struct z3fold_header *zhdr; - struct page *page; + struct zpdesc *zpdesc; void *addr; enum buddy buddy; =20 zhdr =3D get_z3fold_header(handle); addr =3D zhdr; - page =3D virt_to_page(zhdr); + zpdesc =3D page_zpdesc(virt_to_page(zhdr)); =20 - if (test_bit(PAGE_HEADLESS, &page->private)) + if (test_bit(PAGE_HEADLESS, &zpdesc->zppage_flag)) goto out; =20 buddy =3D handle_to_buddy(handle); @@ -1193,7 +1193,7 @@ static void *z3fold_map(struct z3fold_pool *pool, uns= igned long handle) break; case MIDDLE: addr +=3D zhdr->start_middle << CHUNK_SHIFT; - set_bit(MIDDLE_CHUNK_MAPPED, &page->private); + set_bit(MIDDLE_CHUNK_MAPPED, &zpdesc->zppage_flag); break; case LAST: addr +=3D PAGE_SIZE - (handle_to_chunks(handle) << CHUNK_SHIFT); @@ -1220,18 +1220,18 @@ static void *z3fold_map(struct z3fold_pool *pool, u= nsigned long handle) static void z3fold_unmap(struct z3fold_pool *pool, unsigned long handle) { struct z3fold_header *zhdr; - struct page *page; + struct zpdesc *zpdesc; enum buddy buddy; =20 zhdr =3D get_z3fold_header(handle); - page =3D virt_to_page(zhdr); + zpdesc =3D page_zpdesc(virt_to_page(zhdr)); =20 - if (test_bit(PAGE_HEADLESS, &page->private)) + if (test_bit(PAGE_HEADLESS, &zpdesc->zppage_flag)) return; =20 buddy =3D handle_to_buddy(handle); if (buddy =3D=3D MIDDLE) - clear_bit(MIDDLE_CHUNK_MAPPED, &page->private); + clear_bit(MIDDLE_CHUNK_MAPPED, &zpdesc->zppage_flag); zhdr->mapped_count--; put_z3fold_header(zhdr); } --=20 2.43.0 From nobody Tue Dec 16 19:40:58 2025 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 7CE4C16D4D9 for ; Fri, 21 Jun 2024 05:42:47 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718948567; cv=none; b=jHGBZPCRV77NR9hT3WJFQof8BHYRbDzHRmTCyVE5tg11qreXdQdxnck2S/zFF1xCuCe1LMXJcLuiroa43w671bbtgC6raIPpezoozktZpL+rCaJ306zfcpxLacjBcVyDi0wQyXJ3hPMtoevuZECP/nfwTIfPbw8TA+VCO04zHgo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718948567; c=relaxed/simple; bh=ZVUFLxXaSMstqeF9wiClbo0Fyh0HfCRoDm04x2KLjcs=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=gKAxbknGh1WKqeyWDUG90BrSZgSfy9dVp35SuBpeIC+AuGD2NAoTQbdcigy13Z6cJLpRFiyimWJrVmxc8OOgajLQcJivoG58O/FLfIMzeTop5kOtodwuO1U0b/wI9H9LnvrGdjEgfrxrckcUatd1d3fAKrmYFMYCWUfw5a/UZz4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=Smo9cGIV; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="Smo9cGIV" Received: by smtp.kernel.org (Postfix) with ESMTPSA id D9C11C4AF07; Fri, 21 Jun 2024 05:42:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1718948567; bh=ZVUFLxXaSMstqeF9wiClbo0Fyh0HfCRoDm04x2KLjcs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Smo9cGIVWmL2EmyJ8D3bauM2U8VHnP86YPTsc7LWNyv9TNzRXhgzPZGt/BHOQIZzc SZwhipISzcDFOzAYG7tOzqpmjxFuK3oXYwHeoKJ1EY7JJY9P/yvz0lkw9h9CKZ1VG5 RtVZEWyyUY/f6CYtFuUuU4SDpViqbTHhTFZkS4vCwcPTliT7zeA4MGNgCNH43Vxn+W O4Pd09FFoTkrvcCROJvWAREpQd71+NTQ5ZHuv1nv8aWR8g8jlRTS0dfYrxhodoIvo8 F2I6UKDa/XO/cSmo4+hYNCuEhAJQ7lBNcEMPNrORnwi1syjk0hEgoySbpNH64e6nvR uyORwIdsuKSAA== 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 Cc: Alex Shi Subject: [PATCH 14/15] mm/z3fold: introduce __zpdesc_set_movable Date: Fri, 21 Jun 2024 13:46:54 +0800 Message-ID: <20240621054658.1220796-15-alexs@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240621054658.1220796-1-alexs@kernel.org> References: <20240621054658.1220796-1-alexs@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Alex Shi Add a helper __zpdesc_set_movable() for __SetPageMovable(), and use it in callers. Since we actually use the page.mapping for 'struct movable_operations' pointer, we could add it into zpdesc struct now. Originally-by: Hyeonggon Yoo <42.hyeyoo@gmail.com> Signed-off-by: Alex Shi --- mm/z3fold.c | 6 +++--- mm/zpdesc.h | 6 ++++++ 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/mm/z3fold.c b/mm/z3fold.c index 7d95c0293664..35e48440c517 100644 --- a/mm/z3fold.c +++ b/mm/z3fold.c @@ -1050,11 +1050,11 @@ static int z3fold_alloc(struct z3fold_pool *pool, s= ize_t size, gfp_t gfp, } if (can_sleep) { zpdesc_lock(zpdesc); - __SetPageMovable(zpdesc_page(zpdesc), &z3fold_mops); + __zpdesc_set_movable(zpdesc, &z3fold_mops); zpdesc_unlock(zpdesc); } else { WARN_ON(!zpdesc_trylock(zpdesc)); - __SetPageMovable(zpdesc_page(zpdesc), &z3fold_mops); + __zpdesc_set_movable(zpdesc, &z3fold_mops); zpdesc_unlock(zpdesc); } z3fold_page_lock(zhdr); @@ -1334,7 +1334,7 @@ static int z3fold_page_migrate(struct page *newpage, = struct page *page, encode_handle(new_zhdr, MIDDLE); set_bit(NEEDS_COMPACTING, &newzpdesc->zppage_flag); new_zhdr->cpu =3D smp_processor_id(); - __SetPageMovable(zpdesc_page(newzpdesc), &z3fold_mops); + __zpdesc_set_movable(newzpdesc, &z3fold_mops); z3fold_page_unlock(new_zhdr); =20 queue_work_on(new_zhdr->cpu, pool->compact_wq, &new_zhdr->work); diff --git a/mm/zpdesc.h b/mm/zpdesc.h index 9ead7a452f2a..44473382f2cc 100644 --- a/mm/zpdesc.h +++ b/mm/zpdesc.h @@ -73,4 +73,10 @@ static inline void zpdesc_unlock(struct zpdesc *zpdesc) folio_unlock(zpdesc_folio(zpdesc)); } =20 +static inline void __zpdesc_set_movable(struct zpdesc *zpdesc, + const struct movable_operations *mops) +{ + __SetPageMovable(zpdesc_page(zpdesc), mops); +} + #endif --=20 2.43.0 From nobody Tue Dec 16 19:40:58 2025 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E230D16D9B0 for ; Fri, 21 Jun 2024 05:42:50 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718948571; cv=none; b=q0kM/3TuerY0RYSMgz/yY+o4FZ39Ck/JCyEPrL8FnAi8zpiZM/5UVKY3OE6ilH2Gc9zMKzfWogmAfK6ci74VVQwlPQPkaSlHAt/n3vWeLPM9YAncRt14Lw4oFd5Mzsd2iuFqzflTtoRb0aud8BKeEI/fMMtNJiqAfGC5H0DoUJ8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718948571; c=relaxed/simple; bh=8UKqY3YZXZR0aUnfYfC3JUjUQBkkwh7XEloB41aBdHg=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=SCkQzZIKATKMUi67Ue1TvKDWX8FtBAinc39q8wIZuqKRk+OHuMF8aYe+BkcRbbxxljnShwvkcvT3HuQ/78/Hkxsmlu2Y9zYx6rdCABVG+nYx/CcP74RV1/eO1alphvT0b//N0nz302Xn+iTPRy32SNa9SropDJNh7Tk6jUQfyog= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=fiYuYRr7; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="fiYuYRr7" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 005ACC4AF0A; Fri, 21 Jun 2024 05:42:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1718948570; bh=8UKqY3YZXZR0aUnfYfC3JUjUQBkkwh7XEloB41aBdHg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=fiYuYRr7TQp0GCGNgZH88c7pREIwo5/3qN3AIwrtns1l+dudvt+tFgoUVKq89TKyo snExeZWvBIrJREOD7QT35f6EX4JapxfIAgg5B6Sx6sjis+GMfr8SkGndW+9RtZ0TsF 5iuRxriNkO5bDJtffxS9vW3ofHEI3ZyYIYGJbFlRGORoDyZnSK4kn3GXmNYyTPM6Oz gMsTqYpy2JUKfNelSOh95H/jOdtAd+QPOBTQrWHQDstm9U894OjWvPuAzmoGkOOse9 EPDkIaAE/YTiIkhb32EhxY50or0Iin8djeYzNKtChW6gJNoW8To2gLSidmMn9ywxi+ s5yhy6YbOy6rw== 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 Cc: Alex Shi Subject: [PATCH 15/15] mm/z3fold: introduce __zpdesc_clear_movable Date: Fri, 21 Jun 2024 13:46:55 +0800 Message-ID: <20240621054658.1220796-16-alexs@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240621054658.1220796-1-alexs@kernel.org> References: <20240621054658.1220796-1-alexs@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Alex Shi Add a helper __zpdesc_clear_movable() for __ClearPageMovable(), and use it in callers, that make code clear. Signed-off-by: Alex Shi --- mm/z3fold.c | 4 ++-- mm/zpdesc.h | 5 +++++ 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/mm/z3fold.c b/mm/z3fold.c index 35e48440c517..e23d56f46760 100644 --- a/mm/z3fold.c +++ b/mm/z3fold.c @@ -352,7 +352,7 @@ static void free_z3fold_page(struct zpdesc *zpdesc, boo= l headless) { if (!headless) { zpdesc_lock(zpdesc); - __ClearPageMovable(zpdesc_page(zpdesc)); + __zpdesc_clear_movable(zpdesc); zpdesc_unlock(zpdesc); } __free_page(zpdesc_page(zpdesc)); @@ -1322,7 +1322,7 @@ static int z3fold_page_migrate(struct page *newpage, = struct page *page, * so we only have to reinitialize it. */ INIT_LIST_HEAD(&new_zhdr->buddy); - __ClearPageMovable(zpdesc_page(zpdesc)); + __zpdesc_clear_movable(zpdesc); =20 zpdesc_get(newzpdesc); z3fold_page_lock(new_zhdr); diff --git a/mm/zpdesc.h b/mm/zpdesc.h index 44473382f2cc..1319575dc31a 100644 --- a/mm/zpdesc.h +++ b/mm/zpdesc.h @@ -79,4 +79,9 @@ static inline void __zpdesc_set_movable(struct zpdesc *zp= desc, __SetPageMovable(zpdesc_page(zpdesc), mops); } =20 +static inline void __zpdesc_clear_movable(struct zpdesc *zpdesc) +{ + __ClearPageMovable(zpdesc_page(zpdesc)); +} + #endif --=20 2.43.0