From nobody Tue Apr 7 11:15:46 2026 Received: from 011.lax.mailroute.net (011.lax.mailroute.net [199.89.1.14]) (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 4DAEC3CB2E0 for ; Fri, 13 Mar 2026 17:15:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=199.89.1.14 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773422150; cv=none; b=tZ4ioRLFhEJFU/obhxPtN/3vpDESAHRAMlNMI3ahxYjOFtMyinl5HBNsUQGyUqK/a/ysdkGDcxZN0se9XROuoD0ALSqUw1mtOHN/Odi4OoA4TH0xtfLpaRd2ObUbOOMSb0kvStiK+a4RJNxx0A8KnThmPkA+Yr/pKTu6Nm3QQck= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773422150; c=relaxed/simple; bh=i+Q7AKnq7DLfXOmdUYzvfrbefT8mvIN5tfFavZjOwjA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=ahFgHFTfedLTL/pJ5rwjcZVUWs6IwR4KtXQwbC5/XzRAkHKfR5QCHWqbjEiI5Osx/6u/ZwM8/a/etJdhdWZ5DbOyP6vXwIRGFRUx9LzVp2JYLHLxtLns703umSgnShea8Bubbd6i9YhAhfl4YfHS59Vs8jdj4L1W/ipUT/SIA2M= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=acm.org; spf=pass smtp.mailfrom=acm.org; dkim=pass (2048-bit key) header.d=acm.org header.i=@acm.org header.b=FYvR+bCZ; arc=none smtp.client-ip=199.89.1.14 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=acm.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=acm.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=acm.org header.i=@acm.org header.b="FYvR+bCZ" Received: from localhost (localhost [127.0.0.1]) by 011.lax.mailroute.net (Postfix) with ESMTP id 4fXWN50S9mz1XM6JR; Fri, 13 Mar 2026 17:15:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=acm.org; h= content-transfer-encoding:mime-version:references:in-reply-to :x-mailer:message-id:date:date:subject:subject:from:from :received:received; s=mr01; t=1773422142; x=1776014143; bh=Ykfaz +sPZV+TWSVNMsGJbnUfHzryeDJZYUtXSzlgZwg=; b=FYvR+bCZxibaYwNPEVVFh 5oc62dAqRWdhfTfQAJq0bTzo4jdWy5RpoREYE3W0h7qla/2MfauejKPEj04YWZGw 56BTKKEq78CjbmC71+4jkxc9UotcwnknowKDaiOli8MPRkcLWSA/P5s27wE5wOxr tCHdRNNo1qOwcE+qIQyMIRO9NgQC1Cm+fkRoNyWi+L9Kj0s/7eSZTmDLkktsObiC H5gcjEGNUDLkFfHZV9nPrLfR3DfwUDy8jJ9PUhqgUH1A2yjY/cRuX2cSEThiXstB Cx9wm7bE2y3y541B0vslWROhXikzBQzv/8XiPjM0k7ID7xitOA+LygyitSa4xx0W A== X-Virus-Scanned: by MailRoute Received: from 011.lax.mailroute.net ([127.0.0.1]) by localhost (011.lax [127.0.0.1]) (mroute_mailscanner, port 10029) with LMTP id dIGEAncHRF65; Fri, 13 Mar 2026 17:15:42 +0000 (UTC) Received: from bvanassche.mtv.corp.google.com (unknown [104.135.180.219]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: bvanassche@acm.org) by 011.lax.mailroute.net (Postfix) with ESMTPSA id 4fXWMs5dZmz1XM5jn; Fri, 13 Mar 2026 17:15:37 +0000 (UTC) From: Bart Van Assche To: Peter Zijlstra Cc: Ingo Molnar , Will Deacon , Boqun Feng , Waiman Long , linux-kernel@vger.kernel.org, Marco Elver , Bart Van Assche Subject: [PATCH 3/3] locking: Add lock context annotations in the spinlock implementation Date: Fri, 13 Mar 2026 10:15:09 -0700 Message-ID: <20260313171510.230998-4-bvanassche@acm.org> X-Mailer: git-send-email 2.53.0.851.ga537e3e6e9-goog In-Reply-To: <20260313171510.230998-1-bvanassche@acm.org> References: <20260313171510.230998-1-bvanassche@acm.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" Make the spinlock implementation compatible with lock context analysis (CONTEXT_ANALYSIS :=3D 1) by adding lock context annotations to the _raw_##op##_...() macros. Signed-off-by: Bart Van Assche --- kernel/locking/spinlock.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/kernel/locking/spinlock.c b/kernel/locking/spinlock.c index 7685defd7c52..b42d293da38b 100644 --- a/kernel/locking/spinlock.c +++ b/kernel/locking/spinlock.c @@ -64,8 +64,9 @@ EXPORT_PER_CPU_SYMBOL(__mmiowb_state); * time (making _this_ CPU preemptible if possible), and we also signal * towards that other CPU that it should break the lock ASAP. */ -#define BUILD_LOCK_OPS(op, locktype) \ +#define BUILD_LOCK_OPS(op, locktype, lock_ctx_op) \ static void __lockfunc __raw_##op##_lock(locktype##_t *lock) \ + lock_ctx_op(lock) \ { \ for (;;) { \ preempt_disable(); \ @@ -78,6 +79,7 @@ static void __lockfunc __raw_##op##_lock(locktype##_t *lo= ck) \ } \ \ static unsigned long __lockfunc __raw_##op##_lock_irqsave(locktype##_t *lo= ck) \ + lock_ctx_op(lock) \ { \ unsigned long flags; \ \ @@ -96,11 +98,13 @@ static unsigned long __lockfunc __raw_##op##_lock_irqsa= ve(locktype##_t *lock) \ } \ \ static void __lockfunc __raw_##op##_lock_irq(locktype##_t *lock) \ + lock_ctx_op(lock) \ { \ _raw_##op##_lock_irqsave(lock); \ } \ \ static void __lockfunc __raw_##op##_lock_bh(locktype##_t *lock) \ + lock_ctx_op(lock) \ { \ unsigned long flags; \ \ @@ -123,11 +127,11 @@ static void __lockfunc __raw_##op##_lock_bh(locktype#= #_t *lock) \ * __[spin|read|write]_lock_irqsave() * __[spin|read|write]_lock_bh() */ -BUILD_LOCK_OPS(spin, raw_spinlock); +BUILD_LOCK_OPS(spin, raw_spinlock, __acquires); =20 #ifndef CONFIG_PREEMPT_RT -BUILD_LOCK_OPS(read, rwlock); -BUILD_LOCK_OPS(write, rwlock); +BUILD_LOCK_OPS(read, rwlock, __acquires_shared); +BUILD_LOCK_OPS(write, rwlock, __acquires); #endif =20 #endif