From mboxrd@z Thu Jan 1 00:00:00 1970 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 5B9873ECBFC for ; Wed, 25 Feb 2026 18:33:18 +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=1772044399; cv=none; b=fYGqWv6AWRQyKOT36JdOKcwKZY1/CktKiKrcei1iCNvAAXYSlKZ4Sn7N37ETEJsvKasGRlmIb2wOGiMxr4aZFVNh4NsUG+GAL+Mm2ov3cf+pK88NaSMV/pOCNVpp1Ns7UGlQUPAivMQ3/vFw2Xa9q4mhCHuld/TXvkIRkFmrj+Q= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1772044399; c=relaxed/simple; bh=19hrkUbABf0879zue0vUyB3SmJbLRsSTgHGYjcRaEME=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=LnW3nbJ9DXIiIhXgic33b27oM5Ui6lEb1YMHzICs2baM7CMy1GXBQJIf9jZUwCK4U0j1P+UUSbawmvZ/kN3nLLYQydm/0qtHm485R0bUHfy2G+ezWFUDUpXBhIePpBI9OJwa1Fkr00GMND6EAQXJZXF4F8S0usUUI6aUcgacwxg= 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=GysPJpK1; 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="GysPJpK1" Received: from localhost (localhost [127.0.0.1]) by 011.lax.mailroute.net (Postfix) with ESMTP id 4fLjrt026rz1XM6J5; Wed, 25 Feb 2026 18:33:18 +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=1772044395; x=1774636396; bh=uPGzJ hbmcqdlWn8EvwtNYMBLjrN6vXAhnzgQdGow0u4=; b=GysPJpK1LoIr634kBp3+0 UDCWLIhIH1TGctXZToCmKRAHQkdb9xKUqrC8o6B6NhdBradhU3XW1u6j/bl0mx4d uAV9GvNMvuiZdrVZb2EPZ2K3vGFF/4x/NdoxwMh3N7WBdXGW5LwlXoQuItPGBiz8 Sn8tungCv+EnGEhC8gXA4hwo36Rh6VaZCWxOpgnr+rshklmn1NM6GmCUhwSxmpP/ vyGMAW8CV0jnEBQW4Ow9GYVWMaurx4P7/E9bnk+Ljr3Kzt5H3N+tiDpbAbJWGXOU aKL3RQyaZbMn7nTXx5UP6+v9WIMZb3NKqVkqg4MvurVl3ws6wXwl1pFozNTN3EdP g== 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 5SXgN415q68w; Wed, 25 Feb 2026 18:33:15 +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 4fLjrm2ddYz1XM6J6; Wed, 25 Feb 2026 18:33:12 +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 , Christoph Hellwig , Steven Rostedt , Nick Desaulniers , Nathan Chancellor , Kees Cook , Jann Horn , Bart Van Assche Subject: [PATCH v2 4/4] Revert "lockdep: Annotate lockdep assertions for context analysis" Date: Wed, 25 Feb 2026 10:32:44 -0800 Message-ID: <20260225183244.4035378-5-bvanassche@acm.org> X-Mailer: git-send-email 2.53.0.414.gf7e9f6c205-goog In-Reply-To: <20260225183244.4035378-1-bvanassche@acm.org> References: <20260225183244.4035378-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 lockdep_assert_held() supports all data structures that have a member with the name dep_map. __assume_ctx_lock() only supports data structures that support lock context annotation. Remove __assume_ctx_lock() from lockdep_assert_held(). This patch fixes the following build errors if lock context analysis is enabled for the entire kernel tree: drivers/tty/tty_ldisc.c:451:2: error: call to '__assume_ctx_lock' is ambi= guous 451 | lockdep_assert_held_write(&tty->ldisc_sem); | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ drivers/tty/tty_ldisc.c:451:2: error: call to '__assume_ctx_lock' is ambi= guous 451 | lockdep_assert_held_write(&tty->ldisc_sem); | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Fixes: 7c451541743c ("lockdep: Annotate lockdep assertions for context an= alysis") Signed-off-by: Bart Van Assche --- include/linux/lockdep.h | 12 ++++++------ lib/test_context-analysis.c | 6 +++--- mm/kfence/report.c | 1 + 3 files changed, 10 insertions(+), 9 deletions(-) diff --git a/include/linux/lockdep.h b/include/linux/lockdep.h index 621566345406..dd634103b014 100644 --- a/include/linux/lockdep.h +++ b/include/linux/lockdep.h @@ -282,16 +282,16 @@ extern void lock_unpin_lock(struct lockdep_map *loc= k, struct pin_cookie); do { WARN_ON_ONCE(debug_locks && !(cond)); } while (0) =20 #define lockdep_assert_held(l) \ - do { lockdep_assert(lockdep_is_held(l) !=3D LOCK_STATE_NOT_HELD); __ass= ume_ctx_lock(l); } while (0) + lockdep_assert(lockdep_is_held(l) !=3D LOCK_STATE_NOT_HELD) =20 #define lockdep_assert_not_held(l) \ lockdep_assert(lockdep_is_held(l) !=3D LOCK_STATE_HELD) =20 #define lockdep_assert_held_write(l) \ - do { lockdep_assert(lockdep_is_held_type(l, 0)); __assume_ctx_lock(l); = } while (0) + lockdep_assert(lockdep_is_held_type(l, 0)) =20 #define lockdep_assert_held_read(l) \ - do { lockdep_assert(lockdep_is_held_type(l, 1)); __assume_shared_ctx_lo= ck(l); } while (0) + lockdep_assert(lockdep_is_held_type(l, 1)) =20 #define lockdep_assert_held_once(l) \ lockdep_assert_once(lockdep_is_held(l) !=3D LOCK_STATE_NOT_HELD) @@ -389,10 +389,10 @@ extern int lockdep_is_held(const void *); #define lockdep_assert(c) do { } while (0) #define lockdep_assert_once(c) do { } while (0) =20 -#define lockdep_assert_held(l) __assume_ctx_lock(l) +#define lockdep_assert_held(l) do { (void)(l); } while (0) #define lockdep_assert_not_held(l) do { (void)(l); } while (0) -#define lockdep_assert_held_write(l) __assume_ctx_lock(l) -#define lockdep_assert_held_read(l) __assume_shared_ctx_lock(l) +#define lockdep_assert_held_write(l) do { (void)(l); } while (0) +#define lockdep_assert_held_read(l) do { (void)(l); } while (0) #define lockdep_assert_held_once(l) do { (void)(l); } while (0) #define lockdep_assert_none_held_once() do { } while (0) =20 diff --git a/lib/test_context-analysis.c b/lib/test_context-analysis.c index 140efa8a9763..9846da75e9a3 100644 --- a/lib/test_context-analysis.c +++ b/lib/test_context-analysis.c @@ -68,7 +68,7 @@ static void __used test_common_helpers(void) } \ static void __used test_##class##_assert(struct test_##class##_data *d)= \ { \ - lockdep_assert_held(&d->lock); \ + __assume_ctx_lock(&d->lock); \ op(d->counter); \ } \ static void __used test_##class##_guard(struct test_##class##_data *d) = \ @@ -199,7 +199,7 @@ static void __used test_mutex_trylock(struct test_mut= ex_data *d, atomic_t *a) =20 static void __used test_mutex_assert(struct test_mutex_data *d) { - lockdep_assert_held(&d->mtx); + __assume_ctx_lock(&d->mtx); d->counter++; } =20 @@ -311,7 +311,7 @@ static void __used test_rwsem_writer(struct test_rwse= m_data *d) =20 static void __used test_rwsem_assert(struct test_rwsem_data *d) { - rwsem_assert_held_nolockdep(&d->sem); + __assume_ctx_lock(&d->sem); d->counter++; } =20 diff --git a/mm/kfence/report.c b/mm/kfence/report.c index 787e87c26926..d50a3f256650 100644 --- a/mm/kfence/report.c +++ b/mm/kfence/report.c @@ -263,6 +263,7 @@ void kfence_report_error(unsigned long address, bool = is_write, struct pt_regs *r =20 if (meta) { lockdep_assert_held(&meta->lock); + __assume_ctx_lock(&meta->lock); pr_err("\n"); kfence_print_object(NULL, meta); }