Re: [PATCH] x86/cpu: Hide and rename static_cpu_has()

From: Nikolay Borisov

Date: Sun Jun 21 2026 - 18:13:34 EST




On 20.06.26 г. 4:50 ч., Borislav Petkov wrote:
From: "Borislav Petkov (AMD)" <bp@xxxxxxxxx>

cpu_feature_enabled() is the one to use to test feature flags so hide
the static thing which doesn't pay attention to disabled mask bits
anyway.

Use the following command to do the replacement:

$ git grep --files-with-matches -w static_cpu_has -- ':(exclude)*cpufeature.h' \
| xargs sed -i 's/static_cpu_has(/cpu_feature_enabled\(/g'

There should be no functional changes resulting from this.

Signed-off-by: Borislav Petkov (AMD) <bp@xxxxxxxxx>

static_cpu_has is generally used in performance critical parts of the code. Your change basically adds a __builtin_constant_p() && DISABLED_MASK check which only evaluate during compile time so from a perf point of view this shouldn't bring any negative effects.


Reviewed-by: Nikolay Borisov <nik.borisov@xxxxxxxx>