[RFC][PATCH 0/9] smp: irq_work / smp_call_function rework

Peter Zijlstra
2020-07-22T15:33:27Z

Hi,

Here are a number of patches that continue the irq_work / smp_call_function
integration / cleanup.

One of the biggest warts in this area is smp_call_function_single_async(); it
looks like a useful function but is incredibly hard to use correctly due to the
test-and-set LOCK on the csd not being atomic. This means you need to be
incredibly careful to not corrupt the csd.

Simple patterns like allowing any CPU to IPI any other CPU end up requiring
nr_cpu^2 storage because of this.

On top of that the csd has external data, vs the more common internal/embedded
data pattern.

Now, irq_work has the embedded data pattern, but requires arch support for
self-IPI. But because irq_work for remote CPUs relies on the smp_call_function
infrastructure we can implement a generic irq_work_queue_remote().

Then it goes a bit ugly, and I introduce irq_work_queue_remote_static() that is
non-atomic in exactly the same way smp_call_function_single_async() is now, but
at least it has embedded data. A few performance sensitive users of
smp_call_function_single_async() are converted.

Finally, smp_call_function_single_async() is made safer by using an atomic
test-and-set.

TL;DR, I think at least the first few patches should go in the next round, but
the rest can use some feedback.