From patchwork Thu Dec 5 17:49:49 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Matthew Wilcox (Oracle)" X-Patchwork-Id: 13895895 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 CBE9CE77170 for ; Thu, 5 Dec 2024 17:50:21 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 1A5DD6B00A1; Thu, 5 Dec 2024 12:50:09 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id C6D3C6B0179; Thu, 5 Dec 2024 12:50:08 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 920326B017E; Thu, 5 Dec 2024 12:50:08 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id DFED16B0179 for ; Thu, 5 Dec 2024 12:50:07 -0500 (EST) Received: from smtpin15.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id 944FA161660 for ; Thu, 5 Dec 2024 17:50:06 +0000 (UTC) X-FDA: 82861643634.15.D374D44 Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) by imf25.hostedemail.com (Postfix) with ESMTP id 6D220A0004 for ; Thu, 5 Dec 2024 17:49:53 +0000 (UTC) Authentication-Results: imf25.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b="df/MmR1R"; spf=none (imf25.hostedemail.com: domain of willy@infradead.org has no SPF policy when checking 90.155.50.34) smtp.mailfrom=willy@infradead.org; dmarc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1733420997; 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=crjKswtSjiQfBwQcXTW2Ux6px6WFKzD5tBr9/cgLJDg=; b=jCXHlCAd+utTUvd2a4Mt0VxlG9kn49ot9p76jkof/sF/dk+oq3lCqUOOPeg1vPw0Tcw0QO 4Qsq5magR96kywNPCQ9DoGSI7qbEEuE57EE6MA7p55tfhF7mRb4L+UrPvZXBPbY7Cp/23k 5YuYW8Y+O8vHsnF0aFdiJQ+3ak695XA= ARC-Authentication-Results: i=1; imf25.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b="df/MmR1R"; spf=none (imf25.hostedemail.com: domain of willy@infradead.org has no SPF policy when checking 90.155.50.34) smtp.mailfrom=willy@infradead.org; dmarc=none ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1733420997; a=rsa-sha256; cv=none; b=Zdzs8dJa+gnyeCvjctV/UPSLVGBB6yUkg1OmiP7V4U9eUS2kb3adnIaGpNm/cXnbgmMEOL hMQs27zZpLwhnBlNyXBK0/58eZyiVtzXbBfDVDlEO1fTDgKz2msp4mYMQR+9NcWq464SWT AXhjlV9nQGmdgFWXcGO/92v8MAs3it4= DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=Content-Transfer-Encoding:MIME-Version: References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From:Sender:Reply-To: Content-Type:Content-ID:Content-Description; bh=crjKswtSjiQfBwQcXTW2Ux6px6WFKzD5tBr9/cgLJDg=; b=df/MmR1RZK10mtnfYnzbPIbb5U /gFttjvrNlMCxREJOLkPV5DJbNNgyRgS9RAVBmfq6ZMd469NaqUbWC16HiyinSZltF6SnwOzEn5cI z8WKCUgTBjYGRyhM9V5njXdd9JCB/0todTVB2A8YXvYCeqyXrGjPhTNGlMoc6EmQUH/z8cdq0oazP F5mpXuwsx9Pm3L+OUOUqj02TDzi/bvycnei9fHJSv23ZQXTAPy3IRY82QAkpDE//eOqsYLUHsgHmP d3MZRQwWYpyK3KHT1s7TtxAssLdLz1P0XSpOWwAVPXqDqjQNgaTwgFOaGBcYL8d/bUCRhXYciJFlu qad6ARlA==; Received: from willy by casper.infradead.org with local (Exim 4.98 #2 (Red Hat Linux)) id 1tJFzH-0000000DN8Y-2s4R; Thu, 05 Dec 2024 17:50:03 +0000 From: "Matthew Wilcox (Oracle)" To: Minchan Kim , Sergey Senozhatsky Cc: Hyeonggon Yoo <42.hyeyoo@gmail.com>, linux-mm@kvack.org, Alex Shi Subject: [PATCH v8 12/21] mm/zsmalloc: convert __free_zspage() to use zpdesc Date: Thu, 5 Dec 2024 17:49:49 +0000 Message-ID: <20241205175000.3187069-13-willy@infradead.org> X-Mailer: git-send-email 2.47.0 In-Reply-To: <20241205175000.3187069-1-willy@infradead.org> References: <20241205175000.3187069-1-willy@infradead.org> MIME-Version: 1.0 X-Rspamd-Queue-Id: 6D220A0004 X-Stat-Signature: 3bychrbkzetqrjaye1p1kj45qxejc77f X-Rspam-User: X-Rspamd-Server: rspam11 X-HE-Tag: 1733420993-767155 X-HE-Meta: U2FsdGVkX18Jo/33wjFzQf+jOex/Z9a3WKy4/EBID2CGeBbbv+9uTRtF5l9LZA+RLZU3Kj/+O6hOiBS6JA5Oi08kIrWiCrZPn5kmz/C6wk7pqcWMkPDQC+vjSLdgzmxwEbjyPlD2qfJXh4PXqxRveSbM+bGugqzioCpGJMW+pvNW9WckT82eMxUMi3lOuX5AFpvFQvWcqjb2edg2BML9vbDtP1lao1PVJ38k89Xoihi6pi22Aiwxn9ge+X1JonDxUAl7tst7YEjhNjs6LM7yUM7GxC7L0nffTv2JIFoVAL8Dm2lpnPJR8v8cHcEZyymZLhMVvFnM2dxIglPezo3PWRMHO2lGIW69SsfUYCJbPSCRB+IrIvhTSAhoN7/48DN42prZXZBk4crbgma0jTCcxqBVwLLCf41VY81x3+YAQp0piMwX4viqPdItu7yS8KV9RBr59JyKqz7pYJOueBrHFiiTmJBV4xUSk8SuIw65lyrPAE80Nd0I/Vdn59dVUv2djb+Fm+2a2DYe8l5eKCJBKLcLp8BfscqaKyD6+r/VdV4S7zSDLlPc262NlDdTlOn9ZnM3kcz2AEu7yzEfsUWN8dlhIICrQIdpARk903krbQU7lCTbnedj0DDgcMEMbVhiIdyv6PiqS1OF4qVdSwCkAYMGFewbZFfbQGJCUrZx412Ki2go0+uMQgtROFGxwzB/xwLKYwrsv9WpqoSZzu4jTNIONt54p592vcchfJtTiGlX119GCssm4LRA6oTBaz/KPlwKdWM2Rq62XEqH1JINpZLYYqBKgSye3OhBWTmN7Kperm04ZwxlHVlZWDEKzS2tnfcXjtdiu9dOF+A8XUlsz99hhq4FfS4Bahb3Hb6aOz012oyoh4KSjwj8xQAvhc1bZc4ycUlvPetrSImUGQncNK5GeBrPLMBScP8CMPgLaNKF5NCNDFt+94+dIlevCGN6Rkejq+/SFRe2hNDHQaz RZeC0qVZ BBpjGpC39ud7nTgfhIG5wm80p6xy4RUCuh4zG8PB3+Dv4cHy8V5ELuo9IFeV+//jAedpo99XjibWdMXfSac4k3xHEFWwmvDyaj94BU6PphcruDidl+c5uq69c/HK6G2WYwE8kDGcSA4tQShYOK+0Anz1/a4My4NlGKNHJ2Ob9bA3kb3LfozG0bS/oN0Xi2brPpilZvjBG35CU+vKgpmJGotmEfh+Bb4g5/tt+RbYAm65PGANtpmuiUzhy+yxGBnaqCAJd6/vfjmlYVohsAd4YW4I1Okvd1gYGz5zujg48nQ9xiCiVm7gKMhJvf4WXGXs7xoVUMadNPbAhEkgGY/Z7fDyfeA== 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 7d59bc2587bf..89fe78a7f5ca 100644 --- a/mm/zpdesc.h +++ b/mm/zpdesc.h @@ -127,4 +127,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 folio_test_locked(zpdesc_folio(zpdesc)); +} #endif diff --git a/mm/zsmalloc.c b/mm/zsmalloc.c index 87b2b100782f..2932351f4698 100644 --- a/mm/zsmalloc.c +++ b/mm/zsmalloc.c @@ -896,23 +896,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);