From patchwork Tue Aug 6 02:23:03 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: 13754333 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 15E4CC3DA7F for ; Tue, 6 Aug 2024 02:19:01 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 9A24D6B00B5; Mon, 5 Aug 2024 22:19:00 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 952116B00B6; Mon, 5 Aug 2024 22:19:00 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 7F2E86B00B7; Mon, 5 Aug 2024 22:19:00 -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 60A586B00B5 for ; Mon, 5 Aug 2024 22:19:00 -0400 (EDT) Received: from smtpin29.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id 1B53D81D92 for ; Tue, 6 Aug 2024 02:19:00 +0000 (UTC) X-FDA: 82420212840.29.CF89A6D Received: from sin.source.kernel.org (sin.source.kernel.org [145.40.73.55]) by imf24.hostedemail.com (Postfix) with ESMTP id CF52A180009 for ; Tue, 6 Aug 2024 02:18:57 +0000 (UTC) Authentication-Results: imf24.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=lO72cahT; spf=pass (imf24.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-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1722910707; a=rsa-sha256; cv=none; b=TF5UabcfliUvPMytzoke46A4MyobN/whqCvUJBZuPJ4QTN8uyFcfqe9QUfPQCcn5klTRlz gdPGtCh7QPD9SdGefcdwrD+s0XQ+jCYzqYMOnHzOgt6nX+t10gMC3jlK9EFtzQlYxIIKFy HAAgHlBSJucGDxYJ4q6X1/iYAhTNTzc= ARC-Authentication-Results: i=1; imf24.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=lO72cahT; spf=pass (imf24.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=1722910707; 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=mECHyMHpJrdQfrlljgr0KIclcNdpBi3Rbw357iNHdTM=; b=5NH/8jeA7uWvjwu11IQXTxT+c6VCq6127Fd0xidXSniEoh7+sNZbu9k2bl+E9Fk/qwMcHB hdatssFDKGN0BY8QuU1QHAcYrpXRdLeeAus/QDy/dDEv4X8D5rHA8GW30nVb916pfK5+dd Zd5IePjhL+P5ExSU3RiJvuglslK/N8E= Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by sin.source.kernel.org (Postfix) with ESMTP id 556E8CE09AF; Tue, 6 Aug 2024 02:18:55 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 79ED9C32782; Tue, 6 Aug 2024 02:18:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1722910734; bh=dtYWibYOHtP7k2L7bRrRJ0o8M+qJDQY9usNXaIwbwBY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=lO72cahTLoWkgC7Fa1GVC+0hzqrLY7guqKdalHp+19GYloDBXVGgnVMkA6OEbgxLz I0omHi39eDE1hwAIsmiyNC3lQerM4A6pVo0uXUNxZeUyQTI5Rll9kQOReJhxdbTnse 3riuCQoqgpy1oFQmmD0ZEN/HioRasC0sVhguV0gCV6kwUReZeO65WOweOVH7DebCig buBiZCpWOGWi7uSflgP1duhhn/JiZAMVXhBSAcntuFNtApPZZlo5fb18wvMFe1NzvE xLJCqvCx1jHwdpI7Qb+YpqvafIVMoIj7yj4TEfqqTAuyAcFqW0znvZNr7xRenq/Hh5 ERruHjKKT35BA== 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 16/21] mm/zsmalloc: convert SetZsPageMovable and remove unused funcs Date: Tue, 6 Aug 2024 10:23:03 +0800 Message-ID: <20240806022311.3924442-17-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-Stat-Signature: fdtpptgs48kri6q64gkmb5dh98wtikpz X-Rspamd-Queue-Id: CF52A180009 X-Rspam-User: X-Rspamd-Server: rspam10 X-HE-Tag: 1722910737-268088 X-HE-Meta: U2FsdGVkX1+fnrOArcM5nE9wAxNf25GD/gTvPOsOuieHUGNz/SBMOyHJy0GXnX/vlWhgFznmDpsQcwwbb70Pf7i6pa68R/Kc51qgk6CJk8RuAO301AgNjDx2GiErSQtBNwMOD0mjqKYNhOeObxZHDV8tN0gYSQMU2JHPmLKAcjsiaiXv0PSce/F1B6Plfg934AF1K/4oJ1WEZyKia878Y+eIesRTBgJ0mqat73lpiA0sJCI90DdAcg+d4cJNFAlz+jqq3S4cA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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 7ae98d048590..1c53a58e6473 100644 --- a/mm/zsmalloc.c +++ b/mm/zsmalloc.c @@ -448,11 +448,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)); @@ -469,14 +464,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; @@ -767,16 +754,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); @@ -1950,13 +1927,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) { }