From: Dave Martin <Dave.Martin@arm.com>
To: linux-kernel@vger.kernel.org
Cc: linux-arm-kernel@lists.infradead.org,
Zeng Heng <zengheng4@huawei.com>,
Shaopeng Tan <tan.shaopeng@fujitsu.com>,
James Morse <james.morse@arm.com>
Subject: [RFC PATCH v2 11/11] arm_mpam: Detect whether the system can alias PARTIDs
Date: Fri, 17 Jan 2025 15:10:21 +0000 [thread overview]
Message-ID: <20250117151033.1517882-12-Dave.Martin@arm.com> (raw)
In-Reply-To: <20250117151033.1517882-1-Dave.Martin@arm.com>
In order to be able to assign multiple PARTIDs freely to resource
control groups, it is necessary that all MSCs that are used by resctrl
either implement PARTID Narrowing (so that PARTIDs can be remapped
explicitly) or otherwise only have controls whose resource regulation
is stateless and so whose behaviour would not be affected by splitting
a control group across multiple PARTIDs.
Detect this property at the RIS level and merge it up the MPAM devices
tree.
Export the common global result as mpam_partid_aliasing, and apply
it to the PARTIDs-per-CLOSID configuration.
Signed-off-by: Dave Martin <Dave.Martin@arm.com>
---
Currently, this the logic is simple and may forbid PARTID aliasing
on some systems that can support it as a result of the precise set
of MSCs and controls that are exposed through resctrl.
The aim is to make this logic more flexible later.
---
drivers/platform/arm64/mpam/mpam_devices.c | 48 ++++++++++++++++++---
drivers/platform/arm64/mpam/mpam_internal.h | 2 +
drivers/platform/arm64/mpam/mpam_resctrl.c | 12 +++++-
3 files changed, 53 insertions(+), 9 deletions(-)
diff --git a/drivers/platform/arm64/mpam/mpam_devices.c b/drivers/platform/arm64/mpam/mpam_devices.c
index 4b43dfef1cdc..0182c922638f 100644
--- a/drivers/platform/arm64/mpam/mpam_devices.c
+++ b/drivers/platform/arm64/mpam/mpam_devices.c
@@ -68,6 +68,7 @@ static DEFINE_MUTEX(mpam_cpuhp_state_lock);
*/
u16 mpam_partid_max;
u8 mpam_pmg_max;
+bool mpam_partid_aliasing; /* PARTID aliasing supported */
static bool partid_max_init, partid_max_published;
static DEFINE_SPINLOCK(partid_max_lock);
@@ -828,6 +829,7 @@ static void mpam_ris_hw_probe(struct mpam_msc_ris *ris)
struct mpam_msc *msc = ris->vmsc->msc;
struct mpam_props *props = &ris->props;
struct mpam_class *class = ris->vmsc->comp->class;
+ bool partid_can_alias = true;
lockdep_assert_held(&msc->probe_lock);
lockdep_assert_held(&msc->part_sel_lock);
@@ -836,6 +838,8 @@ static void mpam_ris_hw_probe(struct mpam_msc_ris *ris)
/* Cache Capacity Partitioning */
if (FIELD_GET(MPAMF_IDR_HAS_CCAP_PART, ris->idr)) {
+ partid_can_alias = false;
+
ris->ccap_idr = mpam_read_partsel_reg(msc, CCAP_IDR);
props->cmax_wd = FIELD_GET(MPAMF_CCAP_IDR_CMAX_WD, ris->ccap_idr);
@@ -884,14 +888,20 @@ static void mpam_ris_hw_probe(struct mpam_msc_ris *ris)
*/
props->bwa_wd = min(props->bwa_wd, 16);
- if (props->bwa_wd && FIELD_GET(MPAMF_MBW_IDR_HAS_MAX, mbw_features))
+ if (props->bwa_wd && FIELD_GET(MPAMF_MBW_IDR_HAS_MAX, mbw_features)) {
mpam_set_feature(mpam_feat_mbw_max, props);
+ partid_can_alias = false;
+ }
- if (props->bwa_wd && FIELD_GET(MPAMF_MBW_IDR_HAS_MIN, mbw_features))
+ if (props->bwa_wd && FIELD_GET(MPAMF_MBW_IDR_HAS_MIN, mbw_features)) {
mpam_set_feature(mpam_feat_mbw_min, props);
+ partid_can_alias = false;
+ }
- if (props->bwa_wd && FIELD_GET(MPAMF_MBW_IDR_HAS_PROP, mbw_features))
+ if (props->bwa_wd && FIELD_GET(MPAMF_MBW_IDR_HAS_PROP, mbw_features)) {
mpam_set_feature(mpam_feat_mbw_prop, props);
+ partid_can_alias = false;
+ }
}
/* Priority partitioning */
@@ -988,17 +998,26 @@ static void mpam_ris_hw_probe(struct mpam_msc_ris *ris)
* RIS with PARTID narrowing don't have enough storage for one
* configuration per PARTID. If these are in a class we could use,
* reduce the supported partid_max to match the numer of intpartid.
- * If the class is unknown, just ignore it.
+ * If the MSC won't be used for anything or implements PARTID
+ * Narrowing then PARTIDs can be assigned freely, so PARTID
+ * aliasing can be supported regardless of the resource
+ * controls present.
*/
- if (FIELD_GET(MPAMF_IDR_HAS_PARTID_NRW, ris->idr) &&
- class->type != MPAM_CLASS_UNKNOWN) {
+ if (class->type == MPAM_CLASS_UNKNOWN)
+ partid_can_alias = true;
+ else if (FIELD_GET(MPAMF_IDR_HAS_PARTID_NRW, ris->idr)) {
u32 nrwidr = mpam_read_partsel_reg(msc, PARTID_NRW_IDR);
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);
+
+ partid_can_alias = true;
}
+ if (partid_can_alias)
+ mpam_set_feature(mpam_feat_partid_aliasing, props);
+
mpam_mon_sel_outer_unlock(msc);
}
@@ -2368,6 +2387,10 @@ static void __props_mismatch(struct mpam_props *parent,
mpam_clear_feature(mpam_feat_dspri_part_0_low, &parent->features);
}
+ /* PARTID aliasing must be supported everywhere, or not at all: */
+ if (!mpam_has_feature(mpam_feat_partid_aliasing, parent))
+ mpam_clear_feature(mpam_feat_partid_aliasing, &parent->features);
+
if (alias) {
/* Merge features for aliased resources */
parent->features |= child->features;
@@ -2486,6 +2509,7 @@ static void mpam_enable_merge_features(struct list_head *all_classes_list)
{
struct mpam_class *class;
struct mpam_component *comp;
+ bool partid_can_alias = true, comp_partid_aliasing;
lockdep_assert_held(&mpam_list_lock);
@@ -2495,9 +2519,19 @@ static void mpam_enable_merge_features(struct list_head *all_classes_list)
mpam_enable_init_class_features(class);
- list_for_each_entry(comp, &class->components, class_list)
+ list_for_each_entry(comp, &class->components, class_list) {
mpam_enable_merge_class_features(comp);
+
+ comp_partid_aliasing = mpam_has_feature(
+ mpam_feat_partid_aliasing, &class->props);
+ partid_can_alias = partid_can_alias &&
+ comp_partid_aliasing;
+ }
}
+
+ spin_lock(&partid_max_lock);
+ mpam_partid_aliasing = partid_can_alias;
+ spin_unlock(&partid_max_lock);
}
static char *mpam_errcode_names[16] = {
diff --git a/drivers/platform/arm64/mpam/mpam_internal.h b/drivers/platform/arm64/mpam/mpam_internal.h
index 965f4fea3012..6e10e4789506 100644
--- a/drivers/platform/arm64/mpam/mpam_internal.h
+++ b/drivers/platform/arm64/mpam/mpam_internal.h
@@ -215,6 +215,7 @@ enum mpam_device_features {
mpam_feat_msmon_mbwu_hw_nrdy,
mpam_feat_msmon_capt,
mpam_feat_partid_nrw,
+ mpam_feat_partid_aliasing, /* derived feature */
MPAM_FEATURE_LAST,
};
#define MPAM_ALL_FEATURES ((1<<MPAM_FEATURE_LAST) - 1)
@@ -474,6 +475,7 @@ static inline void mpam_assert_srcu_read_lock_held(void)
/* System wide partid/pmg values */
extern u16 mpam_partid_max;
extern u8 mpam_pmg_max;
+extern bool mpam_partid_aliasing;
/* Scheduled work callback to enable mpam once all MSC have been probed */
void mpam_enable(struct work_struct *work);
diff --git a/drivers/platform/arm64/mpam/mpam_resctrl.c b/drivers/platform/arm64/mpam/mpam_resctrl.c
index 1f31b1455f66..5b296e3e27c2 100644
--- a/drivers/platform/arm64/mpam/mpam_resctrl.c
+++ b/drivers/platform/arm64/mpam/mpam_resctrl.c
@@ -160,7 +160,8 @@ static bool mpam_resctrl_hide_cdp(enum resctrl_res_level rid)
return cdp_enabled && !resctrl_arch_get_cdp_enabled(rid);
}
-static unsigned int partid_per_closid = 1;
+static unsigned int bootparam_partid_per_closid = 1;
+static unsigned int partid_per_closid;
static int mpam_resctrl_partid_per_closid_set(const char *val,
const struct kernel_param *kp)
@@ -178,7 +179,7 @@ static const struct kernel_param_ops mpam_resctrl_partid_per_closid_ops = {
};
device_param_cb(partid_per_closid, &mpam_resctrl_partid_per_closid_ops,
- &partid_per_closid, 0444);
+ &bootparam_partid_per_closid, 0444);
static unsigned int mpam_num_pmg(void)
{
@@ -1113,6 +1114,13 @@ int mpam_resctrl_setup(void)
if (!err && !exposed_alloc_capable && !exposed_mon_capable)
err = -EOPNOTSUPP;
+ partid_per_closid = bootparam_partid_per_closid;
+ if ((!mpam_partid_aliasing && bootparam_partid_per_closid > 1) ||
+ resctrl_arch_get_num_closid(NULL) < 1) {
+ pr_warn("Hardware incompatible with PARTID aliasing, limiting monitoring groups\n");
+ partid_per_closid = 1;
+ }
+
if (!err) {
err = resctrl_init();
if (!err)
--
2.34.1
next prev parent reply other threads:[~2025-01-17 15:11 UTC|newest]
Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-01-17 15:10 [RFC PATCH v2 00/11] Introduce PARTID grouping support Dave Martin
2025-01-17 15:10 ` [RFC PATCH v2 01/11] arm_mpam: Fix read-back of cloned resource controls under CDP emulation Dave Martin
2025-01-17 15:10 ` [RFC PATCH v2 02/11] arm_mpam: Delete unused function resctrl_arch_set_rmid() Dave Martin
2025-01-17 15:10 ` [RFC PATCH v2 03/11] arm_mpam: Set INTERNAL as needed when setting MSC controls Dave Martin
2025-01-17 15:10 ` [RFC PATCH v2 04/11] fs/resctrl: Add arch hook to set up the default CLOSID Dave Martin
2025-01-17 15:10 ` [RFC PATCH v2 05/11] arm_mpam: resctrl: Implement " Dave Martin
2025-01-17 15:10 ` [RFC PATCH v2 06/11] arm_mpam: Introduce flexible CLOSID/RMID translation Dave Martin
2025-01-29 10:40 ` Shaopeng Tan (Fujitsu)
2025-01-17 15:10 ` [RFC PATCH v2 07/11] arm_mpam: [NFU] Rework ID remapping to use a kernel command-line argument Dave Martin
2025-01-17 15:10 ` [RFC PATCH v2 08/11] arm_mpam: [NFU] Development diagnostics for MPAM ID assignments Dave Martin
2025-01-17 15:10 ` [RFC PATCH v2 09/11] arm_mpam: Add control partition identifier to mpam_config Dave Martin
2025-01-17 15:10 ` [RFC PATCH v2 10/11] arm_mpam: Skip inapplicable cases when reprogramming a resctrl domain Dave Martin
2025-01-17 15:10 ` Dave Martin [this message]
2025-01-17 15:10 ` [RFC PATCH v2 00/11] Introduce PARTID grouping support Dave Martin
2025-01-17 15:10 ` [RFC PATCH v2 01/11] arm_mpam: Fix read-back of cloned resource controls under CDP emulation Dave Martin
2025-01-17 15:10 ` [RFC PATCH v2 02/11] arm_mpam: Delete unused function resctrl_arch_set_rmid() Dave Martin
2025-01-17 15:10 ` [RFC PATCH v2 03/11] arm_mpam: Set INTERNAL as needed when setting MSC controls Dave Martin
2025-01-17 15:10 ` [RFC PATCH v2 04/11] fs/resctrl: Add arch hook to set up the default CLOSID Dave Martin
2025-01-17 15:10 ` [RFC PATCH v2 05/11] arm_mpam: resctrl: Implement " Dave Martin
2025-01-17 15:10 ` [RFC PATCH v2 06/11] arm_mpam: Introduce flexible CLOSID/RMID translation Dave Martin
2025-01-17 15:10 ` [RFC PATCH v2 07/11] arm_mpam: [NFU] Rework ID remapping to use a kernel command-line argument Dave Martin
2025-01-29 10:57 ` Shaopeng Tan (Fujitsu)
2025-01-17 15:10 ` [RFC PATCH v2 08/11] arm_mpam: [NFU] Development diagnostics for MPAM ID assignments Dave Martin
2025-01-17 15:10 ` [RFC PATCH v2 09/11] arm_mpam: Add control partition identifier to mpam_config Dave Martin
2025-01-17 15:10 ` [RFC PATCH v2 10/11] arm_mpam: Skip inapplicable cases when reprogramming a resctrl domain Dave Martin
2025-01-17 15:10 ` [RFC PATCH v2 11/11] arm_mpam: Detect whether the system can alias PARTIDs Dave Martin
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20250117151033.1517882-12-Dave.Martin@arm.com \
--to=dave.martin@arm.com \
--cc=james.morse@arm.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=tan.shaopeng@fujitsu.com \
--cc=zengheng4@huawei.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®