From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from lgeamrelo03.lge.com (lgeamrelo03.lge.com [156.147.51.102]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A5C692BE02A for ; Mon, 9 Mar 2026 08:42:01 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=156.147.51.102 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773045726; cv=none; b=O5jQpqNehXvpQuMRqmfw/I41btFvBLyiOlVTTxox/FYLOvna/BDhBtjQU1ItOg4vasNf44RcvzeHH0q40jxgVX7TOjDPy7i1HuJFxBU9lYABhUDLjgz8esQlHVGKgwEg8FXYm6LMy+qKY25hqJi8RmZITgYPWnCw2EUvktLzkgU= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773045726; c=relaxed/simple; bh=4U/9NnFHmVrV9GcU9MNy/yRkWzvzh1x3mpYX4HeV8Og=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=ZzSvGNtLT98GvpoB6yIyXn9UDh6wsGzyQYn+O1DlxW3U9Hw4UobURtQYHuctvFGhyfZ73v6zYeZD6u4BREdA1Itb8zPOfksq+bsP1cUxYJmamjlzC/32LtUtE7GNfCtGR8PMZ1Ak+skaQc5GHOMy3TRhtTpxcWPUe1aEevFQJRI= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=lge.com; spf=pass smtp.mailfrom=lge.com; arc=none smtp.client-ip=156.147.51.102 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=lge.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=lge.com Received: from unknown (HELO yjaykim-PowerEdge-T330) (10.177.112.156) by 156.147.51.102 with ESMTP; 9 Mar 2026 17:41:57 +0900 X-Original-SENDERIP: 10.177.112.156 X-Original-MAILFROM: youngjun.park@lge.com Date: Mon, 9 Mar 2026 17:41:28 +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 v2 2/2] mm/swap: Add lockdep for si->global_cluster_lock in swap_cluster_alloc_table() Message-ID: References: <879eff096e46c02f994de62dc210a95cc58e3f19.1773040982.git.zhuhui@kylinos.cn> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <879eff096e46c02f994de62dc210a95cc58e3f19.1773040982.git.zhuhui@kylinos.cn> On Mon, Mar 09, 2026 at 04:05:42PM +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. > Change the order of lockdep_assert_held() to match the actual lock > acquisition order. > > Signed-off-by: Hui Zhu > --- > mm/swapfile.c | 4 +++- > 1 file changed, 3 insertions(+), 1 deletion(-) > > diff --git a/mm/swapfile.c b/mm/swapfile.c > index 3fc2eb30c187..b31b86263b89 100644 > --- a/mm/swapfile.c > +++ b/mm/swapfile.c > @@ -476,8 +476,10 @@ swap_cluster_alloc_table(struct swap_info_struct *si, > * Only cluster isolation from the allocator does table allocation. > * Swap allocator uses percpu clusters and holds the local lock. > */ > - lockdep_assert_held(&ci->lock); > 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); > > /* The cluster must be free and was just isolated from the free list. */ > VM_WARN_ON_ONCE(ci->flags || !cluster_is_empty(ci)); > -- > 2.43.0 The changes look good to me. Thanks! Reviewed-by: Youngjun Park