From patchwork Tue Aug 13 08:46:02 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: 13761565 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 36CFDC52D7B for ; Tue, 13 Aug 2024 08:42:16 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id BF96F6B00B9; Tue, 13 Aug 2024 04:42:15 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id B82416B00BA; Tue, 13 Aug 2024 04:42:15 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id A22DB6B00BB; Tue, 13 Aug 2024 04:42:15 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id 787EB6B00B9 for ; Tue, 13 Aug 2024 04:42:15 -0400 (EDT) Received: from smtpin15.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id 39E16A069D for ; Tue, 13 Aug 2024 08:42:15 +0000 (UTC) X-FDA: 82446580230.15.C352BB3 Received: from sin.source.kernel.org (sin.source.kernel.org [145.40.73.55]) by imf17.hostedemail.com (Postfix) with ESMTP id F315D40016 for ; Tue, 13 Aug 2024 08:42:12 +0000 (UTC) Authentication-Results: imf17.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=JgfTSlvZ; dmarc=pass (policy=none) header.from=kernel.org; spf=pass (imf17.hostedemail.com: domain of alexs@kernel.org designates 145.40.73.55 as permitted sender) smtp.mailfrom=alexs@kernel.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1723538522; a=rsa-sha256; cv=none; b=mblkfmrdt9yACE9un+miM/RagdnmGaQD3/MNLMiquKIfSI4iUnBhS8TdmwiJHJJ5ziz+45 cjYNrXopqqh8xdBEm/g6PhvCY8vdgVsMEIItmX31am0vvTIWijb7MvE3D5IQP46WDCvVs7 QQJYliyZJ8NeBns7LKyZ44loqBoLP6U= ARC-Authentication-Results: i=1; imf17.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=JgfTSlvZ; dmarc=pass (policy=none) header.from=kernel.org; spf=pass (imf17.hostedemail.com: domain of alexs@kernel.org designates 145.40.73.55 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=1723538522; 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=N43L6InCiBMwZBnzz7kfNDs3dEtiPSvTUSj7c7OvkXc=; b=ftC0S3TYvbkSlnO3dtAkBM3Nx4pL22yDp/KE2ihtaD03IKjYaCYdGb4QXKJNxwY1aP+9j0 JiJAHgsuo58QO4UGKrF8bL0HOcCSnDCgkg0416KhF1ZDJyq8SQBr1job/ekfotxeCSUX+K C4QDky+3GoXtx7S6n6vvr84Xx89QD3Y= Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by sin.source.kernel.org (Postfix) with ESMTP id 2C566CE123D; Tue, 13 Aug 2024 08:42:10 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id EE86FC4AF13; Tue, 13 Aug 2024 08:42:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1723538529; bh=gQaMHcDtxoBXgRT3p7vOtyKNFbzrfkZ7CKreedzRtjs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=JgfTSlvZRX5rj4F+je0IgQVoumPPB1HFUsceRotVPVhoikowdDEW0P2qObUTYI398 gR1/EIMADa8MqSXujMKyHg/EExmLFsocPWJg6SoEbAOwiulDmKDAQOclW/XRzGG0uC KpWTOdWx2HgFPAywG6qxV7VN5PH3agkB+nina86PjV5/5qTIA7ebSafJN3QNkipVW5 AUs2ctwy+2+ZBzAftUKxISXseq9T18Wg5QL6U8S+DU1CjGcZJJOMb1wab8R8Mn1GEb IzCYbHJRKIqxQVx1HPqmCnGxr5TG8ZZr16pysTaSatTJE36v7R6CxlKYcdWuIyKVIE HNnVoo5DzUppA== 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 v6 16/21] mm/zsmalloc: convert SetZsPageMovable and remove unused funcs Date: Tue, 13 Aug 2024 16:46:02 +0800 Message-ID: <20240813084611.4122571-17-alexs@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240813084611.4122571-1-alexs@kernel.org> References: <20240813084611.4122571-1-alexs@kernel.org> MIME-Version: 1.0 X-Rspam-User: X-Rspamd-Queue-Id: F315D40016 X-Rspamd-Server: rspam01 X-Stat-Signature: cf3xfqufnbweoothrd86jumy46mrjn3w X-HE-Tag: 1723538532-673725 X-HE-Meta: U2FsdGVkX1/jDSwSEA9mD4axtWsCZfR4X8616fhARl/T5N8/FNy/UuHsicPubppPimdXhSs65XTvpv4VBm+t581NTnIG3WSKJdP3wxlBjNFKg0PZK0fHxMEvGIYxf5gMw7Vv5KuoAAA3le+t3WSIqS0VJK2Yhm603385IWZA2ctB7zWmIlzZFP1XWQBRsozkDSwT7clu2iY8XkbBhGQphPAh+EXYP0+BGEwvTfDlCqGGL3WfYGFQI1nvxBv8FeI99CqB8MCc2CL02Fq2IW6/BWyLn4PzzIuQL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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 5e96ff2ee0d4..e2b203db192a 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; @@ -781,16 +768,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); @@ -1964,13 +1941,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) { }