Skip to content

Commit c924d8b

Browse files
ZhaoxiangJinjhedberg
authored andcommitted
cpu_freq: remove redundant XOR calculation in k_ipi_work_add
In the current code, 'target_cpus ^= (1U << _current_cpu->id)' is first used to remove the current core. Then, k_ipi_work_add performs 'target_cpus ^ (1U << _current_cpu->id)' again when passing parameters. This will add the current core to the mask again, causing the current core to receive IPI and directly call cpu_freq_next_pstate() at the end, which may lead to duplicate execution. This commit changed 'target_cpus ^ (1U << _current_cpu->id)' to 'target_cpus' in k_ipi_work_add to avoid the second XOR. Signed-off-by: Zhaoxiang Jin <[email protected]>
1 parent 1c2d7f4 commit c924d8b

File tree

1 file changed

+2
-4
lines changed

1 file changed

+2
-4
lines changed

subsys/cpu_freq/cpu_freq.c

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -70,11 +70,9 @@ static void cpu_freq_timer_handler(struct k_timer *timer)
7070
*/
7171

7272
target_cpus = (num_cpus == 32U) ? 0xFFFFFFFF : (1U << num_cpus) - 1U;
73-
target_cpus ^= (1U << _current_cpu->id),
73+
target_cpus ^= (1U << _current_cpu->id);
7474

75-
ret = k_ipi_work_add(&cpu_freq_work,
76-
target_cpus ^ (1U << _current_cpu->id),
77-
cpu_freq_ipi_handler);
75+
ret = k_ipi_work_add(&cpu_freq_work, target_cpus, cpu_freq_ipi_handler);
7876

7977
if (ret != 0) {
8078
/*

0 commit comments

Comments
 (0)