[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <ed81aa4e-6ebc-40ad-af45-289cc7138c0f@intel.com>
Date: Wed, 12 Mar 2025 16:16:28 -0700
From: Sohil Mehta <sohil.mehta@...el.com>
To: Ingo Molnar <mingo@...nel.org>
CC: <x86@...nel.org>, Borislav Petkov <bp@...en8.de>, Dave Hansen
<dave.hansen@...ux.intel.com>, Ingo Molnar <mingo@...hat.com>, "Thomas
Gleixner" <tglx@...utronix.de>, "H . Peter Anvin" <hpa@...or.com>, Uros
Bizjak <ubizjak@...il.com>, Sandipan Das <sandipan.das@....com>, Sean
Christopherson <seanjc@...gle.com>, Peter Zijlstra <peterz@...radead.org>,
Vegard Nossum <vegard.nossum@...cle.com>, Tony Luck <tony.luck@...el.com>,
Pawan Gupta <pawan.kumar.gupta@...ux.intel.com>, Nikolay Borisov
<nik.borisov@...e.com>, Eric Biggers <ebiggers@...gle.com>, Xin Li
<xin3.li@...el.com>, "Alexander Shishkin" <alexander.shishkin@...el.com>,
Kirill Shutemov <kirill.shutemov@...ux.intel.com>,
<linux-kernel@...r.kernel.org>
Subject: Re: [PATCH v5] x86/cpufeature: Warn about unmet feature dependencies
On 3/7/2025 3:55 AM, Ingo Molnar wrote:
>>
>> + /* Scan for unmet dependencies based on the CPUID dependency table */
>> + scan_feature_dependencies(c);
>
> s/scane_feature_dependencies
> /x86_check_cpufeature_deps
>
How about check_cpufeature_deps() without the "x86" prefix? It would
blend in with the other function calls in early_identify_cpu() and
identify_cpu().
>
>> + */
>> +static const char *x86_feature_name(unsigned int feature, char *buf)
>> +{
>> + if (x86_cap_flags[feature])
>> + return x86_cap_flags[feature];
>> +
>> + snprintf(buf, 16, "%d*32+%2d", feature / 32, feature % 32);
>> +
>> + return buf;
>> +}
>> +
I was wondering if it would be better to build the feature name using a
macro and reusing it elsewhere? This is all I could come up with:
/*
* Use with a %s format specifier to print the feature name.
*
* Return the feature "name" if set, otherwise return the X86_FEATURE_*
* numerals to make it easier to identify the feature.
*/
#define x86_feature_name(feature) \
(x86_cap_flags[feature] ? x86_cap_flags[feature] : \
({ \
char buf[16]; \
snprintf(buf, 16, "%d*32+%2d", feature >> 5, feature & 31); \
buf; \
}) \
)
This would remove the need for callers to explicitly define a buffer.
Also, it would help reduce a few lines in the newly merged
parse_set_clear_cpuid(). But overall, it doesn't seem worth it. Let me
know if you think otherwise or have a better idea.
>> +void scan_feature_dependencies(struct cpuinfo_x86 *c)
>> +{
>> + char feature_buf[16], depends_buf[16];
>> + const struct cpuid_dep *d;
>> +
>> + for (d = cpuid_deps; d->feature; d++) {
>> + if (cpu_has(c, d->feature) && !cpu_has(c, d->depends)) {
>> + /*
>> + * Only warn about the first unmet dependency on the
>> + * first CPU where it is encountered to avoid spamming
>> + * the kernel log.
>> + */
>> + pr_warn_once("CPU%d: feature:%s may not work properly without feature:%s\n",
>> + smp_processor_id(),
>> + x86_feature_name(d->feature, feature_buf),
>> + x86_feature_name(d->depends, depends_buf));
>
> I'd make this a bit less passive-aggressive, something like:
>
> x86 CPU feature dependency check failure: CPU%d has '%s' enabled but '%s' disabled. Kernel might be fine, but no guarantees.
>
Sure! How about making it slightly shorter?
"x86 CPU feature check: CPU%d has '%s' enabled but '%s' disabled. Kernel
might be fine, but no guarantees."
> Because initially most of these warnings will be about quirks and
> oddities that happen to work fine in the current code.
>
Yeah, we can probably modify the check later based on how it goes.
Powered by blists - more mailing lists