bitmap: optimize API usage
Subsystems (6)
cover bitmap: optimize API usage
In a few places bitmap API is called with such a combination of parameters that makes the call unneeded, or there's a trivial cheaper alternative.
For example, cpumask_copy(dst, src) where dst == src is simply a no-op. This series addresses such cases spotted on x86_64 with LTP.
All the patches are independent and may be applied separately in corresponding subsystems. Or I can take them in bitmap branch, if it's more convenient.
Yury Norov (6):
smp: optimize smp_call_function_many_cond() sched/topology: optimize topology_span_sane() driver core: cpu: optimize print_cpus_isolated()
genirq: optimze irq_do_set_affinity() cgroup/cpuset: optimize cpuset_mems_allowed_intersects() tick/common: optimize cpumask_equal() usage
drivers/base/cpu.c | 6 ++++-- kernel/cgroup/cpuset.c | 3 +++ kernel/irq/manage.c | 3 ++- kernel/sched/topology.c | 2 +- kernel/smp.c | 5 ++++- kernel/time/tick-common.c | 15 +++++++++++---- 6 files changed, 25 insertions(+), 9 deletions(-)
Signature · 1 line
2.40.1
PATCH 1/6 smp: optimize smp_call_function_many_cond()
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().
--- kernel/smp.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
kernel/smp.c +4 -1
@@ -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);
Signature · 1 line
2.40.1
PATCH 2/6 sched/topology: optimize topology_span_sane()
In reply to Yury NorovThe function may call cpumask_equal with tl->mask(cpu) == tl->mask(i), even though cpu != i. In such case, cpumask_equal() would always return true, and we can proceed to the next CPU immediately.
--- kernel/sched/topology.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
kernel/sched/topology.c +1 -1
@@ -2360,7 +2360,7 @@ static bool topology_span_sane(struct sched_domain_topology_level *tl,* breaks the linking done for an earlier span. */ for_each_cpu (i, cpu_map) { -if (i == cpu) +if (i == cpu || tl->mask (cpu) == tl->mask (i))continue ;/* * We should 'and' all those masks with 'cpu_map' to exactly
Signature · 1 line
2.40.1
Re: [PATCH 2/6] sched/topology: optimize topology_span_sane()
Le 14/05/2024 à 00:01, Yury Norov a écrit :
Quoted 14 lines
The function may call
cpumask_equalwithtl->mask(cpu)==tl->mask(i), even though cpu != i. In such case,cpumask_equal()would always return true, and we can proceed to the next CPU immediately.Signed-off-by Yury Norov <[email protected]>--- kernel/sched/topology.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)kernel/sched/topology.c +0
-0
kernel/sched/topology.c static bool topology_span_sane(struct sched_domain_topology_level *tl, · line 2366
Quoted 8 lines
kernel/sched/topology.c +1
-1@@ -2360,7 +2360,7 @@ static bool topology_span_sane(struct sched_domain_topology_level *tl,* breaks the linking done for an earlier span. */ for_each_cpu (i, cpu_map) { -if (i == cpu) +if (i == cpu || tl->mask (cpu) == tl->mask (i))continue ;/* * We should 'and' all those masks with 'cpu_map' to exactly
Hi,
does it make sense to pre-compute tl->mask(cpu) outside the for_each_cpu()?
CJ
Re: [PATCH 2/6] sched/topology: optimize topology_span_sane()
Quoted 26 lines · Christophe JAILLET
Le 14/05/2024 à 00:01, Yury Norov a écrit :
Quoted 14 lines
The function may call
cpumask_equalwithtl->mask(cpu)==tl->mask(i), even though cpu != i. In such case,cpumask_equal()would always return true, and we can proceed to the next CPU immediately.Signed-off-by Yury Norov <[email protected]>--- kernel/sched/topology.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)kernel/sched/topology.c +0
-0kernel/sched/topology.c static bool topology_span_sane(struct sched_domain_topology_level *tl, · line 2366
Quoted 8 lines
kernel/sched/topology.c +1
-1@@ -2360,7 +2360,7 @@ static bool topology_span_sane(struct sched_domain_topology_level *tl,* breaks the linking done for an earlier span. */ for_each_cpu (i, cpu_map) { -if (i == cpu) +if (i == cpu || tl->mask (cpu) == tl->mask (i))continue ;/* * We should 'and' all those masks with 'cpu_map' to exactly Hi,
Quoted 1 line
does it make sense to pre-compute
tl->mask(cpu)outside thefor_each_cpu()?
Looks like a good idea to me.
Leo
Quoted 3 lines
CJ
PATCH 3/6 driver core: cpu: optimize print_cpus_isolated()
In reply to Yury NorovThe function may be called with housekeeping_cpumask == cpu_possible_mask, and in such case the 'isolated' cpumask would be just empty.
We can call cpumask_clear() in that case, and save CPU cycles.
--- drivers/base/cpu.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/base/cpu.c +4 -2
@@ -282,8 +282,10 @@ static ssize_t print_cpus_isolated(struct device *dev,if (!alloc_cpumask_var (&isolated,GFP_KERNEL ))return -ENOMEM ; -cpumask_andnot (isolated, cpu_possible_mask, -housekeeping_cpumask (HK_TYPE_DOMAIN )); +if (cpu_possible_mask !=housekeeping_cpumask (HK_TYPE_DOMAIN )) +cpumask_andnot (isolated, cpu_possible_mask,housekeeping_cpumask (HK_TYPE_DOMAIN )); +else +cpumask_clear (isolated); len =sysfs_emit (buf,"%*pbl\n" ,cpumask_pr_args (isolated));free_cpumask_var (isolated);
Signature · 1 line
2.40.1
Re: [PATCH 3/6] driver core: cpu: optimize print_cpus_isolated()
Quoted 1 line · Yury Norov
The function may be called with
housekeeping_cpumask==cpu_possible_mask,
How so? There is no cpumask argument in the function signature. Can you please be precise?
Quoted 7 lines
and in such case the 'isolated' cpumask would be just empty.
We can call
cpumask_clear()in that case, and save CPU cycles.drivers/base/cpu.c +0
-0@@ -282,8 +282,10 @@ static ssize_t print_cpus_isolated(struct device *dev,if (!alloc_cpumask_var (&isolated,GFP_KERNEL ))return -ENOMEM ;
drivers/base/cpu.c static ssize_t print_cpus_isolated(struct device *dev, · line 291
Quoted 10 lines
drivers/base/cpu.c +4
-2-cpumask_andnot (isolated, cpu_possible_mask, -housekeeping_cpumask (HK_TYPE_DOMAIN )); +if (cpu_possible_mask !=housekeeping_cpumask (HK_TYPE_DOMAIN )) +cpumask_andnot (isolated, cpu_possible_mask,housekeeping_cpumask (HK_TYPE_DOMAIN )); +else +cpumask_clear (isolated); len =sysfs_emit (buf,"%*pbl\n" ,cpumask_pr_args (isolated));free_cpumask_var (isolated);
Seriously? You need clear() to emit an empty string via %*pbl?
if (cpu_possible_mask != housekeeping_cpumask(HK_TYPE_DOMAIN)) {
if (!alloc_cpumask_var(&isolated, GFP_KERNEL))
return -ENOMEM;
cpumask_andnot(isolated, cpu_possible_mask, housekeeping_cpumask(HK_TYPE_DOMAIN));
len = sysfs_emit(buf, "%*pbl\n", cpumask_pr_args(isolated));
free_cpumask_var(isolated);
} else {
len = sysfs_emit(buf, "\n");
}That actually would make sense and spare way more CPU cycles, no?
Is it actually worth the larger text size? Not really convinced about that.
Thanks,
tglx
PATCH 4/6 genirq: optimize irq_do_set_affinity()
In reply to Yury NorovIf mask == desc->irq_common_data.affinity, copying one to another is useless, and we can just skip it.
--- kernel/irq/manage.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
kernel/irq/manage.c +2 -1
@@ -285,7 +285,8 @@ int irq_do_set_affinity(struct irq_data *data, const struct cpumask *mask,switch (ret) {case IRQ_SET_MASK_OK :case IRQ_SET_MASK_OK_DONE : -cpumask_copy (desc->irq_common_data.affinity, mask); +if (desc->irq_common_data.affinity != mask) +cpumask_copy (desc->irq_common_data.affinity, mask); fallthrough;case IRQ_SET_MASK_OK_NOCOPY :irq_validate_effective_affinity (data);
Signature · 1 line
2.40.1
Re: [PATCH 4/6] genirq: optimize irq_do_set_affinity()
Quoted 13 lines · Yury Norov
If mask ==
desc->irq_common_data.affinity, copying one to another is useless, and we can just skip it.Signed-off-by Yury Norov <[email protected]>--- kernel/irq/manage.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)kernel/irq/manage.c +0
-0
kernel/irq/manage.c int irq_do_set_affinity(struct irq_data *data, const struct cpumask *mask, · line 289
Quoted 6 lines
kernel/irq/manage.c +2
-1@@ -285,7 +285,8 @@ int irq_do_set_affinity(struct irq_data *data, const struct cpumask *mask,switch (ret) {case IRQ_SET_MASK_OK :case IRQ_SET_MASK_OK_DONE : -cpumask_copy (desc->irq_common_data.affinity, mask); +if (desc->irq_common_data.affinity != mask) +cpumask_copy (desc->irq_common_data.affinity, mask);
It seems that mask is a pointer, shouldn't use "cpumask_equal"?
Quoted 3 lines
kernel/irq/manage.c +0
-0fallthrough;case IRQ_SET_MASK_OK_NOCOPY :irq_validate_effective_affinity (data);
Re: [PATCH 4/6] genirq: optimize irq_do_set_affinity()
Quoted 12 lines · Jinjie Ruan
Quoted 8 lines · Yury Norov
If mask ==
desc->irq_common_data.affinity, copying one to another is useless, and we can just skip it.Signed-off-by Yury Norov <[email protected]>--- kernel/irq/manage.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
Quoted 13 lines
kernel/irq/manage.c int irq_do_set_affinity(struct irq_data *data, const struct cpumask *mask, · line 289
Quoted 11 lines
kernel/irq/manage.c +2
-1@@ -285,7 +285,8 @@ int irq_do_set_affinity(struct irq_data *data, const struct cpumask *mask,switch (ret) {case IRQ_SET_MASK_OK :case IRQ_SET_MASK_OK_DONE : -cpumask_copy (desc->irq_common_data.affinity, mask); +if (desc->irq_common_data.affinity != mask) +cpumask_copy (desc->irq_common_data.affinity, mask);It seems that mask is a pointer, shouldn't use "cpumask_equal"?
cpumask_equal() is O(N), just as cpumask_copy(), so we'll have no benefit if the masks are equal, and will double slow it if they aren't in the worst case.
On the other hand, pointers comparison is O(1), a very quick tasks, even more the pointers are already in registers.
Quoted 3 lines
Quoted 3 lines
kernel/irq/manage.c +0
-0fallthrough;case IRQ_SET_MASK_OK_NOCOPY :irq_validate_effective_affinity (data);
PATCH 5/6 cgroup/cpuset: optimize cpuset_mems_allowed_intersects()
In reply to Yury NorovIf the function is called with tsk1 == tsk2, we know for sure that their mems_allowed nodes do intersect, and so we can return immediately instead of checking the nodes content.
--- kernel/cgroup/cpuset.c | 3 +++ 1 file changed, 3 insertions(+)
kernel/cgroup/cpuset.c +3 -0
@@ -5010,6 +5010,9 @@ EXPORT_SYMBOL_GPL(cpuset_mem_spread_node);int cpuset_mems_allowed_intersects (const struct task_struct *tsk1,const struct task_struct *tsk2) { +if (tsk1 == tsk2) +return 1 ; +return nodes_intersects (tsk1->mems_allowed, tsk2->mems_allowed); }
Signature · 1 line
2.40.1
Re: [PATCH 5/6] cgroup/cpuset: optimize cpuset_mems_allowed_intersects()
Quoted 14 lines · Yury Norov
If the function is called with tsk1 == tsk2, we know for sure that their
mems_allowednodes do intersect, and so we can return immediately instead of checking the nodes content.Signed-off-by Yury Norov <[email protected]>--- kernel/cgroup/cpuset.c | 3 +++ 1 file changed, 3 insertions(+)kernel/cgroup/cpuset.c +0
-0
kernel/cgroup/cpuset.c EXPORT_SYMBOL_GPL(cpuset_mem_spread_node); · line 5018
Quoted 9 lines
kernel/cgroup/cpuset.c +3
-0@@ -5010,6 +5010,9 @@ EXPORT_SYMBOL_GPL(cpuset_mem_spread_node);int cpuset_mems_allowed_intersects (const struct task_struct *tsk1,const struct task_struct *tsk2) { +if (tsk1 == tsk2) +return 1 ; +return nodes_intersects (tsk1->mems_allowed, tsk2->mems_allowed); }
Tejun Heo
maintainerRe: [PATCH 5/6] cgroup/cpuset: optimize cpuset_mems_allowed_intersects()
Quoted 6 lines · Waiman Long
Quoted 6 lines
kernel/cgroup/cpuset.c +0
-0@@ -5010,6 +5010,9 @@ EXPORT_SYMBOL_GPL(cpuset_mem_spread_node); int cpuset_mems_allowed_intersects(const struct task_struct *tsk1,
Quoted 8 lines
kernel/cgroup/cpuset.c EXPORT_SYMBOL_GPL(cpuset_mem_spread_node); · line 5017
Quoted 7 lines
kernel/cgroup/cpuset.c +3
-0const struct task_struct *tsk2) { +if (tsk1 == tsk2) +return 1 ; +return nodes_intersects (tsk1->mems_allowed, tsk2->mems_allowed); }Reviewed-by Waiman Long <[email protected]>
I'm not sure this is worth the added code.
Thanks.
Signature · 1 line
tejun
Waiman Long
maintainerRe: [PATCH 5/6] cgroup/cpuset: optimize cpuset_mems_allowed_intersects()
Quoted 15 lines · Tejun Heo
Quoted 6 lines · Waiman Long
Quoted 6 lines
kernel/cgroup/cpuset.c +0
-0@@ -5010,6 +5010,9 @@ EXPORT_SYMBOL_GPL(cpuset_mem_spread_node); int cpuset_mems_allowed_intersects(const struct task_struct *tsk1,Quoted 8 lines
kernel/cgroup/cpuset.c EXPORT_SYMBOL_GPL(cpuset_mem_spread_node); · line 5017
Quoted 7 lines
kernel/cgroup/cpuset.c +3
-0const struct task_struct *tsk2) { +if (tsk1 == tsk2) +return 1 ; +return nodes_intersects (tsk1->mems_allowed, tsk2->mems_allowed); }Reviewed-by Waiman Long <[email protected]>
Quoted 1 line
I'm not sure this is worth the added code.
Yes, I do have a second thought afterward. The only caller of cpuset_mems_allowed_intersects() is oom_cpuset_eligible() in mm/oom_kill.c. So I believe a better fix is to avoid calling cpuset_mems_allowed_intersects() there if current == tsk.
Cheers,
Longman
PATCH 6/6 tick/common: optimize cpumask_equal() usage
In reply to Yury NorovSome functions in the file call cpumask_equal() with src1p == src2p. We can obviously just skip comparison entirely in this case.
This patch fixes cpumask_equal invocations when boot-test or LTP detect such condition.
--- kernel/time/tick-common.c | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-)
kernel/time/tick-common.c +11 -4
@@ -253,7 +253,8 @@ static void tick_setup_device(struct tick_device *td,* When the device is not per cpu, pin the interrupt to the * current cpu: */ -if (!cpumask_equal (newdev->cpumask, cpumask)) +if (newdev->cpumask != cpumask && + !cpumask_equal (newdev->cpumask, cpumask))irq_set_affinity (newdev->irq, cpumask);/*
@@ -288,14 +289,19 @@ static bool tick_check_percpu(struct clock_event_device *curdev, {if (!cpumask_test_cpu (cpu, newdev->cpumask))return false; -if (cpumask_equal (newdev->cpumask,cpumask_of (cpu))) +if (newdev->cpumask ==cpumask_of (cpu) || +cpumask_equal (newdev->cpumask,cpumask_of (cpu)))return true;/* Check if irq affinity can be set */ if (newdev->irq >=0 && !irq_can_set_affinity (newdev->irq))return false;/* Prefer an existing cpu local device */ -if (curdev &&cpumask_equal (curdev->cpumask,cpumask_of (cpu))) +if (!curdev) +return true; +if (curdev->cpumask ==cpumask_of (cpu) || +cpumask_equal (curdev->cpumask,cpumask_of (cpu)))return false; +return true; }
@@ -316,7 +322,8 @@ static bool tick_check_preferred(struct clock_event_device *curdev,*/ return !curdev || newdev->rating > curdev->rating || - !cpumask_equal (curdev->cpumask, newdev->cpumask); + !(curdev->cpumask == newdev->cpumask && +cpumask_equal (curdev->cpumask, newdev->cpumask)); }/*
Signature · 1 line
2.40.1
Re: [PATCH 6/6] tick/common: optimize cpumask_equal() usage
Quoted 5 lines · Yury Norov
Some functions in the file call
cpumask_equal()with src1p == src2p. We can obviously just skip comparison entirely in this case.This patch fixes
cpumask_equalinvocations when boot-test or LTP detect such condition.
Please write your changelogs in imperative mood.
git grep 'This patch' Documentation/process/
Also please see Documentation/process/maintainer-tip.rst
Quoted 10 lines
Signed-off-by Yury Norov <[email protected]>--- kernel/time/tick-common.c | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-)kernel/time/tick-common.c +0
-0
kernel/time/tick-common.c static void tick_setup_device(struct tick_device *td, · line 258
Quoted 7 lines
kernel/time/tick-common.c +2
-1@@ -253,7 +253,8 @@ static void tick_setup_device(struct tick_device *td,* When the device is not per cpu, pin the interrupt to the * current cpu: */ -if (!cpumask_equal (newdev->cpumask, cpumask)) +if (newdev->cpumask != cpumask && + !cpumask_equal (newdev->cpumask, cpumask))irq_set_affinity (newdev->irq, cpumask);
I'm not seeing the benefit. This is slow path setup code so the extra comparison does not really buy anything aside of malformatted line breaks.
Thanks,
tglx
Re: [PATCH 6/6] tick/common: optimize cpumask_equal() usage
Quoted 18 lines · Thomas Gleixner
Quoted 5 lines · Yury Norov
Some functions in the file call
cpumask_equal()with src1p == src2p. We can obviously just skip comparison entirely in this case.This patch fixes
cpumask_equalinvocations when boot-test or LTP detect such condition.Please write your changelogs in imperative mood.
git grep 'This patch'
Documentation/process/Also please see
Documentation/process/maintainer-tip.rstQuoted 5 lines
Signed-off-by Yury Norov <[email protected]>--- kernel/time/tick-common.c | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-)
Quoted 16 lines
kernel/time/tick-common.c static void tick_setup_device(struct tick_device *td, · line 258
Quoted 12 lines
kernel/time/tick-common.c +2
-1@@ -253,7 +253,8 @@ static void tick_setup_device(struct tick_device *td,* When the device is not per cpu, pin the interrupt to the * current cpu: */ -if (!cpumask_equal (newdev->cpumask, cpumask)) +if (newdev->cpumask != cpumask && + !cpumask_equal (newdev->cpumask, cpumask))irq_set_affinity (newdev->irq, cpumask);I'm not seeing the benefit. This is slow path setup code so the extra comparison does not really buy anything aside of malformatted line breaks.
Instead of sprinkling these conditional all over the place, can't you just do the obvious and check for ptr1 == ptr2 in bitmap_copy() and bitmap_equal()?
Thanks,
tglx
Re: [PATCH 6/6] tick/common: optimize cpumask_equal() usage
Quoted 37 lines · Thomas Gleixner
Quoted 18 lines · Thomas Gleixner
Quoted 5 lines · Yury Norov
Some functions in the file call
cpumask_equal()with src1p == src2p. We can obviously just skip comparison entirely in this case.This patch fixes
cpumask_equalinvocations when boot-test or LTP detect such condition.Please write your changelogs in imperative mood.
git grep 'This patch'
Documentation/process/Also please see
Documentation/process/maintainer-tip.rstQuoted 5 lines
Signed-off-by Yury Norov <[email protected]>--- kernel/time/tick-common.c | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-)Quoted 16 lines
kernel/time/tick-common.c static void tick_setup_device(struct tick_device *td, · line 258
Quoted 12 lines
kernel/time/tick-common.c +2
-1@@ -253,7 +253,8 @@ static void tick_setup_device(struct tick_device *td,* When the device is not per cpu, pin the interrupt to the * current cpu: */ -if (!cpumask_equal (newdev->cpumask, cpumask)) +if (newdev->cpumask != cpumask && + !cpumask_equal (newdev->cpumask, cpumask))irq_set_affinity (newdev->irq, cpumask);I'm not seeing the benefit. This is slow path setup code so the extra comparison does not really buy anything aside of malformatted line breaks.
Quoted 3 lines
Instead of sprinkling these conditional all over the place, can't you just do the obvious and check for ptr1 == ptr2 in
bitmap_copy()andbitmap_equal()?
I proposed this a while (few years) ago, and it has been rejected. On bitmaps level we decided not to do that for the reasons memcpy() and memcmp() doesn't, and on cpumasks and nodemasks level it hasn't been discussed at all.
Now that most of bitmap ops have inline and outline implementation, we technically can move this checks in outline code, as inline bitmap ops are very lightweight already.
So I see the following options:
- Implement these sanity checks in outline bitmap API (lib/bitmap.c);
- Implement them on cpumask and nodemask level; or
- add a new family of helpers that do this check, like bitmap_copy_if_needed() (better name appreciated).
The argument against #1 and #2 these days was that memcpy() and similarly bitmap_copy() with dst == src may be a sign of error, and we don't want to add a code that optimizes for it.
Now, I ran the kernel through the LTP test and in practice all the cases that I spot look pretty normal. So I can continue sprinkling the checks once a few years, or do something like described above.
Can you / everyone please share your opinion?
Thanks,
Yury
Re: [PATCH 6/6] tick/common: optimize cpumask_equal() usage
Quoted 19 lines · Yury Norov
Quoted 3 lines
Instead of sprinkling these conditional all over the place, can't you just do the obvious and check for ptr1 == ptr2 in
bitmap_copy()andbitmap_equal()?I proposed this a while (few years) ago, and it has been rejected. On bitmaps level we decided not to do that for the reasons
memcpy()andmemcmp()doesn't, and on cpumasks and nodemasks level it hasn't been discussed at all.Now that most of bitmap ops have inline and outline implementation, we technically can move this checks in outline code, as inline bitmap ops are very lightweight already.
So I see the following options:
- Implement these sanity checks in outline bitmap API (lib/bitmap.c);
- Implement them on cpumask and nodemask level; or
- add a new family of helpers that do this check, likebitmap_copy_if_needed()(better name appreciated).
Quoted 3 lines
The argument against #1 and #2 these days was that
memcpy()and similarlybitmap_copy()with dst == src may be a sign of error, and we don't want to add a code that optimizes for it.
That's a fair argument.
Quoted 3 lines
Now, I ran the kernel through the LTP test and in practice all the cases that I spot look pretty normal. So I can continue sprinkling the checks once a few years, or do something like described above.
I don't see these checks as valuable in most cases and I detest them as they make the code harder to read.
Except for smp_call_function_many_cond() and to a lesser extent irq_do_set_affinity() none of them you added really matters.
Though it might be worth to have helper functions which make it obvious that the src == dst case is intentional.
Thanks,
tglx