Skip to content

Commit 9f9f6fd

Browse files
clementlegerpalmer-dabbelt
authored andcommitted
riscv: misaligned: use on_each_cpu() for scalar misaligned access probing
schedule_on_each_cpu() was used without any good reason while documented as very slow. This call was in the boot path, so better use on_each_cpu() for scalar misaligned checking. Vector misaligned check still needs to use schedule_on_each_cpu() since it requires irqs to be enabled but that's less of a problem since this code is ran in a kthread. Add a comment to explicit that. Signed-off-by: Clément Léger <[email protected]> Reviewed-by: Andrew Jones <[email protected]> Reviewed-by: Charlie Jenkins <[email protected]> Tested-by: Charlie Jenkins <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Palmer Dabbelt <[email protected]>
1 parent cf5a8ab commit 9f9f6fd

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

arch/riscv/kernel/traps_misaligned.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -627,6 +627,10 @@ bool __init check_vector_unaligned_access_emulated_all_cpus(void)
627627
{
628628
int cpu;
629629

630+
/*
631+
* While being documented as very slow, schedule_on_each_cpu() is used since
632+
* kernel_vector_begin() expects irqs to be enabled or it will panic()
633+
*/
630634
schedule_on_each_cpu(check_vector_unaligned_access_emulated);
631635

632636
for_each_online_cpu(cpu)
@@ -647,7 +651,7 @@ bool __init check_vector_unaligned_access_emulated_all_cpus(void)
647651

648652
static bool unaligned_ctl __read_mostly;
649653

650-
static void check_unaligned_access_emulated(struct work_struct *work __always_unused)
654+
static void check_unaligned_access_emulated(void *arg __always_unused)
651655
{
652656
int cpu = smp_processor_id();
653657
long *mas_ptr = per_cpu_ptr(&misaligned_access_speed, cpu);
@@ -688,7 +692,7 @@ bool __init check_unaligned_access_emulated_all_cpus(void)
688692
* accesses emulated since tasks requesting such control can run on any
689693
* CPU.
690694
*/
691-
schedule_on_each_cpu(check_unaligned_access_emulated);
695+
on_each_cpu(check_unaligned_access_emulated, NULL, 1);
692696

693697
for_each_online_cpu(cpu)
694698
if (per_cpu(misaligned_access_speed, cpu)

0 commit comments

Comments
 (0)