Merge tag 'clk-fixes-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git...
[deliverable/linux.git] / arch / s390 / numa / toptree.h
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
14 struct 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
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);
30
31 struct toptree *toptree_first(struct toptree *context, int level);
32 struct 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 */
This page took 0.044133 seconds and 6 git commands to generate.