From patchwork Thu Nov 9 17:09:54 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Oleksandr Tyshchenko X-Patchwork-Id: 10051363 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 76A3060381 for ; Thu, 9 Nov 2017 17:13:20 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5DD3A2B043 for ; Thu, 9 Nov 2017 17:13:20 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 52C552B04E; Thu, 9 Nov 2017 17:13:20 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.1 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_MED, T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 889D72B04F for ; Thu, 9 Nov 2017 17:13:19 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1eCqLf-0003zX-Ob; Thu, 09 Nov 2017 17:10:39 +0000 Received: from mail6.bemta6.messagelabs.com ([193.109.254.103]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1eCqLd-0003xk-S6 for xen-devel@lists.xenproject.org; Thu, 09 Nov 2017 17:10:37 +0000 Received: from [193.109.254.147] by server-6.bemta-6.messagelabs.com id CD/94-08608-D0C840A5; Thu, 09 Nov 2017 17:10:37 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFjrKIsWRWlGSWpSXmKPExsVyMfS6iy5PD0u UwYo+FYvvWyYzOTB6HP5whSWAMYo1My8pvyKBNePo7UesBc/0Kl52rWJrYFyi2sXIxSEkMJ1R YubSjewgDovASxaJK9db2EAcCYF+VomP8w4ydTFyAjlZEifn/4ay0yT+vV/ICGGXSfx+tIkZx BYSUJJ4vXMzE4Q9m0liTqsoiM0mYCCx/90TdhBbBKjm3qrJTCALmEFq7u/5CJYQFvCS+HznFp jNIqAqMXPuBLAFvALOEh8eLmSHWCYncfNcJ9gyTgEXiTcfr7NBLHOWuPj6ONsERsEFjAyrGDW KU4vKUot0jY30kooy0zNKchMzc3QNDcz0clOLixPTU3MSk4r1kvNzNzECg44BCHYwnl4XeIhR koNJSZRXypIlSogvKT+lMiOxOCO+qDQntfgQowwHh5IEL083UE6wKDU9tSItMwcY/jBpCQ4eJ RHed11Aad7igsTc4sx0iNQpRleOC3cu/WHiOLbpMpA8sOcWkHw283UDM8e0q61NzEIsefl5qV LivAtAmgVAmjNK8+BGw2L3EqOslDAvI9CxQjwFqUW5mSWo8q8YxTkYlYR5t4NM4cnMK4G74BX QcUxAx0Wzgx1XkoiQkmpg9HxpMreIvb5nqcelWqE/1ieXG6y+4Vb+vFQ6f6Kqja4w071FP+2c XxzTWc559VXp4n1fp1/exn9zelCnQYD7x7abGUG3TnC8XiPQfqpDrM/ps+Sj4woqki+Or+RvT 7zit2aFjugK9XlyRfJ/rvNL6vT2MZxtXPbzwR4FA4+pLRN9lOXOXtm9S4mlOCPRUIu5qDgRAF v73XLYAgAA X-Env-Sender: olekstysh@gmail.com X-Msg-Ref: server-16.tower-27.messagelabs.com!1510247436!115444753!1 X-Originating-IP: [209.85.215.68] X-SpamReason: No, hits=0.0 required=7.0 tests= X-StarScan-Received: X-StarScan-Version: 9.4.45; banners=-,-,- X-VirusChecked: Checked Received: (qmail 58888 invoked from network); 9 Nov 2017 17:10:36 -0000 Received: from mail-lf0-f68.google.com (HELO mail-lf0-f68.google.com) (209.85.215.68) by server-16.tower-27.messagelabs.com with AES128-GCM-SHA256 encrypted SMTP; 9 Nov 2017 17:10:36 -0000 Received: by mail-lf0-f68.google.com with SMTP id a2so8031594lfh.11 for ; Thu, 09 Nov 2017 09:10:36 -0800 (PST) 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; bh=TWSxxdLnI+dH5nWs20tdhGnod254EbQRDh1uJMD80m8=; b=JdpWb/Hqtckl0UroO0KlDAFYokheQFh/Unw2eGyvFtaCGgn/isI3y5yYC+xNIJqgC6 PrkGKjp+8w9JWDFZFCsPGOyMhwJsn9maoaPH/qvYVKLZOU2nOzdFY5jQxClsZhIPQhmN zvef9YCs03bHJIAxBx2AJOoKKVMQCmBtisRJF1OlIU45eccq6JYFCxwEJMg1vgnTzEmr RnWPvJB7GA8xSSYL/iQLzS39xV4iYLyjFz4QXcs+snUSxZ0KzdA3fpFVBrcykNvgqLcS x63277P9ATZvWvCHImC+IGySXFO64rLwfs+9onzQKi2FgqcsJsWQU9kwGM4bkIThcU1b m2HQ== 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; bh=TWSxxdLnI+dH5nWs20tdhGnod254EbQRDh1uJMD80m8=; b=ANVWO3GQbUgN3vxmDo5J/lO7MGXiwQzanotcx6cf+VQRmgHEYm4kZEzmz8Er1zqvFp TynTEgxsA89wtr15l/TaSj41dZhXVy9P2/IvCFjBIOIz9qteYc1BrQVxVGgujZK7yB+n FynILKg2O2AbMohH2qQ9i6qu8T236pKDoz5VCKqI3HdJEuz1tjh7ToPR9CSjDwWL8EkS aJ8jzaOecvXg2Pi8bTyCItrFeBPm3LL4m6Es43xLySPq1tVBNTg6XzipdMXIY/V++FvO gU433pdfoqK/zi2aTmeIctQqqN/iDLf2ZeMX5rIiXPJUQ2g+q0vmjn6j8XJ5sAP2Wq7t YtlA== X-Gm-Message-State: AJaThX5Q6kspVpN3cgQMui4AIeR5EY3uOkstlzYCoJEWb/FCygVisOJh GH4mPJ/vQtBuRzjiGJPkTFCEZQ== X-Google-Smtp-Source: AGs4zMZoGb3kNO39dUpN10zKUgfXY3kWiFVmUvyYDEqj5rgU4h5ipl9V3cuSrtTQm+XBa4mZ0ioqlw== X-Received: by 10.46.21.28 with SMTP id s28mr486625ljd.70.1510247435622; Thu, 09 Nov 2017 09:10:35 -0800 (PST) Received: from otyshchenko.kyiv.epam.com (ll-53.209.223.85.sovam.net.ua. [85.223.209.53]) by smtp.gmail.com with ESMTPSA id x90sm1394299ljb.86.2017.11.09.09.10.34 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 09 Nov 2017 09:10:34 -0800 (PST) From: Oleksandr Tyshchenko To: xen-devel@lists.xenproject.org Date: Thu, 9 Nov 2017 19:09:54 +0200 Message-Id: <1510247421-24094-5-git-send-email-olekstysh@gmail.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1510247421-24094-1-git-send-email-olekstysh@gmail.com> References: <1510247421-24094-1-git-send-email-olekstysh@gmail.com> Cc: Stefano Stabellini , Andrew Cooper , Oleksandr Dmytryshyn , Julien Grall , Oleksandr Tyshchenko , Jan Beulich Subject: [Xen-devel] [RFC PATCH 04/31] cpufreq: make turbo settings to be configurable X-BeenThere: xen-devel@lists.xen.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: xen-devel-bounces@lists.xen.org Sender: "Xen-devel" X-Virus-Scanned: ClamAV using ClamSMTP From: Oleksandr Dmytryshyn This settings is not needed for some architectures. So make it to be configurable and use it for x86 architecture. This is a rebased version of the original patch: https://lists.xen.org/archives/html/xen-devel/2014-11/msg00942.html Signed-off-by: Oleksandr Dmytryshyn Signed-off-by: Oleksandr Tyshchenko CC: Jan Beulich CC: Andrew Cooper CC: Stefano Stabellini CC: Julien Grall --- xen/arch/x86/Kconfig | 1 + xen/drivers/cpufreq/Kconfig | 3 +++ xen/drivers/cpufreq/utility.c | 11 ++++++++++- xen/drivers/pm/stat.c | 6 ++++++ xen/include/xen/cpufreq.h | 6 ++++++ 5 files changed, 26 insertions(+), 1 deletion(-) diff --git a/xen/arch/x86/Kconfig b/xen/arch/x86/Kconfig index 86c8eca..c1eac1d 100644 --- a/xen/arch/x86/Kconfig +++ b/xen/arch/x86/Kconfig @@ -24,6 +24,7 @@ config X86 select NUMA select VGA select HAS_PM + select HAS_CPU_TURBO config ARCH_DEFCONFIG string diff --git a/xen/drivers/cpufreq/Kconfig b/xen/drivers/cpufreq/Kconfig index cce80f4..427ea2a 100644 --- a/xen/drivers/cpufreq/Kconfig +++ b/xen/drivers/cpufreq/Kconfig @@ -1,3 +1,6 @@ config HAS_CPUFREQ bool + +config HAS_CPU_TURBO + bool diff --git a/xen/drivers/cpufreq/utility.c b/xen/drivers/cpufreq/utility.c index a687e5a..25bf983 100644 --- a/xen/drivers/cpufreq/utility.c +++ b/xen/drivers/cpufreq/utility.c @@ -209,7 +209,9 @@ int cpufreq_frequency_table_cpuinfo(struct cpufreq_policy *policy, { unsigned int min_freq = ~0; unsigned int max_freq = 0; +#ifdef CONFIG_HAS_CPU_TURBO unsigned int second_max_freq = 0; +#endif unsigned int i; for (i=0; (table[i].frequency != CPUFREQ_TABLE_END); i++) { @@ -221,6 +223,7 @@ int cpufreq_frequency_table_cpuinfo(struct cpufreq_policy *policy, if (freq > max_freq) max_freq = freq; } +#ifdef CONFIG_HAS_CPU_TURBO for (i=0; (table[i].frequency != CPUFREQ_TABLE_END); i++) { unsigned int freq = table[i].frequency; if (freq == CPUFREQ_ENTRY_INVALID || freq == max_freq) @@ -234,9 +237,13 @@ int cpufreq_frequency_table_cpuinfo(struct cpufreq_policy *policy, printk("max_freq: %u second_max_freq: %u\n", max_freq, second_max_freq); + policy->cpuinfo.second_max_freq = second_max_freq; +#else /* !CONFIG_HAS_CPU_TURBO */ + if (cpufreq_verbose) + printk("max_freq: %u\n", max_freq); +#endif /* CONFIG_HAS_CPU_TURBO */ policy->min = policy->cpuinfo.min_freq = min_freq; policy->max = policy->cpuinfo.max_freq = max_freq; - policy->cpuinfo.second_max_freq = second_max_freq; if (policy->min == ~0) return -EINVAL; @@ -390,6 +397,7 @@ int cpufreq_driver_getavg(unsigned int cpu, unsigned int flag) return policy->cur; } +#ifdef CONFIG_HAS_CPU_TURBO int cpufreq_update_turbo(int cpuid, int new_state) { struct cpufreq_policy *policy; @@ -430,6 +438,7 @@ int cpufreq_get_turbo_status(int cpuid) policy = per_cpu(cpufreq_cpu_policy, cpuid); return policy && policy->turbo == CPUFREQ_TURBO_ENABLED; } +#endif /* CONFIG_HAS_CPU_TURBO */ /********************************************************************* * POLICY * diff --git a/xen/drivers/pm/stat.c b/xen/drivers/pm/stat.c index 2dbde1c..133e64d 100644 --- a/xen/drivers/pm/stat.c +++ b/xen/drivers/pm/stat.c @@ -290,7 +290,11 @@ static int get_cpufreq_para(struct xen_sysctl_pm_op *op) &op->u.get_para.u.ondemand.sampling_rate, &op->u.get_para.u.ondemand.up_threshold); } +#ifdef CONFIG_HAS_CPU_TURBO op->u.get_para.turbo_enabled = cpufreq_get_turbo_status(op->cpuid); +#else + op->u.get_para.turbo_enabled = 0; +#endif return ret; } @@ -473,6 +477,7 @@ int do_pm_op(struct xen_sysctl_pm_op *op) break; } +#ifdef CONFIG_HAS_CPU_TURBO case XEN_SYSCTL_pm_op_enable_turbo: { ret = cpufreq_update_turbo(op->cpuid, CPUFREQ_TURBO_ENABLED); @@ -484,6 +489,7 @@ int do_pm_op(struct xen_sysctl_pm_op *op) ret = cpufreq_update_turbo(op->cpuid, CPUFREQ_TURBO_DISABLED); break; } +#endif /* CONFIG_HAS_CPU_TURBO */ default: printk("not defined sub-hypercall @ do_pm_op\n"); diff --git a/xen/include/xen/cpufreq.h b/xen/include/xen/cpufreq.h index 30c70c9..2e0c16a 100644 --- a/xen/include/xen/cpufreq.h +++ b/xen/include/xen/cpufreq.h @@ -39,7 +39,9 @@ extern struct acpi_cpufreq_data *cpufreq_drv_data[NR_CPUS]; struct cpufreq_cpuinfo { unsigned int max_freq; +#ifdef CONFIG_HAS_CPU_TURBO unsigned int second_max_freq; /* P1 if Turbo Mode is on */ +#endif unsigned int min_freq; unsigned int transition_latency; /* in 10^(-9) s = nanoseconds */ }; @@ -72,9 +74,11 @@ struct cpufreq_policy { bool_t resume; /* flag for cpufreq 1st run * S3 wakeup, hotplug cpu, etc */ +#ifdef CONFIG_HAS_CPU_TURBO s8 turbo; /* tristate flag: 0 for unsupported * -1 for disable, 1 for enabled * See CPUFREQ_TURBO_* below for defines */ +#endif bool_t aperf_mperf; /* CPU has APERF/MPERF MSRs */ }; DECLARE_PER_CPU(struct cpufreq_policy *, cpufreq_cpu_policy); @@ -138,8 +142,10 @@ extern int cpufreq_driver_getavg(unsigned int cpu, unsigned int flag); #define CPUFREQ_TURBO_UNSUPPORTED 0 #define CPUFREQ_TURBO_ENABLED 1 +#ifdef CONFIG_HAS_CPU_TURBO extern int cpufreq_update_turbo(int cpuid, int new_state); extern int cpufreq_get_turbo_status(int cpuid); +#endif static __inline__ int __cpufreq_governor(struct cpufreq_policy *policy, unsigned int event)