aboutsummaryrefslogtreecommitdiffstats
path: root/arch/s390/numa/toptree.h
diff options
context:
space:
mode:
authorPhilipp Hachtmann <phacht@linux.vnet.ibm.com>2014-03-06 12:39:39 -0500
committerMartin Schwidefsky <schwidefsky@de.ibm.com>2015-08-03 12:40:26 -0400
commite8054b654bf5d4f549f4f24b708acce6d2718b1b (patch)
treeeac76bd64bf06f509903d6006f2ae1f1160c928a /arch/s390/numa/toptree.h
parent3a368f742da13955bed4a2efed85ed7c1d826bcc (diff)
s390/numa: add topology tree infrastructure
NUMA emulation needs proper means to mangle the book/mc/core topology of the machine. The topology tree (toptree) consistently maintains cpu masks for the root, each node, and all leaves of the tree while the user may use the toptree functions to rearrange the tree in various ways. This patch contains several changes from Michael Holzheu. Signed-off-by: Philipp Hachtmann <phacht@linux.vnet.ibm.com> Signed-off-by: Michael Holzheu <holzheu@linux.vnet.ibm.com> Signed-off-by: Martin Schwidefsky <schwidefsky@de.ibm.com>
Diffstat (limited to 'arch/s390/numa/toptree.h')
-rw-r--r--arch/s390/numa/toptree.h60
1 files changed, 60 insertions, 0 deletions
diff --git a/arch/s390/numa/toptree.h b/arch/s390/numa/toptree.h
new file mode 100644
index 000000000000..bdf502027af4
--- /dev/null
+++ b/arch/s390/numa/toptree.h
@@ -0,0 +1,60 @@
1/*
2 * NUMA support for s390
3 *
4 * A tree structure used for machine topology mangling
5 *
6 * Copyright IBM Corp. 2015
7 */
8#ifndef S390_TOPTREE_H
9#define S390_TOPTREE_H
10
11#include <linux/cpumask.h>
12#include <linux/list.h>
13
14struct toptree {
15 int level;
16 int id;
17 cpumask_t mask;
18 struct toptree *parent;
19 struct list_head sibling;
20 struct list_head children;
21};
22
23struct toptree *toptree_alloc(int level, int id);
24void toptree_free(struct toptree *cand);
25void toptree_update_mask(struct toptree *cand);
26void toptree_unify(struct toptree *cand);
27struct toptree *toptree_get_child(struct toptree *cand, int id);
28void toptree_move(struct toptree *cand, struct toptree *target);
29int toptree_count(struct toptree *context, int level);
30
31struct toptree *toptree_first(struct toptree *context, int level);
32struct toptree *toptree_next(struct toptree *cur, struct toptree *context,
33 int level);
34
35#define toptree_for_each_child(child, ptree) \
36 list_for_each_entry(child, &ptree->children, sibling)
37
38#define toptree_for_each_child_safe(child, ptmp, ptree) \
39 list_for_each_entry_safe(child, ptmp, &ptree->children, sibling)
40
41#define toptree_is_last(ptree) \
42 ((ptree->parent == NULL) || \
43 (ptree->parent->children.prev == &ptree->sibling))
44
45#define toptree_for_each(ptree, cont, ttype) \
46 for (ptree = toptree_first(cont, ttype); \
47 ptree != NULL; \
48 ptree = toptree_next(ptree, cont, ttype))
49
50#define toptree_for_each_safe(ptree, tmp, cont, ttype) \
51 for (ptree = toptree_first(cont, ttype), \
52 tmp = toptree_next(ptree, cont, ttype); \
53 ptree != NULL; \
54 ptree = tmp, \
55 tmp = toptree_next(ptree, cont, ttype))
56
57#define toptree_for_each_sibling(ptree, start) \
58 toptree_for_each(ptree, start->parent, start->level)
59
60#endif /* S390_TOPTREE_H */