From: Bart Van Assche <bvanassche@acm.org>
To: John Garry <john.garry@linux.dev>,
"Martin K . Petersen" <martin.petersen@oracle.com>
Cc: linux-scsi@vger.kernel.org, John Garry <john.g.garry@oracle.com>,
Christoph Hellwig <hch@lst.de>
Subject: Re: [PATCH v2 6/7] scsi: scsi_debug: Improve lock context annotations
Date: Fri, 25 Sep 2026 08:55:07 -0700 [thread overview]
Message-ID: <08ca7fe8-a767-412d-9e51-716de27748fb@acm.org> (raw)
In-Reply-To: <1fa5a1b7-f35f-49b9-8d87-dd4e0aa3bf68@linux.dev>
On 9/25/26 2:15 AM, John Garry wrote:
> On 9/24/26 23:54, Bart Van Assche wrote:
>> static inline void
>> sdeb_data_lock(struct sdeb_store_info *sip, bool atomic)
>> + __acquires(&sip->macc_data_lck)
>
> Is this proper?
>
> sdeb_data_lock() can call sdeb_data_read_lock(), and
> sdeb_data_read_lock() uses __acquires_shared().
>
> Indeed, but functions which sdeb_data_lock() call already have lock
> context annotations, so I wonder if this annotation is even needed.
>
>> + __context_unsafe(/*conditional locking*/)
Hi John,
Some annotations are needed. If I remove both annotations Clang reports
the following warnings:
drivers/scsi/scsi_debug.c:4168:3: error: rwlock 'sip->macc_data_lck' is
acquired exclusively and shared in the same scope
[-Werror,-Wthread-safety-analysis]
4168 | sdeb_data_write_lock(sip);
| ^
drivers/scsi/scsi_debug.c:4170:3: note: the other acquisition of rwlock
'sip->macc_data_lck' is here
4170 | sdeb_data_read_lock(sip);
| ^
drivers/scsi/scsi_debug.c:4171:1: error: rwlock 'sip->macc_data_lck' is
still held at the end of function [-Werror,-Wthread-safety-analysis]
4171 | }
| ^
drivers/scsi/scsi_debug.c:4168:3: note: rwlock acquired here
4168 | sdeb_data_write_lock(sip);
| ^
drivers/scsi/scsi_debug.c:4177:3: error: releasing rwlock
'sip->macc_data_lck' that was not held [-Werror,-Wthread-safety-analysis]
4177 | sdeb_data_write_unlock(sip);
| ^
drivers/scsi/scsi_debug.c:4179:3: error: releasing rwlock
'sip->macc_data_lck' that was not held [-Werror,-Wthread-safety-analysis]
4179 | sdeb_data_read_unlock(sip);
| ^
Thanks,
Bart.
next prev parent reply other threads:[~2026-09-25 15:55 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-24 22:54 [PATCH v2 0/7] scsi_debug: Enable lock context analysis Bart Van Assche
2026-09-24 22:54 ` [PATCH v2 1/7] scsi: scsi_debug: Fix a locking bug in resp_write_same() Bart Van Assche
2026-09-25 7:06 ` Christoph Hellwig
2026-09-25 8:43 ` John Garry
2026-09-24 22:54 ` [PATCH v2 2/7] scsi: scsi_debug: Split resp_write_same() Bart Van Assche
2026-09-25 7:08 ` Christoph Hellwig
2026-09-25 8:50 ` John Garry
2026-09-24 22:54 ` [PATCH v2 3/7] scsi: scsi_debug: Split corrupt_lbas() Bart Van Assche
2026-09-25 7:09 ` Christoph Hellwig
2026-09-25 8:55 ` John Garry
2026-09-24 22:54 ` [PATCH v2 4/7] scsi: scsi_debug: Split resp_read_dt0() Bart Van Assche
2026-09-25 7:10 ` Christoph Hellwig
2026-09-25 9:06 ` John Garry
2026-09-24 22:54 ` [PATCH v2 5/7] scsi: scsi_debug: Split resp_write_dt0() Bart Van Assche
2026-09-25 7:12 ` Christoph Hellwig
2026-09-24 22:54 ` [PATCH v2 6/7] scsi: scsi_debug: Improve lock context annotations Bart Van Assche
2026-09-25 9:15 ` John Garry
2026-09-25 15:55 ` Bart Van Assche [this message]
2026-09-24 22:54 ` [PATCH v2 7/7] scsi: core: Enable lock context analysis for the scsi_debug driver Bart Van Assche
2026-09-25 7:13 ` Christoph Hellwig
2026-09-25 9:16 ` John Garry
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=08ca7fe8-a767-412d-9e51-716de27748fb@acm.org \
--to=bvanassche@acm.org \
--cc=hch@lst.de \
--cc=john.g.garry@oracle.com \
--cc=john.garry@linux.dev \
--cc=linux-scsi@vger.kernel.org \
--cc=martin.petersen@oracle.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox