[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20241114135037.918470-4-zengheng4@huawei.com>
Date: Thu, 14 Nov 2024 21:50:34 +0800
From: Zeng Heng <zengheng4@...wei.com>
To: <james.morse@....com>, <Dave.Martin@....com>
CC: <bobo.shaobowang@...wei.com>, <linux-kernel@...r.kernel.org>,
<jonathan.cameron@...wei.com>, <linux-arm-kernel@...ts.infradead.org>
Subject: [RFC PATCH mpam mpam/snapshot/v6.11-rc1 3/6] arm_mpam: Create reqPARTIDs resource bitmap
The driver checks whether mpam_partid_max and mpam_intpartid_max are equal
as a basis for supporting reqPARTID. If this feature is supported, use a
bitmap to represent whether the target reqPARTID is available or not.
Create the bitmap during monitor initialization, and the destructor is
called during the monitor exit process.
It is noted that the reqpartid_free_map reserves the first reqPARTID under
each intPARTID (which is equal to the corresponding intPARTID itself). By
default, assigns it to the corresponding control group for use in
monitoring.
Signed-off-by: Zeng Heng <zengheng4@...wei.com>
---
drivers/platform/arm64/mpam/mpam_resctrl.c | 33 ++++++++++++++++++++++
1 file changed, 33 insertions(+)
diff --git a/drivers/platform/arm64/mpam/mpam_resctrl.c b/drivers/platform/arm64/mpam/mpam_resctrl.c
index a74133d7b402..01ad6732eac5 100644
--- a/drivers/platform/arm64/mpam/mpam_resctrl.c
+++ b/drivers/platform/arm64/mpam/mpam_resctrl.c
@@ -1000,6 +1000,33 @@ static void mpam_resctrl_monitor_init(struct mpam_class *class,
return;
}
+static unsigned long *reqpartid_free_map;
+static int reqpartid_free_map_len;
+
+static int reqpartid_create(void)
+{
+ u32 reqpartid_num = get_num_reqpartid();
+ int i;
+
+ reqpartid_free_map = bitmap_alloc(reqpartid_num, GFP_KERNEL);
+ if (!reqpartid_free_map)
+ return -ENOMEM;
+
+ bitmap_fill(reqpartid_free_map, reqpartid_num);
+
+ /* Reserved for the internal partIDs mapping */
+ for (i = 0; i < resctrl_arch_get_num_closid(NULL); i++)
+ __clear_bit(i, reqpartid_free_map);
+
+ reqpartid_free_map_len = reqpartid_num;
+ return 0;
+}
+
+static void reqpartid_destroy(void)
+{
+ bitmap_free(reqpartid_free_map);
+}
+
int mpam_resctrl_setup(void)
{
int err = 0;
@@ -1047,6 +1074,10 @@ int mpam_resctrl_setup(void)
cpus_read_unlock();
+ err = reqpartid_create();
+ if (err)
+ return err;
+
if (!err && !exposed_alloc_capable && !exposed_mon_capable)
err = -EOPNOTSUPP;
@@ -1075,6 +1106,8 @@ static void mpam_resctrl_exit(void)
WRITE_ONCE(resctrl_enabled, false);
resctrl_exit();
+
+ reqpartid_destroy();
}
--
2.25.1
Powered by blists - more mailing lists