From e1e863f86b84236ad29a8f1e4d5cb7c7730fdc6c Mon Sep 17 00:00:00 2001 From: Zeng Heng Date: Thu, 29 May 2025 09:34:49 +0800 Subject: [PATCH 1/3] fs/resctrl: Free mbm_total and mbm_local when fails hulk inclusion category: bugfix bugzilla: https://gitee.com/openeuler/kernel/issues/IC30P1 -------------------------------- When the allocation of mbm_core fails due to insufficient system memory resources, it is necessary to also release the previously allocated mbm_total and mbm_local to prevent memory leakage. Fixes: 556688623b2b ("fs/resctrl: Create l2 cache monitors") Signed-off-by: Zeng Heng --- fs/resctrl/rdtgroup.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/fs/resctrl/rdtgroup.c b/fs/resctrl/rdtgroup.c index b1f127432b42..549bde30da02 100644 --- a/fs/resctrl/rdtgroup.c +++ b/fs/resctrl/rdtgroup.c @@ -4034,7 +4034,8 @@ static int domain_setup_mon_state(struct rdt_resource *r, struct rdt_domain *d) d->mbm_core = kcalloc(idx_limit, tsize, GFP_KERNEL); if (!d->mbm_core) { bitmap_free(d->rmid_busy_llc); - kfree(d->mbm_core); + kfree(d->mbm_total); + kfree(d->mbm_local); return -ENOMEM; } } -- Gitee From 4c3d18ad7785dcad03e8a81fa43dbb6a40481f8b Mon Sep 17 00:00:00 2001 From: Zeng Heng Date: Thu, 29 May 2025 09:34:50 +0800 Subject: [PATCH 2/3] fs/resctrl: Restore default settings for all resctrl_res_level hulk inclusion category: feature bugzilla: https://gitee.com/openeuler/kernel/issues/IC35SV -------------------------------- Each time a new control group is created, all the resctrl_res_level items need to be initialized with default values to prevent the partid from retaining old configurations due to previous usage. Signed-off-by: Zeng Heng --- fs/resctrl/rdtgroup.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/fs/resctrl/rdtgroup.c b/fs/resctrl/rdtgroup.c index 549bde30da02..34580a06b246 100644 --- a/fs/resctrl/rdtgroup.c +++ b/fs/resctrl/rdtgroup.c @@ -3319,7 +3319,7 @@ static int rdtgroup_init_cat(struct resctrl_schema *s, u32 closid) } /* Initialize MBA resource with default values. */ -static void rdtgroup_init_mba(struct rdt_resource *r, u32 closid) +static void rdtgroup_init_res(struct rdt_resource *r, u32 closid) { struct resctrl_staged_config *cfg; struct rdt_domain *d; @@ -3347,15 +3347,16 @@ static int rdtgroup_init_alloc(struct rdtgroup *rdtgrp) list_for_each_entry(s, &resctrl_schema_all, list) { r = s->res; - if (r->rid == RDT_RESOURCE_MBA || - r->rid == RDT_RESOURCE_SMBA) { - rdtgroup_init_mba(r, rdtgrp->closid); - if (is_mba_sc(r)) - continue; - } else { + if (r->rid == RDT_RESOURCE_L2 || + r->rid == RDT_RESOURCE_L3) { ret = rdtgroup_init_cat(s, rdtgrp->closid); if (ret < 0) goto out; + + } else { + rdtgroup_init_res(r, rdtgrp->closid); + if (is_mba_sc(r)) + continue; } ret = resctrl_arch_update_domains(r, rdtgrp->closid); -- Gitee From 8c44479505cc747ac19d838734983ea3f7412897 Mon Sep 17 00:00:00 2001 From: Zeng Heng Date: Thu, 29 May 2025 09:34:51 +0800 Subject: [PATCH 3/3] fs/resctrl: Add missing rdt_last_cmd_clear() after rdtgroup_kn_lock_live() hulk inclusion category: bugfix bugzilla: https://gitee.com/openeuler/kernel/issues/I8T2RT -------------------------------- The fixes tag patch resolves the lockdep warning. However, directly removing rdt_last_cmd_clear() would leave the last_cmd_status interface with stale logs, which does not conform to the functional definition before the fix. Therefore, the rdt_last_cmd_clear() operation is performed after successfully acquiring the rdtgroup_mutex. Fixes: c8eafe149530 ("x86/resctrl: Fix potential lockdep warning") Signed-off-by: Zeng Heng --- fs/resctrl/rdtgroup.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/fs/resctrl/rdtgroup.c b/fs/resctrl/rdtgroup.c index 34580a06b246..39c83694956d 100644 --- a/fs/resctrl/rdtgroup.c +++ b/fs/resctrl/rdtgroup.c @@ -528,6 +528,8 @@ static ssize_t rdtgroup_cpus_write(struct kernfs_open_file *of, goto unlock; } + rdt_last_cmd_clear(); + if (rdtgrp->mode == RDT_MODE_PSEUDO_LOCKED || rdtgrp->mode == RDT_MODE_PSEUDO_LOCKSETUP) { ret = -EINVAL; @@ -3419,6 +3421,8 @@ static int mkdir_rdt_prepare(struct kernfs_node *parent_kn, goto out_unlock; } + rdt_last_cmd_clear(); + if (rtype == RDTMON_GROUP && (prdtgrp->mode == RDT_MODE_PSEUDO_LOCKSETUP || prdtgrp->mode == RDT_MODE_PSEUDO_LOCKED)) { -- Gitee