From mboxrd@z Thu Jan 1 00:00:00 1970 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]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 1EF57F0183E for ; Fri, 6 Mar 2026 14:09:03 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 893AB6B0089; Fri, 6 Mar 2026 09:09:02 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 81C8A6B008A; Fri, 6 Mar 2026 09:09:02 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 7231A6B008C; Fri, 6 Mar 2026 09:09:02 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id 5E70D6B0089 for ; Fri, 6 Mar 2026 09:09:02 -0500 (EST) Received: from smtpin11.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id F34061A0637 for ; Fri, 6 Mar 2026 14:09:01 +0000 (UTC) X-FDA: 84515819682.11.1C2CC19 Received: from lgeamrelo07.lge.com (lgeamrelo07.lge.com [156.147.51.103]) by imf23.hostedemail.com (Postfix) with ESMTP id C957E14000C for ; Fri, 6 Mar 2026 14:08:58 +0000 (UTC) Authentication-Results: imf23.hostedemail.com; dkim=none; spf=pass (imf23.hostedemail.com: domain of youngjun.park@lge.com designates 156.147.51.103 as permitted sender) smtp.mailfrom=youngjun.park@lge.com; dmarc=pass (policy=none) header.from=lge.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1772806140; 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-type:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=c0b/w6C4ybBex3m0FqPqxP/RnhSWe+ivj62c37ZNQag=; b=xgN8VXZ2eBsRKeIYqf9OU3UD73fc/9QYCdfEgr+TdtqdhYCG+CeyJw+A+WZwgLOm45oMnz TuQIeCjNIBe+XFOiSmZSt0sm8MW+vbVeLcBMpWvO7/n6X91TeRqqICfysqVOe51x7ahm63 GbNV7T7ksGiMpMGOcV27+mfcw3M1miI= ARC-Authentication-Results: i=1; imf23.hostedemail.com; dkim=none; spf=pass (imf23.hostedemail.com: domain of youngjun.park@lge.com designates 156.147.51.103 as permitted sender) smtp.mailfrom=youngjun.park@lge.com; dmarc=pass (policy=none) header.from=lge.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1772806140; a=rsa-sha256; cv=none; b=B8Wfq8O8uYjRj1nT+Tqs6qZfc/pDj9sTz5P2vjN+9uAwedRxiwK8ceBvuvGfRCZbADCSUI O3/3JYQiuLlMlGrGyJNmtpkGy0XHifupbiOxlzy4If/W25rYrck8qPB5Yqd7vYjNzieCiA CCNjlStWbNTrzOitsLS2onPPHiqUrV0= Received: from unknown (HELO yjaykim-PowerEdge-T330) (10.177.112.156) by 156.147.51.103 with ESMTP; 6 Mar 2026 23:08:55 +0900 X-Original-SENDERIP: 10.177.112.156 X-Original-MAILFROM: youngjun.park@lge.com Date: Fri, 6 Mar 2026 23:08:55 +0900 From: YoungJun Park To: Hui Zhu Cc: Andrew Morton , Chris Li , Kairui Song , Kemeng Shi , Nhat Pham , Baoquan He , Barry Song , linux-mm@kvack.org, linux-kernel@vger.kernel.org, Hui Zhu Subject: Re: [PATCH 2/2] mm/swap: add lockdep for si->global_cluster_lock in swap_cluster_alloc_table() Message-ID: References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Rspamd-Server: rspam10 X-Rspamd-Queue-Id: C957E14000C X-Stat-Signature: z8b7sfeb16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gAeFmAyojw6TZcUU/G8qmhihWOMcYMx7ClVzQ11hCENlEEjUuFSXN8YWIjCFuUD1tV2XGRlzkSBMBpftgfbnbCCXtOEOfjHp5dwM3VZ5mtGGV7WkgeX2NCTLn+plmU6XK0+4IqV4w2keT9bnOIH01jHQGpd9AJtYNseZRNniD+HTlaJ+EOG9qQakWBOEZVYdZ72jD/F7t0Ai032xUFRT5IwHzMEaTpSwwXPOB5mrk= Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: On Fri, Mar 06, 2026 at 07:50:37PM +0800, Hui Zhu wrote: > From: Hui Zhu > > Add a lockdep_assert_held(&si->global_cluster_lock) in > swap_cluster_alloc_table() for non-SWP_SOLIDSTATE devices. > > The function already requires the caller to hold both ci->lock > and percpu_swap_cluster.lock. > And it also necessitates si->global_cluster_lock when the device is not > SWP_SOLIDSTATE. > Adding this assertion ensures locking consistency and helps catch > potential synchronization issues during development. > > Signed-off-by: Hui Zhu > --- > mm/swapfile.c | 2 ++ > 1 file changed, 2 insertions(+) > > diff --git a/mm/swapfile.c b/mm/swapfile.c > index 2e8717f84ba3..1400a1585033 100644 > --- a/mm/swapfile.c > +++ b/mm/swapfile.c > @@ -477,6 +477,8 @@ swap_cluster_alloc_table(struct swap_info_struct *si, > * Swap allocator uses percpu clusters and holds the local lock. > */ > lockdep_assert_held(&ci->lock); > + if (!(si->flags & SWP_SOLIDSTATE)) > + lockdep_assert_held(&si->global_cluster_lock); > lockdep_assert_held(&this_cpu_ptr(&percpu_swap_cluster)->lock); The addition looks fine to me. If others agree, one minor suggestion: it might be slightly cleaner to order the lockdep_assert_held() calls to match the actual lock acquisition order: lockdep_assert_held(&this_cpu_ptr(&percpu_swap_cluster)->lock); if (!(si->flags & SWP_SOLIDSTATE)) lockdep_assert_held(&si->global_cluster_lock); lockdep_assert_held(&ci->lock); No strong opinion on this, just a thought. :) Best regards, Youngjun Park > /* The cluster must be free and was just isolated from the free list. */ > -- > 2.43.0 > >