Skip to content

Commit c891bae

Browse files
James Morsectmarinas
authored andcommitted
arm_mpam: Add helpers to allocate monitors
MPAM's MSC support a number of monitors, each of which supports bandwidth counters, or cache-storage-utilisation counters. To use a counter, a monitor needs to be configured. Add helpers to allocate and free CSU or MBWU monitors. Signed-off-by: James Morse <james.morse@arm.com> Reviewed-by: Ben Horgan <ben.horgan@arm.com> Reviewed-by: Jonathan Cameron <jonathan.cameron@huawei.com> Reviewed-by: Gavin Shan <gshan@redhat.com> Reviewed-by: Shaopeng Tan <tan.shaopeng@jp.fujitsu.com> Reviewed-by: Fenghua Yu <fenghuay@nvidia.com> Tested-by: Fenghua Yu <fenghuay@nvidia.com> Tested-by: Shaopeng Tan <tan.shaopeng@jp.fujitsu.com> Tested-by: Peter Newman <peternewman@google.com> Tested-by: Carl Worth <carl@os.amperecomputing.com> Tested-by: Gavin Shan <gshan@redhat.com> Tested-by: Zeng Heng <zengheng4@huawei.com> Tested-by: Hanjun Guo <guohanjun@huawei.com> Signed-off-by: Ben Horgan <ben.horgan@arm.com> Signed-off-by: Catalin Marinas <catalin.marinas@arm.com>
1 parent 880df85 commit c891bae

2 files changed

Lines changed: 37 additions & 0 deletions

File tree

drivers/resctrl/mpam_devices.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -305,6 +305,8 @@ mpam_class_alloc(u8 level_idx, enum mpam_class_types type)
305305
class->level = level_idx;
306306
class->type = type;
307307
INIT_LIST_HEAD_RCU(&class->classes_list);
308+
ida_init(&class->ida_csu_mon);
309+
ida_init(&class->ida_mbwu_mon);
308310

309311
list_add_rcu(&class->classes_list, &mpam_classes);
310312

drivers/resctrl/mpam_internal.h

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -200,6 +200,9 @@ struct mpam_class {
200200
/* member of mpam_classes */
201201
struct list_head classes_list;
202202

203+
struct ida ida_csu_mon;
204+
struct ida ida_mbwu_mon;
205+
203206
struct mpam_garbage garbage;
204207
};
205208

@@ -279,6 +282,38 @@ struct mpam_msc_ris {
279282
struct mpam_garbage garbage;
280283
};
281284

285+
static inline int mpam_alloc_csu_mon(struct mpam_class *class)
286+
{
287+
struct mpam_props *cprops = &class->props;
288+
289+
if (!mpam_has_feature(mpam_feat_msmon_csu, cprops))
290+
return -EOPNOTSUPP;
291+
292+
return ida_alloc_max(&class->ida_csu_mon, cprops->num_csu_mon - 1,
293+
GFP_KERNEL);
294+
}
295+
296+
static inline void mpam_free_csu_mon(struct mpam_class *class, int csu_mon)
297+
{
298+
ida_free(&class->ida_csu_mon, csu_mon);
299+
}
300+
301+
static inline int mpam_alloc_mbwu_mon(struct mpam_class *class)
302+
{
303+
struct mpam_props *cprops = &class->props;
304+
305+
if (!mpam_has_feature(mpam_feat_msmon_mbwu, cprops))
306+
return -EOPNOTSUPP;
307+
308+
return ida_alloc_max(&class->ida_mbwu_mon, cprops->num_mbwu_mon - 1,
309+
GFP_KERNEL);
310+
}
311+
312+
static inline void mpam_free_mbwu_mon(struct mpam_class *class, int mbwu_mon)
313+
{
314+
ida_free(&class->ida_mbwu_mon, mbwu_mon);
315+
}
316+
282317
/* List of all classes - protected by srcu*/
283318
extern struct srcu_struct mpam_srcu;
284319
extern struct list_head mpam_classes;

0 commit comments

Comments
 (0)