From patchwork Fri Jun 28 03:11:31 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: 13715402 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 80EF6C30653 for ; Fri, 28 Jun 2024 03:07:54 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 09C5C6B00B7; Thu, 27 Jun 2024 23:07:54 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 024566B00B8; Thu, 27 Jun 2024 23:07:53 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id DB7A96B00B9; Thu, 27 Jun 2024 23:07:53 -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 BE3B46B00B7 for ; Thu, 27 Jun 2024 23:07:53 -0400 (EDT) Received: from smtpin07.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id 6D9D9815D4 for ; Fri, 28 Jun 2024 03:07:53 +0000 (UTC) X-FDA: 82278812826.07.BD7E604 Received: from sin.source.kernel.org (sin.source.kernel.org [145.40.73.55]) by imf02.hostedemail.com (Postfix) with ESMTP id 6770380011 for ; Fri, 28 Jun 2024 03:07:50 +0000 (UTC) Authentication-Results: imf02.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=cnRaB13D; spf=pass (imf02.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=1719544053; 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=GkL7q3elqWvB35+rnNqWKh98ckKaqopv23PrO3Uu+68=; b=h/s56s8Sm0IefSpC6s97Xw2aMio/S08Y+1Qm5VbXDFy0o/E1X8FFX855LBA2g0GQ3hbIHN WyfONFRZVdQg0+0GKQ5d4FHFLQNhy9idqJUOHLq83Lh2QW33u9kqqKVYYopVxz/yLVMTTL B2OT7Wl/EUV7mxB8H0qsFebRiP+tl2o= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1719544053; a=rsa-sha256; cv=none; b=4qX1eQoUN+qh5kYPcpoYDDyVqXo1sf9bNCBmgaOnMAjB1I+3Nq+Pthptp/HR5QJ479ioiV c+qQUTLXLHJvpnXWLt//4vrkrIWeA62Bvr4d7N8/JR3wcrm5QBPp7mFmG7X5ycw6ReRu1o Xbxka+7HCXCg0/Fr/+TEctJn9kjwrVU= ARC-Authentication-Results: i=1; imf02.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=cnRaB13D; spf=pass (imf02.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 Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by sin.source.kernel.org (Postfix) with ESMTP id 720B0CE38E7; Fri, 28 Jun 2024 03:07:48 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 41863C116B1; Fri, 28 Jun 2024 03:07:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1719544068; bh=kldqwAh9cZgKWc/qnQGuGYAkpd0utSr37gCIdaPuGYU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=cnRaB13DEdjhJTai8RSwypjifYR0A/D24GZqzbB/taIZOGJfx5ukrATQw9p8OyWzM iAAxQfNiplB4VzN0rtbVW16IMBdZ/RsWZzSYGoCNXE7P0FcRAh0awod5grcab4giG/ H9STRRKZnmZoXd6hwu7YPDdhTGj85zNkM/x+g2gmKq3nr/+1Yqa5SxXdBusHA0/gHA gavi3MwMdlDst2QYjmWdcNLkXxzrNsfj+AkN1SOSbDG0fQAH2wr8szA84Zub72pyP6 UeXApiZ2X+rmvh2mr8QAuT5tuyHFj2yDnC3+V4z8vxOPqUv+lI8tAvJlryj3mSk/gL rH841R6zzOW+w== 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 Cc: Alex Shi Subject: [PATCH 16/20] mm/zsmalloc: convert SetZsPageMovable and remove unused funcs Date: Fri, 28 Jun 2024 11:11:31 +0800 Message-ID: <20240628031138.429622-17-alexs@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240628031138.429622-1-alexs@kernel.org> References: <20240628031138.429622-1-alexs@kernel.org> MIME-Version: 1.0 X-Stat-Signature: aobchqkbztp37zfuk34wibe5qt6h3se1 X-Rspamd-Queue-Id: 6770380011 X-Rspam-User: X-Rspamd-Server: rspam08 X-HE-Tag: 1719544070-452116 X-HE-Meta: U2FsdGVkX19UGqbm/uFfKA96PmWwZYppeLXfS2qVFchSZHfGXeNai3YxbYIhG+p8UpvWEv100ncVVqHbHvXJXIqiH5LwoXvgw6BvItdS7NDUvykiWiOJ9vz5feZTRDzfXZ60pMTAGIPuruQDGAvTxtM8tf4I806k6hDVb+iEEDoOdrmwbJn2Hhc3fuGhoxwIB+q/SfIUUMCewZUwos61/DHfdB7DOKIigAUQ1DEqHUQ6gsGZuaAkMcrwF9ZMs3YsD+IVc2pJCoyeAvHB4qxhOCmRdAHdefICvkgcmmZXYVLlyGPOViQESBCeNSmTA7iUy1Gv4cL3T1yaF1PjRiQfgZmKZXMmgZCLrfF+rejZdG6Zk4BR67Dx4ktT5lTtBB/gzYTD6s6Z+/1ilfT7bvGnJK80ml5rjpZ5c0NkWg/TktufxomZH2E+V20WckyxZNQuXmG982elxyFgCRPd3Grb3GUjlNU7X7sdqUCR917nKW0ES11A0rHYFzpLiH7WdZ9ZsESMtAhPhgnJwJe3TmHqYAP8lkF9Kg4aL7P++dBKYqCQ/f/3wEweMLUvZmKbEpeJhUJWn9mB/7lpboOSsWQaoEE9CKXDU27tekSTGMDvuSJzZp4lblHis4wpxajuBmlBZDi8bbIGHW6NE4xZhAHuMXu6wP+S6iIFHY9SeMWAYRJHxikxy4Q8ELRDQg5+rqRWJaM5OqVxb83RI+PwYllAiH9sSvuSKvi8inZ3Kn90Q8Iymy9avBL8K0ss70obMOPGpfJwUpVy2fxKXaoBU6TgcOms1vN3nYCVhGU11xnKAtytSnMVzH0jTNE2PWuVdyueuUzjAt6UFIU8QKoijpO5JptZ+ONRdSHYq8cNTdJlxBf96izHeZ1lbRP9RMTXt1+BBYkS0Cb0eMTS3kvXdwarDKWEEHS4b/TGaxopyFZ5th59BoQg3jSjNuugcxUHhGcy8twrnq86GtNWIrYgDiF uqUWgWQu ec/64Z+5NMwAJNP72pJauuD6Xrmj1ijehDMXojquUZcUJP8rRLh54o7x8HQirkSsicYzw+oSudzvjWWppFn8LoQiTM7L0Lpt3lXf/G6FTx9pe538tO1dMjfDkDUfgXovPJWUbkLorOSZDcLbXvVq8kiTkvVbu8US2Zl097723ROpMtuypNjz51qtZSzsL/E/WKwOX/zHxE6qas17D2KPCHF/ldNo1YX48PxnlKAjFPJppB4kGC4u0w0oZa1OzgJBSZQ5r+D3uhlyUHYM9IzqqLWJvThej1zMiDnboPWXIHES1/58c88UnfRxMjIfESnGX/kGtAXVLpt9EZ7E= X-Bogosity: 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 c136124adb10..951292dbcae4 100644 --- a/mm/zsmalloc.c +++ b/mm/zsmalloc.c @@ -470,11 +470,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)); @@ -491,14 +486,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; @@ -789,16 +776,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); @@ -1974,13 +1951,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) { }