From patchwork Mon Jul 29 11:25:28 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: 13744739 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 B942AC3DA4A for ; Mon, 29 Jul 2024 11:21:16 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 4ABDD6B00B1; Mon, 29 Jul 2024 07:21:16 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 40E416B00B2; Mon, 29 Jul 2024 07:21:16 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 28A116B00B3; Mon, 29 Jul 2024 07:21:16 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id F2EE96B00B1 for ; Mon, 29 Jul 2024 07:21:15 -0400 (EDT) Received: from smtpin10.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id B96B61202E0 for ; Mon, 29 Jul 2024 11:21:15 +0000 (UTC) X-FDA: 82392548910.10.F2FF1C0 Received: from sin.source.kernel.org (sin.source.kernel.org [145.40.73.55]) by imf30.hostedemail.com (Postfix) with ESMTP id 9C66880005 for ; Mon, 29 Jul 2024 11:21:13 +0000 (UTC) Authentication-Results: imf30.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b="Cis/sQct"; spf=pass (imf30.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=1722252020; 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=kTm/sX+DW/w9pIMx9ScGftKWcPwLIh0BNYGkIGj7FVU=; b=NMvUC7EgNlMXc1Y2FuqWpONST9ifLrZrw8a/VRO0tOh8+FewLHA3y7O3DCszc2yyotmX2x 0+AVQGWQRkLddDRI1UD/jvmfS3MnZxp2cDdgg3Sk98lnAUzZ6uktvj3alGup+qtc2lAS3F fFDGnLYoQpcnpl8o4Y/JCHW+3V9llkc= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1722252020; a=rsa-sha256; cv=none; b=MebgfD8mzoDj+DY31EibhEAGI+/T277/4xLbCj76ACCZBDOZQ30E0clfsZcfHmhbxOyY9c At4GsqgUPfzWfhfSz6PmI2J0E1uGb+9rORN12tdOcUQaPwdSr7THxAA/AkD5snCY/Dqokb DihegRc9JzFxBGrq5mjH+vzSshWV4Qo= ARC-Authentication-Results: i=1; imf30.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b="Cis/sQct"; spf=pass (imf30.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 Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by sin.source.kernel.org (Postfix) with ESMTP id A8CEFCE0ADB; Mon, 29 Jul 2024 11:21:10 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 2CC73C32786; Mon, 29 Jul 2024 11:21:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1722252069; bh=uH0rZNnpHFMljEmSyKQuSSlLph2dNP0xTWvseJvNDaY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Cis/sQct2oie4isbX0P4WgsHRrGtWLVh7YFLlWHN4Hqxb4Ps0mGmDN5s2E3j4uoLw hcbPLuM3mQCdC8wAZKHt/Fi5LPEaPrAd5zhVLwPvCiqEEsOOljP8QGnJnBIP7iuO2o denYHvyN+8K1G9sUD4xLP82ZAtOnzeMNsYkan3a5EtkxsS9BZddKDmb03Z5zXVaANg aZe32kqPkj3x+SuS/BhLrA2bB+Mxs7Lto2RiN/O3apyJO7inUD8qPFSXMkT1gMuLKV 1rf5SV/fqXZ108XIFo7MPKqAEtCY8JczZCXeoWKST8sS8Bl1na7887/WCHXFmUE+/3 CBqLzo08RhhPg== 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 v4 16/22] mm/zsmalloc: convert SetZsPageMovable and remove unused funcs Date: Mon, 29 Jul 2024 19:25:28 +0800 Message-ID: <20240729112534.3416707-17-alexs@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240729112534.3416707-1-alexs@kernel.org> References: <20240729112534.3416707-1-alexs@kernel.org> MIME-Version: 1.0 X-Stat-Signature: onjn5hyx4r4tidsbr8jxnt9iipksei4n X-Rspamd-Queue-Id: 9C66880005 X-Rspam-User: X-Rspamd-Server: rspam08 X-HE-Tag: 1722252073-682073 X-HE-Meta: U2FsdGVkX19BQDUlPhN1QtRvvvqvsP2zVgwd5UbUOPfIGTOJDIMUaHZKA5+PqYQvb2T4xoMTFoF2EF3Ac8+pE4d7Lqh0qX5YO3Cb+dh6h8aUCrf8PlI68X5W9rxCGJOCE6YOxgwU6E8mF+7Ow9ruh1LAv0FLYqQe1Ys23o2HzNC7TRX34xB4sx/DXeuq46eGDfFrjC2VLlL/l/GWEXlsK+uBaoZBjrJd1MRL1gzQIrHbBq8NcTtyjxsZl3UV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=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 Convert SetZsPageMovable() to use zpdesc, and then remove unused funcs:get_next_page/get_first_page/is_first_page. Originally-by: Hyeonggon Yoo <42.hyeyoo@gmail.com> Signed-off-by: Alex Shi --- mm/zsmalloc.c | 33 +++++---------------------------- 1 file changed, 5 insertions(+), 28 deletions(-) diff --git a/mm/zsmalloc.c b/mm/zsmalloc.c index 458ad696b473..8b713ac03902 100644 --- a/mm/zsmalloc.c +++ b/mm/zsmalloc.c @@ -468,11 +468,6 @@ static DEFINE_PER_CPU(struct mapping_area, zs_map_area) = { .lock = INIT_LOCAL_LOCK(lock), }; -static __maybe_unused int is_first_page(struct page *page) -{ - return PagePrivate(page); -} - static int is_first_zpdesc(struct zpdesc *zpdesc) { return PagePrivate(zpdesc_page(zpdesc)); @@ -489,14 +484,6 @@ static inline void mod_zspage_inuse(struct zspage *zspage, int val) zspage->inuse += val; } -static inline struct page *get_first_page(struct zspage *zspage) -{ - struct page *first_page = zpdesc_page(zspage->first_zpdesc); - - VM_BUG_ON_PAGE(!is_first_page(first_page), first_page); - return first_page; -} - static struct zpdesc *get_first_zpdesc(struct zspage *zspage) { struct zpdesc *first_zpdesc = zspage->first_zpdesc; @@ -787,16 +774,6 @@ static struct zspage *get_zspage(struct zpdesc *zpdesc) return zspage; } -static struct page *get_next_page(struct page *page) -{ - struct zspage *zspage = get_zspage(page_zpdesc(page)); - - if (unlikely(ZsHugePage(zspage))) - return NULL; - - return (struct page *)page->index; -} - static struct zpdesc *get_next_zpdesc(struct zpdesc *zpdesc) { struct zspage *zspage = get_zspage(zpdesc); @@ -1970,13 +1947,13 @@ static void init_deferred_free(struct zs_pool *pool) static void SetZsPageMovable(struct zs_pool *pool, struct zspage *zspage) { - struct page *page = get_first_page(zspage); + struct zpdesc *zpdesc = get_first_zpdesc(zspage); do { - WARN_ON(!trylock_page(page)); - __SetPageMovable(page, &zsmalloc_mops); - unlock_page(page); - } while ((page = get_next_page(page)) != NULL); + WARN_ON(!zpdesc_trylock(zpdesc)); + __zpdesc_set_movable(zpdesc, &zsmalloc_mops); + zpdesc_unlock(zpdesc); + } while ((zpdesc = get_next_zpdesc(zpdesc)) != NULL); } #else static inline void zs_flush_migration(struct zs_pool *pool) { }