From patchwork Tue Aug 6 02:22:59 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: 13754329 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 2C750C3DA4A for ; Tue, 6 Aug 2024 02:18:46 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id B290E6B00AD; Mon, 5 Aug 2024 22:18:45 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id AB00E6B00AE; Mon, 5 Aug 2024 22:18:45 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 951DD6B00AF; Mon, 5 Aug 2024 22:18:45 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id 74BCF6B00AD for ; Mon, 5 Aug 2024 22:18:45 -0400 (EDT) Received: from smtpin27.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id 2DA81C0516 for ; Tue, 6 Aug 2024 02:18:45 +0000 (UTC) X-FDA: 82420212210.27.DF5B62F Received: from sin.source.kernel.org (sin.source.kernel.org [145.40.73.55]) by imf03.hostedemail.com (Postfix) with ESMTP id 1E98E20024 for ; Tue, 6 Aug 2024 02:18:42 +0000 (UTC) Authentication-Results: imf03.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=cvE9YuJi; spf=pass (imf03.hostedemail.com: domain of alexs@kernel.org designates 145.40.73.55 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=1722910693; 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=BdOLw1XUqDePi7WDy52zOYaOjyt2X3wfg8YgocalmFo=; b=ehuW3GNHn6BVSppbZ1n0FW3m/baje2cfMkvZqoi/GvBU6368d2GF64A1T5ujTJvB9YAoCI 33xnsXS/hJkqLbx88eUymNNSbsPmVZIRDR4Y9BxkcYjeg+Lh04r5p6hs4SaEtOPzI2ugub zmh47+Lhba3tRo09AD+mRW3pVOZHViM= ARC-Authentication-Results: i=1; imf03.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=cvE9YuJi; spf=pass (imf03.hostedemail.com: domain of alexs@kernel.org designates 145.40.73.55 as permitted sender) smtp.mailfrom=alexs@kernel.org; dmarc=pass (policy=none) header.from=kernel.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1722910693; a=rsa-sha256; cv=none; b=Z9zRjJB508VY1Rk+VwYzM2gja7/sjPCQ7nlI9GITuSmr1Wn5/JLXRzm6beIRqNzdmQmZgj Ynw7+8lZcEZ6jxr3xM26947yPwLhzKAAlYbUpJPapXAzMkVCBCpmFdCyGq62PqxlD/n1sz EFaJRFMlGCG+8XTR+niaEed9Kqh5vHY= Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by sin.source.kernel.org (Postfix) with ESMTP id 3EEF0CE092D; Tue, 6 Aug 2024 02:18:40 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 88D72C32782; Tue, 6 Aug 2024 02:18:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1722910719; bh=aFVskGOXvp/05Uc/SGs92DOGYm3KvLJCDxXlSNzTuX4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=cvE9YuJiftrDSE1MdCbV7FmQDTvQ0+TQ0arxnPZndZbNu/MTxGTtjGpfe109H63gU EYlozhNKkNouVY2+GUzBSvklk1lOwJte5Wbw/cdE+8jzyW43VHDfNpeanSC+8PlmFA T1z6KNjfNtMt5abA5/7hG2ehSUx5Ru2Mv+oQLyP1YuD7GTKasFewskGQUq8gJrEt/8 5VzOBU3CEAoX4BAIxOH4oznwxYA5GhplD0r91533J0skWDt1FnOyWfJlOEvCQOx7AZ jotgu/PQ420IcxYrbHzQKf4mQnk4BqKD21NVym2jYYv8egk9cSHF8LUQayTgt8GFm+ 0L1DkJwRroClw== 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 v5 12/21] mm/zsmalloc: convert __free_zspage() to use zdsesc Date: Tue, 6 Aug 2024 10:22:59 +0800 Message-ID: <20240806022311.3924442-13-alexs@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240806022311.3924442-1-alexs@kernel.org> References: <20240806022143.3924396-1-alexs@kernel.org> <20240806022311.3924442-1-alexs@kernel.org> MIME-Version: 1.0 X-Rspamd-Server: rspam03 X-Rspam-User: X-Rspamd-Queue-Id: 1E98E20024 X-Stat-Signature: wky8u9tax7sknnwm5jo3mrgk8kifeeg4 X-HE-Tag: 1722910722-902039 X-HE-Meta: U2FsdGVkX1/XXXyE5NADJg2C3LA97yxckl6h7gSJxZpVzizH6bI/0vjPe9wZqBkkxvl3JJ7+BvqVbyUwWwf00UOp5czupt73/PTWYyEv5DnpJgOIFB9UXUxbbcN6Q6yOHyP6u6lAgV7tb6HgcgsdZvX3zgPG7XrxNvotdO+4b3IBGJqZrqeT/5yxJOcJiVpN5gUxiYhRsXO076qkkl7353CBMiQLGWHZkv/G39r+b00yTBMvrBQvxPKk/z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JMAelaA72k3ybQo2VWQ== 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 20881e7e42be..640f33b5c8bd 100644 --- a/mm/zpdesc.h +++ b/mm/zpdesc.h @@ -124,4 +124,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 f4fc79c0bef5..4b948b84e7f3 100644 --- a/mm/zsmalloc.c +++ b/mm/zsmalloc.c @@ -881,23 +881,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);