Linux ATA/IDE development
 help / color / mirror / Atom feed
From: Niklas Cassel <cassel@kernel.org>
To: Damien Le Moal <dlemoal@kernel.org>
Cc: Bart Van Assche <bvanassche@acm.org>,
	Marco Elver <elver@google.com>,
	linux-ide@vger.kernel.org
Subject: Re: [PATCH 1/3] ata: libata-scsi: Remove lockdep_assert_held() in ata_scsi_translate()
Date: Sun, 31 May 2026 15:47:35 +0200	[thread overview]
Message-ID: <ahw794UEfbGSO8d_@ryzen> (raw)
In-Reply-To: <07a727ab-7f0a-4574-8cac-a9e876b1e6be@kernel.org>

On Fri, May 29, 2026 at 03:42:31PM +0900, Damien Le Moal wrote:
> On 2026/05/29 2:28, Niklas Cassel wrote:
> > lockdep_assert_held() indirectly calls __assume_ctx_lock(), which will
> > suppress any real context analysis from being performed.
> > 
> > Remove the lockdep_assert_held(). This will be replaced with context
> > analysis in a follow-up commit.
> 
> I am not really liking the idea of removing runtime checks and replacing them
> with compile time checks that work only with clang. What about gcc ?

Intel 0-day CI testing robot builds with Clang as well.


> And are we sure that the compile time checks are as solid as the runtime
> ones ?

Runtime checking can be performed on more complex cases (like Marco said checks
in runtime does allow to compare two pointers which might point to the same
object, which is something that context analysis might cannot catch), however I
expect in the cases where compile time analysis is possible, as it is in this
case (since we now supply an ap pointer), it will be as solid as runtime checks.


> 
> As the sashiko comment mentions, can't we keep this and simply add a
> __must_hold() annotation in the declaration ?

What I don't like about it is that, since lockdep_assert_held() has a
__assume_ctx_lock(), it will tell the compiler that that the function
always has the lock, which renders the __must_hold() in ata_scsi_translate()
useless. I can even remove the annotation without getting a build error.
(So it basically yields the __most_hold() in ata_scsi_translate() a no-op.)

Without the lockdep_assert_held(), we do get a build error if
ata_scsi_translate() is missing the __must_hold() annotation.
I do like the fact that we get an error if we don't have annotations all
the way from ata_scsi_queuecmd() to ata_qc_issue(), if there is a function
in between that is missing annotations.

And since the lockdep_assert_held() was added only in December last year,
I don't see the big deal with replacing it with a compile time check.

But since both you and Bart seem to want to keep it, let's can keep it.


Kind regards,
Niklas

  reply	other threads:[~2026-05-31 13:47 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-05-28 17:28 [PATCH 0/3] ata: add __must_hold(ap->lock) annotations in issuing path Niklas Cassel
2026-05-28 17:28 ` [PATCH 1/3] ata: libata-scsi: Remove lockdep_assert_held() in ata_scsi_translate() Niklas Cassel
2026-05-28 17:33   ` Bart Van Assche
2026-05-28 17:54     ` Niklas Cassel
2026-05-28 19:48       ` Bart Van Assche
2026-05-28 17:51   ` sashiko-bot
2026-05-29  6:22   ` Hannes Reinecke
2026-05-29  6:42   ` Damien Le Moal
2026-05-31 13:47     ` Niklas Cassel [this message]
2026-05-28 17:28 ` [PATCH 2/3] ata: libata: Pass ap parameter directly to functions in the issuing path Niklas Cassel
2026-05-29  6:22   ` Hannes Reinecke
2026-05-28 17:28 ` [PATCH 3/3] ata: Annotate functions in the issuing path with __must_hold() Niklas Cassel
2026-05-29  6:23   ` Hannes Reinecke
2026-05-31 14:00 ` (subset) [PATCH 0/3] ata: add __must_hold(ap->lock) annotations in issuing path Niklas Cassel

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=ahw794UEfbGSO8d_@ryzen \
    --to=cassel@kernel.org \
    --cc=bvanassche@acm.org \
    --cc=dlemoal@kernel.org \
    --cc=elver@google.com \
    --cc=linux-ide@vger.kernel.org \
    /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