Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

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>

authored by

James Morse and committed by
Catalin Marinas
c891bae6 880df85d

+37
+2
drivers/resctrl/mpam_devices.c
··· 305 305 class->level = level_idx; 306 306 class->type = type; 307 307 INIT_LIST_HEAD_RCU(&class->classes_list); 308 + ida_init(&class->ida_csu_mon); 309 + ida_init(&class->ida_mbwu_mon); 308 310 309 311 list_add_rcu(&class->classes_list, &mpam_classes); 310 312
+35
drivers/resctrl/mpam_internal.h
··· 200 200 /* member of mpam_classes */ 201 201 struct list_head classes_list; 202 202 203 + struct ida ida_csu_mon; 204 + struct ida ida_mbwu_mon; 205 + 203 206 struct mpam_garbage garbage; 204 207 }; 205 208 ··· 281 278 282 279 struct mpam_garbage garbage; 283 280 }; 281 + 282 + static inline int mpam_alloc_csu_mon(struct mpam_class *class) 283 + { 284 + struct mpam_props *cprops = &class->props; 285 + 286 + if (!mpam_has_feature(mpam_feat_msmon_csu, cprops)) 287 + return -EOPNOTSUPP; 288 + 289 + return ida_alloc_max(&class->ida_csu_mon, cprops->num_csu_mon - 1, 290 + GFP_KERNEL); 291 + } 292 + 293 + static inline void mpam_free_csu_mon(struct mpam_class *class, int csu_mon) 294 + { 295 + ida_free(&class->ida_csu_mon, csu_mon); 296 + } 297 + 298 + static inline int mpam_alloc_mbwu_mon(struct mpam_class *class) 299 + { 300 + struct mpam_props *cprops = &class->props; 301 + 302 + if (!mpam_has_feature(mpam_feat_msmon_mbwu, cprops)) 303 + return -EOPNOTSUPP; 304 + 305 + return ida_alloc_max(&class->ida_mbwu_mon, cprops->num_mbwu_mon - 1, 306 + GFP_KERNEL); 307 + } 308 + 309 + static inline void mpam_free_mbwu_mon(struct mpam_class *class, int mbwu_mon) 310 + { 311 + ida_free(&class->ida_mbwu_mon, mbwu_mon); 312 + } 284 313 285 314 /* List of all classes - protected by srcu*/ 286 315 extern struct srcu_struct mpam_srcu;