]> git.proxmox.com Git - mirror_ubuntu-disco-kernel.git/blob - arch/s390/numa/toptree.h
License cleanup: add SPDX GPL-2.0 license identifier to files with no license
[mirror_ubuntu-disco-kernel.git] / arch / s390 / numa / toptree.h
1 /* SPDX-License-Identifier: GPL-2.0 */
2 /*
3 * NUMA support for s390
4 *
5 * A tree structure used for machine topology mangling
6 *
7 * Copyright IBM Corp. 2015
8 */
9 #ifndef S390_TOPTREE_H
10 #define S390_TOPTREE_H
11
12 #include <linux/cpumask.h>
13 #include <linux/list.h>
14
15 struct toptree {
16 int level;
17 int id;
18 cpumask_t mask;
19 struct toptree *parent;
20 struct list_head sibling;
21 struct list_head children;
22 };
23
24 struct toptree *toptree_alloc(int level, int id);
25 void toptree_free(struct toptree *cand);
26 void toptree_update_mask(struct toptree *cand);
27 void toptree_unify(struct toptree *cand);
28 struct toptree *toptree_get_child(struct toptree *cand, int id);
29 void toptree_move(struct toptree *cand, struct toptree *target);
30 int toptree_count(struct toptree *context, int level);
31
32 struct toptree *toptree_first(struct toptree *context, int level);
33 struct toptree *toptree_next(struct toptree *cur, struct toptree *context,
34 int level);
35
36 #define toptree_for_each_child(child, ptree) \
37 list_for_each_entry(child, &ptree->children, sibling)
38
39 #define toptree_for_each_child_safe(child, ptmp, ptree) \
40 list_for_each_entry_safe(child, ptmp, &ptree->children, sibling)
41
42 #define toptree_is_last(ptree) \
43 ((ptree->parent == NULL) || \
44 (ptree->parent->children.prev == &ptree->sibling))
45
46 #define toptree_for_each(ptree, cont, ttype) \
47 for (ptree = toptree_first(cont, ttype); \
48 ptree != NULL; \
49 ptree = toptree_next(ptree, cont, ttype))
50
51 #define toptree_for_each_safe(ptree, tmp, cont, ttype) \
52 for (ptree = toptree_first(cont, ttype), \
53 tmp = toptree_next(ptree, cont, ttype); \
54 ptree != NULL; \
55 ptree = tmp, \
56 tmp = toptree_next(ptree, cont, ttype))
57
58 #define toptree_for_each_sibling(ptree, start) \
59 toptree_for_each(ptree, start->parent, start->level)
60
61 #endif /* S390_TOPTREE_H */