From: "Woods, Brian" <Brian.Woods@amd.com>
To: Wei Liu <wei.liu2@citrix.com>
Cc: "Andrew Cooper" <andrew.cooper3@citrix.com>,
"Roger Pau Monné" <roger.pau@citrix.com>,
"Jan Beulich" <jbeulich@suse.com>,
"xen-devel@lists.xen.org" <xen-devel@lists.xen.org>
Subject: Re: [PATCH 1/3] mwait-idle: add support for using halt
Date: Wed, 27 Feb 2019 18:23:35 +0000 [thread overview]
Message-ID: <d296e362-8171-86f6-6d38-d86381e9f34e@amd.com> (raw)
In-Reply-To: <20190227134752.dpelqznz3adu5vtt@zion.uk.xensource.com>
On 2/27/19 7:47 AM, Wei Liu wrote:
> On Mon, Feb 25, 2019 at 08:23:58PM +0000, Woods, Brian wrote:
>> Some AMD processors can use a mixture of mwait and halt for accessing
>> various c-states. In preparation for adding support for AMD processors,
>> update the mwait-idle driver to optionally use halt.
>>
>> Signed-off-by: Brian Woods <brian.woods@amd.com>
>> ---
>> xen/arch/x86/cpu/mwait-idle.c | 40 +++++++++++++++++++++++++++++++++-------
>> 1 file changed, 33 insertions(+), 7 deletions(-)
>>
>> diff --git a/xen/arch/x86/cpu/mwait-idle.c b/xen/arch/x86/cpu/mwait-idle.c
>> index f89c52f256..a063e39d60 100644
>> --- a/xen/arch/x86/cpu/mwait-idle.c
>> +++ b/xen/arch/x86/cpu/mwait-idle.c
>> @@ -103,6 +103,11 @@ static const struct cpuidle_state {
>>
>> #define CPUIDLE_FLAG_DISABLED 0x1
>> /*
>> + * On certain AMD families that support mwait, only c1 can be reached by
>> + * mwait and to reach c2, halt has to be used.
>> + */
>> +#define CPUIDLE_FLAG_USE_HALT 0x2
>> +/*
>> * Set this flag for states where the HW flushes the TLB for us
>> * and so we don't need cross-calls to keep it consistent.
>> * If this flag is set, SW flushes the TLB, so even if the
>> @@ -783,8 +788,23 @@ static void mwait_idle(void)
>>
>> update_last_cx_stat(power, cx, before);
>>
>> - if (cpu_is_haltable(cpu))
>> - mwait_idle_with_hints(eax, MWAIT_ECX_INTERRUPT_BREAK);
>> + if (cpu_is_haltable(cpu)) {
>> + struct cpu_info *info;
>> + switch (cx->entry_method) {
>> + case ACPI_CSTATE_EM_FFH:
>> + mwait_idle_with_hints(eax, MWAIT_ECX_INTERRUPT_BREAK);
>> + break;
>> + case ACPI_CSTATE_EM_HALT:
>
>> + info = get_cpu_info();
>> + spec_ctrl_enter_idle(info);
>> + safe_halt();
>> + spec_ctrl_exit_idle(info);
>
> May I suggest you make this snippet a function? The same code snippet
> appears a few lines above.
>
> Wei.
>
It's used in various other places as well (cpu_idle.c, x86/domain.c),
would a function like:
void safe_halt_with_spec(cpu_info *info)
{
if (!info)
info = get_cpu_info();
spec_ctrl_enter_idle(info);
safe_halt();
spec_ctrl_exit_idle(info);
}
work since that way it could be used in other places where info is
already defined?
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel
next prev parent reply other threads:[~2019-02-27 18:23 UTC|newest]
Thread overview: 34+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-02-25 20:23 [PATCH 0/3] mwait support for AMD processors Woods, Brian
2019-02-25 20:23 ` [PATCH 1/3] mwait-idle: add support for using halt Woods, Brian
2019-02-27 13:47 ` Wei Liu
2019-02-27 18:23 ` Woods, Brian [this message]
2019-03-05 17:12 ` Wei Liu
2019-03-11 15:10 ` Woods, Brian
2019-03-13 9:35 ` Jan Beulich
2019-03-14 19:00 ` Woods, Brian
2019-03-15 8:37 ` Jan Beulich
2019-03-19 16:12 ` Woods, Brian
2019-03-19 16:58 ` Jan Beulich
2019-03-26 15:54 ` Jan Beulich
2019-03-26 21:56 ` Woods, Brian
2019-03-27 14:48 ` Jan Beulich
2019-03-27 17:28 ` Woods, Brian
2019-03-28 8:26 ` Jan Beulich
2019-03-28 15:02 ` Woods, Brian
2019-03-28 15:50 ` Jan Beulich
2019-03-28 16:26 ` Woods, Brian
2019-02-25 20:23 ` [PATCH 2/3] mwait-idle: add support for AMD processors Woods, Brian
2019-03-13 9:42 ` Jan Beulich
2019-03-14 19:14 ` Woods, Brian
2019-02-25 20:24 ` [PATCH 3/3] mwait-idle: add enablement for AMD Naples and Rome Woods, Brian
2019-03-13 9:51 ` Jan Beulich
2019-03-14 19:29 ` Woods, Brian
2019-03-15 8:54 ` Jan Beulich
2019-03-19 15:59 ` Woods, Brian
2019-03-19 17:01 ` Jan Beulich
2019-02-26 10:49 ` [PATCH 0/3] mwait support for AMD processors Jan Beulich
2019-02-26 16:25 ` Woods, Brian
2019-02-26 16:37 ` Jan Beulich
2019-02-26 16:54 ` Woods, Brian
2019-02-27 8:51 ` Jan Beulich
2019-02-27 16:54 ` Woods, Brian
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=d296e362-8171-86f6-6d38-d86381e9f34e@amd.com \
--to=brian.woods@amd.com \
--cc=andrew.cooper3@citrix.com \
--cc=jbeulich@suse.com \
--cc=roger.pau@citrix.com \
--cc=wei.liu2@citrix.com \
--cc=xen-devel@lists.xen.org \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.