Re: [PATCH 0/5] riscv: Cleanup and deduplicate unaligned access speed probe
From: Nam Cao
Date: Tue Apr 07 2026 - 03:35:40 EST
Michael Neuling <mikey@xxxxxxxxxxx> writes:
>> This series was applied to riscv/linux.git (for-next)
>> by Paul Walmsley <pjw@xxxxxxxxxx>:
>
>> Here is the summary with links:
>> - [1/5] riscv: Clean up & optimize unaligned scalar access probe
>> https://git.kernel.org/riscv/c/c202d70b2244
>
> I think this is causing a regression (SHA1 actually 6455c6c11827) .
> Fast unaligned accesses are no longer being set ever.
>
> Analysis from Claude (Opus 4.6) with Chris Masons kernel patch review skills:
I should start using these AIs..
> --
> > diff --git a/arch/riscv/kernel/unaligned_access_speed.c
> b/arch/riscv/kernel/unaligned_access_speed.c
> > index b36a6a56f4..1f4c128d73 100644
> > --- a/arch/riscv/kernel/unaligned_access_speed.c
> > +++ b/arch/riscv/kernel/unaligned_access_speed.c
>
> [ ... ]
>
> > -arch_initcall(check_unaligned_access_all_cpus);
> > +late_initcall(check_unaligned_access_all_cpus);
>
> With this change, check_unaligned_access_all_cpus() now runs at
> late_initcall (level 7), but lock_and_set_unaligned_access_static_branch()
> remains at arch_initcall_sync (level 3s):
...
> Does this mean fast_unaligned_access_speed_key is never enabled at boot,
> even on hardware with fast unaligned access? The comment in
> set_unaligned_access_static_branches() says "This will be called after
> check_unaligned_access_all_cpus" which is no longer true with this
> ordering change.
Thanks, you are indeed right. This affects do_csum()'s performance.
The below patch should resolve the issue. I will send a proper patch
later today after I have tested with my hardware.
Nam
diff --git a/arch/riscv/kernel/unaligned_access_speed.c b/arch/riscv/kernel/unaligned_access_speed.c
index 485ab1d105d3..96ba80e6ea32 100644
--- a/arch/riscv/kernel/unaligned_access_speed.c
+++ b/arch/riscv/kernel/unaligned_access_speed.c
@@ -244,7 +244,7 @@ static int __init lock_and_set_unaligned_access_static_branch(void)
return 0;
}
-arch_initcall_sync(lock_and_set_unaligned_access_static_branch);
+late_initcall_sync(lock_and_set_unaligned_access_static_branch);
static int riscv_online_cpu(unsigned int cpu)
{