From nobody Tue Apr 28 01:12:03 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 72CD7C433EF for ; Wed, 8 Jun 2022 22:01:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236489AbiFHWBP (ORCPT ); Wed, 8 Jun 2022 18:01:15 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40858 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236012AbiFHWBG (ORCPT ); Wed, 8 Jun 2022 18:01:06 -0400 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8D4405DA1D; Wed, 8 Jun 2022 15:01:05 -0700 (PDT) Date: Wed, 08 Jun 2022 22:01:03 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1654725664; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=cV7/MEgbNdmv3L9TaoMDRtxO0MmFQo38WWCZ06yj7RA=; b=QJo9s4elrnxQIxyc7X9W0nTbQlcI/m8hSb6hgJqk7qGErTMcqbYcGgt4Pci/6fWNQRjQ3V v3rYKzgalxRSvEEqlIsGPuRq5/fACn3BgPtzZu32NoQtNflP7o0qLz/AaiYokSGspXPVkd gLL+jhgOe3fE04jmeWb+DxLlLAOBiMjsx8b2RiegEYlxJj1B0L78fMEI7yZEfMwWHgHHh5 bSJ1A4t/zvn3KR+o6k+/YRz87ohwAlgczaFOZIKwgWTWLEnNZHNkeYONz050wKZXZPBJ0K A8PGVQISRxOIO3ewwCQGuwdxxBtoenNROvhdHVnNoMEJJxT81CPMxKdf8CFGIw== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1654725664; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=cV7/MEgbNdmv3L9TaoMDRtxO0MmFQo38WWCZ06yj7RA=; b=9xDIUSDE60AXjsXGfpVUwoPlpeO99qQEtwWtfcW3VUymdtemUNr58i+3bfDwd/C6wOkN/D agaK3ZJxjZ99vmCw== From: "tip-bot2 for Wyes Karny" Sender: tip-bot2@linutronix.de Reply-to: linux-kernel@vger.kernel.org To: linux-tip-commits@vger.kernel.org Subject: [tip: x86/cpu] x86: Handle idle=nomwait cmdline properly for x86_idle Cc: Wyes Karny , Dave Hansen , Zhang Rui , x86@kernel.org, linux-kernel@vger.kernel.org In-Reply-To: =?utf-8?q?=3Cfdc2dc2d0a1bc21c2f53d989ea2d2ee3ccbc0dbe=2E16545?= =?utf-8?q?38381=2Egit-series=2Ewyes=2Ekarny=40amd=2Ecom=3E?= References: =?utf-8?q?=3Cfdc2dc2d0a1bc21c2f53d989ea2d2ee3ccbc0dbe=2E165453?= =?utf-8?q?8381=2Egit-series=2Ewyes=2Ekarny=40amd=2Ecom=3E?= MIME-Version: 1.0 Message-ID: <165472566300.4207.10310756827106084828.tip-bot2@tip-bot2> Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The following commit has been merged into the x86/cpu branch of tip: Commit-ID: 8bcedb4ce04750e1ccc9a6b6433387f6a9166a56 Gitweb: https://git.kernel.org/tip/8bcedb4ce04750e1ccc9a6b6433387f6a= 9166a56 Author: Wyes Karny AuthorDate: Mon, 06 Jun 2022 23:33:34 +05:30 Committer: Dave Hansen CommitterDate: Wed, 08 Jun 2022 12:58:58 -07:00 x86: Handle idle=3Dnomwait cmdline properly for x86_idle When kernel is booted with idle=3Dnomwait do not use MWAIT as the default idle state. If the user boots the kernel with idle=3Dnomwait, it is a clear direction to not use mwait as the default idle state. However, the current code does not take this into consideration while selecting the default idle state on x86. Fix it by checking for the idle=3Dnomwait boot option in prefer_mwait_c1_over_halt(). Also update the documentation around idle=3Dnomwait appropriately. [ dhansen: tweak commit message ] Signed-off-by: Wyes Karny Signed-off-by: Dave Hansen Tested-by: Zhang Rui Link: https://lkml.kernel.org/r/fdc2dc2d0a1bc21c2f53d989ea2d2ee3ccbc0dbe.16= 54538381.git-series.wyes.karny@amd.com --- Documentation/admin-guide/pm/cpuidle.rst | 15 +++++++++------ arch/x86/kernel/process.c | 9 ++++++--- 2 files changed, 15 insertions(+), 9 deletions(-) diff --git a/Documentation/admin-guide/pm/cpuidle.rst b/Documentation/admin= -guide/pm/cpuidle.rst index aec2cd2..19754be 100644 --- a/Documentation/admin-guide/pm/cpuidle.rst +++ b/Documentation/admin-guide/pm/cpuidle.rst @@ -612,8 +612,8 @@ the ``menu`` governor to be used on the systems that us= e the ``ladder`` governor by default this way, for example. =20 The other kernel command line parameters controlling CPU idle time managem= ent -described below are only relevant for the *x86* architecture and some of -them affect Intel processors only. +described below are only relevant for the *x86* architecture and references +to ``intel_idle`` affect Intel processors only. =20 The *x86* architecture support code recognizes three kernel command line options related to CPU idle time management: ``idle=3Dpoll``, ``idle=3Dhal= t``, @@ -635,10 +635,13 @@ idle, so it very well may hurt single-thread computat= ions performance as well as energy-efficiency. Thus using it for performance reasons may not be a goo= d idea at all.] =20 -The ``idle=3Dnomwait`` option disables the ``intel_idle`` driver and causes -``acpi_idle`` to be used (as long as all of the information needed by it is -there in the system's ACPI tables), but it is not allowed to use the -``MWAIT`` instruction of the CPUs to ask the hardware to enter idle states. +The ``idle=3Dnomwait`` option prevents the use of ``MWAIT`` instruction of +the CPU to enter idle states. When this option is used, the ``acpi_idle`` +driver will use the ``HLT`` instruction instead of ``MWAIT``. On systems +running Intel processors, this option disables the ``intel_idle`` driver +and forces the use of the ``acpi_idle`` driver instead. Note that in either +case, ``acpi_idle`` driver will function only if all the information needed +by it is in the system's ACPI tables. =20 In addition to the architecture-level kernel command line options affectin= g CPU idle time management, there are parameters affecting individual ``CPUIdle`` diff --git a/arch/x86/kernel/process.c b/arch/x86/kernel/process.c index b370767..dca2e5e 100644 --- a/arch/x86/kernel/process.c +++ b/arch/x86/kernel/process.c @@ -824,6 +824,10 @@ static void amd_e400_idle(void) */ static int prefer_mwait_c1_over_halt(const struct cpuinfo_x86 *c) { + /* User has disallowed the use of MWAIT. Fallback to HALT */ + if (boot_option_idle_override =3D=3D IDLE_NOMWAIT) + return 0; + if (c->x86_vendor !=3D X86_VENDOR_INTEL) return 0; =20 @@ -932,9 +936,8 @@ static int __init idle_setup(char *str) } else if (!strcmp(str, "nomwait")) { /* * If the boot option of "idle=3Dnomwait" is added, - * it means that mwait will be disabled for CPU C2/C3 - * states. In such case it won't touch the variable - * of boot_option_idle_override. + * it means that mwait will be disabled for CPU C1/C2/C3 + * states. */ boot_option_idle_override =3D IDLE_NOMWAIT; } else