From patchwork Mon Jul 8 06:33:37 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: 13726204 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 A05ABC3DA45 for ; Mon, 8 Jul 2024 06:29:45 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 413AE6B00B3; Mon, 8 Jul 2024 02:29:44 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 3C6B66B00B4; Mon, 8 Jul 2024 02:29:44 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 0BBE06B00B5; Mon, 8 Jul 2024 02:29:44 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id E3A346B00B3 for ; Mon, 8 Jul 2024 02:29:43 -0400 (EDT) Received: from smtpin11.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id A76DD1C1D47 for ; Mon, 8 Jul 2024 06:29:43 +0000 (UTC) X-FDA: 82315609446.11.2081CBF Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf01.hostedemail.com (Postfix) with ESMTP id 126F34001B for ; Mon, 8 Jul 2024 06:29:41 +0000 (UTC) Authentication-Results: imf01.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=PLZIVCAc; spf=pass (imf01.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=1720420167; 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=QvNipKPteTSiibEbCGzU4M4s8UfTiRuyWVvwWM9yy7c=; b=bzK39HlnJJxL6qEkYpoV3Pa1ULqWaBxQet4dakRsWkqIY2bHFKaELJ6oGwIDz4Pk57mMWl OcdvzeTQFI2on0l2LNOM8ce8A8scOuUxNnqXtzSUF0Bkg5f2ZYrifphyz6WzwrAb8DJNam PG2mC4tk/+Fbx7YTfqFtTI5WUXxk/Kg= ARC-Authentication-Results: i=1; imf01.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=PLZIVCAc; spf=pass (imf01.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-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1720420167; a=rsa-sha256; cv=none; b=kqik0hG1WVmvoW/g01MbIt80KOAdUbcf33TCHsTykmeb69rphNjruqeY0uBknqQjlyHSW0 bQ1hGcIe+jwmdJ4gjFtV0cE/si1eJWTRicaKA9VkRxHaxVqWkWHk2vmGIRRdmSdA8RbP7C TzaUZawNwbEeYxG8ztsjhDkv2MmZYZA= Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id 5387360AD9; Mon, 8 Jul 2024 06:29:41 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id E712BC4AF0C; Mon, 8 Jul 2024 06:29:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1720420181; bh=TaGzviLe6NGcMCDjFOvP7sDnEJpuSU1XTpwZAcepYDo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=PLZIVCAcwi0LP6n9+0RZBSXSigP2dfRTuOADXKXuWbgBCN0En57eYC5RSgs/1KtfS DVIzAun5YHyUuQoBUGzwuDYGBBdNZwNvpM+rRFJ6VWSjPUG5CpnTMp5A1yDpyc7vD2 WP+uhvZep47BARC5c9jpTlVqf0y7Kz7D+Yq3L4MDQ86P1RuxQXIXTqAIQcgXDvnzwg UtAPWYZA9ek8HVwniRE5UU8dKYGfnTrePnKl8DCQDiV1Udgp7vk+n46IaoL/PkmIeF Z5YaezCR7ig33vTKcfrPcYHW37YL2UrMeTFdY3VPVBc3XwPwXe7fFLu9rM4tcZy960 NbRxZc64HmFyA== 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 v3 16/20] mm/zsmalloc: convert SetZsPageMovable and remove unused funcs Date: Mon, 8 Jul 2024 14:33:37 +0800 Message-ID: <20240708063344.1096626-17-alexs@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240708063344.1096626-1-alexs@kernel.org> References: <20240708063344.1096626-1-alexs@kernel.org> MIME-Version: 1.0 X-Rspamd-Server: rspam11 X-Rspamd-Queue-Id: 126F34001B X-Stat-Signature: 4fx3okot4bumodxj9hhf5e8nugs4zpub X-Rspam-User: X-HE-Tag: 1720420181-451242 X-HE-Meta: U2FsdGVkX1/KSKyph2SDXxUfqiI/gs2bvnhezQyBxkzTEB3bDYDAqEKkZvOzEk2s2BhJZVUxMNv6NP1QHmUpwkDuJky+PwejaQVzFV9LNakZW8h70t+gI8PooPKu274y/H2tK8EpXgojFL2hFO6CxnhLQV5B/yOy/icd4gWPkWO+Z7Qy4faEvEnYhwAwIlj352R7OBGISkE4jhcbYCwC3R2gaaRQ/yV/4T4l0z+Z6CLijbo57f09smC+eNG1KDukmC+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osity: 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 (Tencent) 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 (Tencent) --- 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) { }