aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux/nodemask.h
diff options
context:
space:
mode:
authorPaul Jackson <pj@sgi.com>2005-10-30 18:02:33 -0500
committerLinus Torvalds <torvalds@g5.osdl.org>2005-10-30 20:37:21 -0500
commitfb5eeeee44edb248b4837416966f19731f497f79 (patch)
treef947a4dcf103f55d526bb5c71f69b657d8f22e61 /include/linux/nodemask.h
parent28a42b9ea7e42e1efb02cc2dcacba0b6af234e1b (diff)
[PATCH] cpusets: bitmap and mask remap operators
In the forthcoming task migration support, a key calculation will be mapping cpu and node numbers from the old set to the new set while preserving cpuset-relative offset. For example, if a task and its pages on nodes 8-11 are being migrated to nodes 24-27, then pages on node 9 (the 2nd node in the old set) should be moved to node 25 (the 2nd node in the new set.) As with other bitmap operations, the proper way to code this is to provide the underlying calculation in lib/bitmap.c, and then to provide the usual cpumask and nodemask wrappers. This patch provides that. These operations are termed 'remap' operations. Both remapping a single bit and a set of bits is supported. Signed-off-by: Paul Jackson <pj@sgi.com> Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'include/linux/nodemask.h')
-rw-r--r--include/linux/nodemask.h20
1 files changed, 20 insertions, 0 deletions
diff --git a/include/linux/nodemask.h b/include/linux/nodemask.h
index e96fe9062500..4726ef7ba8e8 100644
--- a/include/linux/nodemask.h
+++ b/include/linux/nodemask.h
@@ -12,6 +12,8 @@
12 * see bitmap_scnprintf() and bitmap_parse() in lib/bitmap.c. 12 * see bitmap_scnprintf() and bitmap_parse() in lib/bitmap.c.
13 * For details of nodelist_scnprintf() and nodelist_parse(), see 13 * For details of nodelist_scnprintf() and nodelist_parse(), see
14 * bitmap_scnlistprintf() and bitmap_parselist(), also in bitmap.c. 14 * bitmap_scnlistprintf() and bitmap_parselist(), also in bitmap.c.
15 * For details of node_remap(), see bitmap_bitremap in lib/bitmap.c.
16 * For details of nodes_remap(), see bitmap_remap in lib/bitmap.c.
15 * 17 *
16 * The available nodemask operations are: 18 * The available nodemask operations are:
17 * 19 *
@@ -52,6 +54,8 @@
52 * int nodemask_parse(ubuf, ulen, mask) Parse ascii string as nodemask 54 * int nodemask_parse(ubuf, ulen, mask) Parse ascii string as nodemask
53 * int nodelist_scnprintf(buf, len, mask) Format nodemask as list for printing 55 * int nodelist_scnprintf(buf, len, mask) Format nodemask as list for printing
54 * int nodelist_parse(buf, map) Parse ascii string as nodelist 56 * int nodelist_parse(buf, map) Parse ascii string as nodelist
57 * int node_remap(oldbit, old, new) newbit = map(old, new)(oldbit)
58 * int nodes_remap(dst, src, old, new) *dst = map(old, new)(dst)
55 * 59 *
56 * for_each_node_mask(node, mask) for-loop node over mask 60 * for_each_node_mask(node, mask) for-loop node over mask
57 * 61 *
@@ -307,6 +311,22 @@ static inline int __nodelist_parse(const char *buf, nodemask_t *dstp, int nbits)
307 return bitmap_parselist(buf, dstp->bits, nbits); 311 return bitmap_parselist(buf, dstp->bits, nbits);
308} 312}
309 313
314#define node_remap(oldbit, old, new) \
315 __node_remap((oldbit), &(old), &(new), MAX_NUMNODES)
316static inline int __node_remap(int oldbit,
317 const nodemask_t *oldp, const nodemask_t *newp, int nbits)
318{
319 return bitmap_bitremap(oldbit, oldp->bits, newp->bits, nbits);
320}
321
322#define nodes_remap(dst, src, old, new) \
323 __nodes_remap(&(dst), &(src), &(old), &(new), MAX_NUMNODES)
324static inline void __nodes_remap(nodemask_t *dstp, const nodemask_t *srcp,
325 const nodemask_t *oldp, const nodemask_t *newp, int nbits)
326{
327 bitmap_remap(dstp->bits, srcp->bits, oldp->bits, newp->bits, nbits);
328}
329
310#if MAX_NUMNODES > 1 330#if MAX_NUMNODES > 1
311#define for_each_node_mask(node, mask) \ 331#define for_each_node_mask(node, mask) \
312 for ((node) = first_node(mask); \ 332 for ((node) = first_node(mask); \