From patchwork Tue Aug 13 08:45:58 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: 13761561 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 C2282C52D7B for ; Tue, 13 Aug 2024 08:41:57 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 989D36B00AF; Tue, 13 Aug 2024 04:41:56 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 9107D6B00B1; Tue, 13 Aug 2024 04:41:56 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 78AA96B00B2; Tue, 13 Aug 2024 04:41:56 -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 5648A6B00AF for ; Tue, 13 Aug 2024 04:41:56 -0400 (EDT) Received: from smtpin16.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id 0DDA5806BE for ; Tue, 13 Aug 2024 08:41:56 +0000 (UTC) X-FDA: 82446579432.16.7B0CAC6 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf30.hostedemail.com (Postfix) with ESMTP id 65D8180012 for ; Tue, 13 Aug 2024 08:41:54 +0000 (UTC) Authentication-Results: imf30.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=Ng8rlXIL; spf=pass (imf30.hostedemail.com: domain of alexs@kernel.org designates 139.178.84.217 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=1723538443; 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=+l31cbHDmQQnmUIem/Tt9RW9I4dStO9PjAQ3mgIerxY=; b=M9ztxuIs0ILPwqpkKsXFH3/fmeSiqq9zNMbZPBqDafzzcxBIHIDOYtSvu7G8ckrzLYRPn9 3TQGzer9u67Vni3VeBwyGO6XTksdsrdWEKItkyjYmXwT8WYlIlRZBk1oVntDblk3nYjZjv i9l/W49urYIlePDOAmz87xl7d7a1FDM= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1723538443; a=rsa-sha256; cv=none; b=TKJMt+Y/86K96hXZraAOYtIprXpKaxfxoOiCVq/u9N85muogl9M9d8gOcyDrZfEXvDt0N2 RdD/Z5Y/mKWB2wzcnUaI3U4FGeybvxov2fIN67NI6an/ix+gBbrPsYzjIhzVyp4VrYisVj eQmQUOb4ugsuEQKeAmAxOw5OdMcmIRs= ARC-Authentication-Results: i=1; imf30.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=Ng8rlXIL; spf=pass (imf30.hostedemail.com: domain of alexs@kernel.org designates 139.178.84.217 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 dfw.source.kernel.org (Postfix) with ESMTP id 9D89B615A5; Tue, 13 Aug 2024 08:41:53 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 2AA27C4AF11; Tue, 13 Aug 2024 08:41:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1723538513; bh=Zf9TjxFFbO1e13JTKQj4PfBu8BRbAcD0oZRJJHyNdF8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Ng8rlXILf+oInKW3qAfGb1XtZwQc0EivxacQrteO99zmio5Op2vaSm9cKsH+s1glz hJ0rJrDKlc0/qijL9tJ01zDCu1RpN1zV2AEN9qj11s9Zx10q5OPDKnwo3duHiTiPNx vKSDhEysjCzTbVyFhzVB73nFhg0avnJsnwNCvZDzwTxe8BfEcu0mqXawP/+s19lgK1 phB0C4MjtZvYdtZ79SPDYXjiQjHUc068HvT8fcgQLniUWBeoVsyl6RpGZVF6TwGvSR hW3TDaMc3aKQLK+52Loibwk8NS3uYXPbVig0vN29xtUkM18bRFwOoBXm9j6PKwhxz4 /Hx8TbYDOrQnw== 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 v6 12/21] mm/zsmalloc: convert __free_zspage() to use zdsesc Date: Tue, 13 Aug 2024 16:45:58 +0800 Message-ID: <20240813084611.4122571-13-alexs@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240813084611.4122571-1-alexs@kernel.org> References: <20240813084611.4122571-1-alexs@kernel.org> MIME-Version: 1.0 X-Stat-Signature: pw1dj5g68s5px5c649re8dyd88fwmmh8 X-Rspamd-Queue-Id: 65D8180012 X-Rspam-User: X-Rspamd-Server: rspam08 X-HE-Tag: 1723538514-444826 X-HE-Meta: U2FsdGVkX18gWSm0F6AWs7dd4KaqOCDUs2s3sZzol8nE1HI1RPej7TqYd1qc7ArWqxgwdgrrWQlgHrMQkdgRsqzfm1R1h1fVDnvclpjDTtnAaejcElgSFurQFLi+k4AFqBNy1pSOMtHqmuAdXMEQJbv+H66XHN6O32U7PGj1yRDiKSUrZAbjZC0hk7J2IrcD4CaGCckEcEAO8p6b8QqFCMR3/5tKrbcKk6q6jQQAZbQ6XsutPgHH2ruscfHJaw+7xmareeVpyjXwdg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FDsOaQ/5GojqnwPY6b2No4LyOuZ3fZ 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 6c5dccbc9a60..7b3344c226a0 100644 --- a/mm/zsmalloc.c +++ b/mm/zsmalloc.c @@ -895,23 +895,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);