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+aJk5MFJo10kQ7A3v30bbKd0n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ilter, 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