From: "Jan Beulich" <JBeulich@suse.com>
To: xen-devel <xen-devel@lists.xenproject.org>
Cc: Stefano Stabellini <sstabellini@kernel.org>,
Wei Liu <wei.liu2@citrix.com>,
Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>,
George Dunlap <George.Dunlap@eu.citrix.com>,
Andrew Cooper <andrew.cooper3@citrix.com>,
Ian Jackson <Ian.Jackson@eu.citrix.com>, Tim Deegan <tim@xen.org>,
Julien Grall <julien.grall@arm.com>
Subject: [PATCH v4 08/12] cpufreq: convert to a single post-init driver (hooks) instance
Date: Tue, 02 Oct 2018 04:16:12 -0600 [thread overview]
Message-ID: <5BB3456C02000078001EDA54@prv1-mh.provo.novell.com> (raw)
In-Reply-To: <5BB343D802000078001ED9F6@prv1-mh.provo.novell.com>
This reduces the post-init memory footprint, eliminates a pointless
level of indirection at the use sites, and allows for subsequent
alternatives call patching.
Take the opportunity and also add a name to the PowerNow! instance.
Signed-off-by: Jan Beulich <jbeulich@suse.com>
Reviewed-by: Wei Liu <wei.liu2@citrix.com>
---
v2: New.
--- a/xen/arch/x86/acpi/cpufreq/cpufreq.c
+++ b/xen/arch/x86/acpi/cpufreq/cpufreq.c
@@ -53,8 +53,6 @@ enum {
struct acpi_cpufreq_data *cpufreq_drv_data[NR_CPUS];
-static struct cpufreq_driver acpi_cpufreq_driver;
-
static bool __read_mostly acpi_pstate_strict;
boolean_param("acpi_pstate_strict", acpi_pstate_strict);
@@ -355,7 +353,7 @@ static void feature_detect(void *info)
if ( cpu_has_aperfmperf )
{
policy->aperf_mperf = 1;
- acpi_cpufreq_driver.getavg = get_measured_perf;
+ cpufreq_driver.getavg = get_measured_perf;
}
eax = cpuid_eax(6);
@@ -593,7 +591,7 @@ acpi_cpufreq_cpu_init(struct cpufreq_pol
policy->cur = acpi_cpufreq_guess_freq(data, policy->cpu);
break;
case ACPI_ADR_SPACE_FIXED_HARDWARE:
- acpi_cpufreq_driver.get = get_cur_freq_on_cpu;
+ cpufreq_driver.get = get_cur_freq_on_cpu;
policy->cur = get_cur_freq_on_cpu(cpu);
break;
default:
@@ -635,7 +633,7 @@ static int acpi_cpufreq_cpu_exit(struct
return 0;
}
-static struct cpufreq_driver acpi_cpufreq_driver = {
+static const struct cpufreq_driver __initconstrel acpi_cpufreq_driver = {
.name = "acpi-cpufreq",
.verify = acpi_cpufreq_verify,
.target = acpi_cpufreq_target,
@@ -656,7 +654,7 @@ static int __init cpufreq_driver_init(vo
return ret;
}
-__initcall(cpufreq_driver_init);
+presmp_initcall(cpufreq_driver_init);
int cpufreq_cpu_init(unsigned int cpuid)
{
--- a/xen/arch/x86/acpi/cpufreq/powernow.c
+++ b/xen/arch/x86/acpi/cpufreq/powernow.c
@@ -52,8 +52,6 @@
#define ARCH_CPU_FLAG_RESUME 1
-static struct cpufreq_driver powernow_cpufreq_driver;
-
static void transition_pstate(void *pstate)
{
wrmsrl(MSR_PSTATE_CTRL, *(unsigned int *)pstate);
@@ -215,7 +213,7 @@ static void feature_detect(void *info)
if ( cpu_has_aperfmperf )
{
policy->aperf_mperf = 1;
- powernow_cpufreq_driver.getavg = get_measured_perf;
+ cpufreq_driver.getavg = get_measured_perf;
}
edx = cpuid_edx(CPUID_FREQ_VOLT_CAPABILITIES);
@@ -347,7 +345,8 @@ static int powernow_cpufreq_cpu_exit(str
return 0;
}
-static struct cpufreq_driver powernow_cpufreq_driver = {
+static const struct cpufreq_driver __initconstrel powernow_cpufreq_driver = {
+ .name = "powernow",
.verify = powernow_cpufreq_verify,
.target = powernow_cpufreq_target,
.init = powernow_cpufreq_cpu_init,
--- a/xen/drivers/acpi/pmstat.c
+++ b/xen/drivers/acpi/pmstat.c
@@ -64,7 +64,7 @@ int do_get_pm_info(struct xen_sysctl_get
case PMSTAT_PX:
if ( !(xen_processor_pmbits & XEN_PROCESSOR_PM_PX) )
return -ENODEV;
- if ( !cpufreq_driver )
+ if ( !cpufreq_driver.init )
return -ENODEV;
if ( !pmpt || !(pmpt->perf.init & XEN_PX_INIT) )
return -EINVAL;
@@ -255,16 +255,16 @@ static int get_cpufreq_para(struct xen_s
return ret;
op->u.get_para.cpuinfo_cur_freq =
- cpufreq_driver->get ? cpufreq_driver->get(op->cpuid) : policy->cur;
+ cpufreq_driver.get ? cpufreq_driver.get(op->cpuid) : policy->cur;
op->u.get_para.cpuinfo_max_freq = policy->cpuinfo.max_freq;
op->u.get_para.cpuinfo_min_freq = policy->cpuinfo.min_freq;
op->u.get_para.scaling_cur_freq = policy->cur;
op->u.get_para.scaling_max_freq = policy->max;
op->u.get_para.scaling_min_freq = policy->min;
- if ( cpufreq_driver->name[0] )
+ if ( cpufreq_driver.name[0] )
strlcpy(op->u.get_para.scaling_driver,
- cpufreq_driver->name, CPUFREQ_NAME_LEN);
+ cpufreq_driver.name, CPUFREQ_NAME_LEN);
else
strlcpy(op->u.get_para.scaling_driver, "Unknown", CPUFREQ_NAME_LEN);
--- a/xen/drivers/cpufreq/cpufreq.c
+++ b/xen/drivers/cpufreq/cpufreq.c
@@ -172,7 +172,7 @@ int cpufreq_add_cpu(unsigned int cpu)
if ( !(perf->init & XEN_PX_INIT) )
return -EINVAL;
- if (!cpufreq_driver)
+ if (!cpufreq_driver.init)
return 0;
if (per_cpu(cpufreq_cpu_policy, cpu))
@@ -239,7 +239,7 @@ int cpufreq_add_cpu(unsigned int cpu)
policy->cpu = cpu;
per_cpu(cpufreq_cpu_policy, cpu) = policy;
- ret = cpufreq_driver->init(policy);
+ ret = cpufreq_driver.init(policy);
if (ret) {
free_cpumask_var(policy->cpus);
xfree(policy);
@@ -298,7 +298,7 @@ err1:
cpumask_clear_cpu(cpu, cpufreq_dom->map);
if (cpumask_empty(policy->cpus)) {
- cpufreq_driver->exit(policy);
+ cpufreq_driver.exit(policy);
free_cpumask_var(policy->cpus);
xfree(policy);
}
@@ -362,7 +362,7 @@ int cpufreq_del_cpu(unsigned int cpu)
cpumask_clear_cpu(cpu, cpufreq_dom->map);
if (cpumask_empty(policy->cpus)) {
- cpufreq_driver->exit(policy);
+ cpufreq_driver.exit(policy);
free_cpumask_var(policy->cpus);
xfree(policy);
}
@@ -663,17 +663,17 @@ static int __init cpufreq_presmp_init(vo
}
presmp_initcall(cpufreq_presmp_init);
-int __init cpufreq_register_driver(struct cpufreq_driver *driver_data)
+int __init cpufreq_register_driver(const struct cpufreq_driver *driver_data)
{
if ( !driver_data || !driver_data->init ||
!driver_data->verify || !driver_data->exit ||
(!driver_data->target == !driver_data->setpolicy) )
return -EINVAL;
- if ( cpufreq_driver )
+ if ( cpufreq_driver.init )
return -EBUSY;
- cpufreq_driver = driver_data;
+ cpufreq_driver = *driver_data;
return 0;
}
--- a/xen/drivers/cpufreq/utility.c
+++ b/xen/drivers/cpufreq/utility.c
@@ -31,7 +31,7 @@
#include <acpi/cpufreq/cpufreq.h>
#include <public/sysctl.h>
-struct cpufreq_driver *cpufreq_driver;
+struct cpufreq_driver __read_mostly cpufreq_driver;
struct processor_pminfo *__read_mostly processor_pminfo[NR_CPUS];
DEFINE_PER_CPU_READ_MOSTLY(struct cpufreq_policy *, cpufreq_cpu_policy);
@@ -360,11 +360,11 @@ int __cpufreq_driver_target(struct cpufr
{
int retval = -EINVAL;
- if (cpu_online(policy->cpu) && cpufreq_driver->target)
+ if (cpu_online(policy->cpu) && cpufreq_driver.target)
{
unsigned int prev_freq = policy->cur;
- retval = cpufreq_driver->target(policy, target_freq, relation);
+ retval = cpufreq_driver.target(policy, target_freq, relation);
if ( retval == 0 )
TRACE_2D(TRC_PM_FREQ_CHANGE, prev_freq/1000, policy->cur/1000);
}
@@ -380,9 +380,9 @@ int cpufreq_driver_getavg(unsigned int c
if (!cpu_online(cpu) || !(policy = per_cpu(cpufreq_cpu_policy, cpu)))
return 0;
- if (cpufreq_driver->getavg)
+ if (cpufreq_driver.getavg)
{
- freq_avg = cpufreq_driver->getavg(cpu, flag);
+ freq_avg = cpufreq_driver.getavg(cpu, flag);
if (freq_avg > 0)
return freq_avg;
}
@@ -412,9 +412,9 @@ int cpufreq_update_turbo(int cpuid, int
return 0;
policy->turbo = new_state;
- if (cpufreq_driver->update)
+ if (cpufreq_driver.update)
{
- ret = cpufreq_driver->update(cpuid, policy);
+ ret = cpufreq_driver.update(cpuid, policy);
if (ret)
policy->turbo = curr_state;
}
@@ -450,15 +450,15 @@ int __cpufreq_set_policy(struct cpufreq_
return -EINVAL;
/* verify the cpu speed can be set within this limit */
- ret = cpufreq_driver->verify(policy);
+ ret = cpufreq_driver.verify(policy);
if (ret)
return ret;
data->min = policy->min;
data->max = policy->max;
data->limits = policy->limits;
- if (cpufreq_driver->setpolicy)
- return cpufreq_driver->setpolicy(data);
+ if (cpufreq_driver.setpolicy)
+ return cpufreq_driver.setpolicy(data);
if (policy->governor != data->governor) {
/* save old, working values */
--- a/xen/include/acpi/cpufreq/cpufreq.h
+++ b/xen/include/acpi/cpufreq/cpufreq.h
@@ -153,7 +153,7 @@ __cpufreq_governor(struct cpufreq_policy
#define CPUFREQ_RELATION_H 1 /* highest frequency below or at target */
struct cpufreq_driver {
- char name[CPUFREQ_NAME_LEN];
+ const char *name;
int (*init)(struct cpufreq_policy *policy);
int (*verify)(struct cpufreq_policy *policy);
int (*setpolicy)(struct cpufreq_policy *policy);
@@ -166,9 +166,9 @@ struct cpufreq_driver {
int (*exit)(struct cpufreq_policy *policy);
};
-extern struct cpufreq_driver *cpufreq_driver;
+extern struct cpufreq_driver cpufreq_driver;
-int cpufreq_register_driver(struct cpufreq_driver *);
+int cpufreq_register_driver(const struct cpufreq_driver *);
static __inline__
void cpufreq_verify_within_limits(struct cpufreq_policy *policy,
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel
next prev parent reply other threads:[~2018-10-02 10:16 UTC|newest]
Thread overview: 119+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-09-11 13:26 [PATCH v3 0/9] x86: indirect call overhead reduction Jan Beulich
2018-09-11 13:32 ` [PATCH v3 1/9] x86: infrastructure to allow converting certain indirect calls to direct ones Jan Beulich
2018-09-21 10:49 ` Wei Liu
2018-09-21 11:47 ` Jan Beulich
2018-09-21 13:48 ` Wei Liu
2018-09-21 15:26 ` Jan Beulich
2018-09-26 11:06 ` Wei Liu
2018-09-11 13:32 ` [PATCH v3 2/9] x86/HVM: patch indirect calls through hvm_funcs " Jan Beulich
2018-09-21 10:50 ` Wei Liu
2018-09-11 13:33 ` [PATCH v3 3/9] x86/HVM: patch vINTR " Jan Beulich
2018-09-21 10:50 ` Wei Liu
2018-09-11 13:34 ` [PATCH v3 4/9] x86: patch ctxt_switch_masking() indirect call to direct one Jan Beulich
2018-09-21 10:51 ` Wei Liu
2018-09-11 13:35 ` [PATCH v3 5/9] x86/genapic: remove indirection from genapic hook accesses Jan Beulich
2018-09-21 10:53 ` Wei Liu
2018-09-11 13:35 ` [PATCH v3 6/9] x86/genapic: patch indirect calls to direct ones Jan Beulich
2018-09-21 11:03 ` Wei Liu
2018-09-21 11:53 ` Jan Beulich
2018-09-21 13:55 ` Wei Liu
2018-09-11 13:35 ` [PATCH v3 7/9] x86/cpuidle: patch some " Jan Beulich
2018-09-21 14:01 ` Wei Liu
2018-09-11 13:37 ` [PATCH v3 8/9] cpufreq: convert to a single post-init driver (hooks) instance Jan Beulich
2018-09-21 14:06 ` Wei Liu
2018-09-11 13:37 ` [PATCH v3 9/9] cpufreq: patch target() indirect call to direct one Jan Beulich
2018-09-21 14:06 ` Wei Liu
2018-10-02 10:09 ` [PATCH v4 00/12] x86: indirect call overhead reduction Jan Beulich
2018-10-02 10:12 ` [PATCH v4 01/12] x86: infrastructure to allow converting certain indirect calls to direct ones Jan Beulich
2018-10-02 13:21 ` Andrew Cooper
2018-10-02 13:28 ` Julien Grall
2018-10-02 13:35 ` Andrew Cooper
2018-10-02 13:36 ` Julien Grall
2018-10-02 14:06 ` Jan Beulich
2018-10-02 14:23 ` Andrew Cooper
2018-10-02 14:43 ` Jan Beulich
2018-10-02 15:40 ` Andrew Cooper
2018-10-02 16:06 ` Jan Beulich
2018-10-02 13:55 ` Wei Liu
2018-10-02 14:08 ` Jan Beulich
2018-10-03 18:38 ` Andrew Cooper
2018-10-05 12:39 ` Andrew Cooper
2018-10-05 13:43 ` Jan Beulich
2018-10-05 14:49 ` Andrew Cooper
2018-10-05 15:05 ` Jan Beulich
2018-10-29 11:01 ` Jan Beulich
2018-10-02 10:12 ` [PATCH v4 02/12] x86/HVM: patch indirect calls through hvm_funcs " Jan Beulich
2018-10-02 13:18 ` Paul Durrant
2018-10-03 18:55 ` Andrew Cooper
2018-10-04 10:19 ` Jan Beulich
2018-10-02 10:13 ` [PATCH v4 03/12] x86/HVM: patch vINTR " Jan Beulich
2018-10-03 19:01 ` Andrew Cooper
2018-10-02 10:13 ` [PATCH v4 04/12] x86: patch ctxt_switch_masking() indirect call to direct one Jan Beulich
2018-10-03 19:01 ` Andrew Cooper
2018-10-02 10:14 ` [PATCH v4 05/12] x86/genapic: remove indirection from genapic hook accesses Jan Beulich
2018-10-03 19:04 ` Andrew Cooper
2018-10-02 10:14 ` [PATCH v4 06/12] x86/genapic: patch indirect calls to direct ones Jan Beulich
2018-10-03 19:07 ` Andrew Cooper
2018-10-02 10:15 ` [PATCH v4 07/12] x86/cpuidle: patch some " Jan Beulich
2018-10-04 10:35 ` Andrew Cooper
2018-10-02 10:16 ` Jan Beulich [this message]
2018-10-04 10:36 ` [PATCH v4 08/12] cpufreq: convert to a single post-init driver (hooks) instance Andrew Cooper
2018-10-02 10:16 ` [PATCH v4 09/12] cpufreq: patch target() indirect call to direct one Jan Beulich
2018-10-04 10:36 ` Andrew Cooper
2018-10-02 10:18 ` [PATCH v4 10/12] IOMMU: introduce IOMMU_MIXED config option Jan Beulich
2018-10-02 10:38 ` Julien Grall
2018-10-02 10:42 ` Jan Beulich
2018-10-02 11:00 ` Julien Grall
2018-10-02 11:58 ` Jan Beulich
2018-10-02 12:58 ` Julien Grall
2018-11-06 15:48 ` Jan Beulich
2018-11-07 18:01 ` Julien Grall
2018-10-02 10:18 ` [PATCH v4 11/12] IOMMU: remove indirection from certain IOMMU hook accesses Jan Beulich
2018-10-02 10:19 ` [PATCH v4 12/12] IOMMU: patch certain indirect calls to direct ones Jan Beulich
2018-11-08 15:56 ` [PATCH v5 00/13] x86: indirect call overhead reduction Jan Beulich
2018-11-08 16:05 ` [PATCH v5 01/13] x86: reduce general stack alignment to 8 Jan Beulich
2018-11-29 14:54 ` Wei Liu
2018-11-29 15:03 ` Jan Beulich
2018-11-29 17:44 ` Wei Liu
2018-11-30 9:03 ` Jan Beulich
2018-12-03 11:29 ` Wei Liu
2018-11-08 16:06 ` [PATCH v5 02/13] x86: clone Linux'es ASM_CALL_CONSTRAINT Jan Beulich
2018-11-29 17:13 ` Wei Liu
2018-11-08 16:08 ` [PATCH v5 03/13] x86: infrastructure to allow converting certain indirect calls to direct ones Jan Beulich
2018-11-12 10:36 ` Jan Beulich
2018-11-08 16:09 ` [PATCH v5 04/13] x86/HVM: patch indirect calls through hvm_funcs " Jan Beulich
2018-11-08 16:09 ` [PATCH v5 05/13] x86/HVM: patch vINTR " Jan Beulich
2018-11-08 16:10 ` [PATCH v5 06/13] x86: patch ctxt_switch_masking() indirect call to direct one Jan Beulich
2018-11-08 16:11 ` [PATCH v5 07/13] x86/genapic: patch indirect calls to direct ones Jan Beulich
2018-11-08 16:11 ` [PATCH v5 08/13] x86/cpuidle: patch some " Jan Beulich
2018-11-08 16:12 ` [PATCH v5 09/13] cpufreq: convert to a single post-init driver (hooks) instance Jan Beulich
2018-11-08 16:13 ` [PATCH v5 10/13] cpufreq: patch target() indirect call to direct one Jan Beulich
2018-11-08 16:14 ` [PATCH v5 11/13] IOMMU: move inclusion point of asm/iommu.h Jan Beulich
2018-11-12 11:55 ` Julien Grall
2018-11-08 16:16 ` [PATCH v5 12/13] IOMMU/x86: remove indirection from certain IOMMU hook accesses Jan Beulich
2018-11-14 3:25 ` Tian, Kevin
2018-11-14 17:16 ` Woods, Brian
2018-11-08 16:17 ` [PATCH v5 13/13] IOMMU: patch certain indirect calls to direct ones Jan Beulich
2018-11-29 14:49 ` Wei Liu
2018-12-05 15:54 ` [PATCH v6 00/10] x86: indirect call overhead reduction Jan Beulich
2018-12-05 16:02 ` [PATCH v6 01/10] x86: reduce general stack alignment to 8 Jan Beulich
2018-12-05 16:02 ` [PATCH v6 02/10] x86: clone Linux'es ASM_CALL_CONSTRAINT Jan Beulich
2018-12-05 16:03 ` [PATCH v6 03/10] x86: infrastructure to allow converting certain indirect calls to direct ones Jan Beulich
2018-12-05 16:04 ` [PATCH v6 04/10] x86/HVM: patch indirect calls through hvm_funcs " Jan Beulich
2018-12-05 16:05 ` [PATCH v6 05/10] x86/HVM: patch vINTR " Jan Beulich
2018-12-05 16:06 ` [PATCH v6 06/10] x86: patch ctxt_switch_masking() indirect call to direct one Jan Beulich
2018-12-05 16:06 ` [PATCH v6 07/10] x86/genapic: patch indirect calls to direct ones Jan Beulich
2018-12-05 16:07 ` [PATCH v6 08/10] x86/cpuidle: patch some " Jan Beulich
2018-12-05 16:07 ` [PATCH v6 09/10] cpufreq: patch target() indirect call to direct one Jan Beulich
2018-12-05 16:08 ` [PATCH v6 10/10] IOMMU: patch certain indirect calls to direct ones Jan Beulich
[not found] ` <5C07F49D0200000000101036@prv1-mh.provo.novell.com>
[not found] ` <5C07F49D020000780021DC1A@prv1-mh.provo.novell.com>
2019-03-12 13:59 ` [PATCH v7 00/10] x86: indirect call overhead reduction Jan Beulich
2019-03-12 14:03 ` [PATCH v7 01/10] x86: reduce general stack alignment to 8 Jan Beulich
2019-03-12 14:04 ` [PATCH v7 02/10] x86: clone Linux'es ASM_CALL_CONSTRAINT Jan Beulich
2019-03-12 14:05 ` [PATCH v7 03/10] x86: infrastructure to allow converting certain indirect calls to direct ones Jan Beulich
2019-03-12 14:06 ` [PATCH v7 04/10] x86/HVM: patch indirect calls through hvm_funcs " Jan Beulich
2019-03-12 14:06 ` [PATCH v7 05/10] x86/HVM: patch vINTR " Jan Beulich
2019-03-12 14:07 ` [PATCH v7 06/10] x86: patch ctxt_switch_masking() indirect call to direct one Jan Beulich
2019-03-12 14:07 ` [PATCH v7 07/10] x86/genapic: patch indirect calls to direct ones Jan Beulich
2019-03-12 14:08 ` [PATCH v7 08/10] x86/cpuidle: patch some " Jan Beulich
2019-03-12 14:08 ` [PATCH v7 09/10] cpufreq: patch target() indirect call to direct one Jan Beulich
2019-03-12 14:09 ` [PATCH v7 10/10] IOMMU: patch certain indirect calls to direct ones Jan Beulich
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=5BB3456C02000078001EDA54@prv1-mh.provo.novell.com \
--to=jbeulich@suse.com \
--cc=George.Dunlap@eu.citrix.com \
--cc=Ian.Jackson@eu.citrix.com \
--cc=andrew.cooper3@citrix.com \
--cc=julien.grall@arm.com \
--cc=konrad.wilk@oracle.com \
--cc=sstabellini@kernel.org \
--cc=tim@xen.org \
--cc=wei.liu2@citrix.com \
--cc=xen-devel@lists.xenproject.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).