Re: [PATCH v2 05/17] x86/cpu/intel: Fix page copy performance for extended Families
From: Andrew Cooper
Date: Tue Feb 11 2025 - 19:55:08 EST
On 11/02/2025 8:53 pm, Dave Hansen wrote:
> On 2/11/25 11:43, Sohil Mehta wrote:
>> + /*
>> + * Modern CPUs are generally expected to have a sane fast string
>> + * implementation. However, the BIOS may disable it on certain CPUs
>> + * via the architectural FAST_STRING bit.
>> + */
>> + if (IS_ENABLED(CONFIG_X86_64) && (c->x86 == 6 || c->x86 > 15))
>> + set_cpu_cap(c, X86_FEATURE_REP_GOOD);
> I'm not sure the BIOS comment is helpful here.
>
> Also, at this point, let's just make the check >=6 (or the >=PPRO
> equivalent).
>
> It will only matter if *all* of these are true:
> 1. Someone has a 64-bit capable P4 that powers on
> 2. They're running a 64-bit mainline kernel
> 3. String copy is *actually* slower than the alternative
> 4. They are performance sensitive enough to notice
>
> We don't even know the answer to #3 for sure. Let's just say what we're
> doing in a comment:
>
> /* Assume that any 64-bit CPU has a good implementation */
If you're going to override the BIOS setting, then you need to
explicitly set MSR_MISC_ENABLE.FAST_STRINGS.
Otherwise you're claiming to Linux that REP is good even when hardware
is prohibited from using optimisations.
~Andrew