From patchwork Mon Sep 2 07:21:23 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: 13786836 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 147C6CD13CF for ; Mon, 2 Sep 2024 07:17:18 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 992B68D008F; Mon, 2 Sep 2024 03:17:17 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 93C718D002D; Mon, 2 Sep 2024 03:17:17 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 7DE248D008F; Mon, 2 Sep 2024 03:17:17 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id 5B7318D002D for ; Mon, 2 Sep 2024 03:17:17 -0400 (EDT) Received: from smtpin29.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id 2490BAB0C6 for ; Mon, 2 Sep 2024 07:17:17 +0000 (UTC) X-FDA: 82518942114.29.7225E39 Received: from nyc.source.kernel.org (nyc.source.kernel.org [147.75.193.91]) by imf07.hostedemail.com (Postfix) with ESMTP id 90F9C40004 for ; Mon, 2 Sep 2024 07:17:15 +0000 (UTC) Authentication-Results: imf07.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=QibvnDvI; dmarc=pass (policy=quarantine) header.from=kernel.org; spf=pass (imf07.hostedemail.com: domain of alexs@kernel.org designates 147.75.193.91 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=1725261331; 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=7lgdYI7ZuE3aDl7X8xuB7X/wsruUE99T8odE8I/cP7g=; b=zUrkSMKRkC6Ak+41j6Olfggd0PEdx+0kJQI8DMfpdIr89ORLEAnYcYitLW8PR8RRj1ervo oqvCUUrGnJD4GUwTyKvAuwdu2LIeXETHuT2wvAUgfQ/tI4acHvLIpxe0uV9YJKsVN08UU4 EM4eD6e6JvU8yIbMPMgu4FN6/WUGB6Y= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1725261331; a=rsa-sha256; cv=none; b=yYFM2A/aDh347JJqHVcsihbbMmS0D4ErHcFgt7a0SnYXaJi6lxFapEZtWCOQtuylvi0JFv 2cWP6zFyD3X8oGm8k1IhNmSjxhTvIz1+dZEiXudssf5XKJlZE/1CCk2CSM8/5LMlnsX/pt u06I/VK2Q5HWJ5uiG/XKlMPO0K1fJss= ARC-Authentication-Results: i=1; imf07.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=QibvnDvI; dmarc=pass (policy=quarantine) header.from=kernel.org; spf=pass (imf07.hostedemail.com: domain of alexs@kernel.org designates 147.75.193.91 as permitted sender) smtp.mailfrom=alexs@kernel.org Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by nyc.source.kernel.org (Postfix) with ESMTP id DFDB1A41732; Mon, 2 Sep 2024 07:17:07 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id BA1A4C4CEC4; Mon, 2 Sep 2024 07:17:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1725261434; bh=V2EFOKt+6az/uMmwc5vttTlHqgkkiN0OISIMWGbt/wQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=QibvnDvIwyvgilFEHEmKNY6ncRz9JForNYuHKUV/SasiGH8CLsNIj6aePH+ZrSs3z hUios/48n2louj3GjCRjC0Oawhx0jRpwnhG35lr8yyZApFk47hBbbHO6FkP2hMeGcl VnE8LOmNM1GyTTtZngN4I4ZEWpAG4b0JKq1MykngZEfVoGoJ8ucTz62ynqEVofLygl vd4Y/uW/yblxNd5EQIvkSlGfKW6yOalNJd/t4sSqw34G5Hamy4yimVdGIf54eP5o2e 4jkfeedFF91ZcBTI1Fn/R6LQhRNayDr4GqPp11hZJBPM/uFsHukJ3ZsF1e9RxkbWv3 vmzcC3wTHfggg== 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 v7 12/21] mm/zsmalloc: convert __free_zspage() to use zdsesc Date: Mon, 2 Sep 2024 15:21:23 +0800 Message-ID: <20240902072136.578720-13-alexs@kernel.org> X-Mailer: git-send-email 2.46.0 In-Reply-To: <20240902072136.578720-1-alexs@kernel.org> References: <20240902072136.578720-1-alexs@kernel.org> MIME-Version: 1.0 X-Rspamd-Server: rspam07 X-Rspamd-Queue-Id: 90F9C40004 X-Stat-Signature: kogkrnk7umnpsypbaemwu54apem8zwj1 X-Rspam-User: X-HE-Tag: 1725261435-132689 X-HE-Meta: U2FsdGVkX1/9bWyN1otU1VyMMfRMewxwCMWXxL1MIfKpUP6JvSKSxVhBsAzXH855fJ7Mnp6LO9Afkf/tXg54DHa9vaFsFg0yR2Ep2FnnA9HeUhyz70timKUWMgRiSuQi1Fck5ypXt7uwwir34dhEWNzWWA3wTUJIxPGXuDIR6JdxAG7dGwtJYAfq8TbhzTLIeKMSpRHw5aFvxzppLZ9vIC8hdSnoXC7pxLYMAOCOfNQO3edRzasF7pjAJxlt38PmjPQV5JI9cIl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kIf0ZkWyqQqFCKWZZA== 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 4b42d8517fcb..a1834d36ccfc 100644 --- a/mm/zpdesc.h +++ b/mm/zpdesc.h @@ -125,4 +125,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 b03bd7e07e98..5a8fd5fbc962 100644 --- a/mm/zsmalloc.c +++ b/mm/zsmalloc.c @@ -888,23 +888,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);