From patchwork Thu Dec 5 17:49:56 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Matthew Wilcox (Oracle)" X-Patchwork-Id: 13895892 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 1B122E77170 for ; Thu, 5 Dec 2024 17:50:15 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 618B76B017B; Thu, 5 Dec 2024 12:50:08 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 48E956B0185; Thu, 5 Dec 2024 12:50:08 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 1CEC06B0183; Thu, 5 Dec 2024 12:50:08 -0500 (EST) 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 A01576B0174 for ; Thu, 5 Dec 2024 12:50:07 -0500 (EST) Received: from smtpin30.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id 568318163A for ; Thu, 5 Dec 2024 17:50:07 +0000 (UTC) X-FDA: 82861643550.30.6FFC33C Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) by imf01.hostedemail.com (Postfix) with ESMTP id 8E9BE40011 for ; Thu, 5 Dec 2024 17:49:53 +0000 (UTC) Authentication-Results: imf01.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b="m/6qltxX"; spf=none (imf01.hostedemail.com: domain of willy@infradead.org has no SPF policy when checking 90.155.50.34) smtp.mailfrom=willy@infradead.org; dmarc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1733420988; 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=M0a99fmCVrOPq+PPvnzMWS5DYYkjS0DjuUk6shW5dpQ=; b=fs/A94eNm9GL2ihjXas61k7f/B57AF9j3Fhaj540jiltK1KNSw5evmtHLUvgNKmi6epwxH 4KuVhKIHWU2IkPBac0NQVNLTRnStrGkiWlW+iAP2JUM8JeFcCpcnRR6X3muVnW2ZhMOJSs FHiYxYLbaU/L2zFoOJp2U4DWr5UtNNc= ARC-Authentication-Results: i=1; imf01.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b="m/6qltxX"; spf=none (imf01.hostedemail.com: domain of willy@infradead.org has no SPF policy when checking 90.155.50.34) smtp.mailfrom=willy@infradead.org; dmarc=none ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1733420988; a=rsa-sha256; cv=none; b=UQ6EH/hzdbLZTNJI3wpdemk073mJJTfHHzOe3EwPTWQp7jeqmYxrp8NNQNLEN7JNs3+gE7 VKVA7aRkESSDGl8/GeWcPIgvrkqzdIXbfIrxA79vv9h3n23ZROfgUSaWkKA0sdwQTN+0Wj uhhZzg1Ym4w9zMGIzDY8WYAaEQ4Nk28= DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=Content-Transfer-Encoding:MIME-Version: References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From:Sender:Reply-To: Content-Type:Content-ID:Content-Description; bh=M0a99fmCVrOPq+PPvnzMWS5DYYkjS0DjuUk6shW5dpQ=; b=m/6qltxXXAIe/Xxd1xNLYmLfif DN2syc/DlwdS5QCpdmTfmMwV3QcbyXP3RqxqRDJF+b13nrvDf+n7mXzlpTJZ83TREkfpF08qza8JW L9NFwlaQ/H0BRsKAIjwUqJAE+qPVOSKvrgQ8aPbL4LGZ9MIuTn+elaV3NFQoBqHTrT8XbEkVqis2H MlYR+fXx05iF2fRjJS4c5oABFG5keNS4nKGvc6VRKQZBFnE9Z71kuVMusi3J4qCivTMoAabP4KOha gb+phkT+m7LTZaV41Zzdhn2XT0DUcUX32zeQ5N8CSnAkwaMAtk9lVnV5YD0Y5rHZpqfRSTU/YRYs/ wiTvuMQA==; Received: from willy by casper.infradead.org with local (Exim 4.98 #2 (Red Hat Linux)) id 1tJFzI-0000000DN9J-1uM8; Thu, 05 Dec 2024 17:50:04 +0000 From: "Matthew Wilcox (Oracle)" To: Minchan Kim , Sergey Senozhatsky Cc: Alex Shi , linux-mm@kvack.org Subject: [PATCH v8 19/21] mm/zsmalloc: introduce __zpdesc_clear/set_zsmalloc() Date: Thu, 5 Dec 2024 17:49:56 +0000 Message-ID: <20241205175000.3187069-20-willy@infradead.org> X-Mailer: git-send-email 2.47.0 In-Reply-To: <20241205175000.3187069-1-willy@infradead.org> References: <20241205175000.3187069-1-willy@infradead.org> MIME-Version: 1.0 X-Rspamd-Server: rspam06 X-Rspamd-Queue-Id: 8E9BE40011 X-Rspam-User: X-Stat-Signature: jm8e5uxs1g5s31j5o6de4ihi4rknpaxh X-HE-Tag: 1733420993-605937 X-HE-Meta: U2FsdGVkX18jeycoXYLmQSIwAYzCSV2XjvC9GgHcih9J55GwbPYzIJ8lJBNLjMd8ubij5YCCMdJZ2viMtCgp4cL4oJHOMaUYLwjcaYBdfUbJ4L1Zq+Qc23iRHrWTEJBWyDtupNOEbjT/I2UrSyh7DDGKyqSSToDeGMeIy8l6FwzVqR0HcfU7YpNdkeA4GHR1NhGfiHtOBCAmgK+2/y3ePnYQGCAOzl1LuNWI4lmBFikN2lGTVeI6pZCAlZQCes2AlqxxebNcbcEMJ8xon4yv4Q96y6HOk3qj0jwrP8VdGslkZC9OF/ujFQTkpSw+UUXcTHqv9smwhs7wtC1q8XE/Rz9mbKyxNU//par/0imCVU8uR+bVm3yERDm8rRaWQQbxkNhoNA/CJUz0YCwtaM84oCOO7/Nmw/BS0vHLzn/2wQHWJlOfl68txdxUS07z6+b+lTQYbmeSJ57plaJwsJTrdVESTfuUi7z36zz8Oyek8URG3/yX967fZZLA1g5eS7bOIWlVfe3x5Cc5tKhjt+FFGcjRD5uSvv50HQg2B/MUMvfglrcrsscUV01Qf0WIrXS1y80G8JGcC+OXCuasSDrm5/Xu65C/SlxQR1KPoNtvdVb8e6O1on0048oTcjzHVC6jv2rrbKG+0bVPpRHLe93n7SYFW7kxkLIiXwo3PnJW6+yBtjesQPz+UVMgH7x1/jenY+jQTOtjEkATujRy8qB2Cw0sSGoTUbTBjYHK5e1XNbc3encB8f8Ult/JxwWNZK3tTqpOZ4b5SgfQG9lCsubQj9qznysHsVUvN9HG9U+HvslkDUSqfUnEbuFfIP+2zHK9lz9GQ6FCbCXsZl024RHwP6hLCp6ltcP2KjEf/HB1n+XHQZGgDMC/BH9wAzYmrjgMn2L1AYadDJYPH/uaLaR3xtzFTQxtb+AktuQOXMMpMuVdRhbCjAB3U8RsZLsINi3+cOti2NFV4nwyvGztrw3 Ft0gysh2 o0wqL1y00ZE/+uWcTI4/RTGOWAaWA4/AEMz49edt4YZjP33pT8/HmeOvHTeULbOp2RwsaLKteHYib7hht2/wa8RFarh35BhZtJb0GCaHNRqyLvs55FbnFSnz8uBhM5TVdz8frDdrzH4XCii9CBinL31DKdpmxIsc2baWSHW2KJonbGEhJWGA86FqcdFVaPqeCWdpjfCXegWUdG+he1lE7lNM80ZNI4l15g2pHf/dfAidP+ckykfbbr7DR23UuysZNBYCY 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 helper __zpdesc_clear_zsmalloc() for __ClearPageZsmalloc(), __zpdesc_set_zsmalloc() for __SetPageZsmalloc(), and use them in callers. Signed-off-by: Alex Shi --- mm/zpdesc.h | 10 ++++++++++ mm/zsmalloc.c | 8 ++++---- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/mm/zpdesc.h b/mm/zpdesc.h index d468003c7ebd..a09a63be929e 100644 --- a/mm/zpdesc.h +++ b/mm/zpdesc.h @@ -122,6 +122,16 @@ static inline void __zpdesc_clear_movable(struct zpdesc *zpdesc) __ClearPageMovable(zpdesc_page(zpdesc)); } +static inline void __zpdesc_set_zsmalloc(struct zpdesc *zpdesc) +{ + __SetPageZsmalloc(zpdesc_page(zpdesc)); +} + +static inline void __zpdesc_clear_zsmalloc(struct zpdesc *zpdesc) +{ + __ClearPageZsmalloc(zpdesc_page(zpdesc)); +} + static inline bool zpdesc_is_isolated(struct zpdesc *zpdesc) { return PageIsolated(zpdesc_page(zpdesc)); diff --git a/mm/zsmalloc.c b/mm/zsmalloc.c index bcd5f1b9f382..f9a9c2400e41 100644 --- a/mm/zsmalloc.c +++ b/mm/zsmalloc.c @@ -846,7 +846,7 @@ static void reset_zpdesc(struct zpdesc *zpdesc) ClearPagePrivate(page); zpdesc->zspage = NULL; zpdesc->next = NULL; - __ClearPageZsmalloc(page); + __zpdesc_clear_zsmalloc(zpdesc); } static int trylock_zspage(struct zspage *zspage) @@ -1019,13 +1019,13 @@ static struct zspage *alloc_zspage(struct zs_pool *pool, if (!zpdesc) { while (--i >= 0) { zpdesc_dec_zone_page_state(zpdescs[i]); - __ClearPageZsmalloc(zpdesc_page(zpdescs[i])); + __zpdesc_clear_zsmalloc(zpdescs[i]); free_zpdesc(zpdescs[i]); } cache_free_zspage(pool, zspage); return NULL; } - __SetPageZsmalloc(zpdesc_page(zpdesc)); + __zpdesc_set_zsmalloc(zpdesc); zpdesc_inc_zone_page_state(zpdesc); zpdescs[i] = zpdesc; @@ -1805,7 +1805,7 @@ static int zs_page_migrate(struct page *newpage, struct page *page, VM_BUG_ON_PAGE(!zpdesc_is_isolated(zpdesc), zpdesc_page(zpdesc)); /* We're committed, tell the world that this is a Zsmalloc page. */ - __SetPageZsmalloc(zpdesc_page(newzpdesc)); + __zpdesc_set_zsmalloc(newzpdesc); /* The page is locked, so this pointer must remain valid */ zspage = get_zspage(zpdesc);