[PATCH] arm64: cpucaps: Keep entries sorted

Marc Zyngier maz at kernel.org
Tue May 19 03:22:57 PDT 2026


On Tue, 19 May 2026 10:22:42 +0100,
Will Deacon <will at kernel.org> wrote:
> 
> The cpucaps list is supposed to be sorted, even though the awk script
> which processes it doesn't really care. Since this isn't enforced or
> relied upon and because the alphabet is hard, the list has gradually
> developed an ordering of its own.
> 
> Re-sort the file.
> 
> Cc: Catalin Marinas <catalin.marinas at arm.com>
> Cc: Mark Rutland <mark.rutland at arm.com>
> Reported-by: Marc Zyngier <maz at kernel.org>
> Signed-off-by: Will Deacon <will at kernel.org>
> ---
> 
> Marc pointed out that HAS_BBML2_NOABORT was in the wrong place but, on
> closer inspection, there are a bunch of misplaced entries here. I
> honestly don't like the churn of re-sorting it, so an alternative is
> to live with it and remove the comment at the top asking people to keep
> it sorted it. Any preferences?

I'm not sold on the requirement for keeping this sorted, TBH. The
commit message says "to minimise conflicts", which I can understand as
it avoids people adding entries at the end all the time, but it is
obvious that we (especially myself) can't manage to do that.

If we want to keep this sorted for $reasons, let's actively enforce it
in the generation script:

diff --git a/arch/arm64/tools/gen-cpucaps.awk b/arch/arm64/tools/gen-cpucaps.awk
index 2f4f61a0af17e..2e06768ff432e 100755
--- a/arch/arm64/tools/gen-cpucaps.awk
+++ b/arch/arm64/tools/gen-cpucaps.awk
@@ -20,10 +20,14 @@ BEGIN {
 	print ""
 	print "/* Generated file - do not edit */"
 	cap_num = 0
+	previous = ""
 	print ""
 }
 
 /^[vA-Z0-9_]+$/ {
+	if (cap_num > 0 && previous > $0)
+		fatal("unsorted cap " $0)
+	previous = $0
 	printf("#define ARM64_%-40s\t%d\n", $0, cap_num++)
 	next
 }

although that results in a different sorting order (my awk-foo is limited).

Thanks,

	M.

-- 
Without deviation from the norm, progress is not possible.



More information about the linux-arm-kernel mailing list