hulk inclusion category: feature bugzilla: https://atomgit.com/openeuler/kernel/issues/9840 ------------------ The previous patch implemented resctrl_arch_rmid_expand() and resctrl_arch_rmid_reclaim() for ARM MPAM. This patch integrates these architecture-specific functions into the generic resctrl layer. Refactor resctrl_find_free_rmid() to support dynamic rmid expansion. If no free rmid is available for the current closid, attempt to expand via resctrl_arch_expand_rmid(). On success, retry the rmid allocation. As this capability is architecture-specific, x86 maintains existing behavior by returning -ENOSPC when rmid resources are exhausted. Additionally, invoke resctrl_arch_rmid_reclaim() when rmids are released to enable architecture-specific resource cleanup. Signed-off-by: Zeng Heng <zengheng4@huawei.com> --- fs/resctrl/monitor.c | 32 ++++++++++++++++++++++++++++++-- include/linux/arm_mpam.h | 17 +++++++++++++++++ 2 files changed, 47 insertions(+), 2 deletions(-) diff --git a/fs/resctrl/monitor.c b/fs/resctrl/monitor.c index df6839ebb2d18..e5eb971ee39da 100644 --- a/fs/resctrl/monitor.c +++ b/fs/resctrl/monitor.c @@ -115,6 +115,8 @@ static void limbo_release_entry(struct rmid_entry *entry) if (IS_ENABLED(CONFIG_RESCTRL_RMID_DEPENDS_ON_CLOSID)) closid_num_dirty_rmid[entry->closid]--; + + resctrl_arch_rmid_reclaim(entry->closid, entry->rmid); } /* @@ -178,7 +180,7 @@ bool has_busy_rmid(struct rdt_domain *d) return find_first_bit(d->rmid_busy_llc, idx_limit) != idx_limit; } -struct rmid_entry *resctrl_find_free_rmid(u32 closid) +static struct rmid_entry *__resctrl_find_free_rmid(u32 closid) { struct rmid_entry *itr; u32 itr_idx, cmp_idx; @@ -195,7 +197,12 @@ struct rmid_entry *resctrl_find_free_rmid(u32 closid) * very first entry will be returned. */ itr_idx = resctrl_arch_rmid_idx_encode(itr->closid, itr->rmid); + if (itr_idx == U32_MAX) + continue; + cmp_idx = resctrl_arch_rmid_idx_encode(closid, itr->rmid); + if (cmp_idx == U32_MAX) + continue; if (itr_idx == cmp_idx) return itr; @@ -204,6 +211,25 @@ struct rmid_entry *resctrl_find_free_rmid(u32 closid) return ERR_PTR(-ENOSPC); } +struct rmid_entry *resctrl_find_free_rmid(u32 closid) +{ + struct rmid_entry *err; + int ret; + + err = __resctrl_find_free_rmid(closid); + if (err == ERR_PTR(-ENOSPC)) { + ret = resctrl_arch_rmid_expand(closid); + if (ret < 0) + /* Out of rmid */ + goto out; + + /* Try it again */ + return __resctrl_find_free_rmid(closid); + } +out: + return err; +} + /** * resctrl_find_cleanest_closid() - Find a CLOSID where all the associated * RMID are clean, or the CLOSID that has @@ -320,8 +346,10 @@ void free_rmid(u32 closid, u32 rmid) if (resctrl_arch_is_llc_occupancy_enabled()) add_rmid_to_limbo(entry); - else + else { list_add_tail(&entry->list, &rmid_free_lru); + resctrl_arch_rmid_reclaim(closid, rmid); + } } bool rmid_is_occupied(u32 closid, u32 rmid) diff --git a/include/linux/arm_mpam.h b/include/linux/arm_mpam.h index 541c2f1bf6f4c..a1a511d07eec1 100644 --- a/include/linux/arm_mpam.h +++ b/include/linux/arm_mpam.h @@ -77,6 +77,23 @@ bool resctrl_arch_get_cdp_enabled(enum resctrl_res_level ignored); int resctrl_arch_set_cdp_enabled(enum resctrl_res_level ignored, bool enable); bool resctrl_arch_match_closid(struct task_struct *tsk, u32 closid); bool resctrl_arch_match_rmid(struct task_struct *tsk, u32 closid, u32 rmid); + +/** + * resctrl_arch_rmid_expand() - Expand the RMID resources for the specified closid. + * @closid: closid that matches the rmid. + * + * Return: + * 0 on success, or -ENOSPC etc on error. + */ +int resctrl_arch_rmid_expand(u32 closid); + +/** + * resctrl_arch_rmid_reclaim() - Reclaim the rmid resources for the specified closid. + * @closid: closid that matches the rmid. + * @rmid: Reclaim the rmid specified. + */ +void resctrl_arch_rmid_reclaim(u32 closid, u32 rmid); + void resctrl_arch_set_cpu_default_closid(int cpu, u32 closid); void resctrl_arch_set_closid_rmid(struct task_struct *tsk, u32 closid, u32 rmid); void resctrl_arch_set_cpu_default_closid_rmid(int cpu, u32 closid, u32 rmid); -- 2.43.0