From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 58C3734CFAE; Wed, 5 Nov 2025 21:05:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1762376721; cv=none; b=sNYUHfa37POMGWnF+a2A5+Ml2j5f8reJ4znpoVWxiJ0AZ2hGrMcFeF9MxVjGp8I5WMwWRS/iiLsg/vY8jDmJvuW0KQhH4nxzszgu1KjQnILBfRs3tdDJW4JAZcfjn2h/CGhuvXJJKMQjGm+8SjL13ypdUN5wbJ44GjGQ/xOfxTA= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1762376721; c=relaxed/simple; bh=069wMqK9bF6D74YIJY8nZAw2J7YjllAfy3UAu+j/YUM=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=SWSrX9bJPzTw9IlnKVIxg67ku4U1Gu+J+5VsxK6kGKd//XdJnwb0P93Nr5mlEfM9H/Y+Txxb6tUS7G/liEOgcXP7nragfncwUT7ux3w9XHwg+ciTyIeB0XffEtLAILJk7vz5gpxGl1F9xDnpC0gk3/wqsfFIhZ3JoDBc8flvwzo= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=TjPK2nVT; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="TjPK2nVT" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8A6DBC16AAE; Wed, 5 Nov 2025 21:05:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1762376721; bh=069wMqK9bF6D74YIJY8nZAw2J7YjllAfy3UAu+j/YUM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=TjPK2nVTHpm5UvjRrqC3/iVdJyCu2w8vAKnS5aGQJW33UGGO9u2tYQk8dZwYmSas7 AS1Fq2HfYE07xUSOvClsZpXdjW/NcU2f9X3O1YGo0zlSdDSTnX/4YJxvWxIF6EvsA6 1HoOZJSVB65fyvSzY6HOQQUbrFuT9WvsiOWThdqDs7Vd2rn2VtqKqwNmj9J1f+EOP7 6AQEWF+zq9+uCWgk7nfcuft8ta2vwMKjhXC+7GHobQoc6kg1a6R/Rhgh4HSMk0Rvc7 ajQbnC1myt/oiq3cpaA4PP3eU4zzh01SqlMPVDDuYW12zhVWedDA3qvgsrQ2JhPBUw KsbsHti30dhwQ== From: Frederic Weisbecker To: LKML Cc: Frederic Weisbecker , =?UTF-8?q?Michal=20Koutn=C3=BD?= , Andrew Morton , Bjorn Helgaas , Catalin Marinas , Danilo Krummrich , "David S . Miller" , Eric Dumazet , Gabriele Monaco , Greg Kroah-Hartman , Ingo Molnar , Jakub Kicinski , Jens Axboe , Johannes Weiner , Lai Jiangshan , Marco Crivellari , Michal Hocko , Muchun Song , Paolo Abeni , Peter Zijlstra , Phil Auld , "Rafael J . Wysocki" , Roman Gushchin , Shakeel Butt , Simon Horman , Tejun Heo , Thomas Gleixner , Vlastimil Babka , Waiman Long , Will Deacon , cgroups@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-block@vger.kernel.org, linux-mm@kvack.org, linux-pci@vger.kernel.org, netdev@vger.kernel.org Subject: [PATCH 10/31] cpu: Provide lockdep check for CPU hotplug lock write-held Date: Wed, 5 Nov 2025 22:03:26 +0100 Message-ID: <20251105210348.35256-11-frederic@kernel.org> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20251105210348.35256-1-frederic@kernel.org> References: <20251105210348.35256-1-frederic@kernel.org> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit cpuset modifies partitions, including isolated, while holding the cpu hotplug lock read-held. This means that write-holding the CPU hotplug lock is safe to synchronize against housekeeping cpumask changes. Provide a lockdep check to validate that. Signed-off-by: Frederic Weisbecker --- include/linux/cpuhplock.h | 1 + include/linux/percpu-rwsem.h | 1 + kernel/cpu.c | 5 +++++ 3 files changed, 7 insertions(+) diff --git a/include/linux/cpuhplock.h b/include/linux/cpuhplock.h index f7aa20f62b87..286b3ab92e15 100644 --- a/include/linux/cpuhplock.h +++ b/include/linux/cpuhplock.h @@ -13,6 +13,7 @@ struct device; extern int lockdep_is_cpus_held(void); +extern int lockdep_is_cpus_write_held(void); #ifdef CONFIG_HOTPLUG_CPU void cpus_write_lock(void); diff --git a/include/linux/percpu-rwsem.h b/include/linux/percpu-rwsem.h index 288f5235649a..c8cb010d655e 100644 --- a/include/linux/percpu-rwsem.h +++ b/include/linux/percpu-rwsem.h @@ -161,6 +161,7 @@ extern void percpu_free_rwsem(struct percpu_rw_semaphore *); __percpu_init_rwsem(sem, #sem, &rwsem_key); \ }) +#define percpu_rwsem_is_write_held(sem) lockdep_is_held_type(sem, 0) #define percpu_rwsem_is_held(sem) lockdep_is_held(sem) #define percpu_rwsem_assert_held(sem) lockdep_assert_held(sem) diff --git a/kernel/cpu.c b/kernel/cpu.c index 453a806af2ee..3b0443f7c486 100644 --- a/kernel/cpu.c +++ b/kernel/cpu.c @@ -534,6 +534,11 @@ int lockdep_is_cpus_held(void) { return percpu_rwsem_is_held(&cpu_hotplug_lock); } + +int lockdep_is_cpus_write_held(void) +{ + return percpu_rwsem_is_write_held(&cpu_hotplug_lock); +} #endif static void lockdep_acquire_cpus_lock(void) -- 2.51.0