[PATCH 1/6] smp: optimize smp_call_function_many_cond()

Yury Norov
2024-05-13T22:01:53Z

The function may be called with mask == cpu_online_mask, and in this
case we can use a cheaper cpumask_cooy() instead of cpumask_and().

Signed-off-by: Yury Norov <yury.norov@gmail.com>
---
kernel/smp.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/kernel/smp.c b/kernel/smp.c
index f085ebcdf9e7..6f41214a1b54 100644
--- a/kernel/smp.c
+++ b/kernel/smp.c
@@ -798,7 +798,10 @@ static void smp_call_function_many_cond(const struct cpumask *mask,

if (run_remote) {
cfd = this_cpu_ptr(&cfd_data);
- cpumask_and(cfd->cpumask, mask, cpu_online_mask);
+ if (mask == cpu_online_mask)
+ cpumask_copy(cfd->cpumask, mask);
+ else
+ cpumask_and(cfd->cpumask, mask, cpu_online_mask);
__cpumask_clear_cpu(this_cpu, cfd->cpumask);

cpumask_clear(cfd->cpumask_ipi);
--
2.40.1