Re: [PATCH 2/3] arm64: smp: Implement cpus_has_pending_ipi()

Thomas Gleixner
2025-10-17T14:01:55Z

On Fri, Oct 03 2025 at 17:02, Ulf Hansson wrote:
> Note, the implementation is intentionally lightweight and doesn't use
> any

By some definition of lightweight.

> static void smp_cross_call(const struct cpumask *target, unsigned int ipinr)
> {
> + unsigned int cpu;
> +
> + for_each_cpu(cpu, target)
> + per_cpu(pending_ipi, cpu) = true;

Iterating over a full cpumask on a big system is not necessarily
considered lightweight. And that comes on top of the loop in
smp_call_function_many_cond() plus the potential loop in
arm64_send_ipi()...

None of this is actually needed. If you want a lightweight racy check
whether there is an IPI en route to a set of CPUs then you can simply do
that in kernel/smp.c:

bool smp_pending_ipis_crystalball(mask)
{
for_each_cpu(cpu, mask) {
if (!llist_empty(per_cpu_ptr(&call_single_queue, cpu)))
return true;
}
return false;
}

No?

Thanks,

tglx