From patchwork Tue Aug 6 02:23:06 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: 13754336 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 E41EEC3DA7F for ; Tue, 6 Aug 2024 02:19:10 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 0C7BC6B00B9; Mon, 5 Aug 2024 22:19:09 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 079EA6B00BA; Mon, 5 Aug 2024 22:19:09 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id E0D076B00BB; Mon, 5 Aug 2024 22:19:08 -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 C1BC66B00B9 for ; Mon, 5 Aug 2024 22:19:08 -0400 (EDT) Received: from smtpin08.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id 7EBB3A68DF for ; Tue, 6 Aug 2024 02:19:08 +0000 (UTC) X-FDA: 82420213176.08.C5C0F52 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf20.hostedemail.com (Postfix) with ESMTP id E49431C0029 for ; Tue, 6 Aug 2024 02:19:06 +0000 (UTC) Authentication-Results: imf20.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=HznYQbSG; dmarc=pass (policy=none) header.from=kernel.org; spf=pass (imf20.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=1722910677; 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=ovfDqQxTVdKERQAKtqZwOsjviHhDb3m0AzMbr6CEq8M=; b=7jx7irllh2LZpw2VfXXt2GCCMJqB1oaJDOSXG9L006peWaDQvD6nTC1X8j/Ds1t5xVkdhC o7WAYbZUQjQRMW2dl8f/qCe4sVRrx4fZj5dvG887AMcB9G5Ni35XFo08WaNAiCHBgz287c oxH8XMoK2cbLHZayEbNtmYO1vD/BSU4= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1722910677; a=rsa-sha256; cv=none; b=iLVzWKu8Z8k4N+RvlQJ8mRWStHv1Dq5GGoh92w1f3imLu/gaftBCWm8Atm25s3b5pG9TFZ ZEAMIG38QKOn3S31xSrD3a5RfPFjHDIztGwY0Zj3hFqPDWWpJ0iGo8D1VldsYzcD5U9NpN VNR95UtnWa2dOYRtmmv+9GOT76dBtP4= ARC-Authentication-Results: i=1; imf20.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=HznYQbSG; dmarc=pass (policy=none) header.from=kernel.org; spf=pass (imf20.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 3850960DC4; Tue, 6 Aug 2024 02:19:06 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id BC641C4AF11; Tue, 6 Aug 2024 02:19:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1722910745; bh=oL5cTZYBz5hcMd4ibMjrzRAOxUIAWeTC3GGP5qzznjU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=HznYQbSGB5gQ2kI4wcaUCOnPgGomh9VJ4uFtU8YG1LSpwabhCQ5mxFNi8WpsZ6exU K2rMxdEaj7xFao9BCCnDrHgaXr9hQ4jYCcgFfLBKdAml2YEKJ69MLvRMrXZQgAQxqX RONxiHPQHIUEX/m1A/ofr7XuFO/YWOznmfR9zypSe7GLU6pMZS8Xx3aN/pypoyEzh6 kLyjt2xVtNmiSUqQtoB2AjBnSdr4Dcc/epjg/GoMU4SEg/Xv2KyIEHTI6BaDEVxS8k gT+v+/dqRQT+ymOFOQz2ckMqoZBnAoBylS3mn63NoXSeKUbYwjnzgDGBG/r5ZOElwK iG0VmI/vVGPxQ== 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, Yosry Ahmed , nphamcs@gmail.com Cc: Alex Shi Subject: [PATCH v5 19/21] mm/zsmalloc: introduce __zpdesc_clear/set_zsmalloc() Date: Tue, 6 Aug 2024 10:23:06 +0800 Message-ID: <20240806022311.3924442-20-alexs@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240806022311.3924442-1-alexs@kernel.org> References: <20240806022143.3924396-1-alexs@kernel.org> <20240806022311.3924442-1-alexs@kernel.org> MIME-Version: 1.0 X-Rspamd-Server: rspam07 X-Rspamd-Queue-Id: E49431C0029 X-Stat-Signature: jrs37zritnjuwwg4j335j5g37r8yd598 X-Rspam-User: X-HE-Tag: 1722910746-791517 X-HE-Meta: U2FsdGVkX19r997sVyR9hUNA2800dzmBW1nSsDUOwtxH9Opy+zJY8aCjkqAjH6/Vgi5luYxSi5ynKzdBDLmuZ7NnAanzLu1m6QElrUB8kVJQcAqjK35qB/HbmGxr4pq8ixtdCPlPeomlhvypBK8vgAAXfGYasyTbppA+DtMyHIpHorTWqBoi+aAzV7j89Oj5biIrNLhavv2FFGxPLno8ih8asEsoZ2MhY3a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rhj/NJCy60dltoyJFHg6RU55q7KHXqIanL 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 1ab47faed49b..d0a1af0ee424 100644 --- a/mm/zpdesc.h +++ b/mm/zpdesc.h @@ -119,6 +119,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 7c7432a00a07..0b318db894a8 100644 --- a/mm/zsmalloc.c +++ b/mm/zsmalloc.c @@ -831,7 +831,7 @@ static void reset_zpdesc(struct zpdesc *zpdesc) zpdesc->zspage = NULL; zpdesc->next = NULL; reset_first_obj_offset(zpdesc); - __ClearPageZsmalloc(page); + __zpdesc_clear_zsmalloc(zpdesc); } static int trylock_zspage(struct zspage *zspage) @@ -1004,13 +1004,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_page(zpdesc_page(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; @@ -1800,7 +1800,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);