From patchwork Wed Apr 5 19:48:20 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Reed X-Patchwork-Id: 1765723 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.ubuntu.com (client-ip=91.189.94.19; helo=huckleberry.canonical.com; envelope-from=kernel-team-bounces@lists.ubuntu.com; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=canonical.com header.i=@canonical.com header.a=rsa-sha256 header.s=20210705 header.b=BQWZ6N8r; dkim-atps=neutral Received: from huckleberry.canonical.com (huckleberry.canonical.com [91.189.94.19]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4PsFYX6CMhz1yYP for ; Thu, 6 Apr 2023 05:48:32 +1000 (AEST) Received: from localhost ([127.0.0.1] helo=huckleberry.canonical.com) by huckleberry.canonical.com with esmtp (Exim 4.86_2) (envelope-from ) id 1pk97L-0006u6-3m; Wed, 05 Apr 2023 19:48:27 +0000 Received: from smtp-relay-internal-0.internal ([10.131.114.225] helo=smtp-relay-internal-0.canonical.com) by huckleberry.canonical.com with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.86_2) (envelope-from ) id 1pk97I-0006tB-Mb for kernel-team@lists.ubuntu.com; Wed, 05 Apr 2023 19:48:24 +0000 Received: from mail-oi1-f199.google.com (mail-oi1-f199.google.com [209.85.167.199]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by smtp-relay-internal-0.canonical.com (Postfix) with ESMTPS id 6E51B3F19A for ; Wed, 5 Apr 2023 19:48:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=canonical.com; s=20210705; t=1680724104; bh=DBZQnsw868P+ad8jq4fhc9TOyLOkGgzE521PbDb+H/g=; h=From:To:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=BQWZ6N8rVUFN6rs6mJbs4BUteXGXQLre3h8sUKKcO8eGPWllh7ALh73evGqkdKBRE XOmneH4aTKtNpdKcQ9ynC+I3MEhlOL2od/9tn1jp4zlmqcZJ4dox8/lrIVObVtNn8q 2+sXzvrd4F65JHWz5ysVTWKA0FcGKkO76v2ae9bj6U2urZ/oc1gKDlWeUgEtpFcXeu bnBTk4bwUX9w1HC3rJIbMmno/l8cRMkxPeONajS+XtnV07l14QveswQA7Mc3mI42Wj d0hU753D+LZrkLs8nWhye2s61u6jiy/dO5WdaAoqYc5jWAOsgCnNejCldCEj/QRLF5 nPEACkio7k+xg== Received: by mail-oi1-f199.google.com with SMTP id u21-20020a056808001500b0038970fe327bso5580314oic.17 for ; Wed, 05 Apr 2023 12:48:24 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1680724103; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=DBZQnsw868P+ad8jq4fhc9TOyLOkGgzE521PbDb+H/g=; b=CmV2WGbon2ZtdLDZwMlbo66vvvHIPjUXCcHmOO98xikcBQqi5Du/ti9M1Op+7Qat3H cBEkMSKZcj3ur1IWX3D4coC/C1wvghHygaj4A/ztGtvpE5ILLGVh7+KTE8e+QkWpGMFW ebdMZlzd9sHixGbl6qkPi3FPTxebWWFJiss304BbsdgOMEeNDBdp4rtDIVxRpf0ooHeO J/PLtCrEpmgIeV6r/fc7mQXk9k502zNfkfnZ2at4xzMiQ+gKog8fsD5VOJ7a47jz2I5A tGpCshseIWYyOY2wFy0WEu933s/Y+vLnmtWjr2N1ocnIeP36zyswR4VZvIXfvUl+bvjd AIcQ== X-Gm-Message-State: AAQBX9cr6sLUM2ZzsdarGpSOUHQzINhMYKdc8FZGp1MDK/BS+5fR/xkc KvnOx7wnVkhrC97iuG2qxmqvzRAKSVHCJACP8Z8WuKf2ExzlaZEejHk9qolStOjeEgid1RkDlsJ zA2gCaj3OXlXmKHtxdL7aWatUhUNZvoSQN5iZpDuTxM0604ZHZg== X-Received: by 2002:a9d:6c13:0:b0:69d:e8b5:6faa with SMTP id f19-20020a9d6c13000000b0069de8b56faamr2974112otq.34.1680724103005; Wed, 05 Apr 2023 12:48:23 -0700 (PDT) X-Google-Smtp-Source: AKy350YGtdQ67AxnfWRnWqU1ziZQRPCd+qx4kNPaus4XbLYuBV+ULhzW6LDLLVIkJplm3FOHprfDHQ== X-Received: by 2002:a9d:6c13:0:b0:69d:e8b5:6faa with SMTP id f19-20020a9d6c13000000b0069de8b56faamr2974104otq.34.1680724102617; Wed, 05 Apr 2023 12:48:22 -0700 (PDT) Received: from localhost ([2600:1700:1d0:5e50:5484:869b:2630:869]) by smtp.gmail.com with ESMTPSA id f5-20020a9d6c05000000b006a154373578sm7095858otq.39.2023.04.05.12.48.22 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 05 Apr 2023 12:48:22 -0700 (PDT) From: Michael Reed To: kernel-team@lists.ubuntu.com Subject: [SRU J/K][PATCH V2 1/1] cpufreq: ACPI: Defer setting boost MSRs Date: Wed, 5 Apr 2023 14:48:20 -0500 Message-Id: <20230405194820.13770-2-michael.reed@canonical.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230405194820.13770-1-michael.reed@canonical.com> References: <20230405194820.13770-1-michael.reed@canonical.com> MIME-Version: 1.0 X-BeenThere: kernel-team@lists.ubuntu.com X-Mailman-Version: 2.1.20 Precedence: list List-Id: Kernel team discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: kernel-team-bounces@lists.ubuntu.com Sender: "kernel-team" From: Stuart Hayes When acpi-cpufreq is loaded, boost is enabled on every CPU (by setting an MSR) before the driver is registered with cpufreq. This can be very time consuming, because it is done with a CPU hotplug startup callback, and cpuhp_setup_state() schedules the callback (cpufreq_boost_online()) to run on each CPU one at a time, waiting for each to run before calling the next. If cpufreq_register_driver() fails--if, for example, there are no ACPI P-states present--this is wasted time. Since cpufreq already sets up a CPU hotplug startup callback if and when acpi-cpufreq is registered, set the boost MSRs in acpi_cpufreq_cpu_init(), which is called by the cpufreq cpuhp callback. This allows acpi-cpufreq to exit quickly if it is loaded but not needed. On one system with 192 CPUs, this patch speeds up boot by about 30 seconds. BugLink: https://bugs.launchpad.net/bugs/2008527 Signed-off-by: Stuart Hayes Signed-off-by: Rafael J. Wysocki (cherry picked from commit 13fdbc8b8da6a2325cad3359c9a70504b0ff2f93) Signed-off-by: Michael Reed --- drivers/cpufreq/acpi-cpufreq.c | 31 +++---------------------------- 1 file changed, 3 insertions(+), 28 deletions(-) diff --git a/drivers/cpufreq/acpi-cpufreq.c b/drivers/cpufreq/acpi-cpufreq.c index 28467d83c745..8b5c84c9dc1e 100644 --- a/drivers/cpufreq/acpi-cpufreq.c +++ b/drivers/cpufreq/acpi-cpufreq.c @@ -530,15 +530,6 @@ static void free_acpi_perf_data(void) free_percpu(acpi_perf_data); } -static int cpufreq_boost_online(unsigned int cpu) -{ - /* - * On the CPU_UP path we simply keep the boost-disable flag - * in sync with the current global state. - */ - return boost_set_msr(acpi_cpufreq_driver.boost_enabled); -} - static int cpufreq_boost_down_prep(unsigned int cpu) { /* @@ -892,6 +883,8 @@ static int acpi_cpufreq_cpu_init(struct cpufreq_policy *policy) if (perf->states[0].core_frequency * 1000 != freq_table[0].frequency) pr_warn(FW_WARN "P-state 0 is not max freq\n"); + set_boost(policy, acpi_cpufreq_driver.boost_enabled); + return result; err_unreg: @@ -911,6 +904,7 @@ static int acpi_cpufreq_cpu_exit(struct cpufreq_policy *policy) pr_debug("%s\n", __func__); + cpufreq_boost_down_prep(policy->cpu); policy->fast_switch_possible = false; policy->driver_data = NULL; acpi_processor_unregister_performance(data->acpi_perf_cpu); @@ -967,25 +961,9 @@ static void __init acpi_cpufreq_boost_init(void) acpi_cpufreq_driver.set_boost = set_boost; acpi_cpufreq_driver.boost_enabled = boost_state(0); - /* - * This calls the online callback on all online cpu and forces all - * MSRs to the same value. - */ - ret = cpuhp_setup_state(CPUHP_AP_ONLINE_DYN, "cpufreq/acpi:online", - cpufreq_boost_online, cpufreq_boost_down_prep); - if (ret < 0) { - pr_err("acpi_cpufreq: failed to register hotplug callbacks\n"); - return; - } acpi_cpufreq_online = ret; } -static void acpi_cpufreq_boost_exit(void) -{ - if (acpi_cpufreq_online > 0) - cpuhp_remove_state_nocalls(acpi_cpufreq_online); -} - static int __init acpi_cpufreq_init(void) { int ret; @@ -1027,7 +1005,6 @@ static int __init acpi_cpufreq_init(void) ret = cpufreq_register_driver(&acpi_cpufreq_driver); if (ret) { free_acpi_perf_data(); - acpi_cpufreq_boost_exit(); } return ret; } @@ -1036,8 +1013,6 @@ static void __exit acpi_cpufreq_exit(void) { pr_debug("%s\n", __func__); - acpi_cpufreq_boost_exit(); - cpufreq_unregister_driver(&acpi_cpufreq_driver); free_acpi_perf_data();