From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=199.89.1.14 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796421509; b=KvwpOTb3wjRFHYv2lZiCcV9F25a4tS4ZzY3er8aNcC33syTVJLoUBywMdlIiDr80N6t/ 6bj1/peM2v7wnw5PqktdzKdyXUb1sxXGt28+owhyMrlgrhLCNG4Uc1KEJoG38jLlu30Fq 9cP0Kt/74fFF7ZaldtsOp1Rh9iHABeAatW0VuGgxWh2eTQyrLHOw8gITjiu1YDNQM1WsW N8q6Du0y3f5dkie/utOf0/bEdI8/EyZTWWz6BzZvjxqhgjlsjVIDjKGhe1FNsVhf0IczX a2W7xah5Fd3pAv2N1RsN9ixA104O3Im/TSg2OAY8umFTzZYHdUQTyfc9FxStO+LtaHA== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796421509; h=DMARC-Filter:Received:DKIM-Signature:X-Virus-Scanned:Received: Received:From:To:Cc:Subject:Date:Message-ID:X-Mailer:In-Reply-To: References:MIME-Version:Content-Transfer-Encoding; bh=IpXKtmwzP+i6jyfFqE2DkG4wWKmqxgm/bxpERuoO4dY=; b=WsbwBOG2Ep7zmhEOGCk8f8B/wLFO+8AdfOfY43yuZ9Sg88yp45tZh7pFKJpuWAUs4xBo Di3mHnyhLll+ECyulLKNNEIe8bvOvaEIzLf2TNGxbx/jgGKmxINfamckubsWO9FUeQ9ri Z6pVeimhT2+JG9hEw+NG+maczLa0e/WXH8We8EKT2ptMFUO7MgQxxFaDykB+uBvbTHw4w zCz7rkI/u8hoWQesOcjhTZlDvLIv9Jax2RpLjHpqARTqwvKMRQkMTQD9f54UUnRQysB6f zBdNmCq/PpE1U6brf/PFP1V3L5fL5inQqkHLsMQDbe+oIXLfbxjEkF7+ISKwzjUFebA== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=acm.org; spf=pass smtp.mailfrom=acm.org; dkim=pass header.d=acm.org header.i=@acm.org header.a=rsa-sha256 header.s=mr01 header.b=S8UtQ4kt; arc=none smtp.remote-ip=199.89.1.14 Received: from 011.lax.mailroute.net (011.lax.mailroute.net [199.89.1.14]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 39362606A330 for ; Fri, 4 Dec 2026 21:58:29 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 39362606A330 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, unprotected) header.d=acm.org header.i=@acm.org header.a=rsa-sha256 header.s=mr01 header.b=S8UtQ4kt Received: from localhost (localhost [127.0.0.1]) by 011.lax.mailroute.net (Postfix) with ESMTP id 4jh53N3TTSz1XLQB6; Fri, 4 Dec 2026 21:58:24 +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=1796421501; x=1799013502; bh=IpXKt mwzP+i6jyfFqE2DkG4wWKmqxgm/bxpERuoO4dY=; b=S8UtQ4ktTcp1QoXIt39Fu gBsqxgsW9PTU/rSgIYD/tqD2h29b4fq09s+G14+P4zHKZ9UnI+JLXEgcC9TnBEXm XqizA91ASVtk5seFo5Qh8ekXL81XP38c1+N7ASFTFIxydxCLVITRkPhC4hi1m9Ag Se779ZKY4u9aGJ3p1V7DuVha5LWr1pXZh3zDDQekDsOeKrbdya+QCAIF0b8g/m4B OLVC2aNlrfBOuursn5bWWbAd7b4BenkeXWMEE8HsNaBd3WAyYmGdbUKiM71O/wuf 0U/Ri0d9AEPj1PCqhswfBea5xSMnnhEptKDh/Gyd7dbIBy6aU48ezc0Cn07xhJH3 w== 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 r6o3EVqi7NHA; Fri, 4 Dec 2026 21:58:21 +0000 (UTC) Received: from bvanassche.c.googlers.com.com (57.237.82.34.bc.googleusercontent.com [34.82.237.57]) (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 4jh53H576Fz1XNKvB; Fri, 4 Dec 2026 21:58:19 +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 , Bart Van Assche Subject: [PATCH 2/2] locking/rwlock: Report lock acquisition in non-debug do_raw_*_trylock() Date: Fri, 4 Dec 2026 13:58:07 -0800 Message-ID: <191260628fd9444b1e3ed202cdd1ef52eefe4ec5.1796421357.git.bvanassche@acm.org> X-Mailer: git-send-email 2.56.1.915.g69d5ec7298-goog In-Reply-To: References: X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Report lock acquisition explicitly in the !CONFIG_DEBUG_SPINLOCK definitions of do_raw_{read,write}_trylock() instead of using __no_context_analysis. This allows the compiler to verify that the function bodies match their __cond_acquires*() annotations and matches do_raw_spin_trylock() in include/linux/spinlock.h. Signed-off-by: Bart Van Assche --- include/linux/rwlock.h | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/include/linux/rwlock.h b/include/linux/rwlock.h index 396eb022bbd1..beae43c4655c 100644 --- a/include/linux/rwlock.h +++ b/include/linux/rwlock.h @@ -39,17 +39,25 @@ extern int do_raw_write_trylock(rwlock_t *lock) __con= d_acquires(true, lock); # define do_raw_read_lock(rwlock) do {__acquire_shared(rwlock); arch_rea= d_lock(&(rwlock)->raw_lock); } while (0) 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); + int ret =3D arch_read_trylock(&(rwlock)->raw_lock); + + if (ret) + __acquire_shared(rwlock); + + return ret; } # define do_raw_read_unlock(rwlock) do {arch_read_unlock(&(rwlock)->raw_= lock); __release_shared(rwlock); } while (0) # define do_raw_write_lock(rwlock) do {__acquire(rwlock); arch_write_loc= k(&(rwlock)->raw_lock); } while (0) static inline int do_raw_write_trylock(rwlock_t *rwlock) __cond_acquires(true, rwlock) - __no_context_analysis { - return arch_write_trylock(&(rwlock)->raw_lock); + int ret =3D arch_write_trylock(&(rwlock)->raw_lock); + + if (ret) + __acquire(rwlock); + + return ret; } # define do_raw_write_unlock(rwlock) do {arch_write_unlock(&(rwlock)->ra= w_lock); __release(rwlock); } while (0) #endif