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 E45123C5DC0 for ; Fri, 13 Mar 2026 17:15:42 +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=1773422144; cv=none; b=rbnnDV89cIPnSUzVc9XaVvLKWwZXYXTmoS5Fe7Owsmji2YdbtoyCZsxvr3MSWSfE3zDkAA+uiUFEbPwbJBywMJTfodrM5aZwvCBaY15IyrK7k13cElEwdxqgaXRfm4ksEgL5Ze0pAarl4bKGly+sqxjnY3HuWuhudJzQnr8C1bM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773422144; c=relaxed/simple; bh=8Au6BVMwSr9Gu0ZQnDiH3oTCFL5YDcxF1EVxL6AWPG0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=BjC9+OhH25vwnSkwJMrGU0F+jUeSaDkxPvr6YeZ3nNG3u8U3jE6pN+jI3Nyz6fBFf7vycFJmv538Fe7AgeJMmvh88l5+Z5ozDsHACj4KeQp4ZY6EHuFuLwDGK8DBVaFqzfVl6rQnR+2KXi90zYbX1IpKEh/xnzUjnzI4pcGSLaM= 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=M313rqxQ; 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="M313rqxQ" Received: from localhost (localhost [127.0.0.1]) by 011.lax.mailroute.net (Postfix) with ESMTP id 4fXWMy3TxYz1XM6JB; Fri, 13 Mar 2026 17:15:42 +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=1773422137; x=1776014138; bh=/8lbx DgJuwGT98tI2y90EpnOfED6nIs0PDz9suhaGD0=; b=M313rqxQ9cfvvJWBDUmRr B1zAsIfXo0BJjaKSu5h6lE66CKjgeNo2TPuoPmY9xGZHPqMdQJBz+zJQLY3dBP3a pIC/qDuXEPSJxmZOWGrtgA4uZ0mLL1bgkwbQe4+eAaOUNPM5lQElzxWhwqR/W+pT Q5o31crElg25UB1PpfEK3qQyWdWZ+SdfNnVkbK78CrzN8EPIhOJE2p7sWlpkyJ/S tsXghCuQjRXcSOqXSHPzNMMyX9/Quudd3z6XuxsZrAjz/7VRz+SCJucWfETVaDWD 8Nf0b4oQqlls1SVY5d69MS5Q4CkfFVTwl7HrxKShbPjTdHFUg28obtkCBdwjiBzx Q== 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 5Edvjw65qcFu; Fri, 13 Mar 2026 17:15:37 +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 4fXWMq1y98z1XLwXW; Fri, 13 Mar 2026 17:15:35 +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 2/3] locking: Add lock context support in do_raw_{read,write}_trylock() Date: Fri, 13 Mar 2026 10:15:08 -0700 Message-ID: <20260313171510.230998-3-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" Convert do_raw_{read,write}_trylock() from macros into inline functions and annotate these inline functions with __cond_acquires_shared() or __cond_acquires() as appropriate. This change is necessary to build kernel drivers or subsystems that use rwlock synchronization objects with lock context analysis enabled. The return type 'int' matches the return type for CONFIG_DEBUG_SPINLOCK=3Dy. Signed-off-by: Bart Van Assche --- include/linux/rwlock.h | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/include/linux/rwlock.h b/include/linux/rwlock.h index 21ceefc4a49f..4e67cd934d8f 100644 --- a/include/linux/rwlock.h +++ b/include/linux/rwlock.h @@ -37,10 +37,20 @@ extern int do_raw_write_trylock(rwlock_t *lock) __cond_= acquires(true, lock); extern void do_raw_write_unlock(rwlock_t *lock) __releases(lock); #else # define do_raw_read_lock(rwlock) do {__acquire_shared(lock); arch_read_lo= ck(&(rwlock)->raw_lock); } while (0) -# define do_raw_read_trylock(rwlock) arch_read_trylock(&(rwlock)->raw_lock) +static inline int do_raw_read_trylock(rwlock_t *rwlock) + __cond_acquires_shared(true, rwlock) + __no_context_analysis +{ + return arch_read_trylock(&(rwlock)->raw_lock); +} # define do_raw_read_unlock(rwlock) do {arch_read_unlock(&(rwlock)->raw_lo= ck); __release_shared(lock); } while (0) # define do_raw_write_lock(rwlock) do {__acquire(lock); arch_write_lock(&(= rwlock)->raw_lock); } while (0) -# define do_raw_write_trylock(rwlock) arch_write_trylock(&(rwlock)->raw_lo= ck) +static inline int do_raw_write_trylock(rwlock_t *rwlock) + __cond_acquires(true, rwlock) + __no_context_analysis +{ + return arch_write_trylock(&(rwlock)->raw_lock); +} # define do_raw_write_unlock(rwlock) do {arch_write_unlock(&(rwlock)->raw_= lock); __release(lock); } while (0) #endif =20