mirror of
https://github.com/Fishwaldo/Star64_linux.git
synced 2025-06-25 08:02:56 +00:00
[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>
This commit is contained in:
parent
28a42b9ea7
commit
fb5eeeee44
4 changed files with 212 additions and 0 deletions
|
@ -12,6 +12,8 @@
|
|||
* see bitmap_scnprintf() and bitmap_parse() in lib/bitmap.c.
|
||||
* For details of nodelist_scnprintf() and nodelist_parse(), see
|
||||
* bitmap_scnlistprintf() and bitmap_parselist(), also in bitmap.c.
|
||||
* For details of node_remap(), see bitmap_bitremap in lib/bitmap.c.
|
||||
* For details of nodes_remap(), see bitmap_remap in lib/bitmap.c.
|
||||
*
|
||||
* The available nodemask operations are:
|
||||
*
|
||||
|
@ -52,6 +54,8 @@
|
|||
* int nodemask_parse(ubuf, ulen, mask) Parse ascii string as nodemask
|
||||
* int nodelist_scnprintf(buf, len, mask) Format nodemask as list for printing
|
||||
* int nodelist_parse(buf, map) Parse ascii string as nodelist
|
||||
* int node_remap(oldbit, old, new) newbit = map(old, new)(oldbit)
|
||||
* int nodes_remap(dst, src, old, new) *dst = map(old, new)(dst)
|
||||
*
|
||||
* for_each_node_mask(node, mask) for-loop node over mask
|
||||
*
|
||||
|
@ -307,6 +311,22 @@ static inline int __nodelist_parse(const char *buf, nodemask_t *dstp, int nbits)
|
|||
return bitmap_parselist(buf, dstp->bits, nbits);
|
||||
}
|
||||
|
||||
#define node_remap(oldbit, old, new) \
|
||||
__node_remap((oldbit), &(old), &(new), MAX_NUMNODES)
|
||||
static inline int __node_remap(int oldbit,
|
||||
const nodemask_t *oldp, const nodemask_t *newp, int nbits)
|
||||
{
|
||||
return bitmap_bitremap(oldbit, oldp->bits, newp->bits, nbits);
|
||||
}
|
||||
|
||||
#define nodes_remap(dst, src, old, new) \
|
||||
__nodes_remap(&(dst), &(src), &(old), &(new), MAX_NUMNODES)
|
||||
static inline void __nodes_remap(nodemask_t *dstp, const nodemask_t *srcp,
|
||||
const nodemask_t *oldp, const nodemask_t *newp, int nbits)
|
||||
{
|
||||
bitmap_remap(dstp->bits, srcp->bits, oldp->bits, newp->bits, nbits);
|
||||
}
|
||||
|
||||
#if MAX_NUMNODES > 1
|
||||
#define for_each_node_mask(node, mask) \
|
||||
for ((node) = first_node(mask); \
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue