x86/intel_pstate: support the use of intel_pstate in pmstat.c
PATCH v3 10/11 x86/intel_pstate: support the use of intel_pstate in pmstat.c
Add support in the pmstat.c so that the xenpm tool can request to access the intel_pstate driver.
--- tools/libxc/xc_pm.c | 4 +- xen/drivers/acpi/pmstat.c | 130 +++++++++++++++++++++++++++++++------ xen/include/acpi/cpufreq/cpufreq.h | 2 + xen/include/public/sysctl.h | 16 ++++- 4 files changed, 129 insertions(+), 23 deletions(-)
tools/libxc/xc_pm.c +2 -2
@@ -265,8 +265,8 @@ int xc_get_cpufreq_para(xc_interface *xch, int cpuid, user_para->cpuinfo_max_freq = sys_para->cpuinfo_max_freq; user_para->cpuinfo_min_freq = sys_para->cpuinfo_min_freq; user_para->scaling_cur_freq = sys_para->scaling_cur_freq; - user_para->scaling_max_freq = sys_para->scaling_max_freq; - user_para->scaling_min_freq = sys_para->scaling_min_freq; + user_para->scaling_max_freq = sys_para->scaling_max.freq; + user_para->scaling_min_freq = sys_para->scaling_min.freq; user_para->turbo_enabled = sys_para->turbo_enabled; memcpy(user_para->scaling_driver,
xen/drivers/acpi/pmstat.c +111 -19
197 lines not on this page · raw message
xen/include/acpi/cpufreq/cpufreq.h +2 -0
@@ -109,6 +109,8 @@ struct cpufreq_freqs {* CPUFREQ GOVERNORS * *********************************************************************/ +#define INTEL_PSTATE_INTERNAL_GOV_NUM 4 +/* The four internal governors used in intel_pstate */ #define CPUFREQ_POLICY_POWERSAVE (1)#define CPUFREQ_POLICY_PERFORMANCE (2)
xen/include/public/sysctl.h +14 -2
@@ -315,8 +315,18 @@ struct xen_get_cpufreq_para {uint32_t scaling_cur_freq;char scaling_governor[CPUFREQ_NAME_LEN ]; -uint32_t scaling_max_freq; -uint32_t scaling_min_freq; + +union { +uint32_t freq; +uint32_t pct; + } scaling_max; + +union { +uint32_t freq; +uint32_t pct; + } scaling_min; + +uint32_t scaling_turbo_pct;/* for specific governor */ union {
@@ -337,6 +347,8 @@ struct xen_set_cpufreq_para {#define SCALING_SETSPEED 3#define SAMPLING_RATE 4#define UP_THRESHOLD 5 +#define SCALING_MAX_PCT 6 +#define SCALING_MIN_PCT 7uint32_t ctrl_type;uint32_t ctrl_value;
Signature · 1 line
1.9.1
Hi,
xen/drivers/acpi/pmstat.c static int get_cpufreq_para(struct xen_sysctl_pm_op *op) · line 225
Quoted 2 lines · Wei Wang
xen/drivers/acpi/pmstat.c +1
-1-list_for_each (pos, &cpufreq_governor_list) +if (policy->policy)
What if another cpufreq decides to use policy->policy?
Quoted 1 line
+
gov_num=INTEL_PSTATE_INTERNAL_GOV_NUM;
Why not using cpufreq_governor_list?
xen/drivers/acpi/pmstat.c static int get_cpufreq_para(struct xen_sysctl_pm_op *op) · line 230
Quoted 4 lines
xen/drivers/acpi/pmstat.c +3
-0+else + { +list_for_each (pos, &cpufreq_governor_list) gov_num++;
The indentation looks wrong to me.
Signature · 1 line
Julien Grall
Quoted 5 lines · Julien Grall
xen/drivers/acpi/pmstat.c static int get_cpufreq_para(struct xen_sysctl_pm_op *op) · line 225
Quoted 2 lines · Wei Wang
xen/drivers/acpi/pmstat.c +1
-1-list_for_each (pos, &cpufreq_governor_list) +if (policy->policy)What if another cpufreq decides to use
policy->policy?
What is "another cpufreq"? The "policy" is per-CPU struct.
Quoted 3 lines
Quoted 1 line
+
gov_num=INTEL_PSTATE_INTERNAL_GOV_NUM;Why not using
cpufreq_governor_list?
That's used by the old driver. We are not going through that old governor layer.
Quoted 6 lines
xen/drivers/acpi/pmstat.c static int get_cpufreq_para(struct xen_sysctl_pm_op *op) · line 230
Quoted 4 lines
xen/drivers/acpi/pmstat.c +3
-0+else + { +list_for_each (pos, &cpufreq_governor_list) gov_num++;The indentation looks wrong to me.
It has four "+$", should be correct.
Best,
Wei
Quoted 11 lines
Quoted 1 line
Quoted 1 line · On 12.06.15 at 05:03, <[email protected]> wrote:
Quoted 7 lines · Julien Grall
xen/drivers/acpi/pmstat.c static int get_cpufreq_para(struct xen_sysctl_pm_op *op) · line 230
Quoted 4 lines · Wei Wang
xen/drivers/acpi/pmstat.c +3
-0+else + { +list_for_each (pos, &cpufreq_governor_list) gov_num++;The indentation looks wrong to me.
It has four "+$", should be correct.
The gov_num++ is supposedly the body of the list_for_each(), and hence needs to be indented by four more spaces than the loop header (i.e. a total of 12).
Jan
Hi,
Quoted 8 lines · Wei W
Quoted 5 lines · Julien Grall
xen/drivers/acpi/pmstat.c static int get_cpufreq_para(struct xen_sysctl_pm_op *op) · line 225
Quoted 2 lines · Wei Wang
xen/drivers/acpi/pmstat.c +1
-1-list_for_each (pos, &cpufreq_governor_list) +if (policy->policy)What if another cpufreq decides to use
policy->policy?What is "another cpufreq"? The "policy" is per-CPU struct.
I mean another cpufreq driver. Correct me if I'm wrong but from the name policy is not intel pstate specific. That means that a new cpufreq driver can decide to use the field his own purpose..
Quoted 5 lines
Quoted 3 lines
Quoted 1 line
+
gov_num=INTEL_PSTATE_INTERNAL_GOV_NUM;Why not using
cpufreq_governor_list?That's used by the old driver. We are not going through that old governor layer.
This is common code, it's used by different cpufreq driver for both x86 and ARM (not yet supported). We should not relying on any other cpufreq driver won't use the field policy.
Regards,
Signature · 1 line
Julien Grall
Quoted 6 lines · Julien Grall
Quoted 5 lines · Wei W
Quoted 4 lines · Julien Grall
Quoted 2 lines · Wei Wang
xen/drivers/acpi/pmstat.c +1
-1-list_for_each (pos, &cpufreq_governor_list) +if (policy->policy)
Quoted 7 lines
Quoted 3 lines
Quoted 1 line
What if another cpufreq decides to use
policy->policy?What is "another cpufreq"? The "policy" is per-CPU struct.
I mean another cpufreq driver. Correct me if I'm wrong but from the name policy is not intel pstate specific. That means that a new cpufreq driver can decide to use the field his own purpose..
We actually want it be intel_pstate specific. If maintainers agree, I think renaming it to intel_pstate_policy is a good option.
Quoted 4 lines
Quoted 4 lines
Quoted 3 lines
Quoted 1 line
+
gov_num=INTEL_PSTATE_INTERNAL_GOV_NUM;Why not using
cpufreq_governor_list?
This should not be a problem after renaming "->policy" to be "->intel_pstate_policy".
Best,
Wei
Quoted 6 lines
Quoted 1 line
That's used by the old driver. We are not going through that old governor
layer.
This is common code, it's used by different cpufreq driver for both x86 and ARM (not yet supported). We should not relying on any other cpufreq driver won't use the field policy.
Quoted 12 lines
Quoted 1 line
Quoted 1 line · On 15.06.15 at 02:30, <[email protected]> wrote:
Quoted 10 lines · Julien Grall
Quoted 8 lines · Wei W
Quoted 5 lines · Julien Grall
xen/drivers/acpi/pmstat.c static int get_cpufreq_para(struct xen_sysctl_pm_op *op) · line 225
Quoted 2 lines · Wei Wang
xen/drivers/acpi/pmstat.c +1
-1-list_for_each (pos, &cpufreq_governor_list) +if (policy->policy)What if another cpufreq decides to use
policy->policy?What is "another cpufreq"? The "policy" is per-CPU struct.
Quoted 7 lines
Quoted 2 lines
I mean another cpufreq driver. Correct me if I'm wrong but from the name policy is not intel pstate specific. That means that a new cpufreq driver
can
Quoted 1 line
decide to use the field his own purpose..
We actually want it be
intel_pstatespecific. If maintainers agree, I think renaming it tointel_pstate_policyis a good option.
No, this name is just ugly. If you need driver specific data, have a void pointer in the generic structure; the driver can then allocate memory to be pointed to by that, and can store there whatever private data it needs.
Jan
Quoted 16 lines · Jan Beulich
Quoted 16 lines
Quoted 1 line
Quoted 1 line · On 15.06.15 at 02:30, <[email protected]> wrote:
Quoted 6 lines · Julien Grall
Quoted 5 lines · Wei W
Quoted 4 lines · Julien Grall
Quoted 2 lines · Wei Wang
xen/drivers/acpi/pmstat.c +1
-1-list_for_each (pos, &cpufreq_governor_list) +if (policy->policy)Quoted 7 lines
Quoted 3 lines
Quoted 1 line
What if another cpufreq decides to use
policy->policy?What is "another cpufreq"? The "policy" is per-CPU struct.
I mean another cpufreq driver. Correct me if I'm wrong but from the name policy is not intel pstate specific. That means that a new cpufreq driver
can
Quoted 8 lines
Quoted 4 lines
Quoted 1 line
decide to use the field his own purpose..
We actually want it be
intel_pstatespecific. If maintainers agree, I think renaming it tointel_pstate_policyis a good option.No, this name is just ugly. If you need driver specific data, have a void pointer in the generic structure; the driver can then allocate memory to be pointed to by that, and can store there whatever private data it needs.
OK. I plan to make the following changes:
1) in cpufreq_policy, add a field - void *private_data;
2) add a new structure:
struct intel_pstate_policy {
unsigned int policy;
}3) in intel_pstate_cpu_setup():
struct intel_pstate_policy *private_policy = xzalloc(struct intel_pstate_policy);
private_policy->policy = INTEL_PSTATE_POLICY_ONDEMAND;
policy->private_data = private_policy;4) in intel_pstate_cpu_exit():
xfree(policy->private_data);
5) Change all the "if (policy->policy)" to "if (cpufreq_driver->setpolicy)"
Best,
Wei
Quoted 13 lines
Quoted 1 line
Quoted 1 line · On 15.06.15 at 14:28, <[email protected]> wrote:
Quoted 5 lines · Jan Beulich
Quoted 3 lines
Quoted 1 line
Quoted 1 line · On 15.06.15 at 02:30, <[email protected]> wrote:
We actually want it be
intel_pstatespecific. If maintainers agree, I think renaming it tointel_pstate_policyis a good option.No, this name is just ugly. If you need driver specific data, have a void
pointer
Quoted 2 lines
in the generic structure; the driver can then allocate memory to be pointed to by that, and can store there whatever private data it needs.
OK. I plan to make the following changes:
Quoted 7 lines
1) in
cpufreq_policy, add a field - void*private_data;2) add a new structure:
struct intel_pstate_policy { unsigned int policy; }
struct intel_pstate_private or struct intel_pstate_data please.
Jan
Quoted 17 lines · Jan Beulich
Quoted 17 lines
Quoted 1 line
Quoted 1 line · On 15.06.15 at 14:28, <[email protected]> wrote:
Quoted 6 lines · Jan Beulich
Quoted 3 lines
Quoted 1 line
Quoted 1 line · On 15.06.15 at 02:30, <[email protected]> wrote:
We actually want it be
intel_pstatespecific. If maintainers agree, I think renaming it tointel_pstate_policyis a good option.No, this name is just ugly. If you need driver specific data, have a void
pointer
Quoted 2 lines
in the generic structure; the driver can then allocate memory to be pointed to by that, and can store there whatever private data it needs.
OK. I plan to make the following changes:
1) in
cpufreq_policy, add a field - void*private_data;
Quoted 6 lines
Quoted 4 lines
2) add a new structure:
struct intel_pstate_policy { unsigned int policy; }struct
intel_pstate_privateor structintel_pstate_dataplease.
OK, no problem.
Jan, I will wait for your other comments (if there are), and then send out the new version. Thanks.
Best,
Wei
Quoted 17 lines · Jan Beulich
Quoted 17 lines
Quoted 1 line
Quoted 1 line · On 15.06.15 at 14:28, <[email protected]> wrote:
Quoted 6 lines · Jan Beulich
Quoted 3 lines
Quoted 1 line
Quoted 1 line · On 15.06.15 at 02:30, <[email protected]> wrote:
We actually want it be
intel_pstatespecific. If maintainers agree, I think renaming it tointel_pstate_policyis a good option.No, this name is just ugly. If you need driver specific data, have a void
pointer
Quoted 2 lines
in the generic structure; the driver can then allocate memory to be pointed to by that, and can store there whatever private data it needs.
OK. I plan to make the following changes:
1) in
cpufreq_policy, add a field - void*private_data;
Quoted 7 lines
Quoted 4 lines
2) add a new structure:
struct intel_pstate_policy { unsigned int policy; }struct
intel_pstate_privateor structintel_pstate_dataplease.
"struct perf_limits" is currently used only by intel_pstate, should we also move it to the intel_pstate_private struct, instead of the cpufreq_policy?
Best,
Wei
Quoted 24 lines
Quoted 1 line
Quoted 1 line · On 16.06.15 at 09:09, <[email protected]> wrote:
Quoted 22 lines · Jan Beulich
Quoted 21 lines
Quoted 1 line
Quoted 1 line · On 15.06.15 at 14:28, <[email protected]> wrote:
Quoted 6 lines · Jan Beulich
Quoted 3 lines
Quoted 1 line
Quoted 1 line · On 15.06.15 at 02:30, <[email protected]> wrote:
We actually want it be
intel_pstatespecific. If maintainers agree, I think renaming it tointel_pstate_policyis a good option.No, this name is just ugly. If you need driver specific data, have a void
pointer
Quoted 2 lines
in the generic structure; the driver can then allocate memory to be pointed to by that, and can store there whatever private data it needs.
OK. I plan to make the following changes:
1) in
cpufreq_policy, add a field - void*private_data;2) add a new structure:
struct intel_pstate_policy { unsigned int policy; }
Quoted 5 lines
Quoted 2 lines
struct
intel_pstate_privateor structintel_pstate_dataplease."struct
perf_limits" is currently used only byintel_pstate, should we also move it to theintel_pstate_privatestruct, instead of thecpufreq_policy?
Yes of course - anything private to the driver should go there.
Jan
Quoted 25 lines · Jan Beulich
Quoted 5 lines
Quoted 1 line
Quoted 1 line · On 16.06.15 at 09:09, <[email protected]> wrote:
Quoted 3 lines · Jan Beulich
Quoted 3 lines
Quoted 1 line
Quoted 1 line · On 15.06.15 at 14:28, <[email protected]> wrote:
Quoted 1 line · Jan Beulich
Quoted 1 line
Quoted 1 line
Quoted 1 line · On 15.06.15 at 02:30, <[email protected]> wrote:
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 5 lines
Quoted 2 lines
We actually want it be
intel_pstatespecific. If maintainers agree, I think renaming it tointel_pstate_policyis a good option.No, this name is just ugly. If you need driver specific data, have a void
pointer
Quoted 2 lines
in the generic structure; the driver can then allocate memory to be pointed to by that, and can store there whatever private data it
needs.
Quoted 11 lines
Quoted 11 lines
Quoted 10 lines
OK. I plan to make the following changes:
1) in
cpufreq_policy, add a field - void*private_data;2) add a new structure:
struct intel_pstate_policy { unsigned int policy; }
Quoted 8 lines
Quoted 5 lines
Quoted 2 lines
struct
intel_pstate_privateor structintel_pstate_dataplease."struct
perf_limits" is currently used only byintel_pstate, should we also move it to theintel_pstate_privatestruct, instead of the
cpufreq_policy?Yes of course - anything private to the driver should go there.
Just realized that " struct perf_limits " will also need to be used in the common code (e.g. set max_perf_pct in pmstat.c), so I plan to keep it in the cpufreq_policy struct. Please let me know if you have a different opinion.
Best,
Wei
Hi Jan,
Quoted 2 lines · Wei Wang
Add support in the
pmstat.cso that the xenpm tool can request to access theintel_pstatedriver.
I want to propose some other changes here to commonize the intel_pstate implementation in this common code (pmstat.c).
1) introduce a new struct:
struct internal_governor {
char *avail_gov;
uint32_t cur_gov;
uint32_t gov_num;
}2) a new callback in cpufreq_driver, "cpufreq_driver->get_internal_gov(internal_gov)",
This allows other possible cpufreq drivers, which implement their own internal governors, to return their own interenal governor info (e.g. we will not need to use the INTEL_PSTATE_GOV_NUM, which is defined to be 4, in this patch).
Do you think this would be better?
Best,
Wei
Quoted 14 lines · Wei Wang
Quoted 2 lines · Wei Wang
Add support in the
pmstat.cso that the xenpm tool can request to access theintel_pstatedriver.I want to propose some other changes here to commonize the
intel_pstateimplementation in this common code (pmstat.c).1) introduce a new struct:
struct internal_governor { char *avail_gov; uint32_t cur_gov; uint32_t gov_num; }
Quoted 6 lines
2) a new callback in
cpufreq_driver, "cpufreq_driver-Quoted 1 line
get_internal_gov(internal_gov)",This allows other possible cpufreq drivers, which implement their own
internal governors, to return their own interenal governor info (e.g. we will not need to use theINTEL_PSTATE_GOV_NUM, which is defined to be 4, in this patch).
Jan, do you have any comments on this change?
Best,
Wei
Quoted 16 lines
Quoted 1 line
Quoted 1 line · On 23.06.15 at 03:40, <[email protected]> wrote:
Hi Jan,
Quoted 2 lines · Wei Wang
Add support in the
pmstat.cso that the xenpm tool can request to access theintel_pstatedriver.I want to propose some other changes here to commonize the
intel_pstateimplementation in this common code (pmstat.c).1) introduce a new struct:
struct internal_governor { char *avail_gov; uint32_t cur_gov; uint32_t gov_num; }
Quoted 8 lines
2) a new callback in
cpufreq_driver, "cpufreq_driver->get_internal_gov(internal_gov)",
This allows other possible cpufreq drivers, which implement their own
internal governors, to return their own interenal governor info (e.g. we will not need to use theINTEL_PSTATE_GOV_NUM, which is defined to be 4, in this patch).Do you think this would be better?
I really need to see this in context.
Jan