pmstat&xenpm: Re-arrage for cpufreq union

Rearrange code now that xen_sysctl_pm_op's get_para fields has the
nested union and struct.  In particular, the scaling governor
information like scaling_available_governors is inside the union, so it
is not always available.  Move those fields (op->u.get_para.u.s.u.*)
together as well as the common fields (ones outside the union like
op->u.get_para.turbo_enabled).

With that, gov_num may be 0, so bounce buffer handling needs
to be modified.

scaling_governor and other fields inside op->u.get_para.u.s.u.* won't be
used for hwp, so this will simplify the change when hwp support is
introduced and re-indents these lines all together.

Signed-off-by: Jason Andryuk <jandryuk@gmail.com>
Acked-by: Jan Beulich <jbeulich@suse.com>
Acked-by: Anthony PERARD <anthony.perard@citrix.com>
This commit is contained in:
Jason Andryuk authored and Jan Beulich committed 2023-08-23 10:05:46 +02:00
1 parent 2381dfab08
commit 31e264c672
3 files changed
+22 -17

No files matched your search

+8 -4
View File
@@ -221,7 +221,7 @@ int xc_get_cpufreq_para(xc_interface *xch, int cpuid,
{
if ( (!user_para->affected_cpus) ||
(!user_para->scaling_available_frequencies) ||
(!user_para->scaling_available_governors) )
(user_para->gov_num && !user_para->scaling_available_governors) )
{
errno = EINVAL;
return -1;
@@ -230,12 +230,15 @@ int xc_get_cpufreq_para(xc_interface *xch, int cpuid,
goto unlock_1;
if ( xc_hypercall_bounce_pre(xch, scaling_available_frequencies) )
goto unlock_2;
if ( xc_hypercall_bounce_pre(xch, scaling_available_governors) )
if ( user_para->gov_num &&
xc_hypercall_bounce_pre(xch, scaling_available_governors) )
goto unlock_3;
set_xen_guest_handle(sys_para->affected_cpus, affected_cpus);
set_xen_guest_handle(sys_para->scaling_available_frequencies, scaling_available_frequencies);
set_xen_guest_handle(sys_para->scaling_available_governors, scaling_available_governors);
if ( user_para->gov_num )
set_xen_guest_handle(sys_para->scaling_available_governors,
scaling_available_governors);
}
sysctl.cmd = XEN_SYSCTL_pm_op;
@@ -317,7 +320,8 @@ int xc_get_cpufreq_para(xc_interface *xch, int cpuid,
}
unlock_4:
xc_hypercall_bounce_post(xch, scaling_available_governors);
if ( user_para->gov_num )
xc_hypercall_bounce_post(xch, scaling_available_governors);
unlock_3:
xc_hypercall_bounce_post(xch, scaling_available_frequencies);
unlock_2:
+2 -1
View File
@@ -811,7 +811,8 @@ static int show_cpufreq_para_by_cpuid(xc_interface *xc_handle, int cpuid)
ret = -ENOMEM;
goto out;
}
if (!(p_cpufreq->scaling_available_governors =
if (p_cpufreq->gov_num &&
!(p_cpufreq->scaling_available_governors =
malloc(p_cpufreq->gov_num * CPUFREQ_NAME_LEN * sizeof(char))))
{
fprintf(stderr,
+12 -12
View File
@@ -239,6 +239,18 @@ static int get_cpufreq_para(struct xen_sysctl_pm_op *op)
if ( ret )
return ret;
op->u.get_para.cpuinfo_cur_freq =
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.turbo_enabled = cpufreq_get_turbo_status(op->cpuid);
if ( cpufreq_driver.name[0] )
strlcpy(op->u.get_para.scaling_driver,
cpufreq_driver.name, CPUFREQ_NAME_LEN);
else
strlcpy(op->u.get_para.scaling_driver, "Unknown", CPUFREQ_NAME_LEN);
if ( !(scaling_available_governors =
xzalloc_array(char, gov_num * CPUFREQ_NAME_LEN)) )
return -ENOMEM;
@@ -254,21 +266,10 @@ static int get_cpufreq_para(struct xen_sysctl_pm_op *op)
if ( ret )
return ret;
op->u.get_para.cpuinfo_cur_freq =
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.u.s.scaling_cur_freq = policy->cur;
op->u.get_para.u.s.scaling_max_freq = policy->max;
op->u.get_para.u.s.scaling_min_freq = policy->min;
if ( cpufreq_driver.name[0] )
strlcpy(op->u.get_para.scaling_driver,
cpufreq_driver.name, CPUFREQ_NAME_LEN);
else
strlcpy(op->u.get_para.scaling_driver, "Unknown", CPUFREQ_NAME_LEN);
if ( policy->governor->name[0] )
strlcpy(op->u.get_para.u.s.scaling_governor,
policy->governor->name, CPUFREQ_NAME_LEN);
@@ -291,7 +292,6 @@ static int get_cpufreq_para(struct xen_sysctl_pm_op *op)
&op->u.get_para.u.s.u.ondemand.sampling_rate,
&op->u.get_para.u.s.u.ondemand.up_threshold);
}
op->u.get_para.turbo_enabled = cpufreq_get_turbo_status(op->cpuid);
return ret;
}
Reference in new issue
Block a user
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.