Compare commits
2 commits
5fbe9a94eb
...
69d0a87e2f
Author | SHA1 | Date | |
---|---|---|---|
69d0a87e2f | |||
db3506f4dd |
4 changed files with 21 additions and 11 deletions
18
cputree.c
18
cputree.c
|
@ -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 = OBJ_TYPE_PACKAGE;
|
||||||
package->obj_type_list = &packages;
|
package->obj_type_list = &packages;
|
||||||
package->number = packageid;
|
package->number = packageid;
|
||||||
|
package->max_load = 0;
|
||||||
packages = g_list_append(packages, package);
|
packages = g_list_append(packages, package);
|
||||||
}
|
}
|
||||||
|
|
||||||
entry = g_list_find(package->children, cache);
|
entry = g_list_find(package->children, cache);
|
||||||
if (!entry) {
|
if (!entry) {
|
||||||
|
package->max_load += cache->max_load;
|
||||||
package->children = g_list_append(package->children, cache);
|
package->children = g_list_append(package->children, cache);
|
||||||
cache->parent = package;
|
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->mask = cache_mask;
|
||||||
cache->number = cache_domain_count;
|
cache->number = cache_domain_count;
|
||||||
cache->obj_type_list = &cache_domains;
|
cache->obj_type_list = &cache_domains;
|
||||||
|
cache->max_load = 0;
|
||||||
cache_domains = g_list_append(cache_domains, cache);
|
cache_domains = g_list_append(cache_domains, cache);
|
||||||
cache_domain_count++;
|
cache_domain_count++;
|
||||||
}
|
}
|
||||||
|
|
||||||
entry = g_list_find(cache->children, cpu);
|
entry = g_list_find(cache->children, cpu);
|
||||||
if (!entry) {
|
if (!entry) {
|
||||||
|
cache->max_load += cpu->max_load;
|
||||||
cache->children = g_list_append(cache->children, cpu);
|
cache->children = g_list_append(cache->children, cpu);
|
||||||
cpu->parent = (struct topo_obj *)cache;
|
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->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_online_map);
|
||||||
|
|
||||||
cpu_set(cpu->number, cpu->mask);
|
cpu_set(cpu->number, cpu->mask);
|
||||||
|
@ -398,6 +404,8 @@ static void do_one_cpu(char *path)
|
||||||
* we override package_mask with node mask.
|
* we override package_mask with node mask.
|
||||||
*/
|
*/
|
||||||
node = get_numa_node(nodeid);
|
node = get_numa_node(nodeid);
|
||||||
|
if (node)
|
||||||
|
node->max_load += cpu->max_load;
|
||||||
if (node && (cpus_weight(package_mask) > cpus_weight(node->mask)))
|
if (node && (cpus_weight(package_mask) > cpus_weight(node->mask)))
|
||||||
cpus_and(package_mask, package_mask, node->mask);
|
cpus_and(package_mask, package_mask, node->mask);
|
||||||
}
|
}
|
||||||
|
@ -445,7 +453,7 @@ static void dump_balance_obj(struct topo_obj *d, void *data __attribute__((unuse
|
||||||
log(TO_CONSOLE, LOG_INFO, "%s%s%s%sCPU number %i numa_node is ",
|
log(TO_CONSOLE, LOG_INFO, "%s%s%s%sCPU number %i numa_node is ",
|
||||||
log_indent, log_indent, log_indent, log_indent, c->number);
|
log_indent, log_indent, log_indent, log_indent, c->number);
|
||||||
for_each_object(cpu_numa_node(c), dump_numa_node_num, NULL);
|
for_each_object(cpu_numa_node(c), dump_numa_node_num, NULL);
|
||||||
log(TO_CONSOLE, LOG_INFO, "(load %lu)\n", (unsigned long)c->load);
|
log(TO_CONSOLE, LOG_INFO, "(load %lu, max %lu)\n", (unsigned long)c->load, (unsigned long)c->max_load);
|
||||||
if (c->interrupts)
|
if (c->interrupts)
|
||||||
for_each_irq(c->interrupts, dump_irq, (void *)18);
|
for_each_irq(c->interrupts, dump_irq, (void *)18);
|
||||||
}
|
}
|
||||||
|
@ -457,8 +465,8 @@ static void dump_cache_domain(struct topo_obj *d, void *data)
|
||||||
log(TO_CONSOLE, LOG_INFO, "%s%sCache domain %i: numa_node is ",
|
log(TO_CONSOLE, LOG_INFO, "%s%sCache domain %i: numa_node is ",
|
||||||
log_indent, log_indent, d->number);
|
log_indent, log_indent, d->number);
|
||||||
for_each_object(d->numa_nodes, dump_numa_node_num, NULL);
|
for_each_object(d->numa_nodes, dump_numa_node_num, NULL);
|
||||||
log(TO_CONSOLE, LOG_INFO, "cpu mask is %s (load %lu) \n", buffer,
|
log(TO_CONSOLE, LOG_INFO, "cpu mask is %s (load %lu, max %lu) \n", buffer,
|
||||||
(unsigned long)d->load);
|
(unsigned long)d->load, (unsigned long)d->max_load);
|
||||||
if (d->children)
|
if (d->children)
|
||||||
for_each_object(d->children, dump_balance_obj, NULL);
|
for_each_object(d->children, dump_balance_obj, NULL);
|
||||||
if (g_list_length(d->interrupts) > 0)
|
if (g_list_length(d->interrupts) > 0)
|
||||||
|
@ -471,8 +479,8 @@ static void dump_package(struct topo_obj *d, void *data)
|
||||||
cpumask_scnprintf(buffer, 4096, d->mask);
|
cpumask_scnprintf(buffer, 4096, d->mask);
|
||||||
log(TO_CONSOLE, LOG_INFO, "Package %i: numa_node ", d->number);
|
log(TO_CONSOLE, LOG_INFO, "Package %i: numa_node ", d->number);
|
||||||
for_each_object(d->numa_nodes, dump_numa_node_num, NULL);
|
for_each_object(d->numa_nodes, dump_numa_node_num, NULL);
|
||||||
log(TO_CONSOLE, LOG_INFO, "cpu mask is %s (load %lu)\n",
|
log(TO_CONSOLE, LOG_INFO, "cpu mask is %s (load %lu, max %lu)\n",
|
||||||
buffer, (unsigned long)d->load);
|
buffer, (unsigned long)d->load, (unsigned long)d->max_load);
|
||||||
if (d->children)
|
if (d->children)
|
||||||
for_each_object(d->children, dump_cache_domain, buffer);
|
for_each_object(d->children, dump_cache_domain, buffer);
|
||||||
if (g_list_length(d->interrupts) > 0)
|
if (g_list_length(d->interrupts) > 0)
|
||||||
|
|
1
numa.c
1
numa.c
|
@ -61,6 +61,7 @@ static void add_one_node(int nodeid)
|
||||||
new->obj_type = OBJ_TYPE_NODE;
|
new->obj_type = OBJ_TYPE_NODE;
|
||||||
new->number = nodeid;
|
new->number = nodeid;
|
||||||
new->obj_type_list = &numa_nodes;
|
new->obj_type_list = &numa_nodes;
|
||||||
|
new->max_load = 0;
|
||||||
numa_nodes = g_list_append(numa_nodes, new);
|
numa_nodes = g_list_append(numa_nodes, new);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
10
placement.c
10
placement.c
|
@ -76,7 +76,7 @@ static void find_best_object_packing(GList *objs, struct irq_info *info, struct
|
||||||
entry = g_list_first(objs);
|
entry = g_list_first(objs);
|
||||||
while (entry) {
|
while (entry) {
|
||||||
struct topo_obj *d = entry->data;
|
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 = d;
|
||||||
place->best_cost = d->load + info->load;
|
place->best_cost = d->load + info->load;
|
||||||
return;
|
return;
|
||||||
|
@ -120,11 +120,11 @@ static void find_best_object_for_irq(struct irq_info *info, void *data)
|
||||||
place.best = NULL;
|
place.best = NULL;
|
||||||
place.best_cost = ULLONG_MAX;
|
place.best_cost = ULLONG_MAX;
|
||||||
|
|
||||||
//if (info->level != BALANCE_CORE) {
|
if (info->level != BALANCE_CORE) {
|
||||||
// for_each_object(d->children, find_best_object, &place);
|
for_each_object(d->children, find_best_object, &place);
|
||||||
//} else {
|
} else {
|
||||||
find_best_object_packing(d->children, info, &place);
|
find_best_object_packing(d->children, info, &place);
|
||||||
//}
|
}
|
||||||
|
|
||||||
asign = place.best;
|
asign = place.best;
|
||||||
|
|
||||||
|
|
1
types.h
1
types.h
|
@ -46,6 +46,7 @@ enum obj_type_e {
|
||||||
struct topo_obj {
|
struct topo_obj {
|
||||||
uint64_t load;
|
uint64_t load;
|
||||||
uint64_t last_load;
|
uint64_t last_load;
|
||||||
|
uint64_t max_load;
|
||||||
uint64_t irq_count;
|
uint64_t irq_count;
|
||||||
enum obj_type_e obj_type;
|
enum obj_type_e obj_type;
|
||||||
int number;
|
int number;
|
||||||
|
|
Loading…
Add table
Reference in a new issue