diff --git a/fs/resctrlfs.c b/fs/resctrlfs.c index 239bd4e3d9caac3d979e4526228100292eb5a39f..cfa09344ad5d63eb5e42a84689d1843c37cb32ba 100644 --- a/fs/resctrlfs.c +++ b/fs/resctrlfs.c @@ -320,6 +320,28 @@ static int mkdir_mondata_all(struct kernfs_node *parent_kn, 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, int flags, const char *unused_dev_name, void *data) @@ -389,6 +411,8 @@ static struct dentry *resctrl_mount(struct file_system_type *fs_type, if (IS_ERR(dentry)) goto out_mondata; + resctrl_cdp_update_cpus_state(&resctrl_group_default); + post_resctrl_mount(); goto out;