Skip to content

Commit 57831bf

Browse files
hmynenimpe
authored andcommitted
powerpc/pseries/vas: Use QoS credits from the userspace
The user can change the QoS credits dynamically with the management console interface which notifies OS with sysfs. After returning from the OS interface successfully, the management console updates the hypervisor. Since the VAS capabilities in the hypervisor is not updated when the OS gets the update, the kernel is using the old total credits value from the hypervisor. Fix this issue by using the new QoS credits from the userspace instead of depending on VAS capabilities from the hypervisor. Signed-off-by: Haren Myneni <[email protected]> Signed-off-by: Michael Ellerman <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent bb82c57 commit 57831bf

File tree

3 files changed

+27
-17
lines changed

3 files changed

+27
-17
lines changed

arch/powerpc/platforms/pseries/vas-sysfs.c

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,22 +27,31 @@ struct vas_caps_entry {
2727

2828
/*
2929
* This function is used to get the notification from the drmgr when
30-
* QoS credits are changed. Though receiving the target total QoS
31-
* credits here, get the official QoS capabilities from the hypervisor.
30+
* QoS credits are changed.
3231
*/
33-
static ssize_t update_total_credits_trigger(struct vas_cop_feat_caps *caps,
32+
static ssize_t update_total_credits_store(struct vas_cop_feat_caps *caps,
3433
const char *buf, size_t count)
3534
{
3635
int err;
3736
u16 creds;
3837

3938
err = kstrtou16(buf, 0, &creds);
39+
/*
40+
* The user space interface from the management console
41+
* notifies OS with the new QoS credits and then the
42+
* hypervisor. So OS has to use this new credits value
43+
* and reconfigure VAS windows (close or reopen depends
44+
* on the credits available) instead of depending on VAS
45+
* QoS capabilities from the hypervisor.
46+
*/
4047
if (!err)
41-
err = vas_reconfig_capabilties(caps->win_type);
48+
err = vas_reconfig_capabilties(caps->win_type, creds);
4249

4350
if (err)
4451
return -EINVAL;
4552

53+
pr_info("Set QoS total credits %u\n", creds);
54+
4655
return count;
4756
}
4857

@@ -92,7 +101,7 @@ VAS_ATTR_RO(nr_total_credits);
92101
VAS_ATTR_RO(nr_used_credits);
93102

94103
static struct vas_sysfs_entry update_total_credits_attribute =
95-
__ATTR(update_total_credits, 0200, NULL, update_total_credits_trigger);
104+
__ATTR(update_total_credits, 0200, NULL, update_total_credits_store);
96105

97106
static struct attribute *vas_def_capab_attrs[] = {
98107
&nr_total_credits_attribute.attr,

arch/powerpc/platforms/pseries/vas.c

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -779,10 +779,10 @@ static int reconfig_close_windows(struct vas_caps *vcap, int excess_creds,
779779
* changes. Reconfig window configurations based on the credits
780780
* availability from this new capabilities.
781781
*/
782-
int vas_reconfig_capabilties(u8 type)
782+
int vas_reconfig_capabilties(u8 type, int new_nr_creds)
783783
{
784784
struct vas_cop_feat_caps *caps;
785-
int old_nr_creds, new_nr_creds;
785+
int old_nr_creds;
786786
struct vas_caps *vcaps;
787787
int rc = 0, nr_active_wins;
788788

@@ -795,12 +795,6 @@ int vas_reconfig_capabilties(u8 type)
795795
caps = &vcaps->caps;
796796

797797
mutex_lock(&vas_pseries_mutex);
798-
rc = h_query_vas_capabilities(H_QUERY_VAS_CAPABILITIES, vcaps->feat,
799-
(u64)virt_to_phys(&hv_cop_caps));
800-
if (rc)
801-
goto out;
802-
803-
new_nr_creds = be16_to_cpu(hv_cop_caps.target_lpar_creds);
804798

805799
old_nr_creds = atomic_read(&caps->nr_total_credits);
806800

@@ -832,7 +826,6 @@ int vas_reconfig_capabilties(u8 type)
832826
false);
833827
}
834828

835-
out:
836829
mutex_unlock(&vas_pseries_mutex);
837830
return rc;
838831
}
@@ -850,7 +843,7 @@ static int pseries_vas_notifier(struct notifier_block *nb,
850843
struct of_reconfig_data *rd = data;
851844
struct device_node *dn = rd->dn;
852845
const __be32 *intserv = NULL;
853-
int len, rc = 0;
846+
int new_nr_creds, len, rc = 0;
854847

855848
if ((action == OF_RECONFIG_ATTACH_NODE) ||
856849
(action == OF_RECONFIG_DETACH_NODE))
@@ -862,7 +855,15 @@ static int pseries_vas_notifier(struct notifier_block *nb,
862855
if (!intserv)
863856
return NOTIFY_OK;
864857

865-
rc = vas_reconfig_capabilties(VAS_GZIP_DEF_FEAT_TYPE);
858+
rc = h_query_vas_capabilities(H_QUERY_VAS_CAPABILITIES,
859+
vascaps[VAS_GZIP_DEF_FEAT_TYPE].feat,
860+
(u64)virt_to_phys(&hv_cop_caps));
861+
if (!rc) {
862+
new_nr_creds = be16_to_cpu(hv_cop_caps.target_lpar_creds);
863+
rc = vas_reconfig_capabilties(VAS_GZIP_DEF_FEAT_TYPE,
864+
new_nr_creds);
865+
}
866+
866867
if (rc)
867868
pr_err("Failed reconfig VAS capabilities with DLPAR\n");
868869

arch/powerpc/platforms/pseries/vas.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ struct pseries_vas_window {
135135
};
136136

137137
int sysfs_add_vas_caps(struct vas_cop_feat_caps *caps);
138-
int vas_reconfig_capabilties(u8 type);
138+
int vas_reconfig_capabilties(u8 type, int new_nr_creds);
139139
int __init sysfs_pseries_vas_init(struct vas_all_caps *vas_caps);
140140

141141
#ifdef CONFIG_PPC_VAS

0 commit comments

Comments
 (0)