1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
// Copyright (c) 2026 Mike Grier
//! [`NumaNode`], and the two questions Windows will answer about nodes.
use io;
use RawHandle;
use HANDLE;
use IODeviceIoControl;
use FSCTL_QUERY_VOLUME_NUMA_INFO;
use GetNumaHighestNodeNumber;
/// A NUMA node number, as Windows numbers them.
///
/// A newtype rather than a bare `u32` because the two `u32`s in this area mean
/// different things and are trivially swapped at a call site: a node *number*
/// and a *count* of nodes are both small integers, and
/// [`highest_numa_node`] returns the former while reading like the latter.
///
/// **Node numbers are not an index.** Windows does not promise they run
/// `0..n`, so a caller deriving a node from a position in some list is making
/// an assumption the platform never offered -- see `windows-placement-probe`,
/// where a positional index reaching `VirtualAllocExNuma` was a real defect and
/// is called out at the site that fixed it.
;
/// The highest node number this machine reports, if it answers.
///
/// `GetNumaHighestNodeNumber`. The value is a *node number*, not a count: a
/// machine with one node answers `NumaNode(0)`, not one.
///
/// # Why a caller wants this
///
/// Mostly to qualify a report rather than to drive a choice. On a machine that
/// answers `NumaNode(0)` there is exactly one node, so every placement decision
/// is the same decision, and a line saying "placed on node 0" is true and
/// misleading. Asking this is how a caller can say which of those it is.
///
/// # Errors
///
/// `None` when the call fails, which is reported as "unknown" rather than as a
/// node count of zero -- a machine that will not say how many nodes it has is a
/// different thing from a machine with none.
/// The NUMA node `handle`'s **volume** reports, if it reports one.
///
/// `FSCTL_QUERY_VOLUME_NUMA_INFO`, issued against the handle directly -- the
/// documented control code accepts a file or directory handle, so this needs no
/// device-tree walk and no second open.
///
/// # This answers a question about a volume, not about a file
///
/// The documented meaning is the node the *volume* resides on. A volume may
/// span several devices -- an ordinary spanned volume or a Storage Spaces set
/// does -- and then a single reported node is a fiction rather than an answer,
/// because the file's extents may live anywhere across the set. **It therefore
/// cannot tell a caller which node a particular file's I/O is closest to**, even
/// when it succeeds.
///
/// That is a limit of the question, not of this wrapper, and it is why this
/// function reports rather than acts: a caller who knows their storage layout
/// can decide what the answer is worth, and one who does not should not have a
/// placement chosen for them on the strength of it.
///
/// # Errors
///
/// Any error from `DeviceIoControl`, and
/// [`io::ErrorKind::InvalidData`] if the control code returns a payload that is
/// not the documented single `u32`.