From patchwork Mon Sep 2 07:21:27 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: 13786840 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 DABFDCD13CF for ; Mon, 2 Sep 2024 07:17:32 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 7430B8D0093; Mon, 2 Sep 2024 03:17:32 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 6F2E38D002D; Mon, 2 Sep 2024 03:17:32 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 594278D0093; Mon, 2 Sep 2024 03:17:32 -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 37EF08D002D for ; Mon, 2 Sep 2024 03:17:32 -0400 (EDT) Received: from smtpin24.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id 0F3DEAB0FC for ; Mon, 2 Sep 2024 07:17:31 +0000 (UTC) X-FDA: 82518942702.24.7732A57 Received: from nyc.source.kernel.org (nyc.source.kernel.org [147.75.193.91]) by imf09.hostedemail.com (Postfix) with ESMTP id 71EBC14001F for ; Mon, 2 Sep 2024 07:17:29 +0000 (UTC) Authentication-Results: imf09.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=ERPokKEV; spf=pass (imf09.hostedemail.com: domain of alexs@kernel.org designates 147.75.193.91 as permitted sender) smtp.mailfrom=alexs@kernel.org; dmarc=pass (policy=quarantine) header.from=kernel.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1725261402; a=rsa-sha256; cv=none; b=40+K6SKFZ8BTEEGfkyXs7QYfW5+Tyf51A07dtp7k6HP22raAGawCAE/yyiJQBolho0Uyt8 VI82O1USiPr7zr04Al5mHEYV99J+MypIFk/TNtXqu721gDKj0SCNaqUzgvP2h0qqlQF+57 /+GmMcejhLUxQHz8B0dGGhUAmt/SxXE= ARC-Authentication-Results: i=1; imf09.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=ERPokKEV; spf=pass (imf09.hostedemail.com: domain of alexs@kernel.org designates 147.75.193.91 as permitted sender) smtp.mailfrom=alexs@kernel.org; dmarc=pass (policy=quarantine) header.from=kernel.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1725261402; 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=VIjtBmZVxCU4L7fmy1RUXq/PJdjiwZ5zuPh3lDEwewE=; b=ri9s8HHK3Nqw/CwdGVINcKk1ZWbWSxcBRH8Bv5Z3/l3BQ62VdcB+oeY4x4AC1JaibJeOds 33vj8/akxPHP8nr+y3BaW/URtUO0P/x1oggSQGNGbq9TDia/hPAaz4lfcnV1wND1Cn9jRM PRcAWtJZtZ0f23XBBEvzqxUw6MzoFfY= Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by nyc.source.kernel.org (Postfix) with ESMTP id BC97FA41188; Mon, 2 Sep 2024 07:17:21 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 99803C4CEC4; Mon, 2 Sep 2024 07:17:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1725261448; bh=JuDze2waT5auO9Z7Ml30M0i2Ht/5hJoDWbD0pOFWjSk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ERPokKEVB7btxb1uvOqV12Md3j6Hiln/4Oe6BMGQ0KkLLvi6CvWIloMINQAnte7U7 elqpjG8Xnkla09nh2xTF0/JOW/ym6N4MKk36KVw3BiAIRpJZ9pcJMC3UsMGtOdlnqI if720f3F4KWiQWy84ic+ZksiAvMwBi1dSI/sAKv7FheYygvZZ+iDYNfsHbex8/h9qJ y/OXCEYiHNDN6tbacLZFXUhsNGNqvdN/w6Y82L/yLEqJP6G69cqslsWgZsIh1UUNOB a8U1Xqnj4M60MqOk0doSkUH2avB5I+3G/EckGtiFPlz4Bh+ZpGMsQK7m4iw2GeKdmj 6MeoSLhIzMHxA== 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 16/21] mm/zsmalloc: convert SetZsPageMovable and remove unused funcs Date: Mon, 2 Sep 2024 15:21:27 +0800 Message-ID: <20240902072136.578720-17-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-Stat-Signature: gktw7h93356e6tr5ocshphz98a15csp1 X-Rspamd-Queue-Id: 71EBC14001F X-Rspam-User: X-Rspamd-Server: rspam10 X-HE-Tag: 1725261449-535032 X-HE-Meta: U2FsdGVkX18WVGRcW7VYhK093MY1iZhzpusUaqJ0J+SGgITxZJ7hK3YmVc7pfM1QjA9YieAuBk7OeSqRKi3GqjDwmLeeYnCZy/W7561lSJs4VmyR6qRKoZrcvrd8w/YlvDkjy0S6JeStfhq2DhWnSKEQoWyjCjvdzORhEpmo8io6tHLoDc0jAnQ4vYrf+tOOHHULoV9RiYFj/zCn1/M7zwtzUuyj94zU/m1gKP+mjohVF9GHSMz9dSFITY43L4WgxmkAHvRp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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 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 d9251450ec60..3b98daa63ece 100644 --- a/mm/zsmalloc.c +++ b/mm/zsmalloc.c @@ -462,11 +462,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 inline bool is_first_zpdesc(struct zpdesc *zpdesc) { return PagePrivate(zpdesc_page(zpdesc)); @@ -483,14 +478,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; @@ -775,16 +762,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); @@ -1957,13 +1934,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) { }