From: "Liang, Kan" <kan.liang@linux.intel.com>
To: Cyrill Gorcunov <gorcunov@gmail.com>
Cc: peterz@infradead.org, mingo@redhat.com, acme@kernel.org,
tglx@linutronix.de, bp@alien8.de, x86@kernel.org,
linux-kernel@vger.kernel.org, dave.hansen@intel.com,
yu-cheng.yu@intel.com, bigeasy@linutronix.de, hpa@zytor.com,
eranian@google.com, ak@linux.intel.com, chang.seok.bae@intel.com
Subject: Re: [PATCH] x86/fpu/xstate: Fix an xstate size check warning
Date: Tue, 21 Jul 2020 14:27:17 -0400 [thread overview]
Message-ID: <7fbe722b-7a75-098d-23b5-fd1fd7d310d6@linux.intel.com> (raw)
In-Reply-To: <20200720173313.GA4221@grain>
On 7/20/2020 1:33 PM, Cyrill Gorcunov wrote:
> On Mon, Jul 20, 2020 at 06:50:51AM -0700, kan.liang@linux.intel.com wrote:
> ...
>> static unsigned int __init get_xsave_size(void)
>> {
>> unsigned int eax, ebx, ecx, edx;
>> @@ -710,7 +741,7 @@ static int __init init_xstate_size(void)
>> xsave_size = get_xsave_size();
>>
>> if (boot_cpu_has(X86_FEATURE_XSAVES))
>> - possible_xstate_size = get_xsaves_size();
>> + possible_xstate_size = get_xsaves_size_no_dynamic();
>> else
>> possible_xstate_size = xsave_size;
>
> Hi! Maybe we could enhance get_xsaves_size instead ? The get_xsaves_size is
> static and __init function (thus not a hot path) used once as far as I see.
> Say
>
> static unsigned int __init get_xsaves_size(void)
> {
> u64 mask = xfeatures_mask_dynamic();
> unsigned int eax, ebx, ecx, edx;
>
> /*
> * In case if dynamic features are present make
> * sure they are not accounted in the result since
> * the buffer should be allocated separately from
> * task->fpu.
> */
> if (mask)
> wrmsrl(MSR_IA32_XSS, xfeatures_mask_supervisor());
>
> /*
> * - CPUID function 0DH, sub-function 1:
> * EBX enumerates the size (in bytes) required by
> * the XSAVES instruction for an XSAVE area
> * containing all the state components
> * corresponding to bits currently set in
> * XCR0 | IA32_XSS.
> */
> cpuid_count(XSTATE_CPUID, 1, &eax, &ebx, &ecx, &edx);
>
> if (mask)
> wrmsrl(MSR_IA32_XSS, xfeatures_mask_supervisor() | mask);
>
> return ebx;
> }
>
> but if you expect more use of get_xsaves_size_no_dynamic() and
> get_xsaves_size() in future then sure, we need a separate function.
>
For now, I don't have more use of
get_xsaves_size_no_dynamic()/get_xsaves_size(). I don't know if anyone
else will use them later.
> The benefit from such extension is that when you read get_xsaves_size
> you'll notice the dependency on dynamic features immediaely.
>
> Though I'm fine with current patch as well, up to you. Thanks for the patch!
>
Personally, I prefer to keep the current patch because I like the name
get_xsaves_size_no_dynamic(), which explicitly tells the dynamic
features are excluded.
> Reviewed-by: Cyrill Gorcunov <gorcunov@gmail.com>
>
Thanks for the review.
Kan
next prev parent reply other threads:[~2020-07-21 18:27 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-07-20 13:50 [PATCH] x86/fpu/xstate: Fix an xstate size check warning kan.liang
2020-07-20 17:33 ` Cyrill Gorcunov
2020-07-21 18:27 ` Liang, Kan [this message]
2020-08-06 17:10 ` [tip: x86/urgent] x86/fpu/xstate: Fix an xstate size check warning with architectural LBRs tip-bot2 for Kan Liang
2020-08-06 23:38 ` tip-bot2 for Kan Liang
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=7fbe722b-7a75-098d-23b5-fd1fd7d310d6@linux.intel.com \
--to=kan.liang@linux.intel.com \
--cc=acme@kernel.org \
--cc=ak@linux.intel.com \
--cc=bigeasy@linutronix.de \
--cc=bp@alien8.de \
--cc=chang.seok.bae@intel.com \
--cc=dave.hansen@intel.com \
--cc=eranian@google.com \
--cc=gorcunov@gmail.com \
--cc=hpa@zytor.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@redhat.com \
--cc=peterz@infradead.org \
--cc=tglx@linutronix.de \
--cc=x86@kernel.org \
--cc=yu-cheng.yu@intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox