public inbox for linux-block@vger.kernel.org
 help / color / mirror / Atom feed
From: Ming Lei <ming.lei@redhat.com>
To: Nilay Shroff <nilay@linux.ibm.com>
Cc: Christoph Hellwig <hch@lst.de>,
	linux-block@vger.kernel.org, dlemoal@kernel.org, axboe@kernel.dk,
	gjoyce@ibm.com
Subject: Re: [PATCHv2 1/6] blk-sysfs: remove q->sysfs_lock for attributes which don't need it
Date: Sat, 22 Feb 2025 20:44:51 +0800	[thread overview]
Message-ID: <Z7nGw_PJfAld8fAz@fedora> (raw)
In-Reply-To: <cecc5d49-9a54-4285-a0d2-32699cb1f908@linux.ibm.com>

On Fri, Feb 21, 2025 at 07:32:52PM +0530, Nilay Shroff wrote:
> 
> Hi Christoph, Ming and others,
> 
> On 2/18/25 4:56 PM, Nilay Shroff wrote:
> > 
> > 
> > On 2/18/25 2:16 PM, Christoph Hellwig wrote:
> >> On Tue, Feb 18, 2025 at 01:58:54PM +0530, Nilay Shroff wrote:
> >>> There're few sysfs attributes in block layer which don't really need
> >>> acquiring q->sysfs_lock while accessing it. The reason being, writing
> >>> a value to such attributes are either atomic or could be easily
> >>> protected using WRITE_ONCE()/READ_ONCE(). Moreover, sysfs attributes
> >>> are inherently protected with sysfs/kernfs internal locking.
> >>>
> >>> So this change help segregate all existing sysfs attributes for which 
> >>> we could avoid acquiring q->sysfs_lock. We group all such attributes,
> >>> which don't require any sorts of locking, using macro QUEUE_RO_ENTRY_
> >>> NOLOCK() or QUEUE_RW_ENTRY_NOLOCK(). The newly introduced show/store 
> >>> method (show_nolock/store_nolock) is assigned to attributes using these 
> >>> new macros. The show_nolock/store_nolock run without holding q->sysfs_
> >>> lock.
> >>
> >> Can you add the analys why they don't need sysfs_lock to this commit
> >> message please?
> > Sure will do it in next patchset.
> >>
> >> With that:
> >>
> >> Reviewed-by: Christoph Hellwig <hch@lst.de>
> >>
> > 
> I think we discussed about all attributes which don't require locking,
> however there's one which I was looking at "nr_zones" which we haven't
> discussed. This is read-only attribute and currently protected with 
> q->sysfs_lock.
> 
> Write to this attribute (nr_zones) mostly happens in the driver probe
> method (except nvme) before disk is added and outside of q->sysfs_lock
> or any other lock. But in case of nvme it could be updated from disk 
> scan.   
> nvme_validate_ns
>   -> nvme_update_ns_info_block
>     -> blk_revalidate_disk_zones
>       -> disk_update_zone_resources
> 
> The update to disk->nr_zones is done outside of queue freeze or any 
> other lock today. So do you agree if we could use READ_ONCE/WRITE_ONCE
> to protect this attribute and remove q->sysfs_lock? I think, it'd be 
> great if we could agree upon this one before I send the next patchset.

IMO, it is fine to read it lockless without READ_ONCE/WRITE_ONCE because
disk->nr_zones is defined as 'unsigned int', which won't return garbage
value anytime.

But I don't object if you want to change to READ_ONCE/WRITE_ONCE.


Thanks,
Ming


  reply	other threads:[~2025-02-22 12:45 UTC|newest]

Thread overview: 34+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-02-18  8:28 [PATCHv2 0/6] block: fix lock order and remove redundant locking Nilay Shroff
2025-02-18  8:28 ` [PATCHv2 1/6] blk-sysfs: remove q->sysfs_lock for attributes which don't need it Nilay Shroff
2025-02-18  8:46   ` Christoph Hellwig
2025-02-18 11:26     ` Nilay Shroff
2025-02-21 14:02       ` Nilay Shroff
2025-02-22 12:44         ` Ming Lei [this message]
2025-02-24 13:09           ` Nilay Shroff
2025-02-24 14:49           ` Christoph Hellwig
2025-02-26 12:09             ` Nilay Shroff
2025-02-24  8:41         ` Hannes Reinecke
2025-02-24 13:12           ` Nilay Shroff
2025-02-18 12:10   ` Ming Lei
2025-02-18 13:11     ` Nilay Shroff
2025-02-18 13:45       ` Ming Lei
2025-02-18 16:29         ` Christoph Hellwig
2025-02-19  3:24           ` Ming Lei
2025-02-19  5:42             ` Christoph Hellwig
2025-02-19  8:34             ` Nilay Shroff
2025-02-19  8:56               ` Nilay Shroff
2025-02-19  9:20                 ` Ming Lei
2025-02-18  8:28 ` [PATCHv2 2/6] blk-sysfs: acquire q->limits_lock while reading attributes Nilay Shroff
2025-02-18  8:46   ` Christoph Hellwig
2025-02-18  8:28 ` [PATCHv2 3/6] block: Introduce a dedicated lock for protecting queue elevator updates Nilay Shroff
2025-02-18  9:05   ` Christoph Hellwig
2025-02-18 11:14     ` Nilay Shroff
2025-02-18 16:32       ` Christoph Hellwig
2025-02-19  8:41         ` Nilay Shroff
2025-02-18  8:28 ` [PATCHv2 4/6] blk-sysfs: protect nr_requests update using q->elevator_lock Nilay Shroff
2025-02-18  8:28 ` [PATCHv2 5/6] blk-sysfs: protect wbt_lat_usec " Nilay Shroff
2025-02-18  8:28 ` [PATCHv2 6/6] blk-sysfs: protect read_ahead_kb using q->limits_lock Nilay Shroff
2025-02-18  9:12   ` Christoph Hellwig
2025-02-18 11:27     ` Nilay Shroff
2025-02-18  9:21 ` [PATCHv2 0/6] block: fix lock order and remove redundant locking Christoph Hellwig
2025-02-18 12:09   ` Nilay Shroff

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=Z7nGw_PJfAld8fAz@fedora \
    --to=ming.lei@redhat.com \
    --cc=axboe@kernel.dk \
    --cc=dlemoal@kernel.org \
    --cc=gjoyce@ibm.com \
    --cc=hch@lst.de \
    --cc=linux-block@vger.kernel.org \
    --cc=nilay@linux.ibm.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