[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <87y2eha576.fsf@nanos.tec.linutronix.de>
Date: Sat, 20 Mar 2021 22:25:01 +0100
From: Thomas Gleixner <tglx@...utronix.de>
To: "Chang S. Bae" <chang.seok.bae@...el.com>, bp@...e.de,
luto@...nel.org, mingo@...nel.org, x86@...nel.org
Cc: len.brown@...el.com, dave.hansen@...el.com, jing2.liu@...el.com,
ravi.v.shankar@...el.com, linux-kernel@...r.kernel.org,
chang.seok.bae@...el.com
Subject: Re: [PATCH v4 16/22] x86/fpu/xstate: Extend the table to map state components with features
On Sun, Feb 21 2021 at 10:56, Chang S. Bae wrote:
> +struct xfeature_capflag_info {
> + int xfeature_idx;
> + short cpu_cap;
First of all please format the struct members tabular as x86 does all
over the place.
What's the purpose of 'int' 'short' here? This data is unsinged. We have
no negative feature bits and no negative xfeatures.
Also if your intention is to save space, then you might want to look at
the compiler output. It's not saving anything, it's still 8 byte because
the compiler pads the struct.
> +};
> +
> +static struct xfeature_capflag_info xfeature_capflags[] __initdata = {
> + { XFEATURE_FP, X86_FEATURE_FPU },
> + { XFEATURE_SSE, X86_FEATURE_XMM },
> + { XFEATURE_YMM, X86_FEATURE_AVX },
> + { XFEATURE_BNDREGS, X86_FEATURE_MPX },
> + { XFEATURE_BNDCSR, X86_FEATURE_MPX },
> + { XFEATURE_OPMASK, X86_FEATURE_AVX512F },
> + { XFEATURE_ZMM_Hi256, X86_FEATURE_AVX512F },
> + { XFEATURE_Hi16_ZMM, X86_FEATURE_AVX512F },
> + { XFEATURE_PT_UNIMPLEMENTED_SO_FAR, X86_FEATURE_INTEL_PT },
> + { XFEATURE_PKRU, X86_FEATURE_PKU },
> + { XFEATURE_PASID, X86_FEATURE_ENQCMD },
> };
And you could have changed the existing table just so:
static unsigned short xsave_cpuid_features[] __initdata = {
[XFEATURE_FP] = X86_FEATURE_FPU,
[XFEATURE_SSE] = X86_FEATURE_XMM,
[XFEATURE_YMM] = X86_FEATURE_AVX,
[XFEATURE_BNDREGS] = X86_FEATURE_MPX,
[XFEATURE_BNDCSR] = X86_FEATURE_MPX,
[XFEATURE_OPMASK] = X86_FEATURE_AVX512F,
[XFEATURE_ZMM_Hi256] = X86_FEATURE_AVX512F,
[XFEATURE_Hi16_ZMM] = X86_FEATURE_AVX512F,
[XFEATURE_PT_UNIMPLEMENTED_SO_FAR] = X86_FEATURE_INTEL_PT,
[XFEATURE_PKRU] = X86_FEATURE_PKU,
[XFEATURE_PASID] = X86_FEATURE_ENQCMD,
};
and the implementation to:
for (i = 0; i < ARRAY_SIZE(xsave_cpuid_features); i++) {
- if (xsave_cpuid_features[i] || !boot_cpu_has(xsave_cpuid_features[i]))
+ if (xsave_cpuid_features[i] || !boot_cpu_has(xsave_cpuid_features[i]))
xfeatures_mask_all &= ~BIT_ULL(i);
Even with the gaps for XTILE the table is smaller, the code is simpler...
> + for (i = 0; i < ARRAY_SIZE(xfeature_capflags); i++) {
> + short cpu_cap = xfeature_capflags[i].cpu_cap;
> + int idx = xfeature_capflags[i].xfeature_idx;
> +
> + if (!boot_cpu_has(cpu_cap))
> + xfeatures_mask_all &= ~BIT_ULL(idx);
> }
>
> xfeatures_mask_all &= fpu__get_supported_xfeatures_mask();
Thanks,
tglx
Powered by blists - more mailing lists