From patchwork Mon Jul 29 11:25:24 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: 13744735 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 8AF6BC3DA61 for ; Mon, 29 Jul 2024 11:21:03 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 152056B00A9; Mon, 29 Jul 2024 07:21:03 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 1026C6B00AA; Mon, 29 Jul 2024 07:21:03 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id EE4276B00AB; Mon, 29 Jul 2024 07:21:02 -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 CEB616B00A9 for ; Mon, 29 Jul 2024 07:21:02 -0400 (EDT) Received: from smtpin30.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id 81FF9402A3 for ; Mon, 29 Jul 2024 11:21:02 +0000 (UTC) X-FDA: 82392548364.30.1BCA70A Received: from sin.source.kernel.org (sin.source.kernel.org [145.40.73.55]) by imf18.hostedemail.com (Postfix) with ESMTP id 46C711C0028 for ; Mon, 29 Jul 2024 11:20:59 +0000 (UTC) Authentication-Results: imf18.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=Q6Z5z02c; dmarc=pass (policy=none) header.from=kernel.org; spf=pass (imf18.hostedemail.com: domain of alexs@kernel.org designates 145.40.73.55 as permitted sender) smtp.mailfrom=alexs@kernel.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1722252057; a=rsa-sha256; cv=none; b=KpKEngOQBOY6om8t5HYFY6R0ECMk9W1nwwRtnzsI3Epg9juw8XRz7xvpB2OO9pCuWYt2gd uNhPT1aiRu0XjUdgdsLyh1sibGg3erLXrbdlbpFQ4B8TnfFtHUiibYtsaCN6gHmc+YOulR tQhN3mM7I7n1tjyk4I4WqD4inZFO/w0= ARC-Authentication-Results: i=1; imf18.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=Q6Z5z02c; dmarc=pass (policy=none) header.from=kernel.org; spf=pass (imf18.hostedemail.com: domain of alexs@kernel.org designates 145.40.73.55 as permitted sender) smtp.mailfrom=alexs@kernel.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1722252057; 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=VhKKPt1PwGZfDksxUoF8M7UxAWykfvuSsOiFdpS2s/c=; b=VNURcaf3Q23E2ajAOU57D1QSkISLikq9fuSeaopIwcmp3E8zQ+oJTPRvjyeoYm1xf5UpnN PXrIOqMRv/0iI+N9PuD47f2cRutxfKR4rBXC5jAjeRoM4ciWiuEEVFIR7OKnXi4Xv7X0tk RoDj8jO+c2v5lIPlA3Iz/H65mDKp004= Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by sin.source.kernel.org (Postfix) with ESMTP id A3017CE0ABD; Mon, 29 Jul 2024 11:20:57 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 278FFC32786; Mon, 29 Jul 2024 11:20:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1722252056; bh=/reSYv2I3LBpywbB8eW2CIXO42cQ1NynjFn2dBL53LI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Q6Z5z02cPsiz04Im8TmiPZ0LRtDPvb7j/Z7gsVKUC+vY0bQTeAukeCpSUVaodx8qH 7CIS0LLlHtEwTCDlK7Odzu8VbidIbZIBvA+q3YjUryx+a4UHVnii/qXAjvSBqdjqvR 4tD5ERJ0Pywjn30AShewyQPZTcxGolFIewnVmUTha0nTO+e+wgxNPbfao/L22WkvZ1 QIRFfedl+/ckWEC0oJ4OGBcsN0u7rvH6OsXtffWwPRJe4Y1RQMf034J5/jRZhT06aC Q6nd6bZ+aSHBwOqbIJ778lEu/5fNxKYZs9Xzu4YeC2QTW6M27X8mr9eUEenpkCqCLq YG69szOAWaPKw== 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 v4 12/22] mm/zsmalloc: convert __free_zspage() to use zdsesc Date: Mon, 29 Jul 2024 19:25:24 +0800 Message-ID: <20240729112534.3416707-13-alexs@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240729112534.3416707-1-alexs@kernel.org> References: <20240729112534.3416707-1-alexs@kernel.org> MIME-Version: 1.0 X-Rspam-User: X-Rspamd-Queue-Id: 46C711C0028 X-Rspamd-Server: rspam01 X-Stat-Signature: b4x1ohxghipihyez65915hdtphje1ct4 X-HE-Tag: 1722252059-882788 X-HE-Meta: U2FsdGVkX18VZfbYkGnV6wUohw6/5WXF3kzTVrZYqKAesoQP1PSa1Qu97qrxPaQYYTCczcfaxxmHj8BI00xoHPY5ijb1vV5XiOHkNO6Bkttm0OID99N8cFm9OcP3jo24osS5MhHK+ktgjC/Ly0ax19oHh6m7J6k7j+ZaaiR07eTw3+1OOjSPaebLXSv2ElWp27R9m8bh5JOA+Qn/gPx3hErZyrmbVrFozbC3J70YJtLLb37OMLccsh+qvRsgPzdne+RHrDO+2LMUln0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Cs5lb7YcjaZw== 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: Hyeonggon Yoo <42.hyeyoo@gmail.com> Introduce zpdesc_is_locked() and convert __free_zspage() to use zpdesc. Signed-off-by: Hyeonggon Yoo <42.hyeyoo@gmail.com> Signed-off-by: Alex Shi --- mm/zpdesc.h | 4 ++++ mm/zsmalloc.c | 20 ++++++++++---------- 2 files changed, 14 insertions(+), 10 deletions(-) diff --git a/mm/zpdesc.h b/mm/zpdesc.h index ad04c8337cae..72c8c072b4c8 100644 --- a/mm/zpdesc.h +++ b/mm/zpdesc.h @@ -119,4 +119,8 @@ static inline struct zone *zpdesc_zone(struct zpdesc *zpdesc) return page_zone(zpdesc_page(zpdesc)); } +static inline bool zpdesc_is_locked(struct zpdesc *zpdesc) +{ + return PageLocked(zpdesc_page(zpdesc)); +} #endif diff --git a/mm/zsmalloc.c b/mm/zsmalloc.c index 6d1971836391..68fdea7b6e0d 100644 --- a/mm/zsmalloc.c +++ b/mm/zsmalloc.c @@ -901,23 +901,23 @@ static int trylock_zspage(struct zspage *zspage) static void __free_zspage(struct zs_pool *pool, struct size_class *class, struct zspage *zspage) { - struct page *page, *next; + struct zpdesc *zpdesc, *next; assert_spin_locked(&class->lock); VM_BUG_ON(get_zspage_inuse(zspage)); VM_BUG_ON(zspage->fullness != ZS_INUSE_RATIO_0); - next = page = get_first_page(zspage); + next = zpdesc = get_first_zpdesc(zspage); do { - VM_BUG_ON_PAGE(!PageLocked(page), page); - next = get_next_page(page); - reset_zpdesc(page_zpdesc(page)); - unlock_page(page); - dec_zone_page_state(page, NR_ZSPAGES); - put_page(page); - page = next; - } while (page != NULL); + VM_BUG_ON_PAGE(!zpdesc_is_locked(zpdesc), zpdesc_page(zpdesc)); + next = get_next_zpdesc(zpdesc); + reset_zpdesc(zpdesc); + zpdesc_unlock(zpdesc); + zpdesc_dec_zone_page_state(zpdesc); + zpdesc_put(zpdesc); + zpdesc = next; + } while (zpdesc != NULL); cache_free_zspage(pool, zspage);