Commit dfb6f61f authored by Wang ShaoBo's avatar Wang ShaoBo Committed by Zheng Zengkai
Browse files

arm64/mpam: resctrl: Update resources reset process



hulk inclusion
category: feature
feature: ARM MPAM support
bugzilla: 48265
CVE: NA

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

resctrl_resource_reset() would be excuted if resctrl sysfs umount, this
help to reset all settings stored in related structures (such as mpam_cfg)
and put MSCs back to default state.

This is similar to 6ab0b81f2c18 ("arm64/mpam: Fix unreset resources when mkdir
ctrl group or umount resctrl") but using helpers from mpam devices module.

Signed-off-by: default avatarWang ShaoBo <bobo.shaobowang@huawei.com>
Reviewed-by: default avatarXiongfeng Wang <wangxiongfeng2@huawei.com>
Reviewed-by: default avatarCheng Jian <cj.chengjian@huawei.com>
Signed-off-by: default avatarYang Yingliang <yangyingliang@huawei.com>
Signed-off-by: default avatarZheng Zengkai <zhengzengkai@huawei.com>
parent 9ed38372
Loading
Loading
Loading
Loading
+16 −0
Original line number Diff line number Diff line
@@ -1292,6 +1292,22 @@ int mpam_component_config(struct mpam_component *comp, struct sync_args *args)
	return do_device_sync(comp, &sync_ctx);
}

/*
 * Reset every component, configuring every partid unrestricted.
 */
void mpam_reset_devices(void)
{
	struct mpam_class *class;
	struct mpam_component *comp;

	mutex_lock(&mpam_devices_lock);
	list_for_each_entry(class, &mpam_classes, classes_list) {
		list_for_each_entry(comp, &class->components, class_list)
			mpam_component_config(comp, NULL);
	}
	mutex_unlock(&mpam_devices_lock);
}

static inline void
mpam_device_sync_mon_prepare(struct mpam_component *comp,
		struct mpam_device_sync *sync_ctx, struct sync_args *args)
+2 −0
Original line number Diff line number Diff line
@@ -159,6 +159,8 @@ static inline bool mpam_has_part_sel(mpam_features_t supported)
int mpam_component_config(struct mpam_component *comp,
			struct sync_args *args);

void mpam_reset_devices(void);

int mpam_component_mon(struct mpam_component *comp,
			struct sync_args *args, u64 *result);

+39 −19
Original line number Diff line number Diff line
@@ -526,25 +526,6 @@ void post_resctrl_mount(void)
		static_branch_enable_cpuslocked(&resctrl_enable_key);
}

static int reset_all_ctrls(struct resctrl_resource *r)
{
	return 0;
}

void resctrl_resource_reset(void)
{
	struct mpam_resctrl_res *res;
	struct resctrl_resource *r;

	/*Put everything back to default values. */
	for_each_supported_resctrl_exports(res) {
		r = &res->resctrl_res;

		if (r->alloc_enabled)
			reset_all_ctrls(r);
	}
}

void release_rdtgroupfs_options(void)
{
}
@@ -1498,6 +1479,45 @@ mpam_resctrl_update_component_cfg(struct resctrl_resource *r,
	mpam_update_from_resctrl_cfg(res, resctrl_cfg, mpam_cfg);
}

static void mpam_reset_cfg(struct mpam_resctrl_res *res,
		struct mpam_resctrl_dom *dom, struct rdt_domain *d)

{
	int i;
	struct resctrl_resource *r = &res->resctrl_res;

	for (i = 0; i != mpam_sysprops_num_partid(); i++) {
		mpam_update_from_resctrl_cfg(res, r->default_ctrl,
			&dom->comp->cfg[i]);
		d->ctrl_val[i] = r->default_ctrl;
	}
}

void resctrl_resource_reset(void)
{
	struct mpam_resctrl_res *res;
	struct mpam_resctrl_dom *dom;
	struct rdt_domain *d;

	for_each_supported_resctrl_exports(res) {
		if (!res->resctrl_res.alloc_capable)
			continue;

		list_for_each_entry(d, &res->resctrl_res.domains, list) {
			dom = container_of(d, struct mpam_resctrl_dom,
					resctrl_dom);
			mpam_reset_cfg(res, dom, d);
		}
	}

	mpam_reset_devices();

	/*
	 * reset CDP configuration used in recreating schema list nodes.
	 */
	resctrl_cdp_enabled = false;
}

u16 mpam_resctrl_max_mon_num(void)
{
	struct mpam_resctrl_res *res;