if (hier)
return hier;
- hier = kzalloc(sizeof(*hier), GFP_KERNEL);
+ hier = kzalloc_flex(*hier, level_list, tmigr_hierarchy_levels);
if (!hier)
return ERR_PTR(-ENOMEM);
hier->cpumask = kzalloc(cpumask_size(), GFP_KERNEL);
- if (!hier->cpumask)
- goto err;
-
- hier->level_list = kzalloc_objs(struct list_head, tmigr_hierarchy_levels);
- if (!hier->level_list)
- goto err;
+ if (!hier->cpumask) {
+ kfree(hier);
+ return ERR_PTR(-ENOMEM);
+ }
for (int i = 0; i < tmigr_hierarchy_levels; i++)
INIT_LIST_HEAD(&hier->level_list[i]);
list_add_tail(&hier->node, &tmigr_hierarchy_list);
return hier;
-err:
- kfree(hier->cpumask);
- kfree(hier);
- return ERR_PTR(-ENOMEM);
}
static int tmigr_connect_old_root(struct tmigr_hierarchy *hier, int cpu,
* struct tmigr_hierarchy - a hierarchy associated to a given CPU capacity.
* Homogeneous systems have only one hierarchy.
* Heterogenous have one hierarchy per CPU capacity.
- * @level_list: Per level lists of tmigr groups
* @cpumask: CPUs belonging to this hierarchy
* @root: The current root of the hierarchy
* @capacity: CPU capacity associated to this hierarchy
* @node: Node in the global hierarchy list
+ * @level_list: Per level lists of tmigr groups
*/
struct tmigr_hierarchy {
- struct list_head *level_list;
struct cpumask *cpumask;
struct tmigr_group *root;
unsigned long capacity;
struct list_head node;
-
+ struct list_head level_list[];
};
/**