From patchwork Fri Jun 21 05:46:41 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: 13706856 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 7978FC2BB85 for ; Fri, 21 Jun 2024 05:42:14 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 0DCEB8D012B; Fri, 21 Jun 2024 01:42:14 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 03EBB8D0111; Fri, 21 Jun 2024 01:42:13 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id D5CD58D012B; Fri, 21 Jun 2024 01:42:13 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id B862F8D0111 for ; Fri, 21 Jun 2024 01:42:13 -0400 (EDT) Received: from smtpin04.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id 6AEB31208E3 for ; Fri, 21 Jun 2024 05:42:13 +0000 (UTC) X-FDA: 82253800146.04.D096893 Received: from sin.source.kernel.org (sin.source.kernel.org [145.40.73.55]) by imf08.hostedemail.com (Postfix) with ESMTP id 15DDB160005 for ; Fri, 21 Jun 2024 05:42:10 +0000 (UTC) Authentication-Results: imf08.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=KRbg5wZp; spf=pass (imf08.hostedemail.com: domain of alexs@kernel.org designates 145.40.73.55 as permitted sender) smtp.mailfrom=alexs@kernel.org; dmarc=pass (policy=none) header.from=kernel.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1718948526; a=rsa-sha256; cv=none; b=KWATXxzxlaEh6hzYAoMyQghEurSebHlCWObnCdoKfwnb3DSAWgsM+QlScBb5QqtkwKY4tm RJ3NoJsCHFSiLbmamYLCXDruCWk8ll+qHQPAWDpfTsTBc0LI2Fb5Kq8gLNIydBS64XDPVO usXes7XzEDTdaN984gzvg2t+I/mcAXk= ARC-Authentication-Results: i=1; imf08.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=KRbg5wZp; spf=pass (imf08.hostedemail.com: domain of alexs@kernel.org designates 145.40.73.55 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=1718948526; 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:in-reply-to:references:references:dkim-signature; bh=BkBVYVuMjV3319nLn+w3Yv8JYBQVj4axiEvQvyDorbc=; b=s+/3Eowumw0px0aRWovIgLof+u9lI5rpNCPA18zb+1gP5nx2GlLnVHdBkheaaeFqfF0O7N aZel2/f7bRKGD8tzG+YsY7et8oLA+H3o4vvM/xU0Npw+ObxmIF9NiCBwUjHjgdmBn+9Yk0 Me1c8QXe9whZ9SEoUYHhQ6tbWJEmRZA= Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by sin.source.kernel.org (Postfix) with ESMTP id 0CEC0CE2B50; Fri, 21 Jun 2024 05:42:08 +0000 (UTC) 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> MIME-Version: 1.0 X-Stat-Signature: 3a6kjdyfos8d7fyz3dobtnttwipxf9yt X-Rspamd-Queue-Id: 15DDB160005 X-Rspam-User: X-Rspamd-Server: rspam10 X-HE-Tag: 1718948530-840269 X-HE-Meta: U2FsdGVkX1+GwZjKaFYOenKZ+kQJbtnx3N/K1d6lKSjK9FL8WeGElTkavgXwn9+S1Fs835zpmO71PrJ1S51hXm0rIEfpEdHwQK79xQei70RvI2+krNmffSiy7ErBnU+c7NMbMdRTlo80gNnwpv+8I5rUN32ZILx7/2ayh6Rr9m+2mtQScVnfmahhngFTxXmKmM/Aapd400FeCnozXkktU47jtNQST83qpJfPcO414Is1afwQB1GdJC1qgz6q0Cn5tKhZbayDjJVr7Kq1a+xGJlcLFbDtJxnC0OOpyURjrZQ/435EBqEh1mTabVwCe0RA1yidxB6kCzIDlnK+d0R+lWv57rrgdR2paQsbkdEvVVTzFMe9X17OxDp6+r4AQCwOkY3POauD1JxDtPuc0GVq0I7N56u/FwmHXHeXsYJUq98fjxtTcss67zb0YobmzcO3aZXsiLHcITAAO70HOqGGAEzvT5b3ptyRR46fN3eUB4kjpOQKniTMq1p8QHQKoz0yRnSB3aoqZq6z6UqKP0Zmd4e8WvBIYVWzaPq5TqQKjvwjI2FFLQapQCu8DMynRoRLlJ6b3r5gse2fx6LeZTZwxdO1bYigyhUA7f5W/XGxa7CQYkav9IAxhakFLrX7G2zrJlqOJQiPV4vt4NT5MMJuFyntxkdQQQ3dwi/fX0A3m3h1WkJ8tDG8eknRyrmFhl/I7+jkqQPTJm7V+TtxNuqSpoJYCSTyVqMDZlbI7D7AuQeqLOf3NIESGdvkreO3i/h9cULtU0CxEbFA5GutDQG9BOqGrh26G/18B7lgr1pwspWYHJarCEJZpwoIennDCSjg+qEbkilvMKBAXrWiI1KmSbZxoBWQZEyCWzM01Gn7dx2iZ2GH7P9VMDZStolVWCx1P3S250QSVwjc4mcc2YFuiaIZ0lbN4rTCfXxPDkK9gONGGEfsZOAd3GNCjWz3amfq/X/mn6FZnXXB+rXx5ni icRoMgCD LY3iFrKxGwf0dQ2C9tYICUo/TX3DrWERevMayD0zpdvYQyv8nuLm617rhiq0CaeggNTMC6wb5bAdDFrjrwn0IE5ffj2kL3wwv34RmhvWE/v6vrIUvhmGZLzcrJzxpsthrTG03VGvemJo85kRrqet2Rw7SsXW7OKRlxy3P6j/rQwi26pXcvqVMJgF0X/lDXXzvHTS3xgYQpEF/QVXK4ToTp4hgOOkRwgb44iAFBNJf11W2Y6uFtroRL1LpD32a2ifLwJJEzxCfaKjo5CZzT9zy2kfG0l8LP1pgQYxivZnGBMwq1VgCu6Y+8qU/7J8IhcuqM0uv6SpLakYyYjNdC+ez+h3p9Ik8ohQoeDaP+QwkcsknU9LXP/LlnA3PkeCSVADrht+1a+ZQNF9p7tg= X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: From: Alex Shi 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" /* * NCHUNKS_ORDER determines the internal allocation granularity, effectively @@ -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 = page_zpdesc(page); - VM_BUG_ON_PAGE(PageIsolated(page), page); + VM_BUG_ON_PAGE(PageIsolated(zpdesc_page(zpdesc)), zpdesc_page(zpdesc)); - if (test_bit(PAGE_HEADLESS, &page->private)) + if (test_bit(PAGE_HEADLESS, &zpdesc->zppage_flag)) return false; - zhdr = page_address(page); + zhdr = 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; if (zhdr->mapped_count != 0 || zhdr->foreign_handles != 0) goto out; - if (test_and_set_bit(PAGE_CLAIMED, &page->private)) + if (test_and_set_bit(PAGE_CLAIMED, &zpdesc->zppage_flag)) goto out; pool = 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) == 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) <= 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 From patchwork Fri Jun 21 05:46: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: 13706857 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 B9251C27C4F for ; Fri, 21 Jun 2024 05:42:16 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 7BA208D0111; Fri, 21 Jun 2024 01:42:14 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 6A6868D012C; Fri, 21 Jun 2024 01:42:14 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 4D2558D0111; Fri, 21 Jun 2024 01:42:14 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id 173378D012C for ; Fri, 21 Jun 2024 01:42:14 -0400 (EDT) Received: from smtpin20.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id A8C421C1811 for ; Fri, 21 Jun 2024 05:42:13 +0000 (UTC) X-FDA: 82253800146.20.D3A8A62 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf29.hostedemail.com (Postfix) with ESMTP id 046DD120010 for ; Fri, 21 Jun 2024 05:42:11 +0000 (UTC) Authentication-Results: imf29.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=YFwfQUXj; dmarc=pass (policy=none) header.from=kernel.org; spf=pass (imf29.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=1718948521; 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:in-reply-to:references:references:dkim-signature; bh=Xb3FItqMbWC/nmhMdP1LRKxYgkuWTMw07TV2wI4SFZ4=; b=tka6x+53YQQVtVXfBWye66Pz33quk0OkKkC6PEiOw2ZlGe+qmNrv3MUEVucGgJxh3LujJy pbDU4JpAxEOcuxe6Q2GR1TwfwCcKt6D118SpbrDNuEh1yWYDMuWSdjaHngVZwsbW4XJkOJ lrZxiHXHqrktZ1PK5e2hHlGAC8rAZGI= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1718948521; a=rsa-sha256; cv=none; b=C/BdVm/vmsmVAd2kVoZFoq7wJMC2F2BNNXP82caZQ9M955F233S2Usc03QpeSFR9WxAwzg ImaSYDnNHb9N4hlaHAyjGdsltLj5FcJ1Jj2tJqPWJVil3SEumb8n8u406dpMjWbKMhzTX5 1unsUvB9biTURwcjKXTubsjhWiYxAHY= ARC-Authentication-Results: i=1; imf29.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=YFwfQUXj; dmarc=pass (policy=none) header.from=kernel.org; spf=pass (imf29.hostedemail.com: domain of alexs@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=alexs@kernel.org Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id B3BE462110; Fri, 21 Jun 2024 05:42:10 +0000 (UTC) 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> MIME-Version: 1.0 X-Rspamd-Server: rspam07 X-Rspamd-Queue-Id: 046DD120010 X-Stat-Signature: gor1yxa3w36ssdi5axsm5n6fib8grb5x X-Rspam-User: X-HE-Tag: 1718948531-240159 X-HE-Meta: U2FsdGVkX1/yFQwFSJNsQgTgEiocQesQzMv519uStANTMxxjfmXezSq0ZI/0v29HVIKt46IG0fwhqJ4Vz81RE/L66/aGerihYjEm5pMfHen2DjtQAtNQ2fxL1Cxgqor6uCb+xOXJlwcPDDzHRIceWd8OHD+YodF3J3je1u1ZkVkqDWqrORN4G7eiY1x3SLaCONzBvLhLjkoQu9vCE9N24vpgT0d7V0kPubsXoqVECXB6OYlO/FnEQzpGKgdtyJ3TmJZ9Y7H3vRAb1OIuSbQOPJdZsVeSgHj8AyX5ENa4KsGD5Ka2teDAIw3lUaewuFAhYRtOLa7v+B/lSsI4GA3edfX5bhlA+6ibE0OHftu4LQXfHTFxumB0TheFIW9p+5UHn5v5a7uJPHe5Oj3Xrrf1Ove6B5vpaHo5zTw6E/Vati0232OloBvCNeAdn1n5i917f36e4czy6vRfxoYpV9Tl+3YaxI8TUKhI3E5jIAw8GCSTcsS5Z8qd4aSekStqjoHsr1YCT3D10i/NP44vTy/cHezjuGeoMTz92gKKcpI/uo4txk5CC9YEFAOL3i8Vm8+EX9o9PDlqfs2DhIoyg69ndwTwrmnkHHWc4TiR0Pv7o+0FraPs7MwM51ztst1COSWMrmy3Jo/Ssdh55czCQfW/Ri8VUduvjskfCpnsTDkgBAE4F0zeVc5sTA9VP+aqfs1VhF3h8khTEyMwZ0iLQOnTY5R0XEVUr2+gyc//RcAO1yq/EQjGhmYCJQL15Zm+sYBF7aGZx2QB2NOrad0ieEv/h6xJetsidFVFz5o0eqYhpX2TlslZwB0DodPtTf4PNu21Qwfyt53HBAtFNKxKx+HN/PzSjh4YKAEkfFiOYutV0eHH34JL2fsEC+9EhcdO+1myB/tfhuN1o+5Ek0lGSFcqzwBn8jUh8RYsNqOz4huNUBqsKxbJZrf7/egoIaX4DFD0ahkntvFyXnABCnb0MFB vDR1h0sH 2m3mdBJbR5iI+U+5OA8PV3JI2CtFUi/JMVG7ZqaQ7nbHk7JSprAZyO0RFMpd3oxwSfG5dzMgjgMDNhrQLxM0AWJkLtBbNVwQWgZQ2H6ZLXnS9zBEvxJIJwuNMphleH5zozDywJ3+Kzp/gEILdWz091ezEgpbZrRZ8QFFFnYpcH5WnfH9uQhWn6DN1HUXUYHEVVW+j++PfmYYEcxwJPnCYR0z5z3+sIr5SoiMQfC18kJ+EVniTYOGjXLgtUKx0+tUt5KaCHXv/9l0h31PCV7dQdL/Vwy3cOQKK4tgYp4fr1nKUG4nmvQyT69EiaJMXd/EbBKMRU2WeWaTYOHeJilX1DTCGoUQ4xmyKu96d X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: From: Alex Shi 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 = page_zpdesc(page); + struct zpdesc *newzpdesc = page_zpdesc(newpage); - 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)); - zhdr = page_address(page); + zhdr = zpdesc_address(zpdesc); pool = zhdr_to_pool(zhdr); if (!z3fold_page_trylock(zhdr)) return -EAGAIN; if (zhdr->mapped_count != 0 || zhdr->foreign_handles != 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 = page_address(newpage); + new_zhdr = zpdesc_address(newzpdesc); memcpy(new_zhdr, zhdr, PAGE_SIZE); - newpage->private = page->private; - set_bit(PAGE_MIGRATED, &page->private); + newzpdesc->zppage_flag = 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)); - 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 = smp_processor_id(); - __SetPageMovable(newpage, &z3fold_mops); + __SetPageMovable(zpdesc_page(newzpdesc), &z3fold_mops); z3fold_page_unlock(new_zhdr); queue_work_on(new_zhdr->cpu, pool->compact_wq, &new_zhdr->work); /* PAGE_CLAIMED and PAGE_MIGRATED are cleared now. */ - page->private = 0; - put_page(page); + zpdesc->zppage_flag = 0; + zpdesc_put(zpdesc); return 0; } 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)); } +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 From patchwork Fri Jun 21 05:46:43 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: 13706858 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 B27E0C2BA1A for ; Fri, 21 Jun 2024 05:42:21 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 7E2928D012D; Fri, 21 Jun 2024 01:42:20 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 743708D012C; Fri, 21 Jun 2024 01:42:20 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 4D2BE8D012D; Fri, 21 Jun 2024 01:42:20 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id E6CBF8D012C for ; Fri, 21 Jun 2024 01:42:18 -0400 (EDT) Received: from smtpin11.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id A63CCA092E for ; Fri, 21 Jun 2024 05:42:18 +0000 (UTC) X-FDA: 82253800356.11.39C1240 Received: from sin.source.kernel.org (sin.source.kernel.org [145.40.73.55]) by imf27.hostedemail.com (Postfix) with ESMTP id 9C88440018 for ; Fri, 21 Jun 2024 05:42:16 +0000 (UTC) Authentication-Results: imf27.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=H8XjtS0m; spf=pass (imf27.hostedemail.com: domain of alexs@kernel.org designates 145.40.73.55 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=1718948529; 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:in-reply-to:references:references:dkim-signature; bh=K/mzSlN4QsMDDkd9D4ih1IJ37E6eyAW7SgQimZrJMU4=; b=CCIM+o2om0mi9H4AlCPnUDB8eCPOpcXm611wCezVAD0zc1kcfx045t06Dwz5oOIoroj872 YAXXIhwpNA8KB5HWJYCDyojmpoTLx87pScaTQtOvgtVHvHVexn1uKJYdu+NFMQViM/MYLv 6f7TpPgXLLG0P7kSRAb/bhfCxcQ9xkU= ARC-Authentication-Results: i=1; imf27.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=H8XjtS0m; spf=pass (imf27.hostedemail.com: domain of alexs@kernel.org designates 145.40.73.55 as permitted sender) smtp.mailfrom=alexs@kernel.org; dmarc=pass (policy=none) header.from=kernel.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1718948529; a=rsa-sha256; cv=none; b=UXR27kiqnAY6C86G2UDuEhrAn0789Rf0J+jI2BYRznlCQS//4x4DbleZdzpyeCg8Xj4CXm xMVNTLYA2kXf4BWqh3UznZ+9+mEhFanmLOFzSDuSSMVkwJ5u7qaHMnyVpR/DAiy636dGK3 nZRQCs9nymSwU7q/KYOm5dy6+CxoNOQ= Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by sin.source.kernel.org (Postfix) with ESMTP id DAB15CE2B4E; Fri, 21 Jun 2024 05:42:13 +0000 (UTC) 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> MIME-Version: 1.0 X-Stat-Signature: iof9udbcrgxq5hhxrok5am1y9jzfdwwm X-Rspam-User: X-Rspamd-Queue-Id: 9C88440018 X-Rspamd-Server: rspam02 X-HE-Tag: 1718948536-1105 X-HE-Meta: U2FsdGVkX19W0ti3f5Yp3ZArim6aMppXOBNcRFKEFH3n0BnpydcQ0ewQog2LKHILSKx5JiWA0xN83a13JtC2DoCVZ9Kx9syFT2h4fOoaMqWVv6bXuSdbXyZIX6ltFAHCZ1MmcyC8hq4HBc6kemJ3DUbmc3lDmZsUErdrGoku0si7Trcp2gCHW92vOcHnMBjShfNPvoZ8pSGPKAVW1NGoXuBAJoea4dNB+G8ExTJYF1J7Wg93J2+/d/spUR5RWnZvrGIgqtbeTN4rXNbIRt3Wnm/GjMECOjOx7VtbGTfbeJo/r+91U0eRGTB4xc057MgxSz67H59QMceryoRFmpJOzSTkC+m8+tqHDnOWL+Eu+KjRwtTK4Yho2k0jH61vUie0itFuDeO1FwBhMPj92zE1gNaOe0tVmeCbOqeqUxy2Kg/n1eVEoqj0aMCnO9CYJ4PEQ4kXHrcVdwOjXD6+GA3xRhXdSTZNDFzbfAlUtoN0rjj89tDquoF9z2o/LEgmo+J+HDPIPJFHS3WJAeh65SQieUCTNFo8RYAIQMfDvBCMKF/SWinodFxON6vOAdKyj6UaRNk+9nyJGZNlVkj//lq0dQzR1s5U81o4Le2vUqNy1WKiZk026EBCaRTIbzUbA7obmLb7owiuFH5YmkE3B2bT2E4aJL+tyshvIdzpSAncWFtYViem7+DbPZEch9PzgSlh3A8slmz2h+nVVCLx9riWZo2RJKmMZ/0+vIPrR+HTSJ4iue6bbq7yiz26imhD8mr1DVQT/P0GylBTcb/Ht5D+QEZiZS9hIjl4RqRwYgacrNoIS+w5ObZc5mjeQXZMi0ro1XG9TcL2KjgP8TsmgF+SMhmRnY1uHirEOZiHZpw5FjM29yOie+jkwiBPAmp2/+0W+FETRCGEdEoP7OBUqnylzHSoSUyN46eY3RXWxCfhYlT/eqe6HVey+I1RnuMlPlUHmVA27IW33uWXMlQ/pWs PuuH2Py2 UJdlAOxYGH5aDS222l5yQGMVugaMBDaiUHF7OojtjsE4O/Zzrw2pYEQY5iiS5T/a+FRxL4z/QiBPNKmeSAC3ptYPgh0SMv/Xfr5gMTn7ZtAH86JvRmi5M5jnPAIg4f/0mt5+rhnsPoG69ekmQRZ4vD6yvv7fP/Iz9u2KELiS/zXFnk5fuVzezh2wnSLa6u2NlisFhtEINBdqk1QGraDZifXfWM6MADyp+acmJtGfVm8qhKZMYPaU7lB+XyoZyY7+KyKdh6V/t7VwMmsxc2GsCpUdMk3Dd3b4h0vdt3+KqsCvmqfbE2uI4hD4eVp7I7ETtQWGl5LI9nQoazU743PlkCqonzZv0QL6WNqHr X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: From: Alex Shi 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 = page_zpdesc(page); - zhdr = page_address(page); + zhdr = zpdesc_address(zpdesc); pool = zhdr_to_pool(zhdr); 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); } From patchwork Fri Jun 21 05:46:44 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: 13706859 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 46B66C27C4F for ; Fri, 21 Jun 2024 05:42:25 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id AD33B8D012E; Fri, 21 Jun 2024 01:42:23 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 794E08D012C; Fri, 21 Jun 2024 01:42:23 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 45CAF8D012E; Fri, 21 Jun 2024 01:42:23 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id 01BF88D012C for ; Fri, 21 Jun 2024 01:42:22 -0400 (EDT) Received: from smtpin04.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id B0710160942 for ; Fri, 21 Jun 2024 05:42:22 +0000 (UTC) X-FDA: 82253800524.04.232BE2E Received: from sin.source.kernel.org (sin.source.kernel.org [145.40.73.55]) by imf29.hostedemail.com (Postfix) with ESMTP id ACEB9120010 for ; Fri, 21 Jun 2024 05:42:20 +0000 (UTC) Authentication-Results: imf29.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=egYyPlAu; spf=pass (imf29.hostedemail.com: domain of alexs@kernel.org designates 145.40.73.55 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=1718948533; 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:in-reply-to:references:references:dkim-signature; bh=wOwEp6mCnEWbSRgPCkBcUapv4Ws6mgjoU2AcLoDBd38=; b=HL5T7zzvXZofbIX8a0dP9N5dhS+9pbAmiKw1orJc6c8bj37Bpp22HGRCZWANOoo1MrsPp0 1jq3IdP8njepNNVDOKSRfOsBjLQBvxNYJrNMtfSrtYixB3qtOWmjdQEtSrDTcZdF+mXEGg Hlv4Cd31xkqScTKYb32dhpqzJaJ3x1w= ARC-Authentication-Results: i=1; imf29.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=egYyPlAu; spf=pass (imf29.hostedemail.com: domain of alexs@kernel.org designates 145.40.73.55 as permitted sender) smtp.mailfrom=alexs@kernel.org; dmarc=pass (policy=none) header.from=kernel.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1718948533; a=rsa-sha256; cv=none; b=J8K41BEZfVO5ITNCoaMF2wrMfyS8PznQUVadtGEsi6st72HNgWQAZmVSG4w+2Zr1CgI1yw /8HH0mMzw+rKdlp+Sxz2yMOVJ/740zOucbok3/cTFrGbV+6dwGrKMIbwIqppry8LrWAhFx mb9xEDuCtU/M6uhqlyWqpz/L1kpHHK4= Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by sin.source.kernel.org (Postfix) with ESMTP id 01062CE2B51; Fri, 21 Jun 2024 05:42:17 +0000 (UTC) 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> MIME-Version: 1.0 X-Stat-Signature: 3qz65a5rmjwgxst7b88cnio1yamzgraf X-Rspam-User: X-Rspamd-Queue-Id: ACEB9120010 X-Rspamd-Server: rspam02 X-HE-Tag: 1718948540-222402 X-HE-Meta: U2FsdGVkX18PCijf9dCloLYxVjj7/m515ziMRCesrGvqtpGfUpOymAWbeQ+cp3eBwyTHPYIM5AvuUOddupKrS8bVSrAA360XHTLSLgNRduh/f1mdEJIJhUyq5y5jqGUc/KJ6KATNOz0m2B7rrqPgi/2xcj/uvuoAGbij0Olh5sGh9C8nn2PuYzAEbaF9sz7BeVnN0kYbj/jIIszcBZDcHspUcDd9760e7Mg0iCftPJYIqw/n58FYVxs0w2yVWQUegsVAyItGsfFb8GdK8/ufAdiQk9oDiF5+qCUvt/zvYHR+67VIsNb79UJoCW6VYdK4SDDsoWXg2Xds45TSe8pZOub1qATjrsdBlBdO2at9IR9CB6S1/SfJ1zEu8BzTrwxVtSDzB5rVFcT+ysrl2XebofeyPek8l0BNnGDHPW2mMskaQAJuiGIWrku8M9N/kq1A77MU+p3lW8FWqCatCQ13kkCwnVEHVoxvk82mKsYkStmDgrYd0yRanhMLpLmTli8bq27rjb+IHiLbBiVXc/Tx0fNoiqgHBFXlyliSDgtdFWA45wjKZOLqpR1USVrejAr+wdh8OhJ2Qoeq5vpTEzItcaoW9ycL2NxM2F9Lgc1F/j1r0OWPnO4sU3DVJsQ7cEkeF6YiYK30RNFgALBqmygeC3gDfZLbC+2CAqGTjk8jMvoXDmpiSPbGubaRW4WLWvFJ2NL27HmZtCvf/5AJYotw1lEMeoGKYdI4qSsdgrNIujRmRIch2sQ8ooSnPmJxM4C7TnfqHZ77C4QUp3tgLfUtEqA0fk5dG0WuCagc/hcAFb+5quD6Wtm8Swa7aGNQ7wMnK6LrUWyboH57q9BGb+r1aMPcMmV4PXSsIvUtVyWkPQLtmrYDZciwmuotxfO1jW/34M9U0erNlas+PH6OckBxNCOuK0oBcqDTt/JNcjyMRllW18MLYw6SPTqEE5PJ0kdaNG4TtnhWwKchNxb2BQ6 LS9ltkTg 2hekwtfl8inpdoD7tdMXMT5HW74ZtYCFP0lKYrCYhmLqSjwJTs6Y/OQsfmmYUUbdO0MJR62Qu5oDaeBS2GV17Sy1auDKQTRLTtucK4lAm5XBv5BpYpfG52UnjyBK8/VZFwxF6KIm+1briE6JsSW4/LEjE9yh0G6wFA3EAC4VnucY13buelGZ6ShX1Q0EX139+BhSFPKLoPz1Vn98iJYzIo5Gj3WDPT4s3U3GnMu9RduphGIJjCUjIUlAQ3ldg7UOSEbz5b25wyKp5gYIfk9u+aK5vLWhmD8yGrf69G+5rTIIhMTVYkBMHH/C7LF9H8YAU6dVyrUHnPViXAawvA0FiEKseez8M21/zEGpF X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: From: Alex Shi 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(unsigned long handle) locked = z3fold_page_trylock(zhdr); read_unlock(&slots->lock); if (locked) { - struct page *page = virt_to_page(zhdr); + struct zpdesc *zpdesc = page_zpdesc(virt_to_page(zhdr)); - 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(unsigned long handle) static inline void put_z3fold_header(struct z3fold_header *zhdr) { - struct page *page = virt_to_page(zhdr); + struct zpdesc *zpdesc = page_zpdesc(virt_to_page(zhdr)); - if (!test_bit(PAGE_HEADLESS, &page->private)) + if (!test_bit(PAGE_HEADLESS, &zpdesc->zppage_flag)) z3fold_page_unlock(zhdr); } From patchwork Fri Jun 21 05:46:45 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: 13706860 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 180EDC27C4F for ; Fri, 21 Jun 2024 05:42:28 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id B3CB68D012F; Fri, 21 Jun 2024 01:42:25 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id AC5F98D012C; Fri, 21 Jun 2024 01:42:25 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 807758D012F; Fri, 21 Jun 2024 01:42:25 -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 5ADE88D012C for ; Fri, 21 Jun 2024 01:42:25 -0400 (EDT) Received: from smtpin10.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id D18D51C1811 for ; Fri, 21 Jun 2024 05:42:24 +0000 (UTC) X-FDA: 82253800608.10.61F8E10 Received: from sin.source.kernel.org (sin.source.kernel.org [145.40.73.55]) by imf08.hostedemail.com (Postfix) with ESMTP id CCD9A16000D for ; Fri, 21 Jun 2024 05:42:22 +0000 (UTC) Authentication-Results: imf08.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=W0DztK0m; spf=pass (imf08.hostedemail.com: domain of alexs@kernel.org designates 145.40.73.55 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=1718948538; 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:in-reply-to:references:references:dkim-signature; bh=xpikopE4PcJ48VOowmCsdXL4fCoE5+HS1TgM50UOyZU=; b=cIw9re2P4jjOj5aL+hRdwFGIhL5LSkybPw3YbPg8G1aisl0AutzRb0E7rySrOmXWz3hGpo KIy7uwVfL2EA0MHz76jPSxWeL6U5afGZXGUfAQJTPT0ux6t3NB+gWiWwPkTlhDI9P4gDdn OMdOcRnXabr2H10Ej77NylEby/s2VWc= ARC-Authentication-Results: i=1; imf08.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=W0DztK0m; spf=pass (imf08.hostedemail.com: domain of alexs@kernel.org designates 145.40.73.55 as permitted sender) smtp.mailfrom=alexs@kernel.org; dmarc=pass (policy=none) header.from=kernel.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1718948538; a=rsa-sha256; cv=none; b=qCoj3gBLUqoci1OYv2XNbdYkeNlpI7Jf50iOTyerm9/In8eFU+YbuTloIQthUJttmHmCd7 Q7xznxzrhUN2YpunJHqy9DwqtxRFF4+5b3apkzcoCczkqnIOvOto7LZb8DmrBVJnF3KAJX QBVfVFqiX6qv79QmH/3eUMgQ/UIVzrU= Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by sin.source.kernel.org (Postfix) with ESMTP id 1EAB6CE2B65; Fri, 21 Jun 2024 05:42:20 +0000 (UTC) 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> MIME-Version: 1.0 X-Rspamd-Server: rspam03 X-Rspam-User: X-Rspamd-Queue-Id: CCD9A16000D X-Stat-Signature: 9ntet9gf1uuzb6w3mxy9y8atc9t1e8g5 X-HE-Tag: 1718948542-387307 X-HE-Meta: U2FsdGVkX1999Kl4EUgx83uR/tjgEvGvOryTC5RWv1SQ+1oHEKf6UUQFSCXv5tpvdYPheRb/ub3MJv6a35seKCinolml9Ennjkm+y8TG94T7G9eWg3YBYbpsOa3FVnY/2lGidNc/1v3P0lChl6FTfw/u4uOzsBhuOh6qBOLsUv4uZ9MtSLWrg4Q4EdN8birm7yX62xnSwh4OIjYbPkWBAdJe+Sfn5W0HknXQ0tpNf43Cp8hApBpckieyINPRJG283+DC7P0yW1Y3RXncYYQMGeQqsOyQe3+WpsX1VQBKRFAn5wS48hQr39dmL85tCZqAgABaHQfzNIi/zHntf0gIBuexnQdirJ2Ejoyx47Ugox42wWKv9QpAbtxgteakE0b5/diSW0sbE9rTrab9hsbbOXq7e9WaKqIW4nqADI+oysxOOdkcWDCDJQ2rkbIXi+XlcTsbVUs1sZsD16B725m8OjnegqnuAHTZtJUz932aKWYOlqNAhpbXwg8pUogWc/j81mamkVDRxTl6WcTvp3G0T3n8eGyti3jxpWOyXwGF51wfZg6Mpb43t/0AbT+lBCcdlVygSYLQvCdmj808dumZlVG1kBHBsXTmsiy0WJoRfp0lqAamoDWyhO5Yidqx/AsVHDgQlLzF7uArKLZwcHYIFpjrq0S40GYKMmIhonLOdpCn3NjYV2tJZXzoi2HZzeWMJYOqu5o3Qf4OugANhMtUkYyk1Sbo8ZJ9h87+bax4fs5i88JLe+oClcQr6yyk9L44HU0BNFu9pCDqmltvLqODrvUBnxdfXu6RMvR7QDXdvN0sm58H/lir5KlWfo7i3icezWLG11zoVCy8elGaEfXoHvtO55J3bCltVf2ZIENsLRLOaa0AvohUDoSzNXK5SMF9AyHcFfpZCrOkx3yZisTuUpUi2SHRVXUu6Wab5KwFC5JsyJ7kr0QtWttsn2q+szB4BCE4Q9jPzn7PhYszMe5 i8Gz2c3V 5HGItYW5Tv77OJ1QfRQSfR1meDjCTE+Frjd32CsaY/dvwh08EtR9kQo6H0c3GJmqW+Tsd0HGrFPMCfbtdV8Pgc21FYGYv06f4wpKJcKR9tyrvNH34PwdWy0gOeNwpmckiH0U8EpM2nI4rngf3hdqXKEr8YBAMchto77UfLDQbwE0inNWkpt/dOf/uJ1bOFJmHe8F2K32HPeN29QpYHWavu39VRLMIewelreyA2EMhJLVgvfkwJJsTmT1AO4YHZT4nI61wDuYuGVizNG34haVoNXj4N7gz5WRw7vCqXCDwpdLwmm6G0v6qioieyOUsW01NglIyAajpHMnS+P021e91Oy289TqIEz99iU5j X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: From: Alex Shi 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 headless, struct z3fold_pool *pool, gfp_t gfp) { - struct z3fold_header *zhdr = page_address(page); + struct zpdesc *zpdesc = page_zpdesc(page); + struct z3fold_header *zhdr = zpdesc_address(zpdesc); struct z3fold_buddy_slots *slots; - 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; From patchwork Fri Jun 21 05:46:46 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: alexs@kernel.org X-Patchwork-Id: 13706861 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 1DF73C27C4F for ; Fri, 21 Jun 2024 05:42:34 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 832788D0130; Fri, 21 Jun 2024 01:42:28 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 7908F8D012C; Fri, 21 Jun 2024 01:42:28 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 595EC8D0130; Fri, 21 Jun 2024 01:42:28 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id 2DBA38D012C for ; Fri, 21 Jun 2024 01:42:28 -0400 (EDT) Received: from smtpin26.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id DC1A51C1822 for ; Fri, 21 Jun 2024 05:42:27 +0000 (UTC) X-FDA: 82253800734.26.27EA790 Received: from sin.source.kernel.org (sin.source.kernel.org [145.40.73.55]) by imf23.hostedemail.com (Postfix) with ESMTP id D8C2114000F for ; Fri, 21 Jun 2024 05:42:25 +0000 (UTC) Authentication-Results: imf23.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b="EsKyTF1/"; spf=pass (imf23.hostedemail.com: domain of alexs@kernel.org designates 145.40.73.55 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=1718948541; 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:in-reply-to:references:references:dkim-signature; bh=2pWoO2YklrLpncgr+9OKHBEsXt+jExKlims3feOYEL4=; b=E/ltRENWQIxwRw9mAsiwSbsrSWmYLPW024kmwvmTmtv7SNCQW55mk5j4KjftB8cVRDKpq/ 1Kbu91+ftSmJx1gxCoriuQz0MTVtL6S7DPom+UsKTOWugp9SSbxDIrZ5KHQNEGekj7UEif hHN4hy9DSxcMzA8eI8qgTdx3O/j83AA= ARC-Authentication-Results: i=1; imf23.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b="EsKyTF1/"; spf=pass (imf23.hostedemail.com: domain of alexs@kernel.org designates 145.40.73.55 as permitted sender) smtp.mailfrom=alexs@kernel.org; dmarc=pass (policy=none) header.from=kernel.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1718948541; a=rsa-sha256; cv=none; b=7s8A5W+AXeM0ipJTCCKVVAHXyHMFaw/cQaEaAayOVsxSYvlK/31V5/piwYP3MQnofz6a7r UN9zf7g5LKrL+Gyn/mEBp0AWuVDqrZRJ76SiphcnVCJf/fBWEy76e39rCWBK5Vt1x+V5Tx cCkZDiC3zOl/Q9z5gfdgC8MBW7f0A+0= Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by sin.source.kernel.org (Postfix) with ESMTP id 3AA4DCE2B5A; Fri, 21 Jun 2024 05:42:23 +0000 (UTC) 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> MIME-Version: 1.0 X-Rspamd-Server: rspam03 X-Rspam-User: X-Rspamd-Queue-Id: D8C2114000F X-Stat-Signature: 4me3fifcj64b4cz4j9pfqn4szpde799r X-HE-Tag: 1718948545-564331 X-HE-Meta: U2FsdGVkX1/lp0u17rS8vwL803B8UHvQu/LFPMC8wGUtU8wkJe0zT3Senqe0E+dW9sGeXrk2WTdvy8GyVTPDYtNkyH0egqys7x59QJNUi9Rpm3ED9xxCw2gN2AArtOgpx+OfVCu9KHrh7FB5lEZefDLgvfYBWKJuxrzjY5ee6Djy7PfiHo5UdWAa6mYFOcbqrj69kte86TWTteu0tDFWHidF3zzmz40IpqqHEGY8gfB8FM3Fp77+LDFR5UuDqZ4d1tDd7l1vakupBhaV95/WcH+f+aJk5MFJo10kQ7A3v30bbKd0nrQ9yrAMxtTt9Z+niaaz+cHs/lw7G5Dnn+EhN6nAa4rrdM1qhlQAp07ktmSSM6YcLWlqTV4l9pDazwxaB5GYEA3WlXhQALv8wQb4PpdGfegEicKRVN19i3tfpNe04DuyVRdDGDJxh/F5ByZYA7uYjoANji2hW+F47OtqfXKt6LIf6i58MoECpeJYLIw8j5nVP/Gstey/lj+xznyVP1iulBTfj/ZHdgmJq4dja5p1gHhA9uV9aJPLGj5q4wvAexuSYIKG4p6stq1E8eUbr2zfw03IdmvZBbqCOQci9O5WcIYMGsdtLlNkXbjhPa1xc+pmRSkt3HxI7nNMfvSfRcblsOqFl3qD4jEtiSwICjE7vpch4lf5UZR1XxiCh5S1/CdD2F7Rwra2Vu+pYbc1WrO0gc1Y0/+axqdDnsYTyuxoc3v4DjaCgs9ioiY9GGvmqAbzkcy2kNIS1pYCzf9RvjKM7pfVSG3Bsbop2eCZ6A9qnJG1xJrrYnIdqrKORU+ZaLk9bp67WdoM8tZp+5QixYiUO024WUD+Vp2LYlD07kkBkZThYcwAlrQtcFU+8B70kTcSzb0YSdEK0OUrHUqsxvzLuSvK4wY60pmxzb99f5/O8cLATpnrzZghNOh4h9OKK1M1OjI3Jh+0py2OyJhmWjH3GBUvBoUzxDYwFtx ywYUJJAx z7lyjVhzRmVhmRzcz3wzTAbpMrqYpeCDHi6Hw+5yVhIoeN8PS6wPluYWh1xxOd92ip/JCC5lT3MUpJNaEFT0IICZT5Zc4cvgo9yyIEgn7VXzHiGWnjYo6fLY8xGi33dOQyMPgcAEJwNqpTVfxiMLSvtbABI3IzYlY/1AzMi6ugZ4+VDjQwrL0Rd8SfUUyC1VCCxQfUqNiGK2CMqbbE+Vw2cjWKzXTbu3D/xD3yM2R0/FFdCoGQ5RedlRWnnHiFW7MV20TUoy9l8zH1MUXDaatkK1N8P0vRPK3ihn0Vn2+9FNegRCy0XFY/hf5IBSzCGg3XAO/J9AF/oNQQevvgx8NSYq9TliiMzSPcWih X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: From: Alex Shi 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 = 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)); } /* 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)); } +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 From patchwork Fri Jun 21 05:46:47 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: 13706862 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 CA5CAC2BA1A for ; Fri, 21 Jun 2024 05:42:36 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id DB0C38D0131; Fri, 21 Jun 2024 01:42:31 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id BD81C8D012C; Fri, 21 Jun 2024 01:42:31 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 91D568D0131; Fri, 21 Jun 2024 01:42:31 -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 5F9D68D012C for ; Fri, 21 Jun 2024 01:42:31 -0400 (EDT) Received: from smtpin23.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id D1E944090F for ; Fri, 21 Jun 2024 05:42:30 +0000 (UTC) X-FDA: 82253800860.23.60C2702 Received: from sin.source.kernel.org (sin.source.kernel.org [145.40.73.55]) by imf25.hostedemail.com (Postfix) with ESMTP id CF287A0006 for ; Fri, 21 Jun 2024 05:42:28 +0000 (UTC) Authentication-Results: imf25.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=pMsgGw2f; spf=pass (imf25.hostedemail.com: domain of alexs@kernel.org designates 145.40.73.55 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=1718948539; 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:in-reply-to:references:references:dkim-signature; bh=jfC+rNNm8OlE9BZhnAxVsMusbTuN3XVQRXD4e/x4TVY=; b=8UMP144Ftrs48n71FMVnlsa5vPRyh7fWKzXqYiiB23TByyUgs/3BiM2m00H4AE98Pmdru1 UbR5IRuwhMXXXD31d2YuihSX8RXg7d/Hdg1FCX5Qpfhzz03tnHFykLzyfnriyrSQsx4PKL P7VZhYUZqisQymq21NRssM7L6JIhfeg= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1718948539; a=rsa-sha256; cv=none; b=cjxavwGLZrDKCp3ocPRsTEJ7AlcF47Q7xqw9Y+wCDueLZCMo0nuR2LhDF5fOWvjntCyA5m C3kIQF63HKYpVBkehN5FAPMQDNAdosZLmYRGrNQ2B47SEctki8pztSIWDIIZix/1skx8ci PVU1I3iyKpW76rESnJX2NM1S56n/hjw= ARC-Authentication-Results: i=1; imf25.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=pMsgGw2f; spf=pass (imf25.hostedemail.com: domain of alexs@kernel.org designates 145.40.73.55 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 sin.source.kernel.org (Postfix) with ESMTP id 329B5CE2B5D; Fri, 21 Jun 2024 05:42:26 +0000 (UTC) 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> MIME-Version: 1.0 X-Rspam-User: X-Rspamd-Server: rspam04 X-Rspamd-Queue-Id: CF287A0006 X-Stat-Signature: mqdznbpbm5btwfxwxxfqn9azb857uk86 X-HE-Tag: 1718948548-646173 X-HE-Meta: U2FsdGVkX19zxJ3Mf8L6ZgFyorahuG5giHrEJbioCt5o2bXBQdiImK4pDYAGOD1uLPKIgTQRd8joBNSvIHWWpvAN4QWYIq+qMxF0WSNKtqtI5pXzLOOjZwdaidaVJWhhsg6h8IEJVc7cuF/ZzHCOzBQPawj/KMiJscnUmZhRqcOcyUIkrAO/bt0KoKAt4PCH3PTxcg3i6AY5Rs8CY2V5srjELB6NLMzdPUhG2Az5tcI4CNmPdRWXBfC5UiRx2R+cf+I7JziPXw+3Fz8FVRgg2GclU8+fAECUT6hWXdJttP3X6npzIndYYWHdjGMI+Tmptt75FCNu9qkxXuDPe4nWdIbyfhE/UAz6vyfYAGGnjKL8gbNkhRg+7YKIcM8ZLwVMmxKzCYHYmcJlh6xZYXE1vVFZ1vSCZHG4tX4WesDcA6+Q2RlXkTPjawNxIMjDtylMHXD2uyPMilzhHnGkZDc1iHySGo6T+tIoSmHKpl8Qg/BlfR8BLljJkdLHrAz0Zkit1gSyxA3c6UwiiMfqYsdOYLtpGbBSYzIbTyjd6rf22v6m/kbKJXBtvrskApqQRNDJgHKKll24egBSN0EOinx81MppuV9ws4+mpP44hAvaGAvGBANtDBz2F4YaVALniRPeXdUe1rtLYwpKeISynbAf9ggYwINqccUvK5HzXeP+Ti8CkH3s72peppDlNmQV6FBlKkQA6sJZS/gt0ZOKXJt2P5kXE/yVDHi9/gUoO2oapFLtsuMWMDL1VnQ0HWbJJAK9Dmz7AmZiQGAlQACsEBK16tADPffTRBkiD/vZV3I9+0g4RgWN4JKKUGG7CI4FOgGcKdeQMsrj8JY59a0Dl3KQn4Q9hNPBUREni90Hfw31k7D9w7GDKT4D48KOFduZ81Z7s3l2YLWXw+32JcKmSIYbMnSnSwVnYXM5WOvN6zlYVdKSZuVHFVltk7C0eHC9gEEwy3qkA/tJYkitf5az8Bo OakU5EBC 39kVfjVvUF64/Jm7LbSUYY+a3cUsCKgJ56/Cq7IohxqU7FvRdne66LLVZaCW8ZHR7SwKm9fynMjvD/NsKsiJ0bwJvziBfIXm8Nd1gokVvbzlSFf+m7PhN6xQn0bHmG3Bhkxq0xr8KAJHYJyyb846eQcHS1lM6bHo4A4TlzrgdYb4xWR3EhRP2EmCLPgv/37iFsHQmAqlJSEFSW6bEdimUHOO8aOcUSaiUKuRd7dV1rUniaotqND2keEAYCugDOq7wxlAGwc5rK9xVusc8YQ8OI8f6VnV1HnLgoOU6WMuQmj5W3VEpLVtZBSEq9Kv1tc/dN1hKHSutuy8r7e0e7fVobngNpWZx6adM0lE9Eubb0C21FcECDspeHddibg== X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: From: Alex Shi 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) static void __release_z3fold_page(struct z3fold_header *zhdr, bool locked) { - struct page *page = virt_to_page(zhdr); + struct zpdesc *zpdesc = page_zpdesc(virt_to_page(zhdr)); struct z3fold_pool *pool = zhdr_to_pool(zhdr); 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); From patchwork Fri Jun 21 05:46:48 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: 13706863 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 E5DFAC27C4F for ; Fri, 21 Jun 2024 05:42:40 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id B3DA78D0132; Fri, 21 Jun 2024 01:42:34 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id AC7F88D012C; Fri, 21 Jun 2024 01:42:34 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 8F16F8D0132; Fri, 21 Jun 2024 01:42:34 -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 695EB8D012C for ; Fri, 21 Jun 2024 01:42:34 -0400 (EDT) Received: from smtpin26.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id CD747C0891 for ; Fri, 21 Jun 2024 05:42:33 +0000 (UTC) X-FDA: 82253800986.26.9A48F2E Received: from sin.source.kernel.org (sin.source.kernel.org [145.40.73.55]) by imf01.hostedemail.com (Postfix) with ESMTP id BB72F40014 for ; Fri, 21 Jun 2024 05:42:31 +0000 (UTC) Authentication-Results: imf01.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=czXMYM0b; spf=pass (imf01.hostedemail.com: domain of alexs@kernel.org designates 145.40.73.55 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=1718948547; 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:in-reply-to:references:references:dkim-signature; bh=28J1djLihcUXy4fswcJMnI0rhfSho4qEJW1HrBqLWcA=; b=bx8hBzRb7jAzOftog+C2SZ2rsF6LYoZBzE2C5xZTsRkhdY6omwHDYp191f695DwOXhNi5i qkEV2tmyogAwdxXQkivQO2X/fXe4vriB+AHdgmeAWM6CAPYp1Yym2KixnGqPDlwZfqujxn 0WQQSnbGOdZ0TvgsZXXttkXl0HWXTWE= ARC-Authentication-Results: i=1; imf01.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=czXMYM0b; spf=pass (imf01.hostedemail.com: domain of alexs@kernel.org designates 145.40.73.55 as permitted sender) smtp.mailfrom=alexs@kernel.org; dmarc=pass (policy=none) header.from=kernel.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1718948547; a=rsa-sha256; cv=none; b=8X9Xgcn2N64MZr9kQzITlT7YKw69YH5RPoNMN2zPkKcdrC7TUp3mEZTjfmHGPPYpcrlVCK lZED0MxSF470CxHivuFNZiz3w1XQkPBOgpUOzeILF4y+oCpnheByDhpAXk15T8/mTGnusI Ak6jvT2PxhVA9cYW2j7grVhBDR9DM9w= Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by sin.source.kernel.org (Postfix) with ESMTP id 2BFBBCE2B5B; Fri, 21 Jun 2024 05:42:29 +0000 (UTC) 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> MIME-Version: 1.0 X-Rspamd-Server: rspam03 X-Rspam-User: X-Rspamd-Queue-Id: BB72F40014 X-Stat-Signature: a6mrk77iwnj7dc1hszbjesjynghs5ybx X-HE-Tag: 1718948551-428767 X-HE-Meta: U2FsdGVkX1/Lk8FGQoaM2/2PTHSphI/PjN2uVE9pOjSpwYOYxb9JaM+KdjKn/o/W49v9iOe2cmO0rAxo2CfdyUYFftGwTQrckcvZ2pE9eBzMd+bDkx8BaQoDv7/W9nw9C/8htrPlK5ZCTZXuGXyEiWkxui7x1pLLYd/dlGwMiFDY0T+uZPMn/8G3ObLhbeDPMIs835ek5rqTyVdpPpoBMxUMOVCZAq0NAYsTcjNZ8TSj3vHdFKT3bvEtIO66pPEFYlPc3ZL/Ur4V8c5rx4h4hCsB2/eY8ehV4rjuiQkm8tg1QqPqXDa2VCrXEOXj/3XIqytyxEJm1HjdoY/W56KQxcM1XVJehlgX84GA5WFinlaz9URH/nU8FL7G61ko2poGd87tG9JgBN80R3iD7iOl4JBeI9wU8MQlyn/MKZeoF51r3y0JDQ61BzvAyG6CYAqSkqq6Xx/Sla2n3CKvd4ihGN9yYlBOCjDuPTxG5JotjOzI0d/TnU1OkYCn9IwzLGqAyqK8MmQ1YhGFt8mhQikSIdQJMavVlKGS2W235VJfBIF3RnfvVHOaTOJ854lAh0cLzwjdtiui7anDZd/gE9rex0MCNhK73JBVuwzR7iVIRwLXD/00DTf/qvz70GHIPprEQMoipayDei4sicSgwMec+ecfLfE3HqCJM2zv3pApxC4kR15yoBT5uu9s+i9kx/yCXNKQfBb2vleL6qw/PeJoMPe963WU4pXu/esx+rwCtIJbXJXexaC3xbPgDpkLJUB+jr5EOzGK97HFVkqvOMFlsSYXO2fsMdD7iuYc8btEOkaG/BI9+Fpz7z/Io/qsOJxz0TqlLgeXfysYqvnccWZcQXi25rDHJnLown0w/nv8iYtv4fM0nc7q4OA1En7RqZXtiZOdje8eMjRsS1z/zWUX4QiuAzrM5H9agAAOfGsnvxJbsMo3AXgoHKXs8sGHiBHucrD6ASZVyjpqaFjq0oj ixKvSciy rCPueeKIGwMYmEKhMEiUAtxZgI1Zz3rKmw27dRNJ7WuGn4xAqSeLzSTGN+YFJkVGKbVSauKe7x9xsIM/mb3EZk7yDVJkfV9ckN6oPWna4DfNrRBQKJv+BKFZ0WPS4vLEw1ettrq5arwE0pSVV/VZtvzaGNqGiz4S/ybaJWPUbw44b0R3Qw7UrZndasnCbpjN7PQvSgOblYmsqLFqS5HJL1DTQ0YrHAReYxPl+XMI1PTuBEtH6slOINUU1jgDxFfJHjY0h5yj/LeVTcFS8PN+u7Tii6/P6rrxcAAIV89T4gU0dRACCdumL78YCxdmPS7Xl+QPnq1gKYSTOJHbFTywll2pDpUMyXdoVthk9 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: From: Alex Shi 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 = list_first_entry(&pool->stale, struct z3fold_header, buddy); - struct page *page = virt_to_page(zhdr); + struct zpdesc *zpdesc = page_zpdesc(virt_to_page(zhdr)); 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); } From patchwork Fri Jun 21 05:46:49 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: 13706864 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 8C566C27C4F for ; Fri, 21 Jun 2024 05:42:45 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 706E56B0128; Fri, 21 Jun 2024 01:42:38 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 3E9AD6B0125; Fri, 21 Jun 2024 01:42:38 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id E7EBA8D0133; Fri, 21 Jun 2024 01:42:37 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id 902818D012C for ; Fri, 21 Jun 2024 01:42:37 -0400 (EDT) Received: from smtpin23.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id 0D245140893 for ; Fri, 21 Jun 2024 05:42:37 +0000 (UTC) X-FDA: 82253801154.23.40D439C Received: from sin.source.kernel.org (sin.source.kernel.org [145.40.73.55]) by imf12.hostedemail.com (Postfix) with ESMTP id BEC5740006 for ; Fri, 21 Jun 2024 05:42:34 +0000 (UTC) Authentication-Results: imf12.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=ghaTGi+U; dmarc=pass (policy=none) header.from=kernel.org; spf=pass (imf12.hostedemail.com: domain of alexs@kernel.org designates 145.40.73.55 as permitted sender) smtp.mailfrom=alexs@kernel.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1718948547; a=rsa-sha256; cv=none; b=tYJoBfFxiLIBA1ARH2fvewcgMA/srefkr6QipJ1X5704t1XB8Xm8chlMEIMBwJgGNO6Tpf eRrUMxndP6PJZ9OLGZS0mIupY8SGXFDwHZNSWTpTHZxIg1DTFy/pr2dFWmfZe5sW9rNOv6 300rRqwi0FJX/dz3uSEKw5MW4g4Njxk= ARC-Authentication-Results: i=1; imf12.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=ghaTGi+U; dmarc=pass (policy=none) header.from=kernel.org; spf=pass (imf12.hostedemail.com: domain of alexs@kernel.org designates 145.40.73.55 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=1718948547; 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:in-reply-to:references:references:dkim-signature; bh=J+J2PItsE1ri1g7rWwnqytorc6qNmjtZEhn8PvI1sEk=; b=X5nsR21X75slg0KFigesHH+QcqdlbHxxDVGeiViNOYEBywmneU1uwYHAhP2Cu+iqw5diFH ixMvoeV1Th5nVUb3/Rt9hC5NWCZRQfy9m7YmQ7YvPmPecewdt7QPUmXm3wKRfIwNeqRYHD r/1sQgG6mFUEnEHRB9ZcSHPz1qA32vE= Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by sin.source.kernel.org (Postfix) with ESMTP id 46CCBCE2B5A; Fri, 21 Jun 2024 05:42:32 +0000 (UTC) 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> MIME-Version: 1.0 X-Rspamd-Server: rspam12 X-Rspamd-Queue-Id: BEC5740006 X-Stat-Signature: cth1f3iygfd151kgiufewn4ed99xau85 X-Rspam-User: X-HE-Tag: 1718948554-283547 X-HE-Meta: U2FsdGVkX1+YYvaG9cfdPBqlYvRmnzE03nSpzXED7+RRKtkveI8Zk2z49k7PFeP8p9oDu2usGCeQlZKynUpsBDBMHLF9rKgqk0cyGZjVqcVTBAgJSzhb/NlDfM5ex5glZ7FzCFA3pq652WjiG/hn4KdfuR2CERoAxGexONj9YgREEjxSxfUd47TXg9Gb6aR625Mew4pEsIYRiO2vZqGwRzz3f8CHOIcSixTvyC/TLT4fYvCL+y+DKklbORln8sicy4MBog+gZi73ZBQCbUQGrY5u1VcErWNZkdl7nNKt/bkGsUiF5pOL/82jXu/pERLz+ReBWydRGLKlVMqogUMgkwSfPTdS813fLINYvwJqDxNIFwVffczlZ2xfBFblWMmZvIy3p1AqtHpu+57wJeAt17BftyhXIwOsf6/DyIkUwjFV1nMc0Ca+v8ZNeuRCIa/QRqEK9texyUOVNyefqi0n0NoV7HbTGHatYlf/wqeLnKqGLjXfbp22QFLTqVFSzgOTleswuttA/f4fGZmxsQLpf4aDMsVV/fs0sSzLof2Fw5ZltmUp9e4kHvEjbbBD0zGHQVrATX2ULRCGUGveJHfidrpfbhyBXDn4RynHe8FeBv8zvnEtjaNf7UYt2NBGxDFlk4QCOWwC9VNVP7juI0VX9isRrLBH3ywHmePybuyABXpLuzIPYoSLz/rwGrRFS1iTOC7ivLpKpEs2fZ0rvlsyd38ATHdNpM7B+Z9sbVIpPB7GJIv3ojCuZRtTNZpvEW5vkY+tQSeagga/ol55fA1d9nA4tR3zL7uu9jfi4OByJoKWDzRoWMaRq0pEwlnxPukrKl9dxuIMrHkImVq5lz04aT5sn3WbcFTPY7PRZI+IpEoB1PxL3T22bedS0aMwL3Ndxm9nNkPGp5qPJjEy73+f7ozrbzCQelqabZeDkFXXvbxSnXZuGMMTGNA200NhrLsMO113Q42v1HnVfRqymMj cULmFvVg 9k1MyJ4a2XwTDQReHpkIzWaNDUcLNlPgaZOpvpfXdf21oHO3hjCzJbW/3QKE4caE4LCVO7FjmLFbJZlEiItop7k3pPjmvlRnsnTdCbOSiO5CWAJvWCJxodpItlLXxGC1iRP2B26obobFy6VaOnxymU7lmDYbutAWJg4sD1bopbecdE2jZ25yOLsOZOdxNdQjBMx6R4VslyXamWSD34Y5epzN5vU7XrpdygiLwd077nm1YDFnmp1hpwj87V+LzxaJtb0wg5AqjaSlUf+jSBU98Ni3hKgW+pt+hJQwO68WSwY8v3FFRaAZ3Er/P1jqeAdIq4jU3l3Hei7N2VliHXH1tjT8viCKATk2WtOxb X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: From: Alex Shi 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(struct z3fold_header *zhdr) /* Has to be called with lock held */ static int z3fold_compact_page(struct z3fold_header *zhdr) { - struct page *page = virt_to_page(zhdr); + struct zpdesc *zpdesc = page_zpdesc(virt_to_page(zhdr)); - 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 */ - if (unlikely(PageIsolated(page))) + if (unlikely(PageIsolated(zpdesc_page(zpdesc)))) return 0; if (zhdr->middle_chunks == 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 = zhdr_to_pool(zhdr); - struct page *page; + struct zpdesc *zpdesc = page_zpdesc(virt_to_page(zhdr)); - page = 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; - 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 == 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) 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); } From patchwork Fri Jun 21 05:46:50 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: 13706865 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 6DEECC27C4F for ; Fri, 21 Jun 2024 05:42:49 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 9DD928D0133; Fri, 21 Jun 2024 01:42:40 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 9670E8D012C; Fri, 21 Jun 2024 01:42:40 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 7B8BB8D0133; Fri, 21 Jun 2024 01:42:40 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id 47C918D012C for ; Fri, 21 Jun 2024 01:42:40 -0400 (EDT) Received: from smtpin07.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id 046041408AE for ; Fri, 21 Jun 2024 05:42:39 +0000 (UTC) X-FDA: 82253801280.07.8AD803B Received: from sin.source.kernel.org (sin.source.kernel.org [145.40.73.55]) by imf15.hostedemail.com (Postfix) with ESMTP id 04E26A0007 for ; Fri, 21 Jun 2024 05:42:37 +0000 (UTC) Authentication-Results: imf15.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=IsjvEN5G; spf=pass (imf15.hostedemail.com: domain of alexs@kernel.org designates 145.40.73.55 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=1718948548; 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:in-reply-to:references:references:dkim-signature; bh=H53IT11WWEt3WPpURAkxZojEIUzsZ1uun/xVR3frAcI=; b=yuB/LyPyNcow6W1h6uLQO9G5LHujEodfredl7K84BXIOKRiMvxiJ17LLk8f+myXh9xDhVl RC/2Dn4/U6B26k+bJB0LH9Q/NVgLMcmdiMrd7prlT3VHpiD0SWUgxCRm/H9Bb2jdwZ6ajU 96xajzE+EWk2vKCnjPtTxDGzzYxrgP8= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1718948548; a=rsa-sha256; cv=none; b=1aBmAm47X9Q9Mf4yRkhnCVcmuEyz5dM1PZBlsmsu/nexl7JHLUqF9w8ucXggRPYbJSrhXk 97uaVrAIGWyrwahwbML0sK3X2tyJfc/peTbAa+hkBS4tqDG2hmUhMjOxxLWLArNzhm64yS 4ik0wN7j3/QZr8n84259TNJtx6Hy1Q0= ARC-Authentication-Results: i=1; imf15.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=IsjvEN5G; spf=pass (imf15.hostedemail.com: domain of alexs@kernel.org designates 145.40.73.55 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 sin.source.kernel.org (Postfix) with ESMTP id 63F5ECE2B5B; Fri, 21 Jun 2024 05:42:35 +0000 (UTC) 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> MIME-Version: 1.0 X-Stat-Signature: t49gzsdud9comker6ny6hm85jbzr5y48 X-Rspamd-Queue-Id: 04E26A0007 X-Rspam-User: X-Rspamd-Server: rspam08 X-HE-Tag: 1718948557-658052 X-HE-Meta: U2FsdGVkX19j//5+1hx9zrMzVX4XC9fnTcbb4QZfCrpx77d6dQl2lktt8rkF6nxmbUgVmtKBmoA6f3PQuOTiP5fE1W1OC4xv6gXYZIRlX9MWOwERsqhDLaSinWN6LW8fCKzuetseV4Hyf8AfDmu5WDytpIr25hpBXykXR9ykjYPRAwsJPARN1/rWMm/UIv0dXQ0dXMXvH2sVve79P9r8odwU07TwdP9RdifuN05+RjEUrSHKqZn7yZHJMpUILrjApxFX8z9s8LyehW4991d9lMuarh9JW5hND4tQlzHiE96vKHVZOKHlOxONnyLLgQ8VR0ToHK0ZyAZ6zVgiPwAATY6inafk7t48NBtLGXGRebk5GEzB+Pi/z4uZ/BCWMILvuZW5dbxgF3Fu5kdDdBg3RIv2psmi3KEMZuZY12UQtXkS4PFxz1lHXs4aVQQI9AbJCO7osVrAzjKTXoPEx/CfIkYWrPdXrJQisjUAof97eiZf9nzGIVAnRYWFydrTA9Lvq7R2Sh7zN/BDHyvxdi5l4J4fR8n/NIa/OXPybzjFz8kk4t9j+o73DWt6bOEB2yfQsvpl/SGEDRq+v1b+sPLKoBVxmJaCsj4cuT46K4Uzg5IZO3tQiFLq7smBcJ1YKHDxE3ovhtJhfS70q5JHpd7yQGcHuDY/d5lwtHhKX7NKANiBVcdeO/V5/vKGg48X2me5nYM1bmbZfCiKO0bAnioXdY/RGhLUaNiL7cybE8DdayxxVZZDMbFQjJ9bD/uCGo/TK45D7NKuLjqQ03Lejfqpk9FL+xwbUTmW9UYt6V2UGhSNUgGxaAapi+bXOZMzt+f5Qag2p3cDlIJrF1xyJYCsPfuctRcniYMVn+m6NZtxep9NFnRsHoQT8skH1+UPgnZwr+vGNh1KgLyAAyYbRs7WkdYFNlCsaM4k379URDx5bQ2FHrOKOFZCeGISRgy47YNgRf+gckx5FPjor308JZQ wh4kuj0V 7y1FCjYiTaLe+qS+qFx0ziQ4Jlgw+ppyuTKpTp1cutkcbxNQVIp267dzO0OrF3hQQnCoKSGdL7qJMOhm3UCmw4PAaK2UT8rWR2oTA+ZEYkaDTSsM41X9bo9zCNCBsaedo1CY/KhxJVJjOIgiNxfrFxuAbDnT51vM0EkAsxzLPQ4+Or9Q3S2gTtFH925rbplNXESC6rU/EiZeyuXNOiR5hpynNKAbTm/lppwoND3Knxrct7q9e40M5kEspM9/Y0OJEpUAhL7sT7O5ZHwEf12BN2cbri6Yp5pxhPZCgguiJ6hGlFaZKOtkDogh46cBgjwWBo8upSao7rxwobzb9AjBapYVKV76vYBJUyonE X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: From: Alex Shi 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(struct z3fold_pool *pool, size_t size, bool can_sleep) { struct z3fold_header *zhdr = NULL; - struct page *page; + struct zpdesc *zpdesc; struct list_head *unbuddied; int chunks = size_to_chunks(size), i; @@ -823,9 +823,9 @@ static inline struct z3fold_header *__z3fold_alloc(struct z3fold_pool *pool, zhdr->cpu = -1; spin_unlock(&pool->lock); - page = virt_to_page(zhdr); - if (test_bit(NEEDS_COMPACTING, &page->private) || - test_bit(PAGE_CLAIMED, &page->private)) { + zpdesc = 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 = NULL; migrate_enable(); @@ -868,9 +868,9 @@ static inline struct z3fold_header *__z3fold_alloc(struct z3fold_pool *pool, zhdr->cpu = -1; spin_unlock(&pool->lock); - page = virt_to_page(zhdr); - if (test_bit(NEEDS_COMPACTING, &page->private) || - test_bit(PAGE_CLAIMED, &page->private)) { + zpdesc = 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 = NULL; if (can_sleep) From patchwork Fri Jun 21 05:46:51 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: 13706866 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 C51CBC27C4F for ; Fri, 21 Jun 2024 05:42:53 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 6FE078D0134; Fri, 21 Jun 2024 01:42:44 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 6598C8D012C; Fri, 21 Jun 2024 01:42:44 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 45FA18D0134; Fri, 21 Jun 2024 01:42:44 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id 10C9D8D012C for ; Fri, 21 Jun 2024 01:42:44 -0400 (EDT) Received: from smtpin22.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id BF33FC0912 for ; Fri, 21 Jun 2024 05:42:43 +0000 (UTC) X-FDA: 82253801406.22.1E24123 Received: from sin.source.kernel.org (sin.source.kernel.org [145.40.73.55]) by imf19.hostedemail.com (Postfix) with ESMTP id 88B411A0003 for ; Fri, 21 Jun 2024 05:42:41 +0000 (UTC) Authentication-Results: imf19.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=Dhhurl3c; dmarc=pass (policy=none) header.from=kernel.org; spf=pass (imf19.hostedemail.com: domain of alexs@kernel.org designates 145.40.73.55 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=1718948551; 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:in-reply-to:references:references:dkim-signature; bh=HMk//fdr4CCccqqvWOhTBEl3kE7h3RRH1GcADQePr34=; b=5bBZtxAhuODO9kE5OCclbAoB38j+eh52gFU09Kt7BfHkqceb7+7w1Pm8fkYXogmbK8Tuhb q9bT3aIMEKPuEC8Vj7r7S2Mf8ztxjABWHPSL75yZRgkeRiIudeIJ6k1Kc2p8f22Zgf1EMp DWzffgL8fkViLyCthfzsJdiGAAITl30= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1718948551; a=rsa-sha256; cv=none; b=hjKBGd8J793wCfBuKL/wzu+VsLdaB+2gn1yHInQ+mXn6Csyn33jYz+wmweD8ryC0hay/4T 7V+BXseOwq+1lFwJ1qlWkUUEzXDIEvanyOPjE0xrUBS5UqeWSNa5VelRjF2l1G9E+uOBbq eIRkdemM/XNTkLJKDfampLeUIA+4rlM= ARC-Authentication-Results: i=1; imf19.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=Dhhurl3c; dmarc=pass (policy=none) header.from=kernel.org; spf=pass (imf19.hostedemail.com: domain of alexs@kernel.org designates 145.40.73.55 as permitted sender) smtp.mailfrom=alexs@kernel.org Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by sin.source.kernel.org (Postfix) with ESMTP id D6A24CE0A66; Fri, 21 Jun 2024 05:42:38 +0000 (UTC) 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> MIME-Version: 1.0 X-Rspamd-Server: rspam07 X-Rspamd-Queue-Id: 88B411A0003 X-Stat-Signature: 85qgjr7p7o9k677qhwhfpsrbcmaxissg X-Rspam-User: X-HE-Tag: 1718948561-756795 X-HE-Meta: U2FsdGVkX182sofXzxXO2nJiHEGCEgrsOvkA0+KAduJ0qIe37qBJ82zsTKjWoOWxjbQ7mHJ7YxGOThXeibIV3SdaDtJw42aN9SKh6THs0D9OcIpKRx5PUYQWf2Xo1rjCVljdr508DiUASWQ+hoDsdvw4b7JySXKrQWGWFb3PjlbijfZnwIxRt0RMyH6W0xdgLLTjYTedy8gtJaAc8wjyw0XL4fh0Z1M4jnwBXkfn2H/Rn7hvbvNk5VYInG5tVuHfj8H/Ok/md2jYW7toBiDbDm6EUNpscu4Bf1sIP/SgA/iFMUWHGVvNm07kM50Q7uMFHSmvFnlEfepQUrGljy2s1XGyG+PZch2bGdB/gmxcFs1eJf0Qmsl1YhP/CSFb9UbF2fpI2c3RsgawiGbhfbRNegkN4+LqQecz6fAham2EDcaAPAEDNh9p76o51nkQIRQW7p5FsIengBeXp87FSyu1jHetDbGMbcBRMgP6G1O0xGKC8KUVa8+LN/mVOWxqaS3cP31AbjyYhmFR1WAjRc9drLe5ct7tJBKFrMZuQDtPdAd6wDot+F50sBtF58+JAj2X/LsRx/Izgul6d+5fb24d5z1LTvG/LElejN0qoZlp0ekL3MJl/15ZgWlaRpR/36zOIhVlDDLdP5EVFfR0xXhwzdR+2Xa0KkfhjTCtH53vSJHpoipuE03XXtq0f5uPwwzUDakFlxQn3FsO1ZtMlIXaTRoGrXSj5ZibbigELxGxDLOWO0c0iGZyzpEPsNp0wPHvT2Ki0omOaqrGPeBQs1tBjPpkbOmfks1+k+xuTPTDdtr5BO9NT+SFVxvbiYDmPH56FISmb6mseGZIlgVMvvUoFrpPWFN9wOTNa5B8qqDQRneZ/ouuiR/hYE0a9EFsKPPd93yfp1AHInxcYrfqnzlTVHqkvVoZjleu9gkzuEn8i1d6yDWJniKM3CulszTHgheoFFB9N6l+46tvXVzzjA5 oCLprJM+ FEBmh9n1xczLu6yPh9slqcG1vUUfOnpoqvDThIW9ArZjOgAeHvA5P1eVPQtQDd6M55EmbGxOh2o+95qus9GZT86I5e6EN8fRrr9hpTR5txVQcgvaKfatIJsz3L/4+2pzAKz3+8YC8qeK/qfpKE4ncdpayqksRbTJywIMOEl7Z/LxmP4X9YzlVMq4QH9UKctHihpsYCU8s8xltaN6LuPCJGpidFoI1sxGJvH3vcPmMcIPbU+JV4pL5yrDnlliLNusB7bueCkx4tBZQXihg5mNX8Qq6jlDX4o/dtc/XWG+QULUnluyba57PEDWMtNxQqPO0iZhDDpZ0CTVoESaa9S1TZrUNTxXnWBpWPGv4L1D8wEpri5sqtI7VgxgN6A== X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: From: Alex Shi 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, struct z3fold_header *zhdr) } /* Initializes the z3fold header of a newly allocated z3fold page */ -static struct z3fold_header *init_z3fold_page(struct page *page, bool headless, +static struct z3fold_header *init_z3fold_page(struct zpdesc *zpdesc, bool headless, struct z3fold_pool *pool, gfp_t gfp) { - struct zpdesc *zpdesc = page_zpdesc(page); struct z3fold_header *zhdr = zpdesc_address(zpdesc); struct z3fold_buddy_slots *slots; @@ -1006,7 +1005,7 @@ static int z3fold_alloc(struct z3fold_pool *pool, size_t size, gfp_t gfp, { int chunks = size_to_chunks(size); struct z3fold_header *zhdr = NULL; - struct page *page = NULL; + struct zpdesc *zpdesc = NULL; enum buddy bud; bool can_sleep = gfpflags_allow_blocking(gfp); @@ -1030,35 +1029,35 @@ static int z3fold_alloc(struct z3fold_pool *pool, size_t size, gfp_t gfp, WARN_ON(1); goto retry; } - page = virt_to_page(zhdr); + zpdesc = page_zpdesc(virt_to_page(zhdr)); goto found; } bud = FIRST; } - page = alloc_page(gfp); - if (!page) + zpdesc = page_zpdesc(alloc_page(gfp)); + if (!zpdesc) return -ENOMEM; - zhdr = init_z3fold_page(page, bud == HEADLESS, pool, gfp); + zhdr = init_z3fold_page(zpdesc, bud == HEADLESS, pool, gfp); if (!zhdr) { - __free_page(page); + __free_page(zpdesc_page(zpdesc)); return -ENOMEM; } atomic64_inc(&pool->pages_nr); if (bud == 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); 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)); } +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)); From patchwork Fri Jun 21 05:46:52 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: 13706867 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 1571CC27C4F for ; Fri, 21 Jun 2024 05:42:57 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id AF7BF8D0135; Fri, 21 Jun 2024 01:42:47 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id A76518D012C; Fri, 21 Jun 2024 01:42:47 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 8F2598D0135; Fri, 21 Jun 2024 01:42:47 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id 667278D012C for ; Fri, 21 Jun 2024 01:42:47 -0400 (EDT) Received: from smtpin09.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id CE79E140893 for ; Fri, 21 Jun 2024 05:42:46 +0000 (UTC) X-FDA: 82253801532.09.27FE5E5 Received: from sin.source.kernel.org (sin.source.kernel.org [145.40.73.55]) by imf16.hostedemail.com (Postfix) with ESMTP id 9B38E180002 for ; Fri, 21 Jun 2024 05:42:44 +0000 (UTC) Authentication-Results: imf16.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=H4G9h9IY; spf=pass (imf16.hostedemail.com: domain of alexs@kernel.org designates 145.40.73.55 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=1718948552; 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:in-reply-to:references:references:dkim-signature; bh=+bFzhcB+nRahqVz4kYtabYaeYHyGa//js2ac4ijon9k=; b=LCloerCd85nEqsjcVaOQ5xbPyYh8IbVvjuWnljvCaVTa/X1Tg9Vv6pSMrNGbo2usawmF+h uAo74afedlg1RWVa5L2hhWPS+uiyz3+1OvBWd9kY0a/rTSMWBrV+uuHsrKS6i0OeoIBeIk eTymg4eLFkTyRB28rTb3JhAezCrgUf4= ARC-Authentication-Results: i=1; imf16.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=H4G9h9IY; spf=pass (imf16.hostedemail.com: domain of alexs@kernel.org designates 145.40.73.55 as permitted sender) smtp.mailfrom=alexs@kernel.org; dmarc=pass (policy=none) header.from=kernel.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1718948552; a=rsa-sha256; cv=none; b=t1FYgRRnnBOfwQK2/ZiMuqXnj/AJvNfqrKED0V7P2V3AMxDxCvnvrUetcmysVKse32YAgE kj8Rb5MmdyUIeIGgVhn6iF12qkuU2heZoyWlQR7ANYAGgdKFjlQIWCcZcPIdH5O+9SAk/I dek7Bk7Yb+B2g7RN8QCSX8wNx7H4R9w= Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by sin.source.kernel.org (Postfix) with ESMTP id F197ACE2B56; Fri, 21 Jun 2024 05:42:41 +0000 (UTC) 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> MIME-Version: 1.0 X-Rspamd-Server: rspam06 X-Rspamd-Queue-Id: 9B38E180002 X-Stat-Signature: pmst315e6re18taxugya6zha6ouzxq83 X-Rspam-User: X-HE-Tag: 1718948564-345987 X-HE-Meta: U2FsdGVkX18CDwxgG4zbcIyVecw3r1dRvvlvsqWboc3cWjHzgoqvhcx2R/E/oQ07Ozyv/GJ8oIem+RhT7KF/li9nAefDQQM2PUkDglL0agGnFha+YuZcm9WRWqfA3ji8UufcZaCssqQ1bmxCLw6ve4L2EgKYPykbtAm2drTQZ5Sk9JHe8lBirXOzh1Yqw9gnqBGflpXyjSTEIEobrmm54NDWtaXKWxItp1kb4fgN2RXSMiFPExNZiMA2rNWWyE+yO/m3HfYFfzgoGbXmpawfjd4Vq8K2N6NLsmGEC3mYyHNzArm/ZEb/MihFsBJIhJ9rDwVFUxbgY+4wyvtSOQK4kWu1Dv4EnC2f9BxpM7Vt4sti0/EUnGInTCs7n0uYmhFaq87fRRC8AbDlNn5OimYonsXqHlAxGa8PYv1UrHY2dPid+P3KgH53q+wdIw4QLqU2GfArNJt8KAEM/LOuv/wTRnfsmILKR9h5woW6Y6Lpsv24uMdRaaNerp6iIq7WTgEfHvlOYv5PdUFqLSkMZFro9OrJSgMS8T7+cXtjnGuMsYEtyKRTLgpBPuWj4RHyFK3235EPHstPrE6wbqFsRmpVnDiub+5YdbxViJoPVCTsAW3JKOaUKmtpaSS/W8wn3coSPn6EJ/TQYhZcmU7YHkEb9QMd7forHPHGYayTUffans7dr4Trlj3fl9N8WU8uO1qCKoda4QkknwdeAXuLcF7Vd0lcS28m9ayEVNDsFYVu2KjbU7egRDewr5lk541BJx+LnEFSXqKVHWXNi7vaACBCsrJmbQtuGCMnMb3joAIHdFaw+0r6ckNPLIGlSg1p53vw1Pnvk4kxr2fC3nb3iN/CEPuvjGLq2MD/0Hwqrd6jlHv6cAc65bWh8NgdWNycvx7N1QSG5nbJZwDW0TLZ5Y0gEgyOUbmmRorbq8Ug9ztanZYi/h2FoOoRvuwQJ8lAPjwc+GCa20vhTBGUpLyZ3Sm S7Uth6A5 8YdwQfCQlrTIaoVDJNsmjMURZbi4vL8mtZpqBMBM6DYr9Sigp+p7YfonljU8313nM1AIKMzi4VLEvAd+ecdn8noTIgVuZelqOQ+01nSIL3RqD6QzHw2ePJ04ry6cXS0lVPji+HJCnywtkL6P0smDAA5kR2lRdlzgmgZ/6awY+lv5h+d/ZLaEY+zVhEXsoa9vMN9ZNpgdP2+OGATD61p7GfuI93UVq5Q6gGJdCckIZm69EtoY8yWCMXHiPqu87cbCnPBPnI8rlk4l8JFBKzHyuL6vTzAbza86TKzJdtIqEogAefcdhDUbYG3Pd5Fj6Kp7WxiJHkflpbDFFC1vLFXbzg6lvuT/ZxI7yF2lI X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: From: Alex Shi 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 zpdesc *zpdesc, bool headle return zhdr; } -/* 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 = 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, size_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; zhdr = get_z3fold_header(handle); - page = virt_to_page(zhdr); - page_claimed = test_and_set_bit(PAGE_CLAIMED, &page->private); + zpdesc = page_zpdesc(virt_to_page(zhdr)); + page_claimed = test_and_set_bit(PAGE_CLAIMED, &zpdesc->zppage_flag); - 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, unsigned 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, unsigned 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 = -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); } From patchwork Fri Jun 21 05:46:53 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: 13706868 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 41105C27C4F for ; Fri, 21 Jun 2024 05:43:01 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 486D58D0136; Fri, 21 Jun 2024 01:42:50 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 39A1C8D012C; Fri, 21 Jun 2024 01:42:50 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 152FC8D0136; Fri, 21 Jun 2024 01:42:50 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id D8EC68D012C for ; Fri, 21 Jun 2024 01:42:49 -0400 (EDT) Received: from smtpin05.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id 96B9D80913 for ; Fri, 21 Jun 2024 05:42:49 +0000 (UTC) X-FDA: 82253801658.05.1C45EE8 Received: from sin.source.kernel.org (sin.source.kernel.org [145.40.73.55]) by imf03.hostedemail.com (Postfix) with ESMTP id 88F1B2000A for ; Fri, 21 Jun 2024 05:42:47 +0000 (UTC) Authentication-Results: imf03.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=Zt2liuts; spf=pass (imf03.hostedemail.com: domain of alexs@kernel.org designates 145.40.73.55 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=1718948557; 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:in-reply-to:references:references:dkim-signature; bh=6Megb/PlkgrwupGgpLFTJ8z6gVlLhivc7VDBvSmE93Q=; b=QGhuPUqzSKBSuImav/DAl6HkcBnTSoHvs9Sg6iQeA59ddSCX75UxvE/kpqcDKfH985Q3ZC aCe7uypZmC1jYy+mAwGZ3dwx9xVZaEB87KoEx/eHbWf817AtpJEzqPYCyCLZLXzctiZvaw 1qlvuo6SH+e6LvglwcmmYEC78rxfwps= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1718948557; a=rsa-sha256; cv=none; b=Vcm/uSzzqWjL5VByq43jTh/+1DMqgQr7K3dTlB0Ch5y2uaKvE0F1Ka5wvySMIoHbz2gJjU Ex9IY2e77nDXoBiAix41Qx1hNtFCLROTjquxflfoS29/puR7Nh0Qx+2Gnniz5F2H1QV5rE aTrRLe1QsM9a3iljKS1PDjXCz1NKsww= ARC-Authentication-Results: i=1; imf03.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=Zt2liuts; spf=pass (imf03.hostedemail.com: domain of alexs@kernel.org designates 145.40.73.55 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 sin.source.kernel.org (Postfix) with ESMTP id E7310CE18BE; Fri, 21 Jun 2024 05:42:44 +0000 (UTC) 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> MIME-Version: 1.0 X-Stat-Signature: 64oib8se48bxomtkdsgfc5om4dnhx3du X-Rspamd-Queue-Id: 88F1B2000A X-Rspam-User: X-Rspamd-Server: rspam08 X-HE-Tag: 1718948567-186135 X-HE-Meta: U2FsdGVkX1/1Z2+UKyMfzDiCzqvOP3qTF8ryavtFJRCnedddJeyWC1dxddHfXhbgJ9UrsVS7QQ+JILaLFjCp4/u/9xuTgNf5OFEoLY9/neljA7NP6mngM9ZbM5j6bkEBv4scOp3IO/DxAzun+Qr3CWMVXfhcofBr11bp4iW0KTz+5hWVpbO1soC8INoBiirueExhtryk4Ne9Fk7fMCa/J0Csxcd4ITXw9TdNXFzBXVqEzArnzkx3HUN/LqWqzmvOYFfYjZvoCMvvjbZXRgDX7bTuouZNLrwz7shApbB9ZLd4imK9n9xjkze4u5rmbGQIHrNsqpH473ZFaUy7Wnpq3NPlgI0pO8yTiYzFuVCy1ii5d4vNvazloXk9rT43GGYcONg9HNl/PZn7BMhxeMdwq+N3PODcCbtfTrkhsWZErr9Y2ax6NZvzitCD9Gn9LNKkwYgncuM7dqujI/PPM9eTzdmB1sBSgSfb6VH1xNbzIK49of4qJ9NrPbZKO1fspKPHxXciFOP49OzI+kHQnopFhiLE1FU/FxZf7nTpBsxsOffUDHlBEtznlRKeZMHjTYqHMGc2MFNwlygvP1etUkx7RSQ1RLob30J17A7kg33IZWOLGELIFwleaac2sTwT65sIJ7vSQ/VTfjQ+Aw9Pq81i5fLZUASw3lUtKIN/7v5IPtqDLyFiKMTlQ2ZqySaMLSWPFv1ETrKz4ok5yx5BMtwJart7tmm0QFv3i7Xml04ZcI5K+qt8Mko6iTunQYyaob4p7nLGKJTZhVUzwwFsbnfw+LepHv1wvr5CRQCg7OwPj7uO5sqN5/RlmUWFAEq+4MuzAW4aDCcUI9q+x90jIiuLjhobM5c5WOVTMUw0jxG1xvSi2jLOAC51uoAqM0wD/8veQHtIa8XWQKfb+WskHwq99u2qfhoYhS7iy9nNjMVJfi1az2GZxKAIVDfZlkk6wUofu/QQHprTzEKFjP+IBmj zb9NDFcD nXgGHJzpbmYdtGtNnlzRhEpShWxyO5WL68n6C7PXO/XPkFzWdWK298mPPB5URh1kbB0i/YVrzFfaZA7kWBF8LlG0P9Wnwgq8GaE9enUBsFgjeDwVpYl2J5gJa2k3hybBV5NCqMLfAw9UhBbZHYfwhA/jM8wfyah5v2zpxkiCem+hLu7hp+oPa42aMGX7kebJ0mrJ4RsaJCHgwxW4b+2d9EUCz20LJQey5X1QNg/7YiQ0CSQatnU13DXhHrngmAswa6Zc0snFtSCCGgv+YXe3uuw+p/R8nmMeKPQmxfmwotaZ2v69Px0JWJA9lNWgDzf3LsVgpTv0K/Pe33IS5/WXT5z6X4x64e6yRFeXf X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: From: Alex Shi 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, unsigned 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; zhdr = get_z3fold_header(handle); addr = zhdr; - page = virt_to_page(zhdr); + zpdesc = page_zpdesc(virt_to_page(zhdr)); - if (test_bit(PAGE_HEADLESS, &page->private)) + if (test_bit(PAGE_HEADLESS, &zpdesc->zppage_flag)) goto out; buddy = handle_to_buddy(handle); @@ -1193,7 +1193,7 @@ static void *z3fold_map(struct z3fold_pool *pool, unsigned long handle) break; case MIDDLE: addr += zhdr->start_middle << CHUNK_SHIFT; - set_bit(MIDDLE_CHUNK_MAPPED, &page->private); + set_bit(MIDDLE_CHUNK_MAPPED, &zpdesc->zppage_flag); break; case LAST: addr += PAGE_SIZE - (handle_to_chunks(handle) << CHUNK_SHIFT); @@ -1220,18 +1220,18 @@ static void *z3fold_map(struct z3fold_pool *pool, unsigned 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; zhdr = get_z3fold_header(handle); - page = virt_to_page(zhdr); + zpdesc = page_zpdesc(virt_to_page(zhdr)); - if (test_bit(PAGE_HEADLESS, &page->private)) + if (test_bit(PAGE_HEADLESS, &zpdesc->zppage_flag)) return; buddy = handle_to_buddy(handle); if (buddy == MIDDLE) - clear_bit(MIDDLE_CHUNK_MAPPED, &page->private); + clear_bit(MIDDLE_CHUNK_MAPPED, &zpdesc->zppage_flag); zhdr->mapped_count--; put_z3fold_header(zhdr); } From patchwork Fri Jun 21 05:46:54 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: 13706869 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 73511C27C4F for ; Fri, 21 Jun 2024 05:43:04 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 6A9E28D0137; Fri, 21 Jun 2024 01:42:53 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 632208D012C; Fri, 21 Jun 2024 01:42:53 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 45E108D0137; Fri, 21 Jun 2024 01:42:53 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id 19F138D012C for ; Fri, 21 Jun 2024 01:42:53 -0400 (EDT) Received: from smtpin23.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id BAD6D80918 for ; Fri, 21 Jun 2024 05:42:52 +0000 (UTC) X-FDA: 82253801784.23.A71F875 Received: from sin.source.kernel.org (sin.source.kernel.org [145.40.73.55]) by imf14.hostedemail.com (Postfix) with ESMTP id A5327100006 for ; Fri, 21 Jun 2024 05:42:50 +0000 (UTC) Authentication-Results: imf14.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=Smo9cGIV; spf=pass (imf14.hostedemail.com: domain of alexs@kernel.org designates 145.40.73.55 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=1718948562; 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:in-reply-to:references:references:dkim-signature; bh=xZ4u4n1bR0L8Bhv9HGhI/tmnwckndauqfE9jsrkziy0=; b=nUiZhoMQChNdHKpbO/qoDPU7iBiwi2a372AKinJ5W1sAAiUQ0X/WdviRc0w3AYLs4utiNM 5wyjDQYhsc9AVAw6onfPIGmqVGRRe2IMeY6xcI6zgoHZHn261z3MdaNlYMu18lO8Ac4j1J Lud27mcC5iGToX6PqCbsgEfw/xV0Wgk= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1718948562; a=rsa-sha256; cv=none; b=Z5WonsUlS60Z/hfV0+LDyLOJGuaG6t32em7bP+3sDrflgHlCmXqj07obhtjbjUDBEoHsVM R60lmoFNq/tP6LLxoS79pF/QBzIFxu31WEuw8IbqClQkjb4Cc1ezfVdQUBB2wt5mEboXwO gqqf3nBTtaWFvc9UNwcjDrnL9ze82X8= ARC-Authentication-Results: i=1; imf14.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=Smo9cGIV; spf=pass (imf14.hostedemail.com: domain of alexs@kernel.org designates 145.40.73.55 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 sin.source.kernel.org (Postfix) with ESMTP id 0E75FCE2B4E; Fri, 21 Jun 2024 05:42:48 +0000 (UTC) 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> MIME-Version: 1.0 X-Rspamd-Queue-Id: A5327100006 X-Stat-Signature: aaprdia5zty4af83n9pw48ob3q1ap4cj X-Rspamd-Server: rspam09 X-Rspam-User: X-HE-Tag: 1718948570-482494 X-HE-Meta: U2FsdGVkX1+ANZWkfSFhpOz6bbjsEzskBZo3Q7OJvNZbl+jO+mUBpEOhH96lOQWVFsuy+YF68GvK/XZ05DCYciOW6osVAS4CLSgmWAlz7zEBB465XrToolpRzgXmB2mzHQQeOZbMgLqqUhA5iMeMJSpaXUU+2/j9+8db2P/sp7+ElPYpNuCjX2b8iJX7L/d0FX2jdeYhS2D2QFmX5v3g3CxQeBa5nxigfQ1St0qW9CEqHzxSEMkwGqDoqrQkkPUIRpqTntN2Uc5NfoaRDp2sUB7Ntw+3ITO+sm413I2VhbvBob1/a6W+LLjNYT7EiJtcFVatcVNBrbdFs6AHIuSX0Tv25Wzk+l0k2HXvCiordlQWWM82kmtsdcFofNwn/aR0dMQM2LTe0pTG3sZ7/cW7iZt0IWoSxFkf2pnl4jTlLyxZPwfJUPMu2jv49h3NLbzzpZ2MeNc5y/+cl3mRdxhLVv33dn1oobPzQuPnKopiP3zDK8fxtrueDxbApbwa+SIWA/RI+gk0q/m08NVD2EQ/j68Ppv+e2sJNv6VNMeOBE156/ZLVHs9155rouPY+hCT+1JquCE2ixhBGjd/3CzI8Kv0mnXyt3pMHRDipfmc5E7vQ1LYRDxtR70A7qiRnwMKYj5Hzn7f0IWmvhpWefSFQRI63jUF2PzyEpb8Jkym7ghlYzbDq2EedrUWbJXqV25ZFeK2S1z7ixLU2e4hiurP+RHB2zTvLG8Tg2AKgA6EQUb42lRhj+9Ta6WnuhUf84RV8tQqGGXaLcN5ixfiSBB78t36KGO8eVZd0zV8OTxLKSPk0EgellYSNQKPe9WkK1J37Km3SNeutmps/SKklSrNvz//MIPuoDhPUtrVxXQ29SIN4pWVu1wgIDfS1g3AQ2w8ksemVDyFz1DJHR2vFqr9CPhSUbBjCV/bGM5+F9JHB+gFSqO4enBtwBtifTZAuPgjgzpaYTW2eICO6HuhyiQS FJpDKJpA wvmCOu8FD+osY3pFP5B+mj+U2mNpR+22qszGgCE56jmDmuRXsTOQeS504rqjhGeDMuEfcVXa33zlObNWgZLQ9uE6y9c3qz2YQWZsnuGeIjU4DuNTe9+THRPgTxsSIHj2ZNH9ZIjolmcR8eGspL4+0cCgyHBBPo2/Oo/x7V0iaHQV2riHURPZFKf79Ebhlp3/wq+Imz/2zrG9uUMZ483PPS73ZJDQSalOw28S/rJECmQIDu9lwtkfCJofaKOWLnKbHSdDvCnxmMh/oQnNZ5SEheei//N1e2y4lDRFIltXZH/QD03/4K+kT12pOyTpSYo5K1+DImYhAT+DbHarlmvZfRJCnN73ATYU/MfLWp1ljUYAjq1ozryNxeZ4Qcw== X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: From: Alex Shi 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, size_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 = smp_processor_id(); - __SetPageMovable(zpdesc_page(newzpdesc), &z3fold_mops); + __zpdesc_set_movable(newzpdesc, &z3fold_mops); z3fold_page_unlock(new_zhdr); 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)); } +static inline void __zpdesc_set_movable(struct zpdesc *zpdesc, + const struct movable_operations *mops) +{ + __SetPageMovable(zpdesc_page(zpdesc), mops); +} + #endif From patchwork Fri Jun 21 05:46:55 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: 13706870 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 43B96C27C4F for ; Fri, 21 Jun 2024 05:43:08 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id CC3C18D012C; Fri, 21 Jun 2024 01:42:53 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id C4C2A8D0138; Fri, 21 Jun 2024 01:42:53 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id AA07B8D012C; Fri, 21 Jun 2024 01:42:53 -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 7DC938D0138 for ; Fri, 21 Jun 2024 01:42:53 -0400 (EDT) Received: from smtpin05.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id 35A3F160941 for ; Fri, 21 Jun 2024 05:42:53 +0000 (UTC) X-FDA: 82253801826.05.18A7A2C Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf26.hostedemail.com (Postfix) with ESMTP id 92271140004 for ; Fri, 21 Jun 2024 05:42:51 +0000 (UTC) Authentication-Results: imf26.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=fiYuYRr7; spf=pass (imf26.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=1718948566; 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:in-reply-to:references:references:dkim-signature; bh=O4grW4BWVfJLvdJ5iDlyvwWe35jP4b82YdchEsX2tFE=; b=JT9AGZGiJhcYDcWW0jafbkiP98jeG+4hdBG3+fy6bnGbmXN+hmwzsdGcJKrJ57b9Aw3gdQ C9raHdzfIda9u1FMQ40Hywn353z7bDIlCx9DqYLuibQZVUyAvZQYbhWhnO1qDNTy87wQYJ mM6D+P5R8dxgiQ788vNTuwEWk5rE8kk= ARC-Authentication-Results: i=1; imf26.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=fiYuYRr7; spf=pass (imf26.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-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1718948566; a=rsa-sha256; cv=none; b=oqv2yEMfFJ6RpZ8Rmg4kdRkDAlK2SqtE8ctT9Vmk9JBr9sX8uT/GbpDIOeLyJ12OJgrMaQ UJXDLwwTHOr/VCm406SajPrnZ4e3pbHshPj4rkpbgwD+Ri6cJu/LnQYd1wMSpCjsQ0nefc K8RSTZJFk/qfJuBcckiS0u+qljNyQ6I= Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id BF717623EF; Fri, 21 Jun 2024 05:42:50 +0000 (UTC) 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> MIME-Version: 1.0 X-Rspamd-Server: rspam11 X-Rspamd-Queue-Id: 92271140004 X-Stat-Signature: qgag695nymubhp35ea5ws4fpkws3syxg X-Rspam-User: X-HE-Tag: 1718948571-783438 X-HE-Meta: U2FsdGVkX1+RcNuUMEmZ+1b7zmwUQq+1Xzf25iGok3O8k5XJ+fDD55BcA0Ip+VbXhrdqN7c/pW9HcSxt4d+7bZfmlSm9xb2I14ayhGPHv9640jE/3EEZZSIsoxSefzbnrH8s7QMIZCKELE0xmile457Sfksh8bBHZq885OrW1CIcLGxvoUMZ37LytmH+UeUxEoaJdoJV7kv88PfnNCWthmPvRZFi9wfWAxrZaLBrQS6xhFcWJ+rTXLBODMkf+sAcrlm7xFZmU+kwliBgvnHt2Gii3+1yxMpb2l94xIuLHsGRSFuCiw431ehzeJgaxoFJG2mutvd7iHzkkl7vMD7GC5+JhhAbTfMInPDgPzGWMuxlN2KaSew6u5VhhrGKuZfYj/3ofaE9iW67G/TCE88rtEbFXbhQmjI8BhY3o0vRjKu1fu9HJ0hzRA+6mE3B/dkB9uoY7+exC6+/Wh/Ehb8wPN2o4xBNPtEkeElQ23aNm91SAfi0GJJTXXr2D6wJShHzf+ND+YYWTid+7EQ9zfe3ZR52Pyls0ts/Bnz8vatTlPBdfWGq7Qm8aaJsCnfGc11dgpuHnkanQSLm9j+dNf9qiIeu5Mvg/40lKq7+tci/X1Vvz6Q49DC8KoclZk+PlQq6y7maQJgI9cOqTIuX/g67azEr5YtZ3HK/c7ag9dGMNSNqA4rjZf30qvH2k9a/Sqf1hXaKVIDBe4jhP+PmHaYVh4wyoBUIRZgXJ5ejEFcufU5fSxohLzl9tvHfL70av+3+TrT6mFHD9AAiqgB0wAFB+TAfo58R5FGKCoYsxnpiKqJOWN0GbGs7jgdeFgGtoqUM3DGIU+I5Tb05FbzOTdXewqzmg7vdHv4mxAiYlT3u9vMKddTaaHT4/NkWYJCdmt/Ull/oOGFd/YRvKwvKMugkn53oUMZDCvfCua/WtSru/sowwKOIniNsTvjuCQYVLpGg56tZQdOI+HoxAtf+Oy6 XdyLrysc bXHLUdvDuYcYGM8WJrCpWdZM6s4TN6qfPintyCK0zWfzBR/HBtfjHCPLJhoqYgDEHIktqGA4hC+DK8EnQcRYbObwWVAnK+aktJP0WOLWotfrygT1UIofPo1bmKStRh0z/l3khN0SbzpnAKwxIOKt20IFq8IK9az0p0v2aKnFE9lX1ZNDu+K/D41ufsbbAU8Phh32B7vp+9Fm2dfg00Z8qcMMdHmhF6gXtkbjUl2gp9PEe9fZ6jqkHjLIlABdSUmgG7YdgXPax3po7CdbAMzwmGO9Auw3i24KrVEz/lfNyK2q09QpXXEuLPmMWhDMjz+gVgxQKNvHfqOeIHODgP5RKS2iGIBJn77TUHq4m X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: From: Alex Shi 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, bool 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); 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 *zpdesc, __SetPageMovable(zpdesc_page(zpdesc), mops); } +static inline void __zpdesc_clear_movable(struct zpdesc *zpdesc) +{ + __ClearPageMovable(zpdesc_page(zpdesc)); +} + #endif