From nobody Thu Apr 9 13:33:07 2026 Received: from out-186.mta1.migadu.com (out-186.mta1.migadu.com [95.215.58.186]) (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 BB35E367F27 for ; Mon, 9 Mar 2026 08:06:32 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=95.215.58.186 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773043594; cv=none; b=lk6WsVJDb5y00Pf+Yd3jAyV4IOh8GnaJEpDDXet577/468pZg6TfcTBtt56ZvCBHXohJYosrYy0IDjcr9SGoXxrjtpejQHN0HkuFX4XhnSExYn84uzqH8iADoioJu+nsnxR0SAc2m9BUS6Z88HCq81dZKCw2BOn6Xe8aCBjWD54= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773043594; c=relaxed/simple; bh=ApWMQVBWooXdCYyjaw+zRE6xsU+5G2WqEojyFqHZ8tI=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=JWrQEgoP2kpsUMe82LtOKehHccCfRMGIpAiy9qWTjbk66l5J+CsFuQDh8A1Y5rmCSaSjwMTzU8oOMLhZq01Ha5U6U4PKejbo80yMl1VlxEQWLu7EW7mpoSkc50lHN/aq8Q8SRxGJWS2QXxpXn9xIifPDG+izgehaXXE6U08TmJU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev; spf=pass smtp.mailfrom=linux.dev; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b=ZqEWk6yS; arc=none smtp.client-ip=95.215.58.186 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.dev Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b="ZqEWk6yS" X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1773043591; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=tpBsCDLcm2n1XrByJy4y0AKMK904EnYCVpywQiSZvCo=; b=ZqEWk6ySKPHVezXprH4LiiDhG4zpepfYXmtDqReWcGDqrt/yqnpRmsKUMckTzgguxd1FHp H70+NcvkMtCEmdgekuLrxqjTixhm6i/vpy+vXGuhLdu+crmhkyjWJKc1KAIDWbWEEikTCu 0I8JU1K4ChTGCMiAp3kN8SCRavBr1sw= From: Hui Zhu To: Andrew Morton , Chris Li , Kairui Song , Kemeng Shi , Nhat Pham , Baoquan He , Barry Song , YoungJun Park , linux-mm@kvack.org, linux-kernel@vger.kernel.org Cc: Hui Zhu Subject: [PATCH v2 2/2] mm/swap: Add lockdep for si->global_cluster_lock in swap_cluster_alloc_table() Date: Mon, 9 Mar 2026 16:05:42 +0800 Message-ID: <879eff096e46c02f994de62dc210a95cc58e3f19.1773040982.git.zhuhui@kylinos.cn> In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Migadu-Flow: FLOW_OUT Content-Type: text/plain; charset="utf-8" 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 Reviewed-by: Youngjun Park --- 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); =20 /* The cluster must be free and was just isolated from the free list. */ VM_WARN_ON_ONCE(ci->flags || !cluster_is_empty(ci)); --=20 2.43.0