Subject: Re: [PATCH] arm64: cpucaps: Keep entries sorted

From: Marc Zyngier <[email-masked]>
Date: Tue, 19 May 2026 11:22:57 +0100

On Tue, 19 May 2026 10:22:42 +0100,
Will Deacon <[email-masked]> 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 <[email-masked]>
> Cc: Mark Rutland <[email-masked]>
> Reported-by: Marc Zyngier <[email-masked]>
> Signed-off-by: Will Deacon <[email-masked]>
> ---
> 
> 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.