All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Carroll, Lewis" <Lewis.Carroll@amd.com>
To: Borislav Petkov <bp@alien8.de>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	"peterz@infradead.org" <peterz@infradead.org>,
	"dave.hansen@linux.intel.com" <dave.hansen@linux.intel.com>
Cc: "Karny, Wyes" <Wyes.Karny@amd.com>,
	"Limonciello, Mario" <Mario.Limonciello@amd.com>,
	"Shenoy, Gautham Ranjal" <gautham.shenoy@amd.com>,
	"Narayan, Ananth" <Ananth.Narayan@amd.com>,
	"Rao, Bharata Bhasker" <bharata@amd.com>,
	"len.brown@intel.com" <len.brown@intel.com>,
	"x86@kernel.org" <x86@kernel.org>,
	"tglx@linutronix.de" <tglx@linutronix.de>,
	"mingo@redhat.com" <mingo@redhat.com>,
	"hpa@zytor.com" <hpa@zytor.com>,
	"chang.seok.bae@intel.com" <chang.seok.bae@intel.com>,
	"keescook@chromium.org" <keescook@chromium.org>,
	"metze@samba.org" <metze@samba.org>,
	"zhengqi.arch@bytedance.com" <zhengqi.arch@bytedance.com>,
	"mark.rutland@arm.com" <mark.rutland@arm.com>
Subject: RE: [PATCH] x86: Prefer MWAIT over HALT on AMD processors
Date: Tue, 5 Apr 2022 20:26:53 +0000	[thread overview]
Message-ID: <MN2PR12MB3949923BCD8B368F8269565BFAE49@MN2PR12MB3949.namprd12.prod.outlook.com> (raw)
In-Reply-To: <YkxMtx9zdk+nH33r@zn.tnic>

[AMD Official Use Only]

Merging some comments from subsequent threads below...

> -----Original Message-----
> From: Borislav Petkov <bp@alien8.de>
> Sent: Tuesday, April 5, 2022 10:06 AM
> To: Karny, Wyes <Wyes.Karny@amd.com>
> Cc: linux-kernel@vger.kernel.org; Carroll, Lewis <Lewis.Carroll@amd.com>;
> Limonciello, Mario <Mario.Limonciello@amd.com>; Shenoy, Gautham Ranjal
> <gautham.shenoy@amd.com>; Narayan, Ananth <Ananth.Narayan@amd.com>; Rao,
> Bharata Bhasker <bharata@amd.com>; len.brown@intel.com; x86@kernel.org;
> tglx@linutronix.de; mingo@redhat.com; dave.hansen@linux.intel.com;
> hpa@zytor.com; peterz@infradead.org; chang.seok.bae@intel.com;
> keescook@chromium.org; metze@samba.org; zhengqi.arch@bytedance.com;
> mark.rutland@arm.com
> Subject: Re: [PATCH] x86: Prefer MWAIT over HALT on AMD processors
> 
> [CAUTION: External Email]
> 
> On Tue, Apr 05, 2022 at 06:30:21PM +0530, Wyes Karny wrote:
> > From: Lewis Caroll <lewis.carroll@amd.com>
> >
> > Currently in the absence of the cpuidle driver (eg: when global
> > C-States are disabled in the BIOS or when cpuidle is driver is not
> > compiled in),
> 
> When does that ever happen?
> 
> Sounds like a very very niche situation to me...
> 

This happens when:
 * User disables global C-states in BIOS
 * User disables cpuidle (e.g. idle=off or processor.max_cstate=0)
 * Kernel does not have CONFIG_ACPI_PROCESSOR_IDLE
Genesis of this patch is customer performance observations.

> > Here we enable MWAIT instruction as the default idle call for AMD Zen
> > processors which support MWAIT. We retain the existing behaviour for
> > older processors which depend on HALT.
> 
> Please use passive voice in your commit message: no "we" or "I", etc, and
> describe your changes in imperative mood.
> 
> Also, pls read section "2) Describe your changes" in
> Documentation/process/submitting-patches.rst for more details.
> 
> Also, see section "Changelog" in
> Documentation/process/maintainer-tip.rst
> 
> Bottom line is: personal pronouns are ambiguous in text, especially with so
> many parties/companies/etc developing the kernel so let's avoid them please.
> 
> >  static int prefer_mwait_c1_over_halt(const struct cpuinfo_x86 *c)  {
> > -     if (c->x86_vendor != X86_VENDOR_INTEL)
> > +     if (!early_mwait_supported(c))
> 
> Isn't it enough to simply do here:
> 
>         if (cpu_has(c, X86_FEATURE_ZEN))
>                 return 1;
> 
>         if (c->x86_vendor != X86_VENDOR_INTEL)
>                 return 0;
> 
>         ...

Yes. We felt the code more readable with the prefer_mwait_c1_over_halt fn.
Hygon CPU init indeed sets X86_FEATURE ZEN.
AMD CPU init sets X86_FEATURE_ZEN for family >= 17h (not only 17h).
Cleanest solution might be a new CPU feature (e.g. X86_PREFER_MWAIT_IDLE) that
gets set appropriately, but that would require touching more files.

> 
> 
> --
> Regards/Gruss,
>     Boris.

  reply	other threads:[~2022-04-06  2:23 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-04-05 13:00 [PATCH] x86: Prefer MWAIT over HALT on AMD processors Wyes Karny
2022-04-05 14:05 ` Borislav Petkov
2022-04-05 20:26   ` Carroll, Lewis [this message]
2022-04-05 20:38     ` Borislav Petkov
2022-04-05 21:49       ` Carroll, Lewis
2022-04-06  9:30         ` Borislav Petkov
2022-04-06  6:14   ` Wyes Karny
2022-04-06  9:25     ` Borislav Petkov
2022-04-05 14:07 ` Peter Zijlstra
2022-04-05 15:10   ` Dave Hansen
2022-04-05 15:34     ` Limonciello, Mario
2022-04-05 15:47       ` Dave Hansen
2022-04-05 20:40         ` Limonciello, Mario
2022-04-06  1:44           ` Thomas Gleixner
2022-04-06 14:23             ` Limonciello, Mario
2022-04-07 21:16               ` Dave Hansen
2022-04-08  1:24                 ` Limonciello, Mario
2022-04-14 21:06                   ` Limonciello, Mario
2022-04-07  2:19   ` Wen Pu

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=MN2PR12MB3949923BCD8B368F8269565BFAE49@MN2PR12MB3949.namprd12.prod.outlook.com \
    --to=lewis.carroll@amd.com \
    --cc=Ananth.Narayan@amd.com \
    --cc=Mario.Limonciello@amd.com \
    --cc=Wyes.Karny@amd.com \
    --cc=bharata@amd.com \
    --cc=bp@alien8.de \
    --cc=chang.seok.bae@intel.com \
    --cc=dave.hansen@linux.intel.com \
    --cc=gautham.shenoy@amd.com \
    --cc=hpa@zytor.com \
    --cc=keescook@chromium.org \
    --cc=len.brown@intel.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mark.rutland@arm.com \
    --cc=metze@samba.org \
    --cc=mingo@redhat.com \
    --cc=peterz@infradead.org \
    --cc=tglx@linutronix.de \
    --cc=x86@kernel.org \
    --cc=zhengqi.arch@bytedance.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 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.