[PATCH 09/11] nodemask: add nodes_copy_and_extend()
From: Yury Norov
Date: Fri Nov 27 2026 - 18:02:19 EST
Add nodes_copy_and_extend() to copy the nr_node_ids range and clear all
remaining bits in the destination's MAX_NUMNODES-sized storage.
Signed-off-by: Yury Norov <ynorov@xxxxxxxxxx>
---
include/linux/nodemask.h | 11 +++++++++++
1 file changed, 11 insertions(+)
diff --git a/include/linux/nodemask.h b/include/linux/nodemask.h
index a17aa5c2e562..4ef6ca642054 100644
--- a/include/linux/nodemask.h
+++ b/include/linux/nodemask.h
@@ -30,6 +30,7 @@
* void nodes_or(dst, src1, src2) dst = src1 | src2 [union]
* void nodes_xor(dst, src1, src2) dst = src1 ^ src2
* bool nodes_andnot(dst, src1, src2) dst = src1 & ~src2
+ * void nodes_copy_and_extend(dst, src) Copy runtime nodes, clear remaining bits
* void nodes_complement(dst, src) dst = ~src
*
* bool nodes_equal(mask1, mask2) Does mask1 == mask2?
@@ -218,6 +219,16 @@ static __always_inline void __nodes_copy(nodemask_t *dstp,
bitmap_copy(dstp->bits, srcp->bits, nbits);
}
+/* Copy runtime nodes and clear the rest of the destination's storage. */
+#define nodes_copy_and_extend(dst, src) \
+ __nodes_copy_and_extend(&(dst), &(src), nr_node_ids, MAX_NUMNODES)
+static __always_inline void __nodes_copy_and_extend(nodemask_t *dstp,
+ const nodemask_t *srcp,
+ unsigned int nbits, unsigned int size)
+{
+ bitmap_copy_and_extend(dstp->bits, srcp->bits, nbits, size);
+}
+
#define nodes_complement(dst, src) \
__nodes_complement(&(dst), &(src), MAX_NUMNODES)
static __always_inline void __nodes_complement(nodemask_t *dstp,
--
2.53.0