From patchwork Wed Mar 22 21:39:49 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Reed X-Patchwork-Id: 1760001 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=Lw2m1cMi; 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 4Phhj86nzyz247t for ; Thu, 23 Mar 2023 08:40:27 +1100 (AEDT) Received: from localhost ([127.0.0.1] helo=huckleberry.canonical.com) by huckleberry.canonical.com with esmtp (Exim 4.86_2) (envelope-from ) id 1pf6BZ-0000oV-Ce; Wed, 22 Mar 2023 21:39:57 +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 1pf6BX-0000o9-48 for kernel-team@lists.ubuntu.com; Wed, 22 Mar 2023 21:39:55 +0000 Received: from mail-oo1-f70.google.com (mail-oo1-f70.google.com [209.85.161.70]) (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 7BAB13F144 for ; Wed, 22 Mar 2023 21:39:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=canonical.com; s=20210705; t=1679521194; bh=DBZQnsw868P+ad8jq4fhc9TOyLOkGgzE521PbDb+H/g=; h=From:To:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=Lw2m1cMiyIagPNEj68ov3MWuanQASg7u/KJjJ/cr1shE7hxMXSGyUu9iOfmSuWD2O cYYyzpIWrsaEvEGgmbtpG89ZRTc2RFPosI5u4nFTeBT/0LS5MQPfDT7pnzoI6gMo6U /Mug7nqAULKVwq2ho74kQIMk/MXwtueM5PlZtlX6tYsvXqNvlVRZzFeCzLrAqBE3rp xUZqEYk5Aly44LlIW0RoqoGBpuuUdbFFAiSxe4Y4JuSvYYha3NBbbe9czI62F4A3iu rNmi1g5iJARMs/jGkdTsIOGzLe+6P3NnZwnC9vswzBUu0AoK/UHqcN1kbELf12vpAQ 3kY5gDvKxIo2A== Received: by mail-oo1-f70.google.com with SMTP id bv19-20020a0568201b1300b0053727cb901bso6374370oob.0 for ; Wed, 22 Mar 2023 14:39:54 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1679521193; 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=x/ZjqOfQ4QgOskcslLOvBiJsfCbSRvQudfPMeMZZBrme6KwBVVOYtlTq7gg3oMHnce CVwwXvRyWDLtCm6w8eDrAI3XqxQcfpW7naFxsggGVyuZcLM3zhTicG/c+v+KQoOaZc0u 12sBFKWlhg4yAjHjlQPgwdobdetIZr51BGofcXUUqED3MjN+IVniC/zkmQCyfbV4HSE0 YqNP3RskkwwG9ZoXgqqlmy0LNJj5PtmQz6cgHMJm+UTwxe3gvU4yYkOlqoOXDd8fyrYI i3/7HC3hg5hUEd9iMJ/tfqFu/q5r9GGKDTcpKmaiFJtuSbM8IqPzIhsl/ToXsA6eWneE vB3g== X-Gm-Message-State: AO0yUKUF+RTamzB+P+JO3+njQqARvuWOh6dUmpEub0Jkx97Po5KZuJyD dVVIg0NHAdy/Xf8yV0tjAJ5h4Rtm5hkJXqd+l7c0Op338Fs3xgWaVncp7dzahdLNa8WAqSHIQsr nKWSIpm32DbfvSt3GvJ4hEmVOOzsHNkvdnwZeFFuir3nrWJVUog== X-Received: by 2002:a05:6808:347:b0:386:c879:d3ae with SMTP id j7-20020a056808034700b00386c879d3aemr1793936oie.10.1679521193054; Wed, 22 Mar 2023 14:39:53 -0700 (PDT) X-Google-Smtp-Source: AK7set/4T6crbo2auS5KIWjhL+49pJtodeAyDCwVlAd8B6yb+bHGkRQ3UV7HW6yBxhwPui2yL8RHAw== X-Received: by 2002:a05:6808:347:b0:386:c879:d3ae with SMTP id j7-20020a056808034700b00386c879d3aemr1793926oie.10.1679521192535; Wed, 22 Mar 2023 14:39:52 -0700 (PDT) Received: from localhost ([2600:1700:1d0:5e50:349:bcfc:2d9b:e5b1]) by smtp.gmail.com with ESMTPSA id u4-20020a4aae84000000b005264a1472adsm6413853oon.15.2023.03.22.14.39.52 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 22 Mar 2023 14:39:52 -0700 (PDT) From: Michael Reed To: kernel-team@lists.ubuntu.com Subject: [SRU J][PATCH 1/1] cpufreq: ACPI: Defer setting boost MSRs Date: Wed, 22 Mar 2023 16:39:49 -0500 Message-Id: <20230322213949.23088-2-michael.reed@canonical.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230322213949.23088-1-michael.reed@canonical.com> References: <20230322213949.23088-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();