From patchwork Wed Jul 3 04:06:06 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: 13721086 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 33956C30653 for ; Wed, 3 Jul 2024 04:02:14 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id AEADC6B00AC; Wed, 3 Jul 2024 00:02:13 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id A71A96B00AD; Wed, 3 Jul 2024 00:02:13 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 8C4C56B00AE; Wed, 3 Jul 2024 00:02:13 -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 6A8A66B00AC for ; Wed, 3 Jul 2024 00:02:13 -0400 (EDT) Received: from smtpin11.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id 2FBE4A072E for ; Wed, 3 Jul 2024 04:02:13 +0000 (UTC) X-FDA: 82297093746.11.ECA0731 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf17.hostedemail.com (Postfix) with ESMTP id 92B8F40018 for ; Wed, 3 Jul 2024 04:02:11 +0000 (UTC) Authentication-Results: imf17.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=iPsY0Brd; spf=pass (imf17.hostedemail.com: domain of alexs@kernel.org designates 139.178.84.217 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=1719979308; 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=q5lqyxu+OkDG6O8XL5UL3n8sGEbM/d5VbMclRj5mWANjiTnvcEXwrfw8JfG1Gi2fMu9Iot XYTXFW75FGC4FjQTD8mA9OhcYuuMkCftkVA0HGFplV7ds91uPZ1sK8V8IlXUEX6zjpU+dB JfqPLJ1w+0aNgICvYsSfDzZrOUagYqE= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1719979308; a=rsa-sha256; cv=none; b=vWkIkB6iPJF9vzlhlAtdQ51URki4ZMNMKgd0fJRjwX7JzWCvgTv2UOoHxQPNKgTeC5vpp3 hGApKV5g42XdPRmvmgEnZXYMrk2qR3xZVyrgC42lxLhmqkihixHvPwS/TMUQMJ/Q7vtYsU 2nTqqulgz+b21xZ4UAPPaWRNcV2ov2Q= ARC-Authentication-Results: i=1; imf17.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=iPsY0Brd; spf=pass (imf17.hostedemail.com: domain of alexs@kernel.org designates 139.178.84.217 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 dfw.source.kernel.org (Postfix) with ESMTP id BE3A0620ED; Wed, 3 Jul 2024 04:02:10 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 2E17BC4AF0A; Wed, 3 Jul 2024 04:02:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1719979330; bh=uH0rZNnpHFMljEmSyKQuSSlLph2dNP0xTWvseJvNDaY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=iPsY0Brd5KWtyIOk5fV/0otAMuF46d4KG5B5pddwxSDNlJ1E0cbaAnUHd208Zws0d 9GHVhVF88u6OFKosO7B9jELp3CHwrLGdn4h4C4xb34PtLyYwVbQV+IsjoAXADnV9j9 ZffY97ScQAwMreWa3NmKgcpzng+WKLp1IgAjr1hdxnh4yioFj0tdWX3klI0o5/wT3s XSD0p939k4/5df5GCsmd/HriGXYfyFLk0zojxelaHRW2zZ1egLtRTBjYri2bNAjJLG 3ywNEDpuwtzOPd+oo+1gxRI63Ppyldz7y+1CeuJAmASlFlF6pBtMSPY1r+x5RnQZg2 zkf3T4L1vs6PA== 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 v2 16/20] mm/zsmalloc: convert SetZsPageMovable and remove unused funcs Date: Wed, 3 Jul 2024 12:06:06 +0800 Message-ID: <20240703040613.681396-17-alexs@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240703040613.681396-1-alexs@kernel.org> References: <20240703040613.681396-1-alexs@kernel.org> MIME-Version: 1.0 X-Stat-Signature: bi8djptgndnqnx9agnzj4mqryghy1ybx X-Rspamd-Queue-Id: 92B8F40018 X-Rspam-User: X-Rspamd-Server: rspam08 X-HE-Tag: 1719979331-566427 X-HE-Meta: U2FsdGVkX188cvDEv+UvosmrJS3w6DtLMMmmbKv8z2iyKMGHugNG8WLg/IkEa/pu9jhT52LcaLcyfAHKPRwC2XqYrx/zJSpZSusHSFB3hk6W6WryoCSKPrPYhwYObsYr7WOY63XdcF3FH7kU1WtNSyafy+hzBd/YWVO25MpZCIBu8qsigwcZnQtyvSiY4TjYZ6zgAHjgUJrZfRjEeubeytx8tC69qWW+vRDdk580PlgqM28bge3xWEyglb2xG6eaxvwyaKWlV8Y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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) { }