From patchwork Mon Mar 8 21:01:59 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jason Andryuk X-Patchwork-Id: 12123391 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 28DC8C433E9 for ; Mon, 8 Mar 2021 21:02:58 +0000 (UTC) Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id DC4EA652B6 for ; Mon, 8 Mar 2021 21:02:57 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org DC4EA652B6 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Received: from list by lists.xenproject.org with outflank-mailman.95081.179364 (Exim 4.92) (envelope-from ) id 1lJN1J-0006Qc-0A; Mon, 08 Mar 2021 21:02:29 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 95081.179364; Mon, 08 Mar 2021 21:02:28 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1lJN1I-0006QU-Sv; Mon, 08 Mar 2021 21:02:28 +0000 Received: by outflank-mailman (input) for mailman id 95081; Mon, 08 Mar 2021 21:02:27 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1lJN1H-0006P0-Hx for xen-devel@lists.xenproject.org; Mon, 08 Mar 2021 21:02:27 +0000 Received: from mail-qv1-xf2f.google.com (unknown [2607:f8b0:4864:20::f2f]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id 43aa06a6-76b4-4036-837e-7fcc27eb821d; Mon, 08 Mar 2021 21:02:24 +0000 (UTC) Received: by mail-qv1-xf2f.google.com with SMTP id s17so5311941qvr.12 for ; Mon, 08 Mar 2021 13:02:24 -0800 (PST) Received: from pm2-ws13.praxislan02.com ([2001:470:8:67e:a33e:daa7:46a1:a7eb]) by smtp.gmail.com with ESMTPSA id r2sm8514070qti.4.2021.03.08.13.02.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 08 Mar 2021 13:02:23 -0800 (PST) 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: 43aa06a6-76b4-4036-837e-7fcc27eb821d DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=AfcM/s05qxzInnDElTdSa2MUdrnaUTl8MKM2+TfWCVg=; b=tbMhZo+C/23Qk6OTDzVt4ntvhwQITnUTwcsWvir9zh+CBlzBSXCq/rINAAzPFz88s6 sm65Or2at2PZwM9OyXMQBkwvz8WVbxSIi8kfNdy5sj5TjdAj724obPfg1aOCylj0FKMV 7HU1HUA1MV4DZdfHrDqsj2lX4xt+26nJvNA6K8iAXoZ/yAwryvCAwZXlZ/TY+eHBkMym cADG9C92CEKCTjfN9HXLOPb2B4rgMDImokSiU72PRhEZbKf76RHdH2Bxrsos8D84pzuG oDY4mZQNUJe3nzYoEJkCSQJbl/urs94V8KGdP05uslJ+02VO5KJ2kIFOrMW+NRGYzNTT AwRw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=AfcM/s05qxzInnDElTdSa2MUdrnaUTl8MKM2+TfWCVg=; b=AF8PJwYNOfQysq/gVqLA2/myFhaxfGnCxo9hld4+TM3NnPh4sMiQ+juhUGBD/i9uaO ecGMt13qk2anGvMu0mQO2XhwuHfIbjc8WFeLtgB7j1MwdZi4Hr5lIHnCSI4/T+JKQjTe VogGNe0s6tOaq8AS/6FM61kNWxo5aynHaL1ebtS07czHWOzDS9v8vEtzGdMvk8kttr2V +DZgioOlhBc2ra7qhU7EJH0cExudecf4v7HgLxfLNUVxd5O0hAWEPoB4L9pjfLPTnP3m iAtsb12HUNfbs8UoKCGJevust8pgoR5Ta5EUfP9MxGgGU+h0I0EvcarsUyIbn4nbAHrf BDxw== X-Gm-Message-State: AOAM5330DHGv78YR4Gqktex82hS0RjLYKh+Slj7yP8kIFaYJSMByfsk/ Eu4wB/r3t5NdaFRd11RR31oIKGFzvA4= X-Google-Smtp-Source: ABdhPJyHuwzAX6BTlMOiuZNdGKVNT28aymiqM3iA/I5EocSfeuPmVcrmGeqzJ7pR7YdpkQMQVDFKsg== X-Received: by 2002:ad4:4c0b:: with SMTP id bz11mr1818565qvb.4.1615237344305; Mon, 08 Mar 2021 13:02:24 -0800 (PST) From: Jason Andryuk To: xen-devel@lists.xenproject.org Cc: pawel@invisiblethingslab.com, marmarek@invisiblethingslab.com, Jason Andryuk , Jan Beulich Subject: [RFC 01/12] cpufreq: Allow restricting to internal governors only Date: Mon, 8 Mar 2021 16:01:59 -0500 Message-Id: <20210308210210.116278-2-jandryuk@gmail.com> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20210308210210.116278-1-jandryuk@gmail.com> References: <20210308210210.116278-1-jandryuk@gmail.com> MIME-Version: 1.0 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-internal, will be used. This is set during presmp_initcall, so that it can suppress governor registration during initcall. Only a governor with a name containing "internal" will be allowed in that case. This way, the unuseable governors are not registered, so they internal one is the only one returned to userspace. This means incompatible governors won't be advertised to userspace. Signed-off-by: Jason Andryuk --- xen/drivers/cpufreq/cpufreq.c | 4 ++++ xen/include/acpi/cpufreq/cpufreq.h | 1 + 2 files changed, 5 insertions(+) diff --git a/xen/drivers/cpufreq/cpufreq.c b/xen/drivers/cpufreq/cpufreq.c index e630a47419..b1f668b715 100644 --- a/xen/drivers/cpufreq/cpufreq.c +++ b/xen/drivers/cpufreq/cpufreq.c @@ -57,6 +57,7 @@ struct cpufreq_dom { }; static LIST_HEAD_READ_MOSTLY(cpufreq_dom_list_head); +bool __read_mostly cpufreq_governor_internal; struct cpufreq_governor *__read_mostly cpufreq_opt_governor; LIST_HEAD_READ_MOSTLY(cpufreq_governor_list); @@ -122,6 +123,9 @@ int __init cpufreq_register_governor(struct cpufreq_governor *governor) if (!governor) return -EINVAL; + if (cpufreq_governor_internal && strstr(governor->name, "internal") == NULL) + return -EINVAL; + if (__find_governor(governor->name) != NULL) return -EEXIST; diff --git a/xen/include/acpi/cpufreq/cpufreq.h b/xen/include/acpi/cpufreq/cpufreq.h index e88b20bfed..56df5eebed 100644 --- a/xen/include/acpi/cpufreq/cpufreq.h +++ b/xen/include/acpi/cpufreq/cpufreq.h @@ -115,6 +115,7 @@ extern struct cpufreq_governor cpufreq_gov_dbs; extern struct cpufreq_governor cpufreq_gov_userspace; extern struct cpufreq_governor cpufreq_gov_performance; extern struct cpufreq_governor cpufreq_gov_powersave; +extern bool cpufreq_governor_internal; extern struct list_head cpufreq_governor_list;