Re: [PATCH v5 5/6] scsi: core: Protect host state changes with the host lock
Bart Van Assche <[email protected]>
| Newsgroups | org.kernel.vger.linux-scsi |
|---|---|
| Message-ID | <[email protected]> |
On 8/6/26 2:13 AM, John Garry wrote:
> On 05/08/2026 22:36, Bart Van Assche wrote:
>> +static inline enum scsi_host_state scsi_get_host_state(struct
>> Scsi_Host *shost)
>> +{
>> + return context_unsafe(READ_ONCE(shost->shost_state));
>
> I am wondering if it may be better to protect reading this with the
> spinlock as well. We could lose the READ_ONCE and WRITE_ONCE. And we
> would be more symmetrical with the set function.
>
> I really don't feel strongly about this, though.
I prefer lockless access from scsi_get_host_state() because this
function is called from the hot path. Using locking inside this
function would cause lock contention on the host lock in the hot path.
Thanks,
Bart.