[LTP] [PATCH v2] kernel/irq: Add irqbalance01
Cyril Hrubis
chrubis@suse.cz
Fri Oct 8 10:23:23 CEST 2021
Hi!
> + /* Read the CPU affinity masks for each IRQ. The first CPU is in the
> + * right most (least significant) bit. See bitmap_string() in the kernel
> + * (%*pb)
> + */
> + for (row = 0; row < nr_irqs; row++) {
> + sprintf(path, "/proc/irq/%u/smp_affinity", irq_ids[row]);
> + buf = read_proc_file(path);
> + c = buf;
> + col = 0;
> +
> + while (*c != '\0')
> + c++;
A minor nit, we alredy know the lenght, but we do not return it from the
read_proc_file() we may as well change this so taht the read_proc_file
returns both buffer pointer and the size. E.g. add size_t *len parameter
to the read_proc_file() and set it if it's not NULL.
Other than that the parsing looks good now.
> +static void evidence_of_change(void)
> +{
> + size_t row, col, changed = 0;
> +
> + for (row = 0; row < nr_irqs; row++) {
> + for (col = 0; col < nr_cpus; col++) {
> + if (!irq_stats[row * nr_cpus + col])
> + continue;
> +
> + if (irq_affinity[row * nr_cpus + col] == ALLOW)
> + continue;
> +
> + changed++;
> + }
> + }
> +
> + tst_res(changed ? TPASS : TFAIL,
> + "Heuristic: Detected %zu irq-cpu pairs have been dissallowed",
> + changed);
> +}
I'm still unusure about this part though.
The test fails on my workstation where the IRQs are nicely distributed
by the hardware/BIOS.
Maybe we should check if IRQs are distributed somehow evenly and PASS
the test if that is the case as well.
In my case there is 27 IRQs, 18 of them have non-zero counters and there
is 12 CPUs. For active IRQs that gives 18/12 = 1.5 IRQ per CPU and there
are 7 CPUs that handle 2 IRQs, 4 CPUs that handle 1 IRQ and 1 CPU that
doesn't handle anything. I wonder if we can figure out some kind of
heuristic, but I guess that in the end it wouldn't be worth the effort.
--
Cyril Hrubis
chrubis@suse.cz
More information about the ltp
mailing list