NVMe SQ Associations: From Storage Membership to I/O Queue Routing

21 minute read

繁體中文

00.01.A host knows which namespace an I/O targets, but the controller can also benefit from knowing which storage set a submission queue is intended to serve. SQ Associations supplies that hint when the queue is created. This report connects storage membership, queue setup and command routing, explaining when the hint helps and why successful I/O alone does not prove correct routing.

SQ Associations
A queue-creation hint identifying the NVM Set that an SQ is intended to serve.
controller
Controller, the entity that implements the NVMe interface, fetches commands, and reports completions.
namespace
A logical storage space selected by NSID.
Host
The system running the operating system and issuing NVMe commands.
I/O
Input/Output, the class of data operations performed on a namespace.
SQ
Submission Queue; a memory queue in which the host places commands for execution.

The main ideas

01

Distinguish three relationships

01-01A namespace belongs to a set, an SQ is associated with a set, and completions go to a CQ. Each relationship answers a different question; identifiers are not interchangeable.

CQ
Completion Queue; a memory queue in which the controller posts command completions.
02

Check the hint’s prerequisites

02-01Discover controller support, distinguish mode enablement from support, and consider the set’s current operating window. Capability bits alone provide no fixed application-latency bound.

03

Connect storage queries to queue creation

03-01Read actual set identifiers and namespace membership, then encode Create I/O SQ. List index, byte position and identifier serve different purposes, as does the count encoding for a 64-entry queue.

entry
One list record; an NVM Set Attributes Entry occupies 128 bytes.
index
A zero-based entry position within the list.
04

Check routing for each I/O

04-01Follow command NSID to set to an associated SQ. Compare invalid creation parameters with later queue misuse and their different specified consequences.

NSID
Namespace Identifier; identifies the namespace targeted by an I/O command.

00.02.Assumes operating systems, computer organization and basic SSD knowledge. Sets 7/9, SQ3/4/5, CQ2 and namespace identifiers are illustrative; actual support and identifiers come from the device.

00.03.Start with the queue selection for one I/O, establish the overview, then follow queries, fields and results.

Connecting the main ideas

00.04.One example runs throughout: namespaces A/B belong to set 7 and C to set 9. SQ3/SQ4 serve set 7, SQ5 serves set 9, and completions can share CQ2. Follow where each identifier comes from, where it is encoded and how it selects an SQ.

00.05.SQ Associations is an optional hint for Predictable Latency Mode. Support for the hint, correctness of the hint and the mode’s current quality of service are separate questions.

Predictable Latency Mode
A mode providing deterministic read/write latency per NVM Set during operating windows subject to specified conditions.

01 Tell the controller which set a queue serves

Storage membership, queue hints and completion pathsFollow top to bottom: namespace membership, the matching set chosen for each SQ, then the shared destination for completions. The links do not move namespace storage into host queues. Sources: Base §§3.2.2, 3.3, 5.3.2 and 8.1.28.NVM Set 7A: NSID11 · B: NSID12NVM Set 9C: NSID21SQ3 + SQ4NVMSETID = 7SQ5NVMSETID = 9CQ2Shared completions; set membership unchanged
Follow top to bottom: namespace membership, the matching set chosen for each SQ, then the shared destination for completions. The links do not move namespace storage into host queues. Sources: Base §§3.2.2, 3.3, 5.3.2 and 8.1.28.
NVMSETID
A 16-bit NVM Set identifier, distinct from SQ identifiers and NSIDs.
NVM Set
A logically separate collection of non-volatile memory that may contain multiple namespaces.
NVM
Non-Volatile Memory, memory that retains data without power.

01.01.SQ Associations lets a host associate an I/O Submission Queue with an NVM Set at queue creation, providing a hint for improved performance with Predictable Latency Mode. It is optional; Predictable Latency Mode does not depend on using SQ Associations.

Sources: Base 2.4 §8.1.28

Source: NVME-BASE-2.4, Rev. 2.4, §8.1.28, printed pages 732-733, PDF pages 758-759

02 Separate support, mode state and operating windows

Three separate questions about one controller
ObservationWhat it establishesWhat it does not establish
Three CTRATT bits are oneSQA, NVM Sets and PLM are supportedMode is currently enabled for set 7
Mode enabled for set 7Operating-window rules apply to that setThe set must currently be in DTWIN
Set 7 is in DTWINDeterministic latency under its conditionsUnlimited workload or a bound on all PCIe latency
SQ3 associated with set 7The controller received the queue hintEvery later I/O is necessarily routed correctly
Support, configuration, window state and host routing remain distinct. Sources: Base §§8.1.28, 8.1.21 and Figure 338.
CTRATT
Controller Attributes; a field of capability bits in Identify Controller.
DTWIN
Deterministic Window; the operating window in which a set can provide deterministic read/write latency.
PCIe
PCI Express, the transport and device interconnect used by an NVMe memory-based controller.
PLM
Predictable Latency Mode; the CTRATT bit reporting mode support.
SQA
SQ Associations; the CTRATT bit reporting support for queue-to-set association.

02.01.A controller supporting SQ Associations must advertise SQA, NVM Sets and Predictable Latency Mode in CTRATT. These support bits do not mean that every set has the mode enabled or is currently in a deterministic window.

Sources: Base 2.4 §8.1.28

Source: NVME-BASE-2.4, Rev. 2.4, §8.1.28, printed pages 732-733, PDF pages 758-759

03 Map namespaces to sets before routing commands

List position is not a set identifier
List indexByte range in the listNSETID inside the entryUse at SQ creation
0128–2557CDW12=00000007h
1256–3839CDW12=00000009h
Illustrative NUMENT=2: use the position to find the record, then read its identifier. Do not encode indices 0/1 or offsets 128/256 as set IDs. Sources: Base Figures 344/345/578.
NSETID
NVM Set Identifier; the name used for the set identifier in an NVM Set Attributes Entry.
NUMENT
Number of Entries; the number of entries actually returned in the list.
CDW
CDW (Command Dword): a 32-bit command field. In CDW10, 10 is the field index, not a byte offset.

03.01.The host needs two kinds of information: the NVM Set List identifies accessible sets, while Identify Namespace identifies the set containing a namespace. List position, NVM Set Identifier and NSID are different values.

Sources: Base 2.4 §5.2.14.2.4

Source: NVME-BASE-2.4, Rev. 2.4, §5.2.14.2.4, printed pages 388-389, PDF pages 414-415

04 Select both the set and completion queue when creating an SQ

Check the parameters for a 64-entry SQ3
Command locationComposition in this exampleEncoded value
CDW10Upper 16: 64−1=63; lower 16: QID3003F0003h
CDW11Upper 16: CQID2; PC=1; QPRIO=000020001h
CDW12Lower 16: set 7; upper 16 reserved00000007h
PRP1Allocated contiguous host memory, 4 KiB aligned0000000000100000h
Assumes existing CQ2, available set 7, SQA support, initialized controller and sufficient depth. Round-robin arbitration ignores QPRIO. Sources: Base §5.3.2 and Figures 575–578.
QPRIO
Queue Priority; used only by the applicable weighted round-robin arbitration mechanism.
PRP1
PRP Entry 1; holds the queue base or PRP List address according to PC.
PC
Physically Contiguous; one selects contiguous queue memory, zero a page-list description.

04.01.Create I/O Submission Queue uses CDW12.NVMSETID for the set association and CDW11.CQID for the destination completion queue. NVMSETID=0 or unsupported SQA means no specific set association. With SQA supported, a nonzero identifier absent from the set list must cause Invalid Field in Command.

CQID
Completion Queue Identifier; selects the destination CQ for this SQ’s completions.
Sources: Base 2.4 §5.3.2

Source: NVME-BASE-2.4, Rev. 2.4, §5.3.2, printed pages 529-531, PDF pages 555-557

05 Keep each I/O’s set consistent with its SQ association

Select an SQ from NSID; CQID does not select storageFollow NSID21. A less busy SQ3 still has the wrong set hint; sharing CQ2 does not change the decision. Sources: Base §8.1.28 and Figures 346/578.I/O · NSID21Identify namespace → NVMSETID = 9First establish storage membershipSQ5 → Set 9Match: use SQ5SQ3 → Set 7Mismatch: do not select SQ3
Follow NSID21. A less busy SQ3 still has the wrong set hint; sharing CQ2 does not change the decision. Sources: Base §8.1.28 and Figures 346/578.

05.01.To obtain the benefits of SQ Associations, the host must associate each I/O submission queue with an NVM Set and send commands only to queues matching the set containing the command’s NSID. Violating the operating rules may affect Predictable Latency; this section does not define mandatory access-control rejection of mismatched commands.

Sources: Base 2.4 §8.1.28

Source: NVME-BASE-2.4, Rev. 2.4, §8.1.28, printed pages 733, PDF pages 759

A forward route through the specification

R-1Explain the mechanism with the overview and examples, then follow these Base PDF viewer pages in order. On shared pages, start at the specified heading and stop before the next named heading. The Chinese tutorial explains necessary background without repeated reference detours.

Page orderStart sectionFocus and stop heading
R1 · Base PDF 363–365§5.2.14Read CNS/CNSSID in Figures 333/334, then only CNS 01h/04h/08h and their relevant footnotes in Figure 336. Skip the other CNS rows. Stop before §5.2.14.1.
R2 · Base PDF 370–372§5.2.14.2.1In Figure 338, locate CTRATT at bytes 99:96 and read only SQA bit 8, PLM bit 5 and NSETS bit 2. Stop after those bits. Stop before §5.2.14.2.2.
R3 · Base PDF 414–415§5.2.14.2.4Start at NVM Set List. Use entries for sets 7/9 to explain the starting ID, NUMENT and entries, separating the 128-byte stride from actual identifiers. Stop before §5.2.14.2.5.
R4 · Base PDF 416–419§5.2.14.2.8Check the response condition for an active NSID, then locate NVMSETID at bytes 11:10 and adjacent ENDGID in Figure 346. Stop after membership fields. Stop before §5.2.14.2.9.
R5 · Base PDF 555–557§5.3.2Connect Figures 575–579 with SQ3, CQ2 and set 7, emphasizing the different roles of CDW12/CDW11 and the result of an invalid set at creation. Stop before §5.3.3.
R6 · Base PDF 708–709§8.1.21Read the mode introduction, Figure 751 and the operating conditions in §8.1.21.1, stopping before Figure 752. Separate window state from mode enablement without expanding full configuration. Stop before §8.1.21.2.
R7 · Base PDF 758–759§8.1.28Start at Submission Queue (SQ) Associations and conclude with the complete primary scope: optional hint, support prerequisites, association at creation and the two host routing rules. Stop before §8.1.29.
CNSSID
CNS Specific Identifier; its meaning depends on the selected CNS value.
ENDGID
Endurance Group Identifier; identifies the endurance group containing a set or namespace.
CNS
Controller or Namespace Structure; selects the data returned by Identify.
Open the complete Chinese tutorial and figure explanations →

Check your understanding

1. Do all three capability bits being one guarantee the completion time of the next read?

07.01.No. They report support. Check mode enablement for the target set, the current window and operating limits; the quality-of-service description also excludes PCIe connection latency.

Sources

Source: NVME-BASE-2.4, Rev. 2.4, §8.1.28, printed pages 732-733, PDF pages 758-759

Source: NVME-BASE-2.4, Rev. 2.4, §8.1.21, printed pages 682-683, PDF pages 708-709

2. Entry 1 contains NSETID=9. Should queue creation encode 1, 256 or 9?

07.02.Encode 9. One is the index, 256 is the entry’s byte offset from the list start, and nine is the set identifier for CDW12.

Sources

Source: NVME-BASE-2.4, Rev. 2.4, §5.2.14.2.4, printed pages 388-389, PDF pages 414-415

Source: NVME-BASE-2.4, Rev. 2.4, §5.3.2, printed pages 529-531, PDF pages 555-557

3. NSID21 belongs to set 9, and SQ3/SQ5 share CQ2. Can either SQ be selected?

07.03.Use SQ5, associated with set 9 in this example. Sharing a CQ only shares the completion destination; SQ3 remains associated with set 7.

Sources

Source: NVME-BASE-2.4, Rev. 2.4, §8.1.28, printed pages 733, PDF pages 759

Source: NVME-BASE-2.4, Rev. 2.4, §3.3, printed pages 88, PDF pages 114

4. Does NVMSETID=0 create a shared hint for every set?

07.04.No. Create I/O SQ defines zero as no association with a specific set. It does not provide the association required for the routing discipline described here.

Sources

Source: NVME-BASE-2.4, Rev. 2.4, §5.3.2, printed pages 529-531, PDF pages 555-557

Source: NVME-BASE-2.4, Rev. 2.4, §8.1.28, printed pages 733, PDF pages 759

5. An I/O for set 9 succeeds on an SQ associated with set 7. Does success prove correct host use?

07.05.No. Misrouting violates the operating rules and may affect predictable latency; §8.1.28 does not require rejection with an error each time. This differs from an unsupported nonzero set identifier at SQ creation, which must cause Invalid Field in Command.

Sources

Source: NVME-BASE-2.4, Rev. 2.4, §8.1.28, printed pages 733, PDF pages 759

Source: NVME-BASE-2.4, Rev. 2.4, §5.3.2, printed pages 529-531, PDF pages 555-557

Specification editions

NVM Express Base Specification, Revision 2.4

Jia-Chang

Jia-Chang

Human

Comments

  Write a comment ...