From: sashiko-bot@kernel.org
To: "Bart Van Assche" <bvanassche@acm.org>
Cc: linux-scsi@vger.kernel.org
Subject: Re: [PATCH v3 6/7] scsi: scsi_debug: Improve lock context annotations
Date: Tue, 29 Sep 2026 23:35:30 +0000 [thread overview]
Message-ID: <20260929233530.7CD061F000FF@smtp.kernel.org> (raw)
In-Reply-To: <c0546935640ceffd1b0513753dd469833e767c5e.1790723966.git.bvanassche@acm.org>
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
- [Low] scsi_debug: unconditional exclusive lock annotation for conditional lock
- [Low] scsi_debug: omitted fallback lock tracking in lock annotations
--
commit 2f1a5cf89b239b8a5043e8baea7eb6d404bcc911
Author: Bart Van Assche <bvanassche@acm.org>
scsi: scsi_debug: Improve lock context annotations
This commit prepares the scsi_debug driver for enabling compiler-based lock
context analysis. It annotates lock and unlock helper functions with
acquires and releases macros while removing sparse acquire/release calls
that mislead the analyzer.
> diff --git a/drivers/scsi/scsi_debug.c b/drivers/scsi/scsi_debug.c
> index 44840ba0c5b58..a6cd958855411 100644
> --- a/drivers/scsi/scsi_debug.c
> +++ b/drivers/scsi/scsi_debug.c
[ ... ]
> @@ -4155,6 +4163,8 @@ sdeb_data_sector_write_unlock(struct sdeb_store_info *sip)
>
> static inline void
> sdeb_data_lock(struct sdeb_store_info *sip, bool atomic)
> + __acquires(&sip->macc_data_lck)
> + __context_unsafe(/*conditional locking*/)
> {
> if (atomic)
> sdeb_data_write_lock(sip);
> else
> sdeb_data_read_lock(sip);
> }
[Severity: Low]
Does unconditionally declaring an exclusive lock capability here cause
incorrect compile-time static analysis tracking?
When atomic is false, sdeb_data_read_lock() is called which acquires a
shared lock, but the __acquires() annotation marks it as exclusively
locked. Could this suppress valid compile-time warnings for data races
by tracking shared locks as exclusive?
[ ... ]
> /* Allow many reads but only 1x write per sector */
> static inline void
> sdeb_data_sector_lock(struct sdeb_store_info *sip, bool do_write)
> + __acquires(&sip->macc_sector_lck)
> + __context_unsafe(/*conditional locking*/)
> {
> if (do_write)
> sdeb_data_sector_write_lock(sip);
> else
> sdeb_data_sector_read_lock(sip);
> }
[Severity: Low]
Similar to sdeb_data_lock() above, does this annotation incorrectly track
a shared lock as an exclusive lock when do_write is false?
[ ... ]
> static inline void
> sdeb_meta_read_lock(struct sdeb_store_info *sip)
> + __acquires_shared(&sip->macc_meta_lck)
> + __context_unsafe(/*conditional locking*/)
> {
> - if (sdebug_no_rwlock) {
> - if (sip)
> - __acquire(&sip->macc_meta_lck);
> - else
> - __acquire(&sdeb_fake_rw_lck);
> - } else {
> + if (!sdebug_no_rwlock) {
> if (sip)
> read_lock(&sip->macc_meta_lck);
> else
> read_lock(&sdeb_fake_rw_lck);
[Severity: Low]
Does the annotation completely omit tracking for the fallback
sdeb_fake_rw_lck?
If sip is NULL, the lock tracking seems to fall back to a dummy
capability rather than the actual sdeb_fake_rw_lck. Could this
prevent the analyzer from properly tracking accesses to data
protected by the fallback lock?
[ ... ]
> static inline void
> sdeb_meta_write_lock(struct sdeb_store_info *sip)
> + __acquires(&sip->macc_meta_lck)
> + __context_unsafe(/*conditional locking*/)
> {
> - if (sdebug_no_rwlock) {
> - if (sip)
> - __acquire(&sip->macc_meta_lck);
> - else
> - __acquire(&sdeb_fake_rw_lck);
> - } else {
> + if (!sdebug_no_rwlock) {
> if (sip)
> write_lock(&sip->macc_meta_lck);
> else
> write_lock(&sdeb_fake_rw_lck);
[Severity: Low]
Does this also omit tracking for the sdeb_fake_rw_lck when sip is NULL?
--
Sashiko AI review · https://sashiko.dev/#/patchset/cover.1790723966.git.bvanassche@acm.org?part=6
next prev parent reply other threads:[~2026-09-29 23:35 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-29 23:22 [PATCH v3 0/7] scsi_debug: Enable lock context analysis Bart Van Assche
2026-09-29 23:22 ` [PATCH v3 1/7] scsi: scsi_debug: Fix a locking bug in resp_write_same() Bart Van Assche
2026-09-29 23:22 ` [PATCH v3 2/7] scsi: scsi_debug: Split resp_write_same() Bart Van Assche
2026-09-29 23:22 ` [PATCH v3 3/7] scsi: scsi_debug: Split corrupt_lbas() Bart Van Assche
2026-09-29 23:23 ` [PATCH v3 4/7] scsi: scsi_debug: Split resp_read_dt0() Bart Van Assche
2026-09-29 23:23 ` [PATCH v3 5/7] scsi: scsi_debug: Split resp_write_dt0() Bart Van Assche
2026-09-29 23:23 ` [PATCH v3 6/7] scsi: scsi_debug: Improve lock context annotations Bart Van Assche
2026-09-29 23:35 ` sashiko-bot [this message]
2026-09-30 13:16 ` Bart Van Assche
2026-09-29 23:23 ` [PATCH v3 7/7] scsi: core: Enable lock context analysis for the scsi_debug driver Bart Van Assche
2026-10-03 14:24 ` [PATCH v3 0/7] scsi_debug: Enable lock context analysis Martin K. Petersen (Oracle)
2026-10-04 22:39 ` Bart Van Assche
2026-10-06 1:39 ` Martin K. Petersen
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=20260929233530.7CD061F000FF@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=bvanassche@acm.org \
--cc=linux-scsi@vger.kernel.org \
--cc=sashiko-reviews@lists.linux.dev \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.