2 * NUMA support for s390
4 * A tree structure used for machine topology mangling
6 * Copyright IBM Corp. 2015
11 #include <linux/cpumask.h>
12 #include <linux/list.h>
18 struct toptree
*parent
;
19 struct list_head sibling
;
20 struct list_head children
;
23 struct toptree
*toptree_alloc(int level
, int id
);
24 void toptree_free(struct toptree
*cand
);
25 void toptree_update_mask(struct toptree
*cand
);
26 void toptree_unify(struct toptree
*cand
);
27 struct toptree
*toptree_get_child(struct toptree
*cand
, int id
);
28 void toptree_move(struct toptree
*cand
, struct toptree
*target
);
29 int toptree_count(struct toptree
*context
, int level
);
31 struct toptree
*toptree_first(struct toptree
*context
, int level
);
32 struct toptree
*toptree_next(struct toptree
*cur
, struct toptree
*context
,
35 #define toptree_for_each_child(child, ptree) \
36 list_for_each_entry(child, &ptree->children, sibling)
38 #define toptree_for_each_child_safe(child, ptmp, ptree) \
39 list_for_each_entry_safe(child, ptmp, &ptree->children, sibling)
41 #define toptree_is_last(ptree) \
42 ((ptree->parent == NULL) || \
43 (ptree->parent->children.prev == &ptree->sibling))
45 #define toptree_for_each(ptree, cont, ttype) \
46 for (ptree = toptree_first(cont, ttype); \
48 ptree = toptree_next(ptree, cont, ttype))
50 #define toptree_for_each_safe(ptree, tmp, cont, ttype) \
51 for (ptree = toptree_first(cont, ttype), \
52 tmp = toptree_next(ptree, cont, ttype); \
55 tmp = toptree_next(ptree, cont, ttype))
57 #define toptree_for_each_sibling(ptree, start) \
58 toptree_for_each(ptree, start->parent, start->level)
60 #endif /* S390_TOPTREE_H */