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/m3HfYFfzgoGbXmpawfjd4Vq8K2N6NLsmGEC3mYyHNzAr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, 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); }