activate_mapping: activate only online CPUs

When echoing a mask to /proc/irq/N/smp_affinity make sure to activate
only CPUs which are online. Activating a CPU which is not online results
in a EOVERFLOW.

Originally fixed in Debian by Helge Deller <deller@gmx.de>.
This commit is contained in:
Paride Legovini 2020-08-25 23:18:27 +02:00
parent afc0e8b1d2
commit c8757c6d87
1 changed files with 6 additions and 2 deletions

View File

@ -49,6 +49,7 @@ static void activate_mapping(struct irq_info *info, void *data __attribute__((un
char buf[PATH_MAX]; char buf[PATH_MAX];
FILE *file; FILE *file;
int ret = 0; int ret = 0;
cpumask_t applied_mask;
/* /*
* only activate mappings for irqs that have moved * only activate mappings for irqs that have moved
@ -59,10 +60,13 @@ static void activate_mapping(struct irq_info *info, void *data __attribute__((un
if (!info->assigned_obj) if (!info->assigned_obj)
return; return;
/* activate only online cpus, otherwise writing to procfs returns EOVERFLOW */
cpus_and(applied_mask, cpu_online_map, info->assigned_obj->mask);
/* /*
* Don't activate anything for which we have an invalid mask * Don't activate anything for which we have an invalid mask
*/ */
if (check_affinity(info, info->assigned_obj->mask)) if (check_affinity(info, applied_mask))
return; return;
sprintf(buf, "/proc/irq/%i/smp_affinity", info->irq); sprintf(buf, "/proc/irq/%i/smp_affinity", info->irq);
@ -70,7 +74,7 @@ static void activate_mapping(struct irq_info *info, void *data __attribute__((un
if (!file) if (!file)
return; return;
cpumask_scnprintf(buf, PATH_MAX, info->assigned_obj->mask); cpumask_scnprintf(buf, PATH_MAX, applied_mask);
ret = fprintf(file, "%s", buf); ret = fprintf(file, "%s", buf);
if (ret < 0) { if (ret < 0) {
log(TO_ALL, LOG_WARNING, "cannot change irq %i's affinity, add it to banned list", info->irq); log(TO_ALL, LOG_WARNING, "cannot change irq %i's affinity, add it to banned list", info->irq);