public inbox for linux-scsi@vger.kernel.org
 help / color / mirror / Atom feed
From: John Garry <john.g.garry@oracle.com>
To: Bart Van Assche <bvanassche@acm.org>,
	martin.petersen@oracle.com,
	james.bottomley@hansenpartnership.com
Cc: linux-scsi@vger.kernel.org, jiangjianjun3@huawei.com
Subject: Re: [PATCH 2/6] scsi: scsi_debug: Stop using READ/WRITE_ONCE() when accessing sdebug_defer.defer_t
Date: Fri, 14 Nov 2025 09:02:05 +0000	[thread overview]
Message-ID: <a0e4fdd2-3dce-46c8-94ad-cdddbf90676a@oracle.com> (raw)
In-Reply-To: <0108b7fd-77c5-4aa5-a761-2a7640d2a024@acm.org>

On 13/11/2025 17:45, Bart Van Assche wrote:
> 
> On 11/13/25 5:36 AM, John Garry wrote:
>> Using READ/WRITE_ONCE() means that the read or write is not torn by the
>> compiler.
>>
>> READ/WRITE_ONCE() is always used when accessing sdebug_defer.defer_t.
>>
>> However, we also guard the access in a spinlock when accessing that 
>> member,
>> and spinlock already guarantees no tearing, so stop using
>> READ/WRITE_ONCE().
> 
> According to the Linux kernel memory model, if a variable is accessed
> outside a critical section then READ_ONCE() and WRITE_ONCE() must be
> used when accessing that variable inside a critical section.

So do you see a problem with this patch? As mentioned, 
sdebug_defer.defer_t is already only accessed with a spinlock held 
(sdebug_scsi_cmd.lock) (which I consider being a critical section).

Thanks,
John

  reply	other threads:[~2025-11-14  9:02 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-11-13 13:36 [PATCH RFT 0/6] scsi_debug: fake timeout handling improvements John Garry
2025-11-13 13:36 ` [PATCH 1/6] scsi: scsi_debug: Stop printing extra function name in debug logs John Garry
2025-11-13 13:36 ` [PATCH 2/6] scsi: scsi_debug: Stop using READ/WRITE_ONCE() when accessing sdebug_defer.defer_t John Garry
2025-11-13 17:45   ` Bart Van Assche
2025-11-14  9:02     ` John Garry [this message]
2025-11-14 16:27       ` Bart Van Assche
2025-11-13 13:36 ` [PATCH 3/6] scsi: scsi_debug: Drop NULL scsi_cmnd check in sdebug_q_cmd_complete() John Garry
2025-11-13 17:46   ` Bart Van Assche
2025-11-14  9:02     ` John Garry
2025-11-13 13:36 ` [PATCH RFT 4/6] scsi: scsi_debug: Call sdebug_q_cmd_complete() from sdebug_blk_mq_poll_iter() John Garry
2025-11-13 13:36 ` [PATCH RFT 5/6] scsi: scsi_debug: Clear sd_dp->defer_t in sdebug_q_cmd_complete() John Garry
2025-11-13 13:36 ` [PATCH RFT 6/6] scsi: scsi_debug: Add special abort handling for fake timeout John Garry
2025-12-01 15:32 ` [PATCH RFT 0/6] scsi_debug: fake timeout handling improvements John Garry
2025-12-17  2:48   ` Martin K. Petersen
2025-12-17 12:48     ` John Garry
2026-04-16  2:30       ` JiangJianJun
2026-04-16  9:12         ` John Garry
2026-01-04 21:43 ` (subset) " 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=a0e4fdd2-3dce-46c8-94ad-cdddbf90676a@oracle.com \
    --to=john.g.garry@oracle.com \
    --cc=bvanassche@acm.org \
    --cc=james.bottomley@hansenpartnership.com \
    --cc=jiangjianjun3@huawei.com \
    --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