From patchwork Wed Jul 3 04:06:02 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: 13721082 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 90220C31D97 for ; Wed, 3 Jul 2024 04:01:58 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 216B86B00A4; Wed, 3 Jul 2024 00:01:58 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 19A906B00A5; Wed, 3 Jul 2024 00:01:58 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id EB90F6B00A6; Wed, 3 Jul 2024 00:01:57 -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 C43F96B00A4 for ; Wed, 3 Jul 2024 00:01:57 -0400 (EDT) Received: from smtpin14.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id 7828640786 for ; Wed, 3 Jul 2024 04:01:57 +0000 (UTC) X-FDA: 82297093074.14.61073C0 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf24.hostedemail.com (Postfix) with ESMTP id D3563180016 for ; Wed, 3 Jul 2024 04:01:55 +0000 (UTC) Authentication-Results: imf24.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=f1t7hQXJ; dmarc=pass (policy=none) header.from=kernel.org; spf=pass (imf24.hostedemail.com: domain of alexs@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=alexs@kernel.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1719979296; a=rsa-sha256; cv=none; b=vZf1Y8JCRbGtwEY4Itkt2mSS2pBXRtr75bZGpFbspVVgogf5x5ohFQf8Zt9LET/oAcRtT1 FYwp5zYpkt+NnCnknCE8k81m75c52kvdS9Sv4Jp97vfnWjGXUaKJPLzqNED8ZwBw0HhfHX sxoaHSRPUZsHqjXGzXTY2caym/H/4Sw= ARC-Authentication-Results: i=1; imf24.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=f1t7hQXJ; dmarc=pass (policy=none) header.from=kernel.org; spf=pass (imf24.hostedemail.com: domain of alexs@kernel.org designates 139.178.84.217 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=1719979296; 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=KXF/dnRNKSbeaumpIz17Eg4SmWxMyzprpVBUw6ZMybs=; b=CD1+ZX7MtYbCDnej1euVKx/IhhNCEZwi+qxio7tNjqfVgQ+pI1PhpZXOI9XGWWaFq+uk9Z BXuogXIh0Cx6LuxFx50dF8UrLpZGQTW2YOlb1QNTgMlgZup3Qt9F28oUgDkhcNpSPlV+Vl HPNV2EHz8+yhTmCv2GaL4ojcR6L70J0= Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id 18900620E8; Wed, 3 Jul 2024 04:01:55 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 7B8A6C32781; Wed, 3 Jul 2024 04:01:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1719979314; bh=rKWZuiJgMM3PFhIFbKbki7RwNRU1BYQ1UAI5bUa3ql8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=f1t7hQXJQvhCEgu9b1n3nE1YlFOxjEC/c/pUUWyfXG22Tw8QUwfCTUD9VZwL94fSY jv3/8d/eHpn1e+fQuoItWy8ZyrfsKIGYgO1xWlKssWAy9Twg9jtJDGp5cvknh2HJWd W5YnUonQE4WtBpZK6/z/Pci54CDg8ZV0li79TV2nbsIfnaWFZcSmGtqrgFhEgf8bOO OgWHm/ztVeQ56/PIb+6/rkbf8o6xP5OOTqlSNjwL6lQI1m8k5SNG5ocMCkzRy7TSwM Nqt/bERDQCtXlJL3/j3SpvyzKvCox2IVzTHeBDk2M3v70gQMtckTQ2XRIaKeFXX8LZ FKT2rzHyQimFQ== 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 v2 12/20] mm/zsmalloc: convert __free_zspage() to use zdsesc Date: Wed, 3 Jul 2024 12:06:02 +0800 Message-ID: <20240703040613.681396-13-alexs@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240703040613.681396-1-alexs@kernel.org> References: <20240703040613.681396-1-alexs@kernel.org> MIME-Version: 1.0 X-Rspamd-Server: rspam12 X-Rspamd-Queue-Id: D3563180016 X-Stat-Signature: fs6jtoffiprbxowur4st8pnf6fop3wqw X-Rspam-User: X-HE-Tag: 1719979315-241829 X-HE-Meta: U2FsdGVkX18r7uxAFAILwtQYSbzk06DwBIFvxlWiIHVkn91ByUs8FTtkv8DoVLGswhztMl2kDkdH8TkAtTNeuxE820ZIe4i1XrisXXOyIQKMrvAHYg4xclwnQgpELH4lAX+OeERh305qNuyTrxE/FlrI5Z6ETcMcWWbUsnvdJfCiR1g8HB2NIxpFS3ZBbNcv+/+ikYrHfwcL580XzLZWHpDmuNyVRwyWxz0Txu4oxJV5m9Cfjg4zPWBNqjVUGrK7kdS1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rgmNu6hL+FXrmZHYieXt3/ucx44Qik3pC3O2P94TX8JTsnUH0CMGn 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 61d7ba0c626e..6de3c5d095bd 100644 --- a/mm/zpdesc.h +++ b/mm/zpdesc.h @@ -117,4 +117,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);