You need to sign in or sign up before continuing.
提交 e6ec459f 编写于 作者: W Wang ShaoBo 提交者: Yang Yingliang

arm64/mpam: resctrl: Refresh cpu mask for handling cpuhp

hulk inclusion
category: bugfix
bugzilla: 34278
CVE: NA

-------------------------------------------------

This fixes two problems:

1) when cpu offline, we should clear cpu mask from all associated resctrl
   group but not only default group.

2) when cpu online, we should set cpu mask for default group and update
   default group's cpus to default state if cdp on, this operation is to
   fill code and data fields of mpam sysregs with appropriate value.

Fixes: 88371f8b ("arm64/mpam: resctrl: Handle cpuhp and resctrl_dom allocation")
Signed-off-by: NWang ShaoBo <bobo.shaobowang@huawei.com>
Reviewed-by: NJian Cheng <cj.chengjian@huawei.com>
Signed-off-by: NYang Yingliang <yangyingliang@huawei.com>
Signed-off-by: NCheng Jian <cj.chengjian@huawei.com>
上级 f1d1f6c6
...@@ -447,6 +447,31 @@ int parse_rdtgroupfs_options(char *data); ...@@ -447,6 +447,31 @@ int parse_rdtgroupfs_options(char *data);
int resctrl_group_add_files(struct kernfs_node *kn, unsigned long fflags); int resctrl_group_add_files(struct kernfs_node *kn, unsigned long fflags);
static inline void resctrl_cdp_update_cpus_state(struct resctrl_group *rdtgrp)
{
int cpu;
/*
* If cdp on, tasks in resctrl default group with closid=0
* and rmid=0 don't know how to fill proper partid_i/pmg_i
* and partid_d/pmg_d into MPAMx_ELx sysregs by mpam_sched_in()
* called by __switch_to(), it's because current cpu's default
* closid and rmid are also equal to 0 and make the operation
* modifying configuration passed. Update per cpu default closid
* of none-zero value, call update_closid_rmid() to update each
* cpu's mpam proper MPAMx_ELx sysregs for setting partid and
* pmg when mounting resctrl sysfs, which is a practical method;
* Besides, to support cpu online and offline we should set
* cur_closid to 0.
*/
for_each_cpu(cpu, &rdtgrp->cpu_mask) {
per_cpu(pqr_state.default_closid, cpu) = ~0;
per_cpu(pqr_state.cur_closid, cpu) = 0;
}
update_closid_rmid(&rdtgrp->cpu_mask, NULL);
}
#define RESCTRL_MAX_CBM 32 #define RESCTRL_MAX_CBM 32
/* /*
......
...@@ -90,15 +90,24 @@ static bool resctrl_cdp_enabled; ...@@ -90,15 +90,24 @@ static bool resctrl_cdp_enabled;
int mpam_resctrl_set_default_cpu(unsigned int cpu) int mpam_resctrl_set_default_cpu(unsigned int cpu)
{ {
/* The cpu is set in default rdtgroup after online. */ /* The cpu is set in default rdtgroup after online. */
cpumask_set_cpu(cpu, &resctrl_group_default.cpu_mask); cpumask_set_cpu(cpu, &resctrl_group_default.cpu_mask);
/* Update CPU mpam sysregs' default setting when cdp enabled */
if (resctrl_cdp_enabled)
resctrl_cdp_update_cpus_state(&resctrl_group_default);
return 0; return 0;
} }
void mpam_resctrl_clear_default_cpu(unsigned int cpu) void mpam_resctrl_clear_default_cpu(unsigned int cpu)
{ {
/* The cpu is set in default rdtgroup after online. */ struct resctrl_group *rdtgrp;
cpumask_clear_cpu(cpu, &resctrl_group_default.cpu_mask);
list_for_each_entry(rdtgrp, &resctrl_all_groups, resctrl_group_list) {
/* The cpu is clear in associated rdtgroup after offline. */
cpumask_clear_cpu(cpu, &rdtgrp->cpu_mask);
}
} }
bool is_resctrl_cdp_enabled(void) bool is_resctrl_cdp_enabled(void)
......
...@@ -320,28 +320,6 @@ static int mkdir_mondata_all(struct kernfs_node *parent_kn, ...@@ -320,28 +320,6 @@ static int mkdir_mondata_all(struct kernfs_node *parent_kn,
return ret; return ret;
} }
static void resctrl_cdp_update_cpus_state(struct resctrl_group *r)
{
int cpu;
/*
* If cdp on, tasks in resctrl default group with closid=0
* and rmid=0 don't know how to fill proper partid_i/pmg_i
* and partid_d/pmg_d into MPAMx_ELx sysregs by mpam_sched_in()
* called by __switch_to(), it's because current cpu's default
* closid and rmid are also equal to 0 and to make the operation
* modifying configuration passed. Update per cpu default closid
* of none-zero value, call update_closid_rmid() to update each
* cpu's mpam proper MPAMx_ELx sysregs for setting partid and
* pmg when mounting resctrl sysfs, it looks like a practical
* method.
*/
for_each_cpu(cpu, &r->cpu_mask)
per_cpu(pqr_state.default_closid, cpu) = ~0;
update_closid_rmid(&r->cpu_mask, NULL);
}
static struct dentry *resctrl_mount(struct file_system_type *fs_type, static struct dentry *resctrl_mount(struct file_system_type *fs_type,
int flags, const char *unused_dev_name, int flags, const char *unused_dev_name,
void *data) void *data)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册