From patchwork Thu Dec 5 17:49:53 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Matthew Wilcox (Oracle)" X-Patchwork-Id: 13895939 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 BF8D6E77170 for ; Thu, 5 Dec 2024 18:49:14 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 1D7CE6B0159; Thu, 5 Dec 2024 13:49:14 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 186986B015A; Thu, 5 Dec 2024 13:49:14 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 04E936B0174; Thu, 5 Dec 2024 13:49:14 -0500 (EST) 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 DB42B6B0159 for ; Thu, 5 Dec 2024 13:49:13 -0500 (EST) Received: from smtpin11.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id 45097426B4 for ; Thu, 5 Dec 2024 18:49:13 +0000 (UTC) X-FDA: 82861792650.11.29996D7 Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) by imf27.hostedemail.com (Postfix) with ESMTP id 4679240005 for ; Thu, 5 Dec 2024 18:48:52 +0000 (UTC) Authentication-Results: imf27.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=juIPpL6F; spf=none (imf27.hostedemail.com: domain of willy@infradead.org has no SPF policy when checking 90.155.50.34) smtp.mailfrom=willy@infradead.org; dmarc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1733424535; 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=+0KpkIbIdWpRoLKWbvLyo2kOfKZAUmAJeeYsmD3sRK0=; b=kw91/QL7xKKBg5akLjrNErVbGfl3vMKab8QmFbp+non5paeY8cnfHhBYgLOt4G9vdLFE1o xlfiPloCDf6nxBKrDuygoEi79TDmpLN/Wdo16RH406tGyULZLlftpl5QdJ7ld4tYVlqNVC pXFwQQEOyUfadGjFO9SK1Y3VA/GWeg8= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1733424535; a=rsa-sha256; cv=none; b=0lIUWWCKD/eHOJCFiU+Cm+IADHZk5dL98xywRnBy80FoqTm0znziiz98pe3qw/xgYXi8b4 5XjrIHNiePeCQHm1ViM/I4wbNUaecuDJAFti/3Ddc4XtSiRKT/5Zbwmkg8Yt6mCWa2Nky9 LJ9TrgJ+9YmA5TaI/KWatKnNsWghu44= ARC-Authentication-Results: i=1; imf27.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=juIPpL6F; spf=none (imf27.hostedemail.com: domain of willy@infradead.org has no SPF policy when checking 90.155.50.34) smtp.mailfrom=willy@infradead.org; dmarc=none DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=Content-Transfer-Encoding:MIME-Version: References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From:Sender:Reply-To: Content-Type:Content-ID:Content-Description; bh=+0KpkIbIdWpRoLKWbvLyo2kOfKZAUmAJeeYsmD3sRK0=; b=juIPpL6FcQ2xiieMijXu7M+ceA jgfy68Re2EzSIkjZRm362NZ79vqg/6NGp7HhOuJ2xzVMgxj3GE3cF7QVY/Pi7537msf2Es/aJVPIX +RLW8iSQgvBzf+Dkvy7UrLB83QzloseQXh5hSw4vlDJyzeY+AskUYupf1Sn+TvaaMUqMm75gkCq4X Q22lcwpyyc50u4Ga5IEavMpFupujSB/fCKJ1DNY5O8BTol18qyEWuGlNHTdHPVQmgshu+0Kcc/e+n 9z7AMH67u7Cua+7kfwbbuDQO8CPfctThshPm9ZVMZXMDFjIIrvNj7fwYqIGzVkSgKKDgD3Y6/ImjF 18lBuadQ==; Received: from willy by casper.infradead.org with local (Exim 4.98 #2 (Red Hat Linux)) id 1tJFzI-0000000DN8z-0cBP; Thu, 05 Dec 2024 17:50:04 +0000 From: "Matthew Wilcox (Oracle)" To: Minchan Kim , Sergey Senozhatsky Cc: Alex Shi , linux-mm@kvack.org, Hyeonggon Yoo <42.hyeyoo@gmail.com> Subject: [PATCH v8 16/21] mm/zsmalloc: convert SetZsPageMovable and remove unused funcs Date: Thu, 5 Dec 2024 17:49:53 +0000 Message-ID: <20241205175000.3187069-17-willy@infradead.org> X-Mailer: git-send-email 2.47.0 In-Reply-To: <20241205175000.3187069-1-willy@infradead.org> References: <20241205175000.3187069-1-willy@infradead.org> MIME-Version: 1.0 X-Rspamd-Queue-Id: 4679240005 X-Rspam-User: X-Rspamd-Server: rspam07 X-Stat-Signature: 9nzhgsjrrsyzm3eahzcfkd8j6jbw4hti X-HE-Tag: 1733424532-843413 X-HE-Meta: U2FsdGVkX191alRBwWIa/RLyqsT9o4OsgDpYuRZiQvb9uQ219G4sVrQivS2GblSYNx1D7Cz5NE8r8szzAt+k66owFSK9rxwCcef/P/8DcAu8wV/asn1DQsW922BdZ09wePBTlmULJPu0eBrfeo1A/pLsL/UKs321F5iVbju56/K1KWdc10OJs3GJTc7QY7h+rAhLrkwUQrB+/IkQd0kU3128b4Taq5+URk0cioNfc/p8vMDWv+yN+T0lyUAEKcUL07OPChd7TSxi+Lb45bZyNvzyl/YCGDI+HAKljBAwg/PxZHJVBR/htmjVfBBd/8QfwytGGgk2YSWnMQRcar9smf2Vrj3RyPz8d2l0MMTVTbQTZjN+F6GpJrQ6SKB5Qtpu6pqN0FjZQsUS1suhEpG+u5VttjYwO0vq8nRxR40IuzD1+1D4xLho4nvMu4nC4d8IspIOSPfplhD3WGbonCsSbbskiTjNKTGSLn5YgeL8Qx8K12dj5eGdpgGPyrfOs6emlkwc75+yB43EJ+LLzqH3mivlgAdJt9ppmoxndHSauYWlYWoicGIY30KhLqOVw0RkMxTkgSmSMCAtbsF+LpVfB83KT2W04AIgFMDm2YuBsZ+4U0cf1gFm1tASjq9q3l30sj/ZijzDYHANSK0YzNAbqddEje5bNT2NyUGNwSK2BK3PHhj9XeIPkqC5and1mRSwWo8EEOPhUZPIrtqEptZVQVPH/sd7FrSKPLr3TcXQS0gSj4a4YjYPs0Vv/ePTgD7bbvcTz1GvapLvHwZ4UoCsWvoYaaev4ZwGHovi6ZnsyP26n9wtB6xD8uWZhzfqJesESL8L9q231SlVZ8oNTrpZ8RyQwohjP5RjZP0upHC2VEHdyha+mzYIFSpnh8szQKOIYQjHnIqzMz+FwQTrJpniLYu8NIKnsE5IwiScnY9C7gZKHQMFfVfHS3s0eHaYQxORuH3bpWwEYEADzTKkbN/ sm0ONyXY ytP/epMqVlJjS2/KWVmvSmuiUF7SZAGeKsNV4JR6Ijev5mnmcHRtVxpLa9HvaAyjTCPKJk+xPfcGQxkDVx98U5RUQegs+v4PL3tY+INvfr1okzy8ULNeONDGF0/PBzLjxRYHreFMsZLgWzMDqzbOkq1dptk3ZgnxBZMxoKFw8QsIhGJ+tF9bq0+MXsPCTIGjPYJ22rj/vavlSZsMh8WRulBU0Co/8EC686gLrb+6JKrXdFME3vQzmggeGQKcPBEBXjpeW/WXZxcj+X3gqG7noezUBjNaguMPBYW9MhQz1QHcy6LM= 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 bf1db07c58cf..16e3d6705563 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 inline bool 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; @@ -783,16 +770,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); @@ -1955,13 +1932,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) { }