linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Srivatsa S. Bhat" <srivatsa.bhat@linux.vnet.ibm.com>
To: lenb@kernel.org,
	"akpm@linux-foundation.org" <akpm@linux-foundation.org>,
	"Rafael J. Wysocki" <rjw@sisk.pl>
Cc: venki@google.com, suresh.b.siddha@intel.com,
	Borislav Petkov <bp@amd64.org>,
	Thomas Gleixner <tglx@linutronix.de>,
	Ingo Molnar <mingo@kernel.org>, "H. Peter Anvin" <hpa@zytor.com>,
	x86@kernel.org, Deepthi Dharwar <deepthi@linux.vnet.ibm.com>,
	Linux PM mailing list <linux-pm@vger.kernel.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	"Srivatsa S. Bhat" <srivatsa.bhat@linux.vnet.ibm.com>
Subject: [PATCH v2][RESEND] x86: Make mwait_usable() heed to "idle=" kernel parameters properly
Date: Mon, 30 Apr 2012 12:26:56 +0530	[thread overview]
Message-ID: <4F9E37B8.30001@linux.vnet.ibm.com> (raw)

From: Srivatsa S. Bhat <srivatsa.bhat@linux.vnet.ibm.com>

The checks that exist in mwait_usable() for "idle=" kernel parameters
are insufficient. As a result, mwait_usable() can return 1 even if
"idle=nomwait" or "idle=poll" or "idle=halt" parameters are passed.

Of these cases, incorrect handling of idle=nomwait is a universal problem
since mwait can get used for usual CPU idling. However the rest of the
cases are problematic only during CPU Hotplug (offline) because, in the
CPU offline path, the function mwait_play_dead() is called, which might
result in mwait being used in the offline CPUs, if mwait_usable() happens
to return 1.

Fix these issues by checking for the boot time "idle=" kernel parameter
properly in mwait_usable().

The first issue (usual cpu idling) is demonstrated below:

Before applying the patch (dmesg snippet):
[    0.000000] Command line: [...] idle=nomwait
[    0.000000] Kernel command line: [...] idle=nomwait
[    0.000000]  RCU dyntick-idle grace-period acceleration is enabled.
[    0.140606] using mwait in idle threads.         <======= mwait being used
[    4.303986] cpuidle: using governor ladder
[    4.308232] cpuidle: using governor menu

After applying the patch:
[    0.000000] Command line: [...] idle=nomwait
[    0.000000] Kernel command line: [...] idle=nomwait
[    0.000000]  RCU dyntick-idle grace-period acceleration is enabled.
[    4.264100] cpuidle: using governor ladder
[    4.268342] cpuidle: using governor menu

Signed-off-by: Deepthi Dharwar <deepthi@linux.vnet.ibm.com>
Signed-off-by: Srivatsa S. Bhat <srivatsa.bhat@linux.vnet.ibm.com>
---

 arch/x86/kernel/process.c |    8 ++++++++
 1 files changed, 8 insertions(+), 0 deletions(-)

diff --git a/arch/x86/kernel/process.c b/arch/x86/kernel/process.c
index a33afaa..b526c4e 100644
--- a/arch/x86/kernel/process.c
+++ b/arch/x86/kernel/process.c
@@ -618,9 +618,17 @@ int mwait_usable(const struct cpuinfo_x86 *c)
 {
 	u32 eax, ebx, ecx, edx;

+	/* Use mwait if idle=mwait boot option is given */
 	if (boot_option_idle_override == IDLE_FORCE_MWAIT)
 		return 1;

+	/*
+	 * Any idle= boot option other than idle=mwait means that we must not
+	 * use mwait. Eg: idle=halt or idle=poll or idle=nomwait
+	 */
+	if (boot_option_idle_override != IDLE_NO_OVERRIDE)
+		return 0;
+
 	if (c->cpuid_level < MWAIT_INFO)
 		return 0;


             reply	other threads:[~2012-04-30  6:57 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-04-30  6:56 Srivatsa S. Bhat [this message]
2012-05-08  4:25 ` [tip:sched/core] x86/sched: Make mwait_usable() heed to "idle=" kernel parameters properly tip-bot for Srivatsa S. Bhat

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=4F9E37B8.30001@linux.vnet.ibm.com \
    --to=srivatsa.bhat@linux.vnet.ibm.com \
    --cc=akpm@linux-foundation.org \
    --cc=bp@amd64.org \
    --cc=deepthi@linux.vnet.ibm.com \
    --cc=hpa@zytor.com \
    --cc=lenb@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=mingo@kernel.org \
    --cc=rjw@sisk.pl \
    --cc=suresh.b.siddha@intel.com \
    --cc=tglx@linutronix.de \
    --cc=venki@google.com \
    --cc=x86@kernel.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).