hc
2023-12-08 01573e231f18eb2d99162747186f59511f56b64d
kernel/include/linux/nodemask.h
....@@ -42,11 +42,11 @@
4242 * void nodes_shift_right(dst, src, n) Shift right
4343 * void nodes_shift_left(dst, src, n) Shift left
4444 *
45
- * int first_node(mask) Number lowest set bit, or MAX_NUMNODES
46
- * int next_node(node, mask) Next node past 'node', or MAX_NUMNODES
47
- * int next_node_in(node, mask) Next node past 'node', or wrap to first,
45
+ * unsigned int first_node(mask) Number lowest set bit, or MAX_NUMNODES
46
+ * unsigend int next_node(node, mask) Next node past 'node', or MAX_NUMNODES
47
+ * unsigned int next_node_in(node, mask) Next node past 'node', or wrap to first,
4848 * or MAX_NUMNODES
49
- * int first_unset_node(mask) First node not set in mask, or
49
+ * unsigned int first_unset_node(mask) First node not set in mask, or
5050 * MAX_NUMNODES
5151 *
5252 * nodemask_t nodemask_of_node(node) Return nodemask with bit 'node' set
....@@ -90,9 +90,9 @@
9090 * for such situations. See below and CPUMASK_ALLOC also.
9191 */
9292
93
-#include <linux/kernel.h>
9493 #include <linux/threads.h>
9594 #include <linux/bitmap.h>
95
+#include <linux/minmax.h>
9696 #include <linux/numa.h>
9797
9898 typedef struct { DECLARE_BITMAP(bits, MAX_NUMNODES); } nodemask_t;
....@@ -153,7 +153,7 @@
153153
154154 #define node_test_and_set(node, nodemask) \
155155 __node_test_and_set((node), &(nodemask))
156
-static inline int __node_test_and_set(int node, nodemask_t *addr)
156
+static inline bool __node_test_and_set(int node, nodemask_t *addr)
157157 {
158158 return test_and_set_bit(node, addr->bits);
159159 }
....@@ -200,7 +200,7 @@
200200
201201 #define nodes_equal(src1, src2) \
202202 __nodes_equal(&(src1), &(src2), MAX_NUMNODES)
203
-static inline int __nodes_equal(const nodemask_t *src1p,
203
+static inline bool __nodes_equal(const nodemask_t *src1p,
204204 const nodemask_t *src2p, unsigned int nbits)
205205 {
206206 return bitmap_equal(src1p->bits, src2p->bits, nbits);
....@@ -208,7 +208,7 @@
208208
209209 #define nodes_intersects(src1, src2) \
210210 __nodes_intersects(&(src1), &(src2), MAX_NUMNODES)
211
-static inline int __nodes_intersects(const nodemask_t *src1p,
211
+static inline bool __nodes_intersects(const nodemask_t *src1p,
212212 const nodemask_t *src2p, unsigned int nbits)
213213 {
214214 return bitmap_intersects(src1p->bits, src2p->bits, nbits);
....@@ -216,20 +216,20 @@
216216
217217 #define nodes_subset(src1, src2) \
218218 __nodes_subset(&(src1), &(src2), MAX_NUMNODES)
219
-static inline int __nodes_subset(const nodemask_t *src1p,
219
+static inline bool __nodes_subset(const nodemask_t *src1p,
220220 const nodemask_t *src2p, unsigned int nbits)
221221 {
222222 return bitmap_subset(src1p->bits, src2p->bits, nbits);
223223 }
224224
225225 #define nodes_empty(src) __nodes_empty(&(src), MAX_NUMNODES)
226
-static inline int __nodes_empty(const nodemask_t *srcp, unsigned int nbits)
226
+static inline bool __nodes_empty(const nodemask_t *srcp, unsigned int nbits)
227227 {
228228 return bitmap_empty(srcp->bits, nbits);
229229 }
230230
231231 #define nodes_full(nodemask) __nodes_full(&(nodemask), MAX_NUMNODES)
232
-static inline int __nodes_full(const nodemask_t *srcp, unsigned int nbits)
232
+static inline bool __nodes_full(const nodemask_t *srcp, unsigned int nbits)
233233 {
234234 return bitmap_full(srcp->bits, nbits);
235235 }
....@@ -260,15 +260,15 @@
260260 > MAX_NUMNODES, then the silly min_ts could be dropped. */
261261
262262 #define first_node(src) __first_node(&(src))
263
-static inline int __first_node(const nodemask_t *srcp)
263
+static inline unsigned int __first_node(const nodemask_t *srcp)
264264 {
265
- return min_t(int, MAX_NUMNODES, find_first_bit(srcp->bits, MAX_NUMNODES));
265
+ return min_t(unsigned int, MAX_NUMNODES, find_first_bit(srcp->bits, MAX_NUMNODES));
266266 }
267267
268268 #define next_node(n, src) __next_node((n), &(src))
269
-static inline int __next_node(int n, const nodemask_t *srcp)
269
+static inline unsigned int __next_node(int n, const nodemask_t *srcp)
270270 {
271
- return min_t(int,MAX_NUMNODES,find_next_bit(srcp->bits, MAX_NUMNODES, n+1));
271
+ return min_t(unsigned int, MAX_NUMNODES, find_next_bit(srcp->bits, MAX_NUMNODES, n+1));
272272 }
273273
274274 /*
....@@ -276,7 +276,7 @@
276276 * the first node in src if needed. Returns MAX_NUMNODES if src is empty.
277277 */
278278 #define next_node_in(n, src) __next_node_in((n), &(src))
279
-int __next_node_in(int node, const nodemask_t *srcp);
279
+unsigned int __next_node_in(int node, const nodemask_t *srcp);
280280
281281 static inline void init_nodemask_of_node(nodemask_t *mask, int node)
282282 {
....@@ -296,9 +296,9 @@
296296 })
297297
298298 #define first_unset_node(mask) __first_unset_node(&(mask))
299
-static inline int __first_unset_node(const nodemask_t *maskp)
299
+static inline unsigned int __first_unset_node(const nodemask_t *maskp)
300300 {
301
- return min_t(int,MAX_NUMNODES,
301
+ return min_t(unsigned int, MAX_NUMNODES,
302302 find_first_zero_bit(maskp->bits, MAX_NUMNODES));
303303 }
304304
....@@ -375,14 +375,13 @@
375375 }
376376
377377 #if MAX_NUMNODES > 1
378
-#define for_each_node_mask(node, mask) \
379
- for ((node) = first_node(mask); \
380
- (node) < MAX_NUMNODES; \
381
- (node) = next_node((node), (mask)))
378
+#define for_each_node_mask(node, mask) \
379
+ for ((node) = first_node(mask); \
380
+ (node >= 0) && (node) < MAX_NUMNODES; \
381
+ (node) = next_node((node), (mask)))
382382 #else /* MAX_NUMNODES == 1 */
383
-#define for_each_node_mask(node, mask) \
384
- if (!nodes_empty(mask)) \
385
- for ((node) = 0; (node) < 1; (node)++)
383
+#define for_each_node_mask(node, mask) \
384
+ for ((node) = 0; (node) < 1 && !nodes_empty(mask); (node)++)
386385 #endif /* MAX_NUMNODES */
387386
388387 /*
....@@ -399,6 +398,7 @@
399398 #endif
400399 N_MEMORY, /* The node has memory(regular, high, movable) */
401400 N_CPU, /* The node has one or more cpus */
401
+ N_GENERIC_INITIATOR, /* The node has one or more Generic Initiators */
402402 NR_NODE_STATES
403403 };
404404
....@@ -435,17 +435,17 @@
435435
436436 #define first_online_node first_node(node_states[N_ONLINE])
437437 #define first_memory_node first_node(node_states[N_MEMORY])
438
-static inline int next_online_node(int nid)
438
+static inline unsigned int next_online_node(int nid)
439439 {
440440 return next_node(nid, node_states[N_ONLINE]);
441441 }
442
-static inline int next_memory_node(int nid)
442
+static inline unsigned int next_memory_node(int nid)
443443 {
444444 return next_node(nid, node_states[N_MEMORY]);
445445 }
446446
447
-extern int nr_node_ids;
448
-extern int nr_online_nodes;
447
+extern unsigned int nr_node_ids;
448
+extern unsigned int nr_online_nodes;
449449
450450 static inline void node_set_online(int nid)
451451 {
....@@ -485,8 +485,8 @@
485485 #define first_online_node 0
486486 #define first_memory_node 0
487487 #define next_online_node(nid) (MAX_NUMNODES)
488
-#define nr_node_ids 1
489
-#define nr_online_nodes 1
488
+#define nr_node_ids 1U
489
+#define nr_online_nodes 1U
490490
491491 #define node_set_online(node) node_set_state((node), N_ONLINE)
492492 #define node_set_offline(node) node_clear_state((node), N_ONLINE)