From patchwork Mon Sep 2 07:21:30 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: 13786843 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 D0EF1CA0ED3 for ; Mon, 2 Sep 2024 07:17:42 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 632518D002D; Mon, 2 Sep 2024 03:17:42 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 5BA0C6B008A; Mon, 2 Sep 2024 03:17:42 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 434778D002D; Mon, 2 Sep 2024 03:17:42 -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 1FDF96B0088 for ; Mon, 2 Sep 2024 03:17:42 -0400 (EDT) Received: from smtpin15.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id C80F5419E5 for ; Mon, 2 Sep 2024 07:17:41 +0000 (UTC) X-FDA: 82518943122.15.5850908 Received: from nyc.source.kernel.org (nyc.source.kernel.org [147.75.193.91]) by imf22.hostedemail.com (Postfix) with ESMTP id 43888C0006 for ; Mon, 2 Sep 2024 07:17:40 +0000 (UTC) Authentication-Results: imf22.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=rmCwtlM6; dmarc=pass (policy=quarantine) header.from=kernel.org; spf=pass (imf22.hostedemail.com: domain of alexs@kernel.org designates 147.75.193.91 as permitted sender) smtp.mailfrom=alexs@kernel.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1725261437; a=rsa-sha256; cv=none; b=u/G2L6uXoQpxWVZ/0qNBt4Vj7izthBFyWbzMBpXKyayd9dZDqpdoTxLzGj351J9HUrSeT6 w3FNn2z1NQaW1kAxO6jXQ2vPzpPwpCRzMadEav6hWL2JV7e716yh1PqJTQe+AeDqu3OQHn xXTH7qnojYIIB8EWYitIa5hAujZwf0c= ARC-Authentication-Results: i=1; imf22.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=rmCwtlM6; dmarc=pass (policy=quarantine) header.from=kernel.org; spf=pass (imf22.hostedemail.com: domain of alexs@kernel.org designates 147.75.193.91 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=1725261437; 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=gfjn5uAhOLEypwo9zarT1J2Zt/g3So2BaRMmNkbhT24=; b=kdX6MDheQP4p8M3GdNm5wQQ2BeGiTRb/JEPLMaioa7Pk4FzBbhHAmSvcRc09mkAT4twrAw t6BaJofdC+xAVP85FGMlNJL81LIkptK1KoWIK5kMWE6C3twrW5qok841Wee7nGoiXThkHA 07pDUxCoGrvGYBObkFA9IKIPDik8p+g= Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by nyc.source.kernel.org (Postfix) with ESMTP id 89DA4A41733; Mon, 2 Sep 2024 07:17:32 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 1DA3BC4CEC4; Mon, 2 Sep 2024 07:17:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1725261459; bh=qBTLwe3n68h/nHaRcrmhMxfrsTQQMe/QD9FAr8WVzS4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=rmCwtlM67H383ue/d1A7wHWuRCZDakd/TZzSnpJeA4VFGc32hDbeOS8FTOWo5sRb0 ViqeWCYjWICvSaWY72rsoZUG4M6YX+PGvWQMmy3jIv7c7QCQS60yusdDIeSZK812FQ WLRmX14gVqvnz4Cdklb3OlLQTXo9nCCtLvzPXK8uSEjWqTwzP+fhJ4ututCYbSksjy f7Osa+8CG1OpTfqZwFyicoXReh1YIGFAQgIjmm0MeiZif5Ahk46Xc59XHm09Urv5Zk lBJVGSAjYGJy3i6OlV8Yy5/NI7Ll8uGLNkXK40cfZieLx7/rjrLINdxsuvXMIZaOKL uY/1WpeDffh0Q== 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 v7 19/21] mm/zsmalloc: introduce __zpdesc_clear/set_zsmalloc() Date: Mon, 2 Sep 2024 15:21:30 +0800 Message-ID: <20240902072136.578720-20-alexs@kernel.org> X-Mailer: git-send-email 2.46.0 In-Reply-To: <20240902072136.578720-1-alexs@kernel.org> References: <20240902072136.578720-1-alexs@kernel.org> MIME-Version: 1.0 X-Rspam-User: X-Rspamd-Queue-Id: 43888C0006 X-Rspamd-Server: rspam01 X-Stat-Signature: d5ergtueyzd47wwwsqqfpe49rpnqa1ni X-HE-Tag: 1725261460-105573 X-HE-Meta: U2FsdGVkX19zaXzHf5Q8jBoHNdDm82Lm6a50NkbgNBVtoBohCnBKCPPzGjMvQSrFbHI8XP6LTwMucHojQWURolUWNeot+Nwnd1tgVlynCHe1EaklQyJpeI0xT7XfGVp5jXrRzMim/RCxDsGQz6Edu+G80Ckfmx3bdLmc+KdT5P05DjZASSSSS3TngSj8dVaungAuvyFthvdxIu3iAsCoOhligLzwKb0d2y+PbD65zYH9ImlWayyyS8vnZMZy+E9kfz7iNGrucp++jwYu0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IlCYujjttk= 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 747a2d410a35..33f599081281 100644 --- a/mm/zpdesc.h +++ b/mm/zpdesc.h @@ -120,6 +120,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 107973a2a36e..411621f00a02 100644 --- a/mm/zsmalloc.c +++ b/mm/zsmalloc.c @@ -838,7 +838,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) @@ -1011,13 +1011,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; @@ -1807,7 +1807,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);