From nobody Sat Sep 21 05:36:43 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1690203579; cv=none; d=zohomail.com; s=zohoarc; b=H3BiY1yp2IQp4s4s6AtgGufM0cTqlSk14H0Vk87RHOW/tCet5dLC3Zpm7tBlyZHWiZtyzJ//+vUq3/USxG2pgEasHjSb3BiWLtbD65POx1FnWxQJONVyOgAe44HDSj3VQ41hbmcVUJ5HlCZHhoNPirYJi0PiNjUIshNb+Nzet7Y= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1690203579; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=vNQhWJqSLtysm6iaINr+s0i3gnrhiDBqgnXkQD6RBcM=; b=G/5eaO/rjSbTYKSRm+5vIUiPXTbsZHURUuso3KOD1HzVsxb9vCHUe8+HVcO8D1LeKy5eibtn7MIsUby4zLJdOfMYYGbc9dcs/1XoUzd3rVCTzWDACWw+vjCQfZBInhiK0C79xHQOYK7JeoHBWWktgERU3AYJU7J7vHhDRdIC5lM= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 169020357934590.34225800940635; Mon, 24 Jul 2023 05:59:39 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.568913.889033 (Exim 4.92) (envelope-from ) id 1qNv9m-0003z6-NK; Mon, 24 Jul 2023 12:59:22 +0000 Received: by outflank-mailman (output) from mailman id 568913.889033; Mon, 24 Jul 2023 12:59:22 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1qNv9m-0003yz-Ji; Mon, 24 Jul 2023 12:59:22 +0000 Received: by outflank-mailman (input) for mailman id 568913; Mon, 24 Jul 2023 12:59:21 +0000 Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50] helo=se1-gles-flk1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1qNv9l-0003BP-HJ for xen-devel@lists.xenproject.org; Mon, 24 Jul 2023 12:59:21 +0000 Received: from mail-qt1-x82c.google.com (mail-qt1-x82c.google.com [2607:f8b0:4864:20::82c]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id e6c3b833-2a21-11ee-8612-37d641c3527e; Mon, 24 Jul 2023 14:59:19 +0200 (CEST) Received: by mail-qt1-x82c.google.com with SMTP id d75a77b69052e-403f65a3f8cso33875051cf.2 for ; Mon, 24 Jul 2023 05:59:19 -0700 (PDT) Received: from pm2-ws13.praxislan02.com (207-172-141-204.s8906.c3-0.slvr-cbr1.lnh-slvr.md.cable.rcncustomer.com. [207.172.141.204]) by smtp.gmail.com with ESMTPSA id d3-20020ac81183000000b00402364e77dcsm3273060qtj.7.2023.07.24.05.59.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 24 Jul 2023 05:59:17 -0700 (PDT) X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: e6c3b833-2a21-11ee-8612-37d641c3527e DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1690203558; x=1690808358; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=vNQhWJqSLtysm6iaINr+s0i3gnrhiDBqgnXkQD6RBcM=; b=jzJf7FgcwuUKsKESZMpF55d1xqwWqJHwFCR4zuSTi+QWm3u8jN0QVvhkIGBQRXFD7y YZV5+qeXwjJK2oIVQ6A61KGyl3JEIti2HJkuhraBoFQc4S6WDGYRzqbB7O6Yo9nON5Qr YIFdWnq72RVfzRflIjH6IBoNSuhJ/Lx/lhtUpV6DcaGP6VY0l3pBINRta1CauaZQ+0HZ 1YNa7biAradn/d5roC/ZdEpqDc2dXEIX+LWbACL2EC14akyYOkCrM+snVWxsgY4CFPvg egvmx8Klc/7eqFe5ujV9bOnU1zc7qFaW7GZ3oVu+C+6mGRIS7LlXHL9eVMLS78VjiYTK F7Yw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1690203558; x=1690808358; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=vNQhWJqSLtysm6iaINr+s0i3gnrhiDBqgnXkQD6RBcM=; b=ERev7igYntj78oaenAkoiIhyxjPawOC3lsWiRxRb0CtRYCWtv6TMSX6qRYDqXEYlar bJ0gkG6TFeUjiSJt44n/kW4U48rjF4zNVQx27AzfuvMmRDaqcEXHsKyrhElbOwgTfnfB DPHXELJpuvEzgzA/mH+HsCbp3l36ijUypb7C5BpdA6ikUAiZ/qfBqYy52GAlahNhGmSE 6oPyn/8kL64l1m97g4qqri/s0cXit7jX4PjCQ32opvlNiAhI3ae6fpFc2mhNrLW7NBA/ kVcaTzHc2KZpTAOqRA4pmz6QYRU2KL0J4bIjTHqdQrZEiklLWTB/BDYazS8hEpQMdG6w FZ8Q== X-Gm-Message-State: ABy/qLbwB4VBqEOeueKfuWp0c/nIMvOcYDta/16jZYmCLOmSVvgWVbEk Mans1X29tykwaspQHph7ivzNV26papY= X-Google-Smtp-Source: APBJJlHC4Avp8+Uss8Thrg0l6R9yg0cs9o3uBbVy0DGpOB/Ec+Z1s8yL4NlgLNOMeOEwphsJvge5+g== X-Received: by 2002:ac8:5786:0:b0:403:e895:155b with SMTP id v6-20020ac85786000000b00403e895155bmr8528736qta.34.1690203557767; Mon, 24 Jul 2023 05:59:17 -0700 (PDT) From: Jason Andryuk To: xen-devel@lists.xenproject.org Cc: Jason Andryuk , Jan Beulich Subject: [PATCH v6 01/15] cpufreq: Allow restricting to internal governors only Date: Mon, 24 Jul 2023 08:58:43 -0400 Message-ID: <20230724125857.11133-2-jandryuk@gmail.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230724125857.11133-1-jandryuk@gmail.com> References: <20230724125857.11133-1-jandryuk@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1690203580496100001 Content-Type: text/plain; charset="utf-8" For hwp, the standard governors are not usable, and only the internal one is applicable. Add the cpufreq_governor_internal boolean to indicate when an internal governor, like hwp, will be used. This is set during presmp_initcall, and governor registration can be skipped when called during initcall. This way unusable governors are not registered, and only compatible governors are advertised to userspace. Signed-off-by: Jason Andryuk Acked-by: Jan Beulich --- v6: Add Jan's Ack v5: Check cpufreq_governor_internal and skip registration as applicable Remove internal flag v4: Rework to use an internal flag Removed Jan's Ack since the approach is different. v3: Switch to initdata Add Jan Acked-by Commit message s/they/the/ typo Don't register hwp-internal when running non-hwp - Marek v2: Switch to "-internal" Add blank line in header --- xen/drivers/cpufreq/cpufreq.c | 1 + xen/drivers/cpufreq/cpufreq_misc_governors.c | 9 +++++++++ xen/drivers/cpufreq/cpufreq_ondemand.c | 3 +++ xen/include/acpi/cpufreq/cpufreq.h | 2 ++ 4 files changed, 15 insertions(+) diff --git a/xen/drivers/cpufreq/cpufreq.c b/xen/drivers/cpufreq/cpufreq.c index 2321c7dd07..67a58d409b 100644 --- a/xen/drivers/cpufreq/cpufreq.c +++ b/xen/drivers/cpufreq/cpufreq.c @@ -56,6 +56,7 @@ struct cpufreq_dom { }; static LIST_HEAD_READ_MOSTLY(cpufreq_dom_list_head); =20 +bool __initdata cpufreq_governor_internal; struct cpufreq_governor *__read_mostly cpufreq_opt_governor; LIST_HEAD_READ_MOSTLY(cpufreq_governor_list); =20 diff --git a/xen/drivers/cpufreq/cpufreq_misc_governors.c b/xen/drivers/cpu= freq/cpufreq_misc_governors.c index f5571f5486..0327fad23b 100644 --- a/xen/drivers/cpufreq/cpufreq_misc_governors.c +++ b/xen/drivers/cpufreq/cpufreq_misc_governors.c @@ -120,6 +120,9 @@ static int __init cf_check cpufreq_gov_userspace_init(v= oid) { unsigned int cpu; =20 + if ( cpufreq_governor_internal ) + return 0; + for_each_online_cpu(cpu) per_cpu(cpu_set_freq, cpu) =3D userspace_cmdline_freq; register_cpu_notifier(&cpufreq_userspace_cpu_nfb); @@ -162,6 +165,9 @@ struct cpufreq_governor cpufreq_gov_performance =3D { =20 static int __init cf_check cpufreq_gov_performance_init(void) { + if ( cpufreq_governor_internal ) + return 0; + return cpufreq_register_governor(&cpufreq_gov_performance); } __initcall(cpufreq_gov_performance_init); @@ -201,6 +207,9 @@ struct cpufreq_governor cpufreq_gov_powersave =3D { =20 static int __init cf_check cpufreq_gov_powersave_init(void) { + if ( cpufreq_governor_internal ) + return 0; + return cpufreq_register_governor(&cpufreq_gov_powersave); } __initcall(cpufreq_gov_powersave_init); diff --git a/xen/drivers/cpufreq/cpufreq_ondemand.c b/xen/drivers/cpufreq/c= pufreq_ondemand.c index fbcd14d6c3..06cfc88d30 100644 --- a/xen/drivers/cpufreq/cpufreq_ondemand.c +++ b/xen/drivers/cpufreq/cpufreq_ondemand.c @@ -360,6 +360,9 @@ struct cpufreq_governor cpufreq_gov_dbs =3D { =20 static int __init cf_check cpufreq_gov_dbs_init(void) { + if ( cpufreq_governor_internal ) + return 0; + return cpufreq_register_governor(&cpufreq_gov_dbs); } __initcall(cpufreq_gov_dbs_init); diff --git a/xen/include/acpi/cpufreq/cpufreq.h b/xen/include/acpi/cpufreq/= cpufreq.h index 35dcf21e8f..44fc4c58fc 100644 --- a/xen/include/acpi/cpufreq/cpufreq.h +++ b/xen/include/acpi/cpufreq/cpufreq.h @@ -116,6 +116,8 @@ extern struct cpufreq_governor cpufreq_gov_powersave; =20 extern struct list_head cpufreq_governor_list; =20 +extern bool cpufreq_governor_internal; + extern int cpufreq_register_governor(struct cpufreq_governor *governor); extern struct cpufreq_governor *__find_governor(const char *governor); #define CPUFREQ_DEFAULT_GOVERNOR &cpufreq_gov_dbs --=20 2.41.0