Skip to contentSkip to conversation

nvme: write streams are used even when streams are disabled

PATCH In review Cassiano Campes 2 participants 2 messages Sep 17, 2019 NVMe

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 nvme: write streams are used even when streams are disabled

Even when the streams flag at the nvme_core module is not set, the nvme_assign_write_stream is called unnecessarily, and the write hint is passed to the controller, thus resulting in a shadowed stream usage.

Although the user application may pass the write_hint to the device driver, the user may have disabled the streams support by toggling the /sys/module/nvme_core/parameters/streams flag.

Later, the user may want to enable the streams support to get some write performance improvement, however the user will not notice any performance difference because the write streams separation was already happening although the streams flag was not set.

---
 drivers/nvme/host/core.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/nvme/host/core.c +1 -1
index d3d6b7bd6903..5a77aea0a58e 100644
@@ -645,7 +645,7 @@ static inline blk_status_t nvme_setup_rw(struct nvme_ns *ns,
 	cmnd->rw.slba = cpu_to_le64(nvme_block_nr(ns, blk_rq_pos(req)));
 	cmnd->rw.length = cpu_to_le16((blk_rq_bytes(req) >> ns->lba_shift) - 1);
 
-	if (req_op(req) == REQ_OP_WRITE && ctrl->nr_streams)
+	if (req_op(req) == REQ_OP_WRITE && ctrl->nr_streams && streams)
 		nvme_assign_write_stream(ctrl, req, &control, &dsmgmt);
 
 	if (ns->ms) {
Signature · 7 lines
2.17.1


_______________________________________________
Linux-nvme mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-nvme
maintainer
#1 lore raw
Quoted 3 lines · Cassiano Campes

Even when the streams flag at the nvme_core module is not set, the nvme_assign_write_stream is called unnecessarily, and the write hint is passed to the controller, thus resulting in a shadowed stream usage.

If the parameter was disabled when the controller was initialized, ctrl->nr_streams is 0, so streams already will not be used.

If you start the module with the parameter enabled, but then disable it at runtime, the controller was previously initialized to enable directives. This should probably be writeable only at modprobe time, or you'd have to require to reset each stream enabled controller in order to disable the streams directives.

Quoted 20 lines

Although the user application may pass the write_hint to the device driver, the user may have disabled the streams support by toggling the /sys/module/nvme_core/parameters/streams flag.

Later, the user may want to enable the streams support to get some write performance improvement, however the user will not notice any performance difference because the write streams separation was already happening although the streams flag was not set.

---
 drivers/nvme/host/core.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/nvme/host/core.c +0 -0
index d3d6b7bd6903..5a77aea0a58e 100644

drivers/nvme/host/core.c static inline blk_status_t nvme_setup_rw(struct nvme_ns *ns, · line 651

Quoted 8 lines
drivers/nvme/host/core.c +1 -1
@@ -645,7 +645,7 @@ static inline blk_status_t nvme_setup_rw(struct nvme_ns *ns,
 	cmnd->rw.slba = cpu_to_le64(nvme_block_nr(ns, blk_rq_pos(req)));
 	cmnd->rw.length = cpu_to_le16((blk_rq_bytes(req) >> ns->lba_shift) - 1);
 
-	if (req_op(req) == REQ_OP_WRITE && ctrl->nr_streams)
+	if (req_op(req) == REQ_OP_WRITE && ctrl->nr_streams && streams)
 		nvme_assign_write_stream(ctrl, req, &control, &dsmgmt);
 
 	if (ns->ms) {

_______________________________________________
Linux-nvme mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-nvme