Fix a segfault with powersave mode
If we detect a powersave condition we may accidentally pass a NULL list to migrate_irq (if the object going into powersave has no irqs on it). Fix that to prevent the crash. Signed-off-by: Neil Horman <nhorman@tuxdriver.com>
This commit is contained in:
parent
fa7e2ea4db
commit
c34312bded
|
@ -281,7 +281,7 @@ static void dump_cache_domain(struct topo_obj *d, void *data)
|
||||||
printf(" Cache domain %i: numa_node is %d cpu mask is %s (load %lu) \n", d->number, cache_domain_numa_node(d)->number, buffer, (unsigned long)d->load);
|
printf(" Cache domain %i: numa_node is %d cpu mask is %s (load %lu) \n", d->number, cache_domain_numa_node(d)->number, buffer, (unsigned long)d->load);
|
||||||
if (d->children)
|
if (d->children)
|
||||||
for_each_object(d->children, dump_topo_obj, NULL);
|
for_each_object(d->children, dump_topo_obj, NULL);
|
||||||
if (d->interrupts)
|
if (g_list_length(d->interrupts) > 0)
|
||||||
for_each_irq(d->interrupts, dump_irq, (void *)10);
|
for_each_irq(d->interrupts, dump_irq, (void *)10);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -292,7 +292,7 @@ static void dump_package(struct topo_obj *d, void *data)
|
||||||
printf("Package %i: numa_node is %d cpu mask is %s (load %lu)\n", d->number, package_numa_node(d)->number, buffer, (unsigned long)d->load);
|
printf("Package %i: numa_node is %d cpu mask is %s (load %lu)\n", d->number, package_numa_node(d)->number, buffer, (unsigned long)d->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 (d->interrupts)
|
if (g_list_length(d->interrupts) > 0)
|
||||||
for_each_irq(d->interrupts, dump_irq, (void *)2);
|
for_each_irq(d->interrupts, dump_irq, (void *)2);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
10
irqlist.c
10
irqlist.c
|
@ -112,7 +112,9 @@ static void migrate_overloaded_irqs(struct topo_obj *obj, void *data)
|
||||||
if (obj->load <= info->avg_load) {
|
if (obj->load <= info->avg_load) {
|
||||||
if ((obj->load + info->std_deviation) <= info->avg_load) {
|
if ((obj->load + info->std_deviation) <= info->avg_load) {
|
||||||
info->num_under++;
|
info->num_under++;
|
||||||
info->powersave = obj;
|
if (!info->powersave)
|
||||||
|
if (!obj->powersave_mode)
|
||||||
|
info->powersave = obj;
|
||||||
} else
|
} else
|
||||||
info->num_within++;
|
info->num_within++;
|
||||||
return;
|
return;
|
||||||
|
@ -169,13 +171,13 @@ static void clear_powersave_mode(struct topo_obj *obj, void *data __attribute__(
|
||||||
void update_migration_status(void)
|
void update_migration_status(void)
|
||||||
{
|
{
|
||||||
struct load_balance_info info;
|
struct load_balance_info info;
|
||||||
|
|
||||||
find_overloaded_objs(cpus, info);
|
find_overloaded_objs(cpus, info);
|
||||||
if (cycle_count > 5) {
|
if (cycle_count > 5) {
|
||||||
if (!info.num_over && (info.num_under >= power_thresh)) {
|
if (!info.num_over && (info.num_under >= power_thresh) && info.powersave) {
|
||||||
syslog(LOG_INFO, "cpu %d entering powersave mode\n", info.powersave->number);
|
syslog(LOG_INFO, "cpu %d entering powersave mode\n", info.powersave->number);
|
||||||
info.powersave->powersave_mode = 1;
|
info.powersave->powersave_mode = 1;
|
||||||
for_each_irq(info.powersave->interrupts, force_irq_migration, NULL);
|
if (g_list_length(info.powersave->interrupts) > 0)
|
||||||
|
for_each_irq(info.powersave->interrupts, force_irq_migration, NULL);
|
||||||
} else if (info.num_over) {
|
} else if (info.num_over) {
|
||||||
syslog(LOG_INFO, "Load average increasing, re-enabling all cpus for irq balancing\n");
|
syslog(LOG_INFO, "Load average increasing, re-enabling all cpus for irq balancing\n");
|
||||||
for_each_object(cpus, clear_powersave_mode, NULL);
|
for_each_object(cpus, clear_powersave_mode, NULL);
|
||||||
|
|
|
@ -171,7 +171,7 @@ static void validate_irq(struct irq_info *info, void *data)
|
||||||
|
|
||||||
static void validate_object(struct topo_obj *d, void *data __attribute__((unused)))
|
static void validate_object(struct topo_obj *d, void *data __attribute__((unused)))
|
||||||
{
|
{
|
||||||
if (d->interrupts)
|
if (g_list_length(d->interrupts) > 0)
|
||||||
for_each_irq(d->interrupts, validate_irq, d);
|
for_each_irq(d->interrupts, validate_irq, d);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue