All of lore.kernel.org
 help / color / mirror / Atom feed
From: Hannes Reinecke <hare@suse.de>
To: Nilay Shroff <nilay@linux.ibm.com>, linux-nvme@lists.infradead.org
Cc: kbusch@kernel.org, hch@lst.de, sagi@grimberg.me, dwagner@suse.de,
	kanie@linux.alibaba.com, jmeneghi@redhat.com,
	randyj@purestorage.com, martin.petersen@oracle.com,
	john.g.garry@oracle.com, gjoyce@linux.ibm.com
Subject: Re: [PATCH v8 03/10] block: support nesting for blk-mq flag QUEUE_FLAG_SAME_FORCE
Date: Wed, 19 Aug 2026 15:51:43 +0200	[thread overview]
Message-ID: <59a3afbf-421a-40fd-a90d-521004f7de2e@suse.de> (raw)
In-Reply-To: <ebfdc6e5-36ef-43ee-bd19-53b40e4682a2@linux.ibm.com>

On 8/18/26 1:59 PM, Nilay Shroff wrote:
> On 8/18/26 3:28 PM, Hannes Reinecke wrote:
>> On 8/15/26 7:34 PM, Nilay Shroff wrote:
>>> QUEUE_FLAG_SAME_FORCE is currently used when setting rq_affinity
>>> through sysfs as well as by UFS mediatek driver while configuring scsi
>>> parameters. A subsequent patch adding a latency-based I/O policy
>>> for NVMe multipath will also use this flag.
>>>
>>> With multiple users able to set and clear QUEUE_FLAG_SAME_FORCE, the
>>> flag needs to support nesting so that one user clearing the flag does
>>> not inadvertently disable it for another user.
>>>
>>> Add a nesting counter, q->same_force_depth, for QUEUE_FLAG_SAME_FORCE.
>>> The flag is set when the first user acquires it and the nesting counter
>>> is incremented for each subsequent user. Similarly, each user releases
>>> its reference by decrementing the counter. The flag is cleared only
>>> when the last user releases it and the counter reaches zero.
>>>
>>> Preserve the existing sysfs rq_affinity semantics with a new
>>> q->same_force_sysfs flag. When userspace enables QUEUE_FLAG_SAME_FORCE
>>> by writing 2 to rq_affinity, mark q->same_force_sysfs as set and
>>> increment q->same_force_depth by one. Subsequent writes of 2 to
>>> rq_affinity while q->same_force_sysfs is already set are ignored, so
>>> repeated writes of 2 from userspace do not increase q->same_force_depth.
>>> Similarly, writing 0 or 1 decrements the q->same_force_depth and if
>>> nesting counter reached to 0 then clears the QUEUE_FLAG_SAME_FORCE.
>>> This ensures that multiple writes of 2 to rq_affinity do not require
>>> multiple writes of 0 or 1.
>>>
>>> This change ensures that sysfs interface retains its existing set/clear
>>> semantics while also allowing other kernel users to hold or release
>>> QUEUE_FLAG_SAME_FORCE.
>>>
>>> Added two new APIs blk_mq_same_force_set() and blk_mq_same_force_clear()
>>> to set and clear QUEUE_FLAG_SAME_FORCE respectively. Also, updated
>>> existing call paths using these new APIs which toggles
>>> QUEUE_FLAG_SAME_FORCE.
>>>
>> Yikes. Is this really necessary?
>> The flag can be set by different subsystems/drivers, sure, but from
>> what I've seen each user is mutually exclusive.
>> I'd rather disallow modifying this flag if the driver sets it, to
>> avoid upper layers or sysfs modifying it.
>>
> 
> If we want to disallow userspace from modifying QUEUE_FLAG_SAME_FORCE
> while a driver owns it, then a userspace write to rq_affinity would have
> to either fail (e.g. with -EINVAL) or be silently ignored. In either case,
> that changes the existing userspace/sysfs semantics and may break userspace
> that expects the write to succeed.
> 
But _allowing_ userspace to modify it for drivers which requires it to
be set will break the drivers.
Similar for the upcoming latency-based I/O scheduler; disabling
QUEUE_FLAG_SAME_FORCE there will cause misaccounting and the scheduler
will not work properly.

So I would argue to have a flag for making QUEUE_FLAG_SAME_FORCE driver 
owned, and reject any attempts to change it via sysfs with EINVAL.

Cheers,

Hannes
-- 
Dr. Hannes Reinecke                  Kernel Storage Architect
hare@suse.de                                +49 911 74053 688
SUSE Software Solutions GmbH, Frankenstr. 146, 90461 Nürnberg
HRB 36809 (AG Nürnberg), GF: I. Totev, A. McDonald, W. Knoblich


  reply	other threads:[~2026-08-19 13:52 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-08-15 17:34 [PATCH v8 00/10] nvme-multipath: introduce latency I/O policy Nilay Shroff
2026-08-15 17:34 ` [PATCH v8 01/10] block: expose blk_stat_{enable,disable}_accounting() to drivers Nilay Shroff
2026-08-15 17:34 ` [PATCH v8 02/10] block: record I/O request start time for passthru request Nilay Shroff
2026-08-15 17:34 ` [PATCH v8 03/10] block: support nesting for blk-mq flag QUEUE_FLAG_SAME_FORCE Nilay Shroff
2026-08-18  9:58   ` Hannes Reinecke
2026-08-18 11:59     ` Nilay Shroff
2026-08-19 13:51       ` Hannes Reinecke [this message]
2026-08-20  6:15         ` Nilay Shroff
2026-08-15 17:34 ` [PATCH v8 04/10] nvme-multipath: pass I/O type to nvme_find_path() Nilay Shroff
2026-08-15 17:34 ` [PATCH v8 05/10] nvme-multipath: add support for latency I/O policy Nilay Shroff
2026-08-15 17:34 ` [PATCH v8 06/10] nvme: add generic debugfs support Nilay Shroff
2026-08-15 17:34 ` [PATCH v8 07/10] nvme-multipath: add debugfs attribute latency_ewma_shift Nilay Shroff
2026-08-15 17:34 ` [PATCH v8 08/10] nvme-multipath: add debugfs attribute latency_batch_timeout Nilay Shroff
2026-08-15 17:34 ` [PATCH v8 09/10] nvme-multipath: add debugfs attribute latency_stat Nilay Shroff
2026-08-15 17:34 ` [PATCH v8 10/10] nvme-multipath: add documentation for latency I/O policy Nilay Shroff
2026-08-22 22:47 ` [PATCH v8 00/10] nvme-multipath: introduce " Sagi Grimberg

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=59a3afbf-421a-40fd-a90d-521004f7de2e@suse.de \
    --to=hare@suse.de \
    --cc=dwagner@suse.de \
    --cc=gjoyce@linux.ibm.com \
    --cc=hch@lst.de \
    --cc=jmeneghi@redhat.com \
    --cc=john.g.garry@oracle.com \
    --cc=kanie@linux.alibaba.com \
    --cc=kbusch@kernel.org \
    --cc=linux-nvme@lists.infradead.org \
    --cc=martin.petersen@oracle.com \
    --cc=nilay@linux.ibm.com \
    --cc=randyj@purestorage.com \
    --cc=sagi@grimberg.me \
    /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.