@@ -1005,6 +1005,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;
@@ -1052,6 +1079,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;
@@ -1080,6 +1111,8 @@ static void mpam_resctrl_exit(void)
WRITE_ONCE(resctrl_enabled, false);
resctrl_exit();
+
+ reqpartid_destroy();
}
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@huawei.com> --- drivers/platform/arm64/mpam/mpam_resctrl.c | 33 ++++++++++++++++++++++ 1 file changed, 33 insertions(+)