[DNM] Implement packing for all balancing levels

This commit is contained in:
Peter Cai 2022-09-15 18:52:51 -04:00
parent 5fbe9a94eb
commit db3506f4dd
4 changed files with 16 additions and 6 deletions

View file

@ -224,11 +224,13 @@ static struct topo_obj* add_cache_domain_to_package(struct topo_obj *cache,
package->obj_type = OBJ_TYPE_PACKAGE;
package->obj_type_list = &packages;
package->number = packageid;
package->max_load = 0;
packages = g_list_append(packages, package);
}
entry = g_list_find(package->children, cache);
if (!entry) {
package->max_load += cache->max_load;
package->children = g_list_append(package->children, cache);
cache->parent = package;
}
@ -264,12 +266,14 @@ static struct topo_obj* add_cpu_to_cache_domain(struct topo_obj *cpu,
cache->mask = cache_mask;
cache->number = cache_domain_count;
cache->obj_type_list = &cache_domains;
cache->max_load = 0;
cache_domains = g_list_append(cache_domains, cache);
cache_domain_count++;
}
entry = g_list_find(cache->children, cpu);
if (!entry) {
cache->max_load += cpu->max_load;
cache->children = g_list_append(cache->children, cpu);
cpu->parent = (struct topo_obj *)cache;
}
@ -317,6 +321,8 @@ static void do_one_cpu(char *path)
cpu->number = strtoul(&path[27], NULL, 10);
cpu->max_load = SLEEP_INTERVAL * 1000 * 1000; // SLEEP_INTERVAL in nanoseconds, should be a good enough approximation
cpu_set(cpu->number, cpu_online_map);
cpu_set(cpu->number, cpu->mask);
@ -398,6 +404,8 @@ static void do_one_cpu(char *path)
* we override package_mask with node mask.
*/
node = get_numa_node(nodeid);
if (node)
node->max_load += cpu->max_load;
if (node && (cpus_weight(package_mask) > cpus_weight(node->mask)))
cpus_and(package_mask, package_mask, node->mask);
}

3
numa.c
View file

@ -58,9 +58,10 @@ static void add_one_node(int nodeid)
process_one_line(path, get_mask_from_bitmap, &new->mask);
}
new->obj_type = OBJ_TYPE_NODE;
new->obj_type = OBJ_TYPE_NODE;
new->number = nodeid;
new->obj_type_list = &numa_nodes;
new->max_load = 0;
numa_nodes = g_list_append(numa_nodes, new);
}

View file

@ -76,7 +76,7 @@ static void find_best_object_packing(GList *objs, struct irq_info *info, struct
entry = g_list_first(objs);
while (entry) {
struct topo_obj *d = entry->data;
if (d->load + info->load < 0.9e9) {
if (d->load + info->load < d->max_load) {
place->best = d;
place->best_cost = d->load + info->load;
return;
@ -120,11 +120,11 @@ static void find_best_object_for_irq(struct irq_info *info, void *data)
place.best = NULL;
place.best_cost = ULLONG_MAX;
//if (info->level != BALANCE_CORE) {
// for_each_object(d->children, find_best_object, &place);
//} else {
if (info->level != BALANCE_CORE) {
for_each_object(d->children, find_best_object, &place);
} else {
find_best_object_packing(d->children, info, &place);
//}
}
asign = place.best;

View file

@ -46,6 +46,7 @@ enum obj_type_e {
struct topo_obj {
uint64_t load;
uint64_t last_load;
uint64_t max_load;
uint64_t irq_count;
enum obj_type_e obj_type;
int number;