From nobody Fri Oct 3 15:37:01 2025 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 CCDC53277A7 for ; Fri, 29 Aug 2025 15:48:51 +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=1756482532; cv=none; b=n4l8cwICahxKAL2L6uN12J+h16J183JqVBjfuOsq6mdsUgFCIhLtRJlmN9J3uxNuqLa/TjWCcs6NVD9CSnMU8yzb+H253vrnCbkpOs+Twph7DOkwLfh2g77AGcDXTayS+rQ3mK++NXIGT8fpi4L9gYHNvfwmHmatg/OlAGt2caw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1756482532; c=relaxed/simple; bh=069wMqK9bF6D74YIJY8nZAw2J7YjllAfy3UAu+j/YUM=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=DYZCuJPc0JbF9raQzeWkbyFGT5CPv0wQ3L7wsXKXOSR82Nt3Ka8s2C02Y8dq9Qirtn6olpnzFt98vW7UDvsCUZTAc6XIUh16KSVWIl85dRACiup7/8s/j9WRD67PuRgJRO3108PXGvlP2vbd+rGe6zBT9LWjK6drW17BOdlJ9pA= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=Rjmbh3Ol; 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="Rjmbh3Ol" Received: by smtp.kernel.org (Postfix) with ESMTPSA id A59EAC4CEF0; Fri, 29 Aug 2025 15:48:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1756482531; bh=069wMqK9bF6D74YIJY8nZAw2J7YjllAfy3UAu+j/YUM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Rjmbh3OlGvhaN0dbZ5yNeJrUoVWLD/BjCk7ULf1qSy3haIqWabdL8HqM4GG1mFsRx jgzgaB5upUO/2BF4fmUF0Lzx00uVPiWqDTb7I62rqAaUFKlypIeXs8gXmGhu3XgnsL PZuRkBC4xg0+VssfKSaBa6K/pTdflh7yGllFEfB/AvR++fP0oz2H/E2kcCPPS3ZF/4 SlqIvBX3iapid3lzmeBU0aKhXqD+N/a8lOK9PNjUg92/KFjzdNkq0BLQkI/aNi/xBP 0dPZZR5sn0+sESUqseEoAMZto60pDaHnTGdJI48djTiSgWEaZ0IHuIxaSn8j4WWqu0 Gz8P9EKsOQGJA== From: Frederic Weisbecker To: LKML Cc: Frederic Weisbecker , Marco Crivellari , Michal Hocko , Peter Zijlstra , Tejun Heo , Thomas Gleixner , Waiman Long Subject: [PATCH 11/33] cpu: Provide lockdep check for CPU hotplug lock write-held Date: Fri, 29 Aug 2025 17:47:52 +0200 Message-ID: <20250829154814.47015-12-frederic@kernel.org> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20250829154814.47015-1-frederic@kernel.org> References: <20250829154814.47015-1-frederic@kernel.org> 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 Content-Type: text/plain; charset="utf-8" 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; =20 extern int lockdep_is_cpus_held(void); +extern int lockdep_is_cpus_write_held(void); =20 #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_semaphor= e *); __percpu_init_rwsem(sem, #sem, &rwsem_key); \ }) =20 +#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) =20 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 =20 static void lockdep_acquire_cpus_lock(void) --=20 2.51.0