[PATCH OLK-6.6 0/9] arm_mpam: Introduce the Narrow-PARTID feature for MPAM driver
The narrow-partid feature in MPAM allows for a more efficient use of PARTIDs by enabling a many-to-one mapping of reqpartids (requested PARTIDs) to intpartids (internal PARTIDs). This mapping reduces the number of unique PARTIDs needed, thus allowing more tasks or processes to be monitored and managed with the available resources. For a mixture of MSCs system, for MSCs that do not support narrow-partid, we use the PARTIDs exceeding the number of closids as reqPARTIDs for expanding the monitoring groups. Therefore, we will expand the information contained in the RMID, so that it includes not only PMG, but also reqPARTIDs information. The new RMID would be like: RMID = (reqPARTID << shift | PMG). Each control group has m (req)PARTIDs, which are used to expand the number of monitoring groups under one control group. Therefore, the number of monitoring groups is no longer limited by the range of MPAM's PMG, which enhances the extensibility of the system's monitoring capabilities. Dave Martin (1): arm_mpam: Set INTERNAL as needed when setting MSC controls Zeng Heng (8): arm_mpam: Introduce the definitions of intPARTID and reqPARTID arm_mpam: Add limitation for the Narrow-PARTID feature arm_mpam: Expand the composition of RMID arm_mpam: Automatically synchronize the configuration of all sub-monitoring groups Revert "arm_mpam: Add limitation for the Narrow-PARTID feature" fs/resctrl: Add resctrl_arch_expand_rmid() fs/resctrl: Deploy resctrl_arch_expand_rmid() arm64/mpam: Add limitation arch/x86/include/asm/resctrl.h | 7 + drivers/platform/mpam/mpam_devices.c | 61 ++++- drivers/platform/mpam/mpam_internal.h | 5 + drivers/platform/mpam/mpam_resctrl.c | 355 ++++++++++++++++++++------ fs/resctrl/monitor.c | 45 +++- include/linux/arm_mpam.h | 16 ++ include/linux/resctrl.h | 18 ++ 7 files changed, 415 insertions(+), 92 deletions(-) -- 2.25.1
hulk inclusion category: feature bugzilla: https://atomgit.com/openeuler/kernel/issues/8420 ------------------ The narrow-partid feature in MPAM allows for a more efficient use of PARTIDs by enabling a many-to-one mapping of reqpartids (requested PARTIDs) to intpartids (internal PARTIDs). This mapping reduces the number of unique PARTIDs needed, thus allowing more tasks or processes to be monitored and managed with the available resources. Regarding intPARTID, MPAM uses it as the unit for control group configuration delivery. MPAM will synchronize the delivered configuration to all reqPARTIDs mapped to the same intPARTIDs. The number of intPARTIDs is indicated by MPAMF_PARTID_NRW_IDR.INTPARTID_MAX if implemented, or directly use the number of PARTID as intpartid_max if narrow-partid feature is not supported. reqPARTIDs can be used to expand the number of monitors, for each control group is no longer simply restricted by the range of PMG. By mapping between intPARTID and reqPARTID, the number of monitors would be greatly expanded and more fine-grained monitoring under a control group will be achieved. As a MPAM driver applicable to general scenarios, it needs to be compatible with systems not supporting narrow-partid and mixed MSCs (some MSCs support narrow-partid and some do not) systems. We determine the number of closids in the following manner: reqPARTID-np -- The number of reqPARTIDs supported by MSCs that support narrow-partid. intPARTID-np -- The number of intPARTIDs supported by MSCs that support narrow partid. PARTID -- The number of PARTIDs supported by MSCs that do not support narrow partid. n - Indicates the maximum number of control groups l - Represents the total number of reqpartids m - Indicates the number of reqpartids per control group n = min(intPARTID-np, PARTID) l = min(reqPARTID-np, PARTID) m = l // n To illustrate how to determine n, l, and m through examples, we can assume a specific example: l3 - Does not support the narrow PARTID feature, supports a range of 256 PARTIDs. mata - Supports the narrow-partid feature, supports 32 intPARTIDs, and supports 256 reqPARTIDs. Then, n = min(PARTID-l3, intPARTID-mata) = min(256, 32) = 32 l = min(PARTID-l3, reqPARTID-mata) = min(256,256) = 256 m = 256 / 32 = 8 After initialization, the driver determines the 'n' parameter returned by resctrl_arch_get_num_closid() and the 'l' parameter returned by get_num_reqpartid(). Signed-off-by: Zeng Heng <zengheng4@huawei.com> --- drivers/platform/mpam/mpam_devices.c | 12 +++++++++++- drivers/platform/mpam/mpam_internal.h | 2 ++ drivers/platform/mpam/mpam_resctrl.c | 9 +++++++-- 3 files changed, 20 insertions(+), 3 deletions(-) diff --git a/drivers/platform/mpam/mpam_devices.c b/drivers/platform/mpam/mpam_devices.c index 6c1c82f79ec0..42d1e5bbe810 100644 --- a/drivers/platform/mpam/mpam_devices.c +++ b/drivers/platform/mpam/mpam_devices.c @@ -56,6 +56,7 @@ static DEFINE_MUTEX(mpam_cpuhp_state_lock); * Generating traffic outside this range will result in screaming interrupts. */ u16 mpam_partid_max; +u16 mpam_intpartid_max; u8 mpam_pmg_max; static bool partid_max_init, partid_max_published; static DEFINE_SPINLOCK(partid_max_lock); @@ -201,10 +202,16 @@ int mpam_register_requestor(u16 partid_max, u8 pmg_max) spin_lock(&partid_max_lock); if (!partid_max_init) { mpam_partid_max = partid_max; + /* + * Update mpam_intpartid_max here, in case the + * system doesn't have narrow-partid feature. + */ + mpam_intpartid_max = partid_max; mpam_pmg_max = pmg_max; partid_max_init = true; } else if (!partid_max_published) { mpam_partid_max = min(mpam_partid_max, partid_max); + mpam_intpartid_max = min(mpam_intpartid_max, partid_max); mpam_pmg_max = min(mpam_pmg_max, pmg_max); } else { /* New requestors can't lower the values */ @@ -741,7 +748,9 @@ static void mpam_ris_hw_probe(struct mpam_msc_ris *ris) u16 partid_max = FIELD_GET(MPAMF_PARTID_NRW_IDR_INTPARTID_MAX, nrwidr); mpam_set_feature(mpam_feat_partid_nrw, props); - msc->partid_max = min(msc->partid_max, partid_max); + msc->intpartid_max = min(msc->partid_max, partid_max); + } else { + msc->intpartid_max = msc->partid_max; } } @@ -806,6 +815,7 @@ static int mpam_msc_hw_probe(struct mpam_msc *msc) spin_lock(&partid_max_lock); mpam_partid_max = min(mpam_partid_max, msc->partid_max); + mpam_intpartid_max = min(mpam_intpartid_max, msc->intpartid_max); mpam_pmg_max = min(mpam_pmg_max, msc->pmg_max); spin_unlock(&partid_max_lock); diff --git a/drivers/platform/mpam/mpam_internal.h b/drivers/platform/mpam/mpam_internal.h index 5f60e0cc4eeb..e4809f2242ec 100644 --- a/drivers/platform/mpam/mpam_internal.h +++ b/drivers/platform/mpam/mpam_internal.h @@ -58,6 +58,7 @@ struct mpam_msc bool error_irq_requested; bool error_irq_hw_enabled; u16 partid_max; + u16 intpartid_max; u8 pmg_max; unsigned long ris_idxs[128 / BITS_PER_LONG]; u32 ris_max; @@ -303,6 +304,7 @@ extern struct srcu_struct mpam_srcu; /* System wide partid/pmg values */ extern u16 mpam_partid_max; +extern u16 mpam_intpartid_max; extern u8 mpam_pmg_max; /* Scheduled work callback to enable mpam once all MSC have been probed */ diff --git a/drivers/platform/mpam/mpam_resctrl.c b/drivers/platform/mpam/mpam_resctrl.c index 8ee0857f9a93..ae0bb95aa97a 100644 --- a/drivers/platform/mpam/mpam_resctrl.c +++ b/drivers/platform/mpam/mpam_resctrl.c @@ -147,6 +147,11 @@ bool resctrl_arch_hide_cdp(enum resctrl_res_level rid) * only the system wide safe value is safe to use. */ u32 resctrl_arch_get_num_closid(struct rdt_resource *ignored) +{ + return mpam_intpartid_max + 1; +} + +static u32 get_num_reqpartid(void) { return mpam_partid_max + 1; } @@ -154,9 +159,9 @@ u32 resctrl_arch_get_num_closid(struct rdt_resource *ignored) u32 resctrl_arch_system_num_rmid_idx(void) { u8 closid_shift = fls(mpam_pmg_max); - u32 num_partid = resctrl_arch_get_num_closid(NULL); + u32 num_reqpartid = get_num_reqpartid(); - return num_partid << closid_shift; + return num_reqpartid << closid_shift; } u32 resctrl_arch_rmid_idx_encode(u32 closid, u32 rmid) -- 2.25.1
hulk inclusion category: feature bugzilla: https://atomgit.com/openeuler/kernel/issues/8420 ------------------ Because it needs to support mixed systems that include MSCs with and without Narrow-PARTID support, there are the following incompatible control issues. If an MSC does not support Narrow-PARTID and its control method is not of the "partition bitmap" type, then delivering the resctrl control group configuration across multiple PARTIDs will change the user's expected behavior. Currently, there is no way to solve this problem by programming different control values simply, so here decide to restrict the usage scenarios of this feature. When we find that the MATA MSC does not support the Narrow-PARTID feature, the driver will disable the feature, which means get_num_reqpartid() directly returns the number of intPARTIDs. Signed-off-by: Zeng Heng <zengheng4@huawei.com> --- drivers/platform/mpam/mpam_resctrl.c | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/drivers/platform/mpam/mpam_resctrl.c b/drivers/platform/mpam/mpam_resctrl.c index ae0bb95aa97a..5342073e8d9e 100644 --- a/drivers/platform/mpam/mpam_resctrl.c +++ b/drivers/platform/mpam/mpam_resctrl.c @@ -151,8 +151,24 @@ u32 resctrl_arch_get_num_closid(struct rdt_resource *ignored) return mpam_intpartid_max + 1; } +/* It's valid only after mpam_resctrl_pick_mba() */ static u32 get_num_reqpartid(void) { + struct mpam_resctrl_res *res; + struct rdt_resource *r_mba; + struct mpam_props *cprops; + + r_mba = resctrl_arch_get_resource(RDT_RESOURCE_MBA); + res = container_of(r_mba, struct mpam_resctrl_res, resctrl_res); + cprops = &res->class->props; + + /* + * If the MBA does not support Narrow-PARTID, + * then the feature should be disabled at the system level. + */ + if (!mpam_has_feature(mpam_feat_partid_nrw, cprops)) + return resctrl_arch_get_num_closid(NULL); + return mpam_partid_max + 1; } @@ -1185,9 +1201,9 @@ int mpam_resctrl_setup(void) res->resctrl_res.rid = i; } - mpam_resctrl_pick_caches(); mpam_resctrl_pick_mba(); /* TODO: mpam_resctrl_pick_counters(); */ + mpam_resctrl_pick_caches(); for (i = 0; i < RDT_NUM_RESOURCES; i++) { res = &mpam_resctrl_exports[i]; -- 2.25.1
hulk inclusion category: feature bugzilla: https://atomgit.com/openeuler/kernel/issues/8420 ------------------ The Narrow Partid feature supports for the MPAM driver statically or dynamically allocates all reqPARTIDs to various intPARTIDs. The new RMID allocation strategy will check whether there are available reqPARTIDs for the incoming closid, rather than simply checking for available PMGs. For a mixture of MSCs system, for MSCs that do not support narrow-partid, we use the PARTIDs exceeding the number of closids as reqPARTIDs for expanding the monitoring groups. Therefore, we will expand the information contained in the RMID, so that it includes not only PMG, but also reqPARTIDs information. The new RMID would be like: RMID = (reqPARTID << shift | PMG). In order to keep the existing resctrl layer interfaces, the reqPARTIDs are allocated statically. Here req2intpartid() linearly binds each reqPARTID to the corresponding intPARTID. If reqPARTID needs to support dynamic allocation in the future, then simply rewrite req2intpartid() and can be replaced with a table-lookup approach. The static mapping relationships between each group's closid/rmid and the respective MSCs' intPARTID/reqPARTID/PARTID are illustrated: n - Indicates the total number of intPARTIDs m - Indicates the number of reqPARTIDs per intPARTID P - Partition group M - Monitoring group Group closid rmid.reqPARTID MSCs with narrow-partid MSCs without narrow-partid P1 0 intPARTID_1 PARTID_1 M1_1 0 0 ├── reqPARTID_1_1 ├── PARTID_1 M1_2 0 0+n ├── reqPARTID_1_2 ├── PARTID_1_2 M1_3 0 0+n*2 ├── reqPARTID_1_3 ├── PARTID_1_3 ... ├── ... ├── ... M1_m 0 0+n*(m-1) └── reqPARTID_1_m └── PARTID_1_m P2 1 intPARTID_2 PARTID_2 M2_1 1 1 ├── reqPARTID_2_1 ├── PARTID_2 M2_2 1 1+n ├── reqPARTID_2_2 ├── PARTID_2_2 M2_3 1 1+n*2 ├── reqPARTID_2_3 ├── PARTID_2_3 ... ├── ... ├── ... M2_m 1 1+n*(m-1) └── reqPARTID_2_m └── PARTID_2_m Pn (n-1) intPARTID_n PARTID_n Mn_1 (n-1) (n-1) ├── reqPARTID_n_1 ├── PARTID_n Mn_2 (n-1) (n-1)+n ├── reqPARTID_n_2 ├── PARTID_n_2 Mn_3 (n-1) (n-1)+n*2 ├── reqPARTID_n_3 ├── PARTID_n_3 ... ├── ... ├── ... Mn_m (n-1) (n-1)+n*(m-1) = n*m-1 └── reqPARTID_n_m └── PARTID_n_m The resctrl layer uses the new conversion functions rmid2reqpartid() and rmid2pmg() respectively to gain the new reqPARTID/PMG pair by RMID. And still, the translation between closid and intPARTID follows the original conversion logic of closid: intPARTID = resctrl_get_config_index(closid, resctrl_conf_type). It can be noted that the approach of allocating the first n IDs to intPARTIDs keeps the existing conversion between closid and intPARTID. We still use the resctrl_get_config_index() for conversion, maintaining the original semantics during the MPAM configuration updating. Essentially, the narrowing feature is an enhanced monitoring feature, we only expand the definition of rmid, while reqPARTID is only used in monitoring-related processes. Now each control group has m (req)PARTIDs, which are used to expand the number of monitoring groups under one control group. Therefore, the number of monitoring groups is no longer limited by the range of MPAM's PMG, which enhances the extensibility of the system's monitoring capabilities. Signed-off-by: Zeng Heng <zengheng4@huawei.com> --- drivers/platform/mpam/mpam_resctrl.c | 152 ++++++++++++++++----------- 1 file changed, 90 insertions(+), 62 deletions(-) diff --git a/drivers/platform/mpam/mpam_resctrl.c b/drivers/platform/mpam/mpam_resctrl.c index 5342073e8d9e..49a2fa098d0a 100644 --- a/drivers/platform/mpam/mpam_resctrl.c +++ b/drivers/platform/mpam/mpam_resctrl.c @@ -180,24 +180,65 @@ u32 resctrl_arch_system_num_rmid_idx(void) return num_reqpartid << closid_shift; } +static u32 rmid2reqpartid(u32 rmid) +{ + u8 pmg_shift = fls(mpam_pmg_max); + + WARN_ON_ONCE(pmg_shift > 8); + + return rmid >> pmg_shift; +} + +static u32 rmid2pmg(u32 rmid) +{ + u8 pmg_shift = fls(mpam_pmg_max); + u32 pmg_mask = ~(~0 << pmg_shift); + + return rmid & pmg_mask; +} + +static u32 req2intpartid(u32 reqpartid) +{ + u8 intpartid_shift = fls(mpam_intpartid_max); + u32 intpartid_mask = ~(~0 << intpartid_shift); + + return reqpartid & intpartid_mask; +} + +/* + * To avoid the reuse of rmid across multiple control groups, check + * the incoming closid to prevent rmid from being reallocated by + * resctrl_find_free_rmid(). + * + * If the closid and rmid do not match upon inspection, immediately + * returns an invalid rmid. A valid rmid must not exceed 24 bits. + */ u32 resctrl_arch_rmid_idx_encode(u32 closid, u32 rmid) { - u8 closid_shift = fls(mpam_pmg_max); + u32 reqpartid = rmid2reqpartid(rmid); + u32 intpartid = req2intpartid(reqpartid); + + if (cdp_enabled) + intpartid >>= 1; - BUG_ON(closid_shift > 8); + if (closid != intpartid) + return U32_MAX; - return (closid << closid_shift) | rmid; + return rmid; } void resctrl_arch_rmid_idx_decode(u32 idx, u32 *closid, u32 *rmid) { - u8 closid_shift = fls(mpam_pmg_max); - u32 pmg_mask = ~(~0 << closid_shift); - - BUG_ON(closid_shift > 8); + u32 reqpartid = rmid2reqpartid(idx); + u32 intpartid = req2intpartid(reqpartid); - *closid = idx >> closid_shift; - *rmid = idx & pmg_mask; + if (rmid) + *rmid = idx; + if (closid) { + if (cdp_enabled) + intpartid >>= 1; + *closid = intpartid; + } } void resctrl_sched_in(struct task_struct *tsk) @@ -207,23 +248,22 @@ void resctrl_sched_in(struct task_struct *tsk) mpam_thread_switch(tsk); } -void resctrl_arch_set_cpu_default_closid_rmid(int cpu, u32 closid, u32 pmg) +void resctrl_arch_set_cpu_default_closid_rmid(int cpu, u32 closid, u32 rmid) { - BUG_ON(closid > U16_MAX); - BUG_ON(pmg > U8_MAX); + u32 reqpartid = rmid2reqpartid(rmid); + u32 pmg = rmid2pmg(rmid); - if (!cdp_enabled) { - mpam_set_cpu_defaults(cpu, closid, closid, pmg, pmg); - } else { + WARN_ON_ONCE(reqpartid > U16_MAX); + WARN_ON_ONCE(pmg > U8_MAX); + + if (!cdp_enabled) + mpam_set_cpu_defaults(cpu, reqpartid, reqpartid, pmg, pmg); + else /* * When CDP is enabled, resctrl halves the closid range and we * use odd/even partid for one closid. */ - u32 partid_d = resctrl_get_config_index(closid, CDP_DATA); - u32 partid_i = resctrl_get_config_index(closid, CDP_CODE); - - mpam_set_cpu_defaults(cpu, partid_d, partid_i, pmg, pmg); - } + mpam_set_cpu_defaults(cpu, reqpartid, reqpartid + 1, pmg, pmg); } void resctrl_arch_sync_cpu_defaults(void *info) @@ -242,43 +282,40 @@ void resctrl_arch_sync_cpu_defaults(void *info) void resctrl_arch_set_closid_rmid(struct task_struct *tsk, u32 closid, u32 rmid) { + u32 reqpartid = rmid2reqpartid(rmid); + u32 pmg = rmid2pmg(rmid); + WARN_ON_ONCE(reqpartid > U16_MAX); + WARN_ON_ONCE(pmg > U8_MAX); - BUG_ON(closid > U16_MAX); - BUG_ON(rmid > U8_MAX); - - if (!cdp_enabled) { - mpam_set_task_partid_pmg(tsk, closid, closid, rmid, rmid); - } else { - u32 partid_d = resctrl_get_config_index(closid, CDP_DATA); - u32 partid_i = resctrl_get_config_index(closid, CDP_CODE); - - mpam_set_task_partid_pmg(tsk, partid_d, partid_i, rmid, rmid); - } + if (!cdp_enabled) + mpam_set_task_partid_pmg(tsk, reqpartid, reqpartid, pmg, pmg); + else + mpam_set_task_partid_pmg(tsk, reqpartid, reqpartid + 1, pmg, pmg); } bool resctrl_arch_match_closid(struct task_struct *tsk, u32 closid) { u64 regval = mpam_get_regval(tsk); - u32 tsk_closid = FIELD_GET(MPAM_SYSREG_PARTID_D, regval); + u32 tsk_partid = FIELD_GET(MPAM1_EL1_PARTID_D, regval); + + tsk_partid = req2intpartid(tsk_partid); if (cdp_enabled) - tsk_closid >>= 1; + tsk_partid >>= 1; - return tsk_closid == closid; + return tsk_partid == closid; } /* The task's pmg is not unique, the partid must be considered too */ bool resctrl_arch_match_rmid(struct task_struct *tsk, u32 closid, u32 rmid) { u64 regval = mpam_get_regval(tsk); - u32 tsk_closid = FIELD_GET(MPAM_SYSREG_PARTID_D, regval); - u32 tsk_rmid = FIELD_GET(MPAM_SYSREG_PMG_D, regval); + u32 tsk_partid = FIELD_GET(MPAM1_EL1_PARTID_D, regval); + u32 tsk_pmg = FIELD_GET(MPAM1_EL1_PMG_D, regval); - if (cdp_enabled) - tsk_closid >>= 1; - - return (tsk_closid == closid) && (tsk_rmid == rmid); + return (tsk_partid == rmid2reqpartid(rmid)) && + (tsk_pmg == rmid2pmg(rmid)); } #ifdef CONFIG_RESCTRL_IOMMU @@ -424,29 +461,24 @@ int resctrl_arch_rmid_read(struct rdt_resource *r, struct rdt_domain *d, num_mon = res->class->props.num_csu_mon; cfg.match_pmg = true; - cfg.pmg = rmid; + cfg.pmg = rmid2pmg(rmid); cfg.opts = resctrl_evt_config_to_mpam(dom->mbm_local_evt_cfg); + cfg.partid = rmid2reqpartid(rmid); - if (cdp_enabled) { - cfg.partid = resctrl_get_config_index(closid, CDP_DATA); - cfg.mon = cfg.partid % num_mon; - err = mpam_msmon_read(dom->comp, &cfg, type, val); - if (err) - return err; + cfg.mon = cfg.partid % num_mon; + err = mpam_msmon_read(dom->comp, &cfg, type, val); + if (err) + return err; - cfg.partid = resctrl_get_config_index(closid, CDP_CODE); + if (cdp_enabled) { + cfg.partid += 1; cfg.mon = cfg.partid % num_mon; err = mpam_msmon_read(dom->comp, &cfg, type, &cdp_val); if (!err) { - pr_debug("read monitor rmid %u %s:%u CODE/DATA: %lld/%lld\n", - resctrl_arch_rmid_idx_encode(closid, rmid), - r->name, dom->comp->comp_id, cdp_val, *val); + pr_debug("read monitor closid %u rmid %u %s:%u CODE/DATA: %lld/%lld\n", + closid, rmid, r->name, dom->comp->comp_id, cdp_val, *val); *val += cdp_val; } - } else { - cfg.partid = closid; - cfg.mon = cfg.partid % num_mon; - err = mpam_msmon_read(dom->comp, &cfg, type, val); } return err; @@ -468,19 +500,15 @@ void resctrl_arch_reset_rmid(struct rdt_resource *r, struct rdt_domain *d, num_mbwu_mon = res->class->props.num_mbwu_mon; cfg.mon = resctrl_arch_rmid_idx_encode(closid, rmid) % num_mbwu_mon; cfg.match_pmg = true; - cfg.pmg = rmid; + cfg.pmg = rmid2pmg(rmid); + cfg.partid = rmid2reqpartid(rmid); dom = container_of(d, struct mpam_resctrl_dom, resctrl_dom); + mpam_msmon_reset_mbwu(dom->comp, &cfg); if (cdp_enabled) { - cfg.partid = closid << 1; - mpam_msmon_reset_mbwu(dom->comp, &cfg); - cfg.partid += 1; mpam_msmon_reset_mbwu(dom->comp, &cfg); - } else { - cfg.partid = closid; - mpam_msmon_reset_mbwu(dom->comp, &cfg); } } -- 2.25.1
From: Dave Martin <Dave.Martin@arm.com> hulk inclusion category: feature bugzilla: https://atomgit.com/openeuler/kernel/issues/8420 ------------------ Currently, when an MSC implements PARTID narrowing, MPAMCFG_PART_SEL is left set to the reqPARTID while programming resource controls in an MSC. The MPAM architecture does not guarantee that any particular resource controls will be updated correctly in this scenario. Instead, MPAMCFG_PART_SEL must be written with the corresponding intPARTID and with the INTERNAL bit set before attempting to program resource controls. Only the PARTID->intPARTID mappings can be written without the INTERNAL bit set in MPAMCFG_PART_SEL. Fix it, by rewriting MPAMCFG_PART_SEL appropriately after setting the intPARTID mapping. The MPAMCFG_INTPARTID_INTERNAL flag is not currently accepted as input to the __mpam_part_sel() helper. In the interest of keeping the code clean, break this helper up. Signed-off-by: Dave Martin <Dave.Martin@arm.com> Signed-off-by: James Morse <james.morse@arm.com> --- drivers/platform/mpam/mpam_devices.c | 26 ++++++++++++++++++++------ 1 file changed, 20 insertions(+), 6 deletions(-) diff --git a/drivers/platform/mpam/mpam_devices.c b/drivers/platform/mpam/mpam_devices.c index 42d1e5bbe810..5e7777b19574 100644 --- a/drivers/platform/mpam/mpam_devices.c +++ b/drivers/platform/mpam/mpam_devices.c @@ -184,15 +184,27 @@ static u64 mpam_msc_read_esr(struct mpam_msc *msc) return (esr_high << 32) | esr_low; } +static void __mpam_part_sel_raw(u32 partsel, struct mpam_msc *msc) +{ + lockdep_assert_held(&msc->part_sel_lock); + mpam_write_partsel_reg(msc, PART_SEL, partsel); +} + static void __mpam_part_sel(u8 ris_idx, u16 partid, struct mpam_msc *msc) { - u32 partsel; + u32 partsel = FIELD_PREP(MPAMCFG_PART_SEL_RIS, ris_idx) | + FIELD_PREP(MPAMCFG_PART_SEL_PARTID_SEL, partid); - lockdep_assert_held(&msc->part_sel_lock); + __mpam_part_sel_raw(partsel, msc); +} - partsel = FIELD_PREP(MPAMCFG_PART_SEL_RIS, ris_idx) | - FIELD_PREP(MPAMCFG_PART_SEL_PARTID_SEL, partid); - mpam_write_partsel_reg(msc, PART_SEL, partsel); +static void __mpam_intpart_sel(u8 ris_idx, u16 intpartid, struct mpam_msc *msc) +{ + u32 partsel = FIELD_PREP(MPAMCFG_PART_SEL_RIS, ris_idx) | + FIELD_PREP(MPAMCFG_PART_SEL_PARTID_SEL, intpartid) | + MPAMCFG_PART_SEL_INTERNAL; + + __mpam_part_sel_raw(partsel, msc); } int mpam_register_requestor(u16 partid_max, u8 pmg_max) @@ -1364,9 +1376,11 @@ static void mpam_reprogram_ris_partid(struct mpam_msc_ris *ris, u16 partid, spin_lock(&msc->part_sel_lock); __mpam_part_sel(ris->ris_idx, partid, msc); - if(mpam_has_feature(mpam_feat_partid_nrw, rprops)) + if(mpam_has_feature(mpam_feat_partid_nrw, rprops)) { mpam_write_partsel_reg(msc, INTPARTID, (MPAMCFG_PART_SEL_INTERNAL | partid)); + __mpam_intpart_sel(ris->ris_idx, partid, msc); + } if (mpam_has_feature(mpam_feat_cpor_part, rprops)) { if (mpam_has_feature(mpam_feat_cpor_part, cfg)) -- 2.25.1
hulk inclusion category: feature bugzilla: https://atomgit.com/openeuler/kernel/issues/8420 ------------------ After the system expands the narrow-partid feature and statically assigns all (req)PARTIDs to each control group, the following scenarios require configuration synchronization operations: 1. MSCs that support narrow-partid need to establish a mapping between reqPARTID and intPARTID after creating a new monitoring group. 2. MSCs that do not support narrow-partid need to synchronize the configuration of sub-monitoring groups after users update the control group configuration. In __write_config(), we synchronize a control group's configuration to each sub-monitoring group. Signed-off-by: Zeng Heng <zengheng4@huawei.com> --- drivers/platform/mpam/mpam_devices.c | 26 +++++++++++++++++++++++--- drivers/platform/mpam/mpam_internal.h | 3 +++ drivers/platform/mpam/mpam_resctrl.c | 7 ++++++- 3 files changed, 32 insertions(+), 4 deletions(-) diff --git a/drivers/platform/mpam/mpam_devices.c b/drivers/platform/mpam/mpam_devices.c index 5e7777b19574..0d4e83001ae6 100644 --- a/drivers/platform/mpam/mpam_devices.c +++ b/drivers/platform/mpam/mpam_devices.c @@ -1371,6 +1371,7 @@ static void mpam_reprogram_ris_partid(struct mpam_msc_ris *ris, u16 partid, u16 cmax = MPAMCFG_CMAX_CMAX; struct mpam_msc *msc = ris->msc; u16 bwa_fract = MPAMCFG_MBW_MAX_MAX; + u16 intpartid = req2intpartid(partid); struct mpam_props *rprops = &ris->props; spin_lock(&msc->part_sel_lock); @@ -1378,8 +1379,14 @@ static void mpam_reprogram_ris_partid(struct mpam_msc_ris *ris, u16 partid, if(mpam_has_feature(mpam_feat_partid_nrw, rprops)) { mpam_write_partsel_reg(msc, INTPARTID, - (MPAMCFG_PART_SEL_INTERNAL | partid)); - __mpam_intpart_sel(ris->ris_idx, partid, msc); + MPAMCFG_INTPARTID_INTERNAL | + intpartid); + + /* Already finish mapping reqPARTID to intPARTID */ + if (partid != intpartid) + goto out; + + __mpam_intpart_sel(ris->ris_idx, intpartid, msc); } if (mpam_has_feature(mpam_feat_cpor_part, rprops)) { @@ -1463,6 +1470,7 @@ static void mpam_reprogram_ris_partid(struct mpam_msc_ris *ris, u16 partid, mpam_has_feature(mpam_feat_dspri_part, rprops)) mpam_write_partsel_reg(msc, PRI, pri_val); +out: spin_unlock(&msc->part_sel_lock); } @@ -2570,9 +2578,21 @@ struct mpam_write_config_arg { static int __write_config(void *arg) { + int closid_num = resctrl_arch_get_num_closid(NULL); struct mpam_write_config_arg *c = arg; + u32 reqpartid, req_idx; + + /* This partid should be in the range of intPARTIDs */ + WARN_ON_ONCE(c->partid >= closid_num); - mpam_reprogram_ris_partid(c->ris, c->partid, &c->comp->cfg[c->partid]); + /* Synchronize the configuration to each sub-monitoring group. */ + for (req_idx = 0; req_idx < get_num_reqpartid_per_closid(); + req_idx++) { + reqpartid = req_idx * closid_num + c->partid; + + mpam_reprogram_ris_partid(c->ris, reqpartid, + &c->comp->cfg[c->partid]); + } return 0; } diff --git a/drivers/platform/mpam/mpam_internal.h b/drivers/platform/mpam/mpam_internal.h index e4809f2242ec..11564ee44025 100644 --- a/drivers/platform/mpam/mpam_internal.h +++ b/drivers/platform/mpam/mpam_internal.h @@ -594,4 +594,7 @@ bool mpam_cpbm_hisi_check_invalid(struct rdt_resource *r, unsigned long val); int mpam_resctrl_prepare_offline(void); +u32 req2intpartid(u32 reqpartid); +u32 get_num_reqpartid_per_closid(void); + #endif /* MPAM_INTERNAL_H */ diff --git a/drivers/platform/mpam/mpam_resctrl.c b/drivers/platform/mpam/mpam_resctrl.c index 49a2fa098d0a..18e23f47a5c1 100644 --- a/drivers/platform/mpam/mpam_resctrl.c +++ b/drivers/platform/mpam/mpam_resctrl.c @@ -172,6 +172,11 @@ static u32 get_num_reqpartid(void) return mpam_partid_max + 1; } +u32 get_num_reqpartid_per_closid(void) +{ + return get_num_reqpartid() / resctrl_arch_get_num_closid(NULL); +} + u32 resctrl_arch_system_num_rmid_idx(void) { u8 closid_shift = fls(mpam_pmg_max); @@ -197,7 +202,7 @@ static u32 rmid2pmg(u32 rmid) return rmid & pmg_mask; } -static u32 req2intpartid(u32 reqpartid) +u32 req2intpartid(u32 reqpartid) { u8 intpartid_shift = fls(mpam_intpartid_max); u32 intpartid_mask = ~(~0 << intpartid_shift); -- 2.25.1
hulk inclusion category: feature bugzilla: https://atomgit.com/openeuler/kernel/issues/8420 ------------------ This reverts commit 6420897facc73e9a86d9a1c6deababcf4d0a22cd. --- drivers/platform/mpam/mpam_resctrl.c | 18 +----------------- 1 file changed, 1 insertion(+), 17 deletions(-) diff --git a/drivers/platform/mpam/mpam_resctrl.c b/drivers/platform/mpam/mpam_resctrl.c index 18e23f47a5c1..3b53eccda018 100644 --- a/drivers/platform/mpam/mpam_resctrl.c +++ b/drivers/platform/mpam/mpam_resctrl.c @@ -151,24 +151,8 @@ u32 resctrl_arch_get_num_closid(struct rdt_resource *ignored) return mpam_intpartid_max + 1; } -/* It's valid only after mpam_resctrl_pick_mba() */ static u32 get_num_reqpartid(void) { - struct mpam_resctrl_res *res; - struct rdt_resource *r_mba; - struct mpam_props *cprops; - - r_mba = resctrl_arch_get_resource(RDT_RESOURCE_MBA); - res = container_of(r_mba, struct mpam_resctrl_res, resctrl_res); - cprops = &res->class->props; - - /* - * If the MBA does not support Narrow-PARTID, - * then the feature should be disabled at the system level. - */ - if (!mpam_has_feature(mpam_feat_partid_nrw, cprops)) - return resctrl_arch_get_num_closid(NULL); - return mpam_partid_max + 1; } @@ -1234,9 +1218,9 @@ int mpam_resctrl_setup(void) res->resctrl_res.rid = i; } + mpam_resctrl_pick_caches(); mpam_resctrl_pick_mba(); /* TODO: mpam_resctrl_pick_counters(); */ - mpam_resctrl_pick_caches(); for (i = 0; i < RDT_NUM_RESOURCES; i++) { res = &mpam_resctrl_exports[i]; -- 2.25.1
hulk inclusion category: feature bugzilla: https://atomgit.com/openeuler/kernel/issues/8420 ------------------ Signed-off-by: Zeng Heng <zengheng4@huawei.com> --- drivers/platform/mpam/mpam_devices.c | 13 ++- drivers/platform/mpam/mpam_internal.h | 2 +- drivers/platform/mpam/mpam_resctrl.c | 143 +++++++++++++++++++++----- fs/resctrl/monitor.c | 18 +++- include/linux/resctrl.h | 18 ++++ 5 files changed, 160 insertions(+), 34 deletions(-) diff --git a/drivers/platform/mpam/mpam_devices.c b/drivers/platform/mpam/mpam_devices.c index 0d4e83001ae6..4d05803192be 100644 --- a/drivers/platform/mpam/mpam_devices.c +++ b/drivers/platform/mpam/mpam_devices.c @@ -2580,18 +2580,17 @@ static int __write_config(void *arg) { int closid_num = resctrl_arch_get_num_closid(NULL); struct mpam_write_config_arg *c = arg; - u32 reqpartid, req_idx; + u32 reqpartid; /* This partid should be in the range of intPARTIDs */ WARN_ON_ONCE(c->partid >= closid_num); /* Synchronize the configuration to each sub-monitoring group. */ - for (req_idx = 0; req_idx < get_num_reqpartid_per_closid(); - req_idx++) { - reqpartid = req_idx * closid_num + c->partid; - - mpam_reprogram_ris_partid(c->ris, reqpartid, - &c->comp->cfg[c->partid]); + for (reqpartid = closid_num; + reqpartid < get_num_reqpartid(); reqpartid++) { + if (req2intpartid(reqpartid) == c->partid) + mpam_reprogram_ris_partid(c->ris, reqpartid, + &c->comp->cfg[c->partid]); } return 0; diff --git a/drivers/platform/mpam/mpam_internal.h b/drivers/platform/mpam/mpam_internal.h index 11564ee44025..3e9f150e358a 100644 --- a/drivers/platform/mpam/mpam_internal.h +++ b/drivers/platform/mpam/mpam_internal.h @@ -595,6 +595,6 @@ bool mpam_cpbm_hisi_check_invalid(struct rdt_resource *r, unsigned long val); int mpam_resctrl_prepare_offline(void); u32 req2intpartid(u32 reqpartid); -u32 get_num_reqpartid_per_closid(void); +u32 get_num_reqpartid(void); #endif /* MPAM_INTERNAL_H */ diff --git a/drivers/platform/mpam/mpam_resctrl.c b/drivers/platform/mpam/mpam_resctrl.c index 3b53eccda018..e277934e8138 100644 --- a/drivers/platform/mpam/mpam_resctrl.c +++ b/drivers/platform/mpam/mpam_resctrl.c @@ -151,16 +151,11 @@ u32 resctrl_arch_get_num_closid(struct rdt_resource *ignored) return mpam_intpartid_max + 1; } -static u32 get_num_reqpartid(void) +u32 get_num_reqpartid(void) { return mpam_partid_max + 1; } -u32 get_num_reqpartid_per_closid(void) -{ - return get_num_reqpartid() / resctrl_arch_get_num_closid(NULL); -} - u32 resctrl_arch_system_num_rmid_idx(void) { u8 closid_shift = fls(mpam_pmg_max); @@ -186,12 +181,28 @@ static u32 rmid2pmg(u32 rmid) return rmid & pmg_mask; } +static u32 req_pmg2rmid(u32 reqpartid, u32 pmg) +{ + u8 pmg_shift = fls(mpam_pmg_max); + u32 pmg_mask = ~(~0 << pmg_shift); + + return (reqpartid << pmg_shift) | (pmg & pmg_mask); +} + +static u32 *reqpartid_map; + u32 req2intpartid(u32 reqpartid) { - u8 intpartid_shift = fls(mpam_intpartid_max); - u32 intpartid_mask = ~(~0 << intpartid_shift); + WARN_ON_ONCE(reqpartid >= get_num_reqpartid()); - return reqpartid & intpartid_mask; + /* + * Directly return intPartid in case that mpam_reset_ris() access + * NULL pointer. + */ + if (reqpartid < resctrl_arch_get_num_closid(NULL)) + return reqpartid; + + return reqpartid_map[reqpartid]; } /* @@ -1202,6 +1213,78 @@ static int mpam_resctrl_resource_init(struct mpam_resctrl_res *res) return 0; } +static int reqpartid_init(void) +{ + int req_num, idx; + + req_num = get_num_reqpartid(); + reqpartid_map = kcalloc(req_num, sizeof(u32), GFP_KERNEL); + if (!reqpartid_map) + return -ENOMEM; + + for (idx = 0; idx < req_num; idx++) { + if (idx < resctrl_arch_get_num_closid(NULL)) + reqpartid_map[idx] = idx; + else + /* dummy intPartid */ + reqpartid_map[idx] = U32_MAX; + } + + return 0; +} + +void reqpartid_exit(void) +{ + kfree(reqpartid_map); +} + +void update_rmid_entries_for_reqpartid(u32 reqpartid) +{ + int pmg; + + for (pmg = 0; pmg <= mpam_pmg_max; pmg++) + update_rmid_entry(reqpartid_map[reqpartid], + req_pmg2rmid(reqpartid, pmg)); +} + +int resctrl_arch_expand_rmid(u32 intpartid) +{ + int i; + + for (i = resctrl_arch_get_num_closid(NULL); + i < get_num_reqpartid(); i++) { + if (reqpartid_map[i] == U32_MAX) { + reqpartid_map[i] = intpartid; + update_rmid_entries_for_reqpartid(i); + return i; + } + } + + return -ENOSPC; +} + +void resctrl_arch_shrink_rmid(u32 closid, u32 rmid) +{ + int pmg; + int reqpartid = rmid2reqpartid(rmid); + + if (reqpartid < resctrl_arch_get_num_closid(NULL)) + return; + + WARN_ON_ONCE(closid != req2intpartid(reqpartid)); + + for (pmg = 0; pmg <= mpam_pmg_max; pmg++) { + if (rmid_is_occupied(reqpartid_map[reqpartid], + req_pmg2rmid(reqpartid, pmg))) + break; + } + + if (pmg > mpam_pmg_max) { + reqpartid_map[reqpartid] = U32_MAX; + update_rmid_entries_for_reqpartid(reqpartid); + } +} + int mpam_resctrl_setup(void) { int err = 0; @@ -1233,24 +1316,35 @@ int mpam_resctrl_setup(void) } cpus_read_unlock(); - if (!err && !exposed_alloc_capable && !exposed_mon_capable) - err = -EOPNOTSUPP; - - if (!err) { - if (!is_power_of_2(mpam_pmg_max + 1)) { - /* - * If not all the partid*pmg values are valid indexes, - * resctrl may allocate pmg that don't exist. This - * should cause an error interrupt. - */ - pr_warn("Number of PMG is not a power of 2! resctrl may misbehave"); - } + if (err) + return err; + + if (!exposed_alloc_capable && !exposed_mon_capable) + return -EOPNOTSUPP; - err = resctrl_init(); - if (!err) - WRITE_ONCE(resctrl_enabled, true); + err = reqpartid_init(); + if (err) + return err; + + if (!is_power_of_2(mpam_pmg_max + 1)) { + /* + * If not all the partid*pmg values are valid indexes, + * resctrl may allocate pmg that don't exist. This + * should cause an error interrupt. + */ + pr_warn("Number of PMG is not a power of 2! resctrl may misbehave"); } + err = resctrl_init(); + if (err) + goto err; + + WRITE_ONCE(resctrl_enabled, true); + + return 0; + +err: + reqpartid_exit(); return err; } @@ -1261,6 +1355,7 @@ void mpam_resctrl_exit(void) WRITE_ONCE(resctrl_enabled, false); resctrl_exit(); + reqpartid_exit(); } u32 resctrl_arch_get_config(struct rdt_resource *r, struct rdt_domain *d, diff --git a/fs/resctrl/monitor.c b/fs/resctrl/monitor.c index b651b37e7e65..034d426d24e4 100644 --- a/fs/resctrl/monitor.c +++ b/fs/resctrl/monitor.c @@ -265,7 +265,7 @@ int alloc_rmid(u32 closid) if (IS_ERR(entry)) return PTR_ERR(entry); - list_del(&entry->list); + list_del_init(&entry->list); return entry->rmid; } @@ -324,6 +324,13 @@ void free_rmid(u32 closid, u32 rmid) list_add_tail(&entry->list, &rmid_free_lru); } +bool rmid_is_occupied(u32 closid, u32 rmid) +{ + u32 idx = resctrl_arch_rmid_idx_encode(closid, rmid); + + return list_empty(&rmid_ptrs[idx].list); +} + static struct mbm_state *get_mbm_state(struct rdt_domain *d, u32 closid, u32 rmid, enum resctrl_event_id evtid) { @@ -733,6 +740,13 @@ void mbm_setup_overflow_handler(struct rdt_domain *dom, unsigned long delay_ms, schedule_delayed_work_on(cpu, &dom->mbm_over, delay); } +void update_rmid_entry(u32 closid, u32 rmid) +{ + u32 idx = resctrl_arch_rmid_idx_encode(closid, rmid); + + rmid_ptrs[idx].closid = closid; +} + static int dom_data_init(struct rdt_resource *r) { u32 idx_limit = resctrl_arch_system_num_rmid_idx(); @@ -780,7 +794,7 @@ static int dom_data_init(struct rdt_resource *r) idx = resctrl_arch_rmid_idx_encode(RESCTRL_RESERVED_CLOSID, RESCTRL_RESERVED_RMID); entry = __rmid_entry(idx); - list_del(&entry->list); + list_del_init(&entry->list); out_unlock: mutex_unlock(&rdtgroup_mutex); diff --git a/include/linux/resctrl.h b/include/linux/resctrl.h index 958b1f39d016..4597bc0987e6 100644 --- a/include/linux/resctrl.h +++ b/include/linux/resctrl.h @@ -438,6 +438,24 @@ void resctrl_arch_reset_rmid_all(struct rdt_resource *r, struct rdt_domain *d); extern unsigned int resctrl_rmid_realloc_threshold; extern unsigned int resctrl_rmid_realloc_limit; +/** + * rmid_is_occupied() - Check whether the specified rmid has been allocated + * and is in use. + * @closid: Specify the closid that matches the rmid. + * @rmid: Specify the rmid entry to check status. + * + * Return: + * True if the specified rmid is still in use. + */ +bool rmid_is_occupied(u32 closid, u32 rmid); + +/** + * update_rmid_entry() - Update rmid entry content. + * @closid: Specify the closid that matches the rmid. + * @rmid: Specify the rmid entry to update content. + */ +void update_rmid_entry(u32 closid, u32 rmid); + extern bool resctrl_mounted; int resctrl_init(void); -- 2.25.1
hulk inclusion category: feature bugzilla: https://atomgit.com/openeuler/kernel/issues/8420 ------------------ Signed-off-by: Zeng Heng <zengheng4@huawei.com> --- arch/x86/include/asm/resctrl.h | 7 +++++++ fs/resctrl/monitor.c | 27 +++++++++++++++++++++++++-- include/linux/arm_mpam.h | 16 ++++++++++++++++ 3 files changed, 48 insertions(+), 2 deletions(-) diff --git a/arch/x86/include/asm/resctrl.h b/arch/x86/include/asm/resctrl.h index 406b4cf301bb..4a65eb19b2cf 100644 --- a/arch/x86/include/asm/resctrl.h +++ b/arch/x86/include/asm/resctrl.h @@ -181,6 +181,13 @@ static inline bool resctrl_arch_match_rmid(struct task_struct *tsk, u32 ignored, return READ_ONCE(tsk->rmid) == rmid; } +static inline int resctrl_arch_expand_rmid(u32 closid) +{ + return -ENOSPC; +} + +static inline void resctrl_arch_shrink_rmid(u32 closid, u32 rmid) {} + static inline void resctrl_sched_in(struct task_struct *tsk) { if (static_branch_likely(&rdt_enable_key)) diff --git a/fs/resctrl/monitor.c b/fs/resctrl/monitor.c index 034d426d24e4..6672f7ea91ae 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_shrink_rmid(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) +struct rmid_entry *__resctrl_find_free_rmid(u32 closid) { struct rmid_entry *itr; u32 itr_idx, cmp_idx; @@ -204,6 +206,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_expand_rmid(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 +341,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_shrink_rmid(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 3a06a8afad7c..cd46a7cb9df4 100644 --- a/include/linux/arm_mpam.h +++ b/include/linux/arm_mpam.h @@ -78,6 +78,22 @@ int resctrl_arch_set_cdp_enabled(enum resctrl_res_level ignored, bool enable); bool resctrl_arch_hide_cdp(enum resctrl_res_level rid); 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_expand_rmid() - 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_expand_rmid(u32 closid); +/** + * resctrl_arch_expand_rmid() - Release the rmid resources for the specified closid. + * @closid: closid that matches the rmid. + * @rmid: Release the rmid specified. + */ +void resctrl_arch_shrink_rmid(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 pmg); -- 2.25.1
hulk inclusion category: feature bugzilla: https://atomgit.com/openeuler/kernel/issues/8420 ------------------ Signed-off-by: Zeng Heng <zengheng4@huawei.com> --- drivers/platform/mpam/mpam_resctrl.c | 64 ++++++++++++++++++++++++++++ 1 file changed, 64 insertions(+) diff --git a/drivers/platform/mpam/mpam_resctrl.c b/drivers/platform/mpam/mpam_resctrl.c index e277934e8138..a49411da3368 100644 --- a/drivers/platform/mpam/mpam_resctrl.c +++ b/drivers/platform/mpam/mpam_resctrl.c @@ -1247,10 +1247,47 @@ void update_rmid_entries_for_reqpartid(u32 reqpartid) req_pmg2rmid(reqpartid, pmg)); } +static bool check_narrow_mkdir_limit(u32 closid) +{ + struct rdt_domain *d; + struct mpam_props *cprops; + struct mpam_resctrl_res *res; + struct mpam_resctrl_dom *dom; + struct rdt_resource *r = resctrl_arch_get_resource(RDT_RESOURCE_MBA); + struct rdt_resource *r_min = resctrl_arch_get_resource(RDT_RESOURCE_MB_MIN); + + res = container_of(r, struct mpam_resctrl_res, resctrl_res); + cprops = &res->class->props; + + if (mpam_has_feature(mpam_feat_partid_nrw, cprops)) + return false; + + if (get_num_reqpartid() == resctrl_arch_get_num_closid(NULL)) + return false; + + /* Config has changed */ + list_for_each_entry(d, &r->domains, list) { + dom = container_of(d, struct mpam_resctrl_dom, resctrl_dom); + + if (dom->comp->cfg[closid].mbw_max != + percent_to_mbw_max(r->default_ctrl, cprops->bwa_wd)) + return true; + + if (dom->comp->cfg[closid].mbw_min != + percent_to_mbw_max(r_min->default_ctrl, cprops->bwa_wd)) + return true; + } + + return false; +} + int resctrl_arch_expand_rmid(u32 intpartid) { int i; + if (check_narrow_mkdir_limit(intpartid)) + return -ENOSPC; + for (i = resctrl_arch_get_num_closid(NULL); i < get_num_reqpartid(); i++) { if (reqpartid_map[i] == U32_MAX) { @@ -1458,6 +1495,27 @@ u32 resctrl_arch_get_config(struct rdt_resource *r, struct rdt_domain *d, } } +static bool check_narrow_config_limit(u32 closid, struct mpam_props *cprops) +{ + int reqpartid; + int req_num = get_num_reqpartid(); + int closid_num = resctrl_arch_get_num_closid(NULL); + + if (mpam_has_feature(mpam_feat_partid_nrw, cprops)) + return false; + + if (req_num == closid_num) + return false; + + /* Already deploys reqPartid */ + for (reqpartid = closid_num; reqpartid < req_num; reqpartid++) { + if (req2intpartid(reqpartid) == closid) + return true; + } + + return false; +} + int resctrl_arch_update_one(struct rdt_resource *r, struct rdt_domain *d, u32 closid, enum resctrl_conf_type t, u32 cfg_val) { @@ -1514,12 +1572,18 @@ int resctrl_arch_update_one(struct rdt_resource *r, struct rdt_domain *d, mpam_set_feature(mpam_feat_mbw_part, &cfg); break; } else if (mpam_has_feature(mpam_feat_mbw_max, cprops)) { + if (check_narrow_config_limit(closid, cprops)) + return -EINVAL; + cfg.mbw_max = percent_to_mbw_max(cfg_val, cprops->bwa_wd); mpam_set_feature(mpam_feat_mbw_max, &cfg); break; } return -EINVAL; case RDT_RESOURCE_MB_MIN: + if (check_narrow_config_limit(closid, cprops)) + return -EINVAL; + cfg.mbw_min = percent_to_mbw_max(cfg_val, cprops->bwa_wd); mpam_set_feature(mpam_feat_mbw_min, &cfg); break; -- 2.25.1
反馈: 您发送到kernel@openeuler.org的补丁/补丁集,已成功转换为PR! PR链接地址: https://atomgit.com/openeuler/kernel/merge_requests/20310 邮件列表地址:https://mailweb.openeuler.org/archives/list/kernel@openeuler.org/message/OHK... FeedBack: The patch(es) which you have sent to kernel@openeuler.org mailing list has been converted to a pull request successfully! Pull request link: https://atomgit.com/openeuler/kernel/merge_requests/20310 Mailing list address: https://mailweb.openeuler.org/archives/list/kernel@openeuler.org/message/OHK...
participants (2)
-
patchwork bot -
Zeng Heng