From patchwork Mon Jul 8 06:33:33 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: 13726200 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 59A77C3271E for ; Mon, 8 Jul 2024 06:29:32 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id E74386B00AC; Mon, 8 Jul 2024 02:29:31 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id E22A46B00AD; Mon, 8 Jul 2024 02:29:31 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id CEBC16B00AE; Mon, 8 Jul 2024 02:29:31 -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 AFBEC6B00AC for ; Mon, 8 Jul 2024 02:29:31 -0400 (EDT) Received: from smtpin27.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id 536E014111B for ; Mon, 8 Jul 2024 06:29:31 +0000 (UTC) X-FDA: 82315608942.27.9523F86 Received: from sin.source.kernel.org (sin.source.kernel.org [145.40.73.55]) by imf08.hostedemail.com (Postfix) with ESMTP id 53D59160002 for ; Mon, 8 Jul 2024 06:29:28 +0000 (UTC) Authentication-Results: imf08.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=RiUIttnE; dmarc=pass (policy=none) header.from=kernel.org; spf=pass (imf08.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=1720420137; 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=V6ERS0tQTmFArjz0DBTTuSqJLGZAXlVcoV29bs+X2Eg=; b=PjbziEcj4WUuPFpngcaZPQwhCVmTmGomxYdkTYs6E/0/T+4AaXp0d1dZPBYAmqqUmbAMQy Ws1Wx3rMEFOG/GozCpP1tZrzu712gyobTGdeoXKqnkmdHNQlHIFphOR1SFreb4EdUYOo3w 9dhQUTLJt81i2NBpdgwhsFdbqkhYWuw= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1720420137; a=rsa-sha256; cv=none; b=tJpmn1sIyuZeN9mLqC7ay+0S1Xo0zXFyMARXyqOIv7KTVz+IIKQt5cpTxMRiGcZ+zp301s jaZ9u7lcxpE8qPUifhES0UQ3n084YtHd6NSWAhsLdcgK8xICfJWd9qW113z0UdR0S43Feg yIKB3Rfj8cO3gz2Kijz+6RiQrCVYrAM= ARC-Authentication-Results: i=1; imf08.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=RiUIttnE; dmarc=pass (policy=none) header.from=kernel.org; spf=pass (imf08.hostedemail.com: domain of alexs@kernel.org designates 145.40.73.55 as permitted sender) smtp.mailfrom=alexs@kernel.org Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by sin.source.kernel.org (Postfix) with ESMTP id 9B39BCE0AB8; Mon, 8 Jul 2024 06:29:26 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 2D450C4AF0B; Mon, 8 Jul 2024 06:29:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1720420166; bh=F6gyGa/Nhcaa49tqL1AcCvvFaZR6EdIliZgtM0OjhK4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=RiUIttnE915B5POlt/rGkjRDxwMkMUiIsyhchqZid2hdw6qQfozwkJ9cRUtOfaZWY ecSVJ4QQb/fdFBE9zfzyTA2BZQ/RZsYI6z/9adNmf/+XhmJydHF+/B49U4BOPli6FZ i+H2xFep0Wh7TcTsawSQ0/5F+Km/FzU4iOKH5y+BJhwbFrL+YhRlq7VBl8TY9/DR6+ 9B9+DFLrjkjS9AcDH5+JUEVesyTatZ396Mq4zYeXPyscrToCEr2YgnPtcKHsDEslgD MVG6bEWLnGK/BxKoGIZwYSo/4qLqon08Zeykg32nXyrja7dsffK90F6QWlZSv8eCUu qhdiNIl+Xz0Ug== 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 v3 12/20] mm/zsmalloc: convert __free_zspage() to use zdsesc Date: Mon, 8 Jul 2024 14:33:33 +0800 Message-ID: <20240708063344.1096626-13-alexs@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240708063344.1096626-1-alexs@kernel.org> References: <20240708063344.1096626-1-alexs@kernel.org> MIME-Version: 1.0 X-Rspamd-Server: rspam07 X-Rspamd-Queue-Id: 53D59160002 X-Stat-Signature: jrjdkcmtiuj916riji57obpigzhaosdx X-Rspam-User: X-HE-Tag: 1720420168-822695 X-HE-Meta: U2FsdGVkX18v4OxGMXkCd+UT/RZEc3aJ5u1jTOE+LDre3zNKmi/qqFmCKWN/VuNmZRiH6mafFOVxCGHc7iM6dQEw1cW1JYUY6chwypUikPjRP7LZOAkEzDA9cY2JAjABheFSU7W7kpQ9LHVBjV0WaKue8zBJJLsrUxg40HETImJgzaUfmpFXBDeXoh0NfbSDzM925v9jYUcu4LOXTV7jZj70d7wuIvFoGSEnd5G/NYZkQNiIP1775wD4tyd81x9LFzWwSJPN18PTyMQTNeCK+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B7oySiP0g9P+4fMdK0zPzWqWv 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 (Tencent) --- 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);