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: resctrl: Add resctrl_arch_rmid_read()

resctrl uses resctrl_arch_rmid_read() to read counters. CDP emulation means
the counter may need reading in three different ways.

The helpers behind the resctrl_arch_ functions will be re-used for the ABMC
equivalent functions.

Add the rounding helper for checking monitor values while we're here.

Tested-by: Gavin Shan <gshan@redhat.com>
Tested-by: Shaopeng Tan <tan.shaopeng@jp.fujitsu.com>
Tested-by: Peter Newman <peternewman@google.com>
Tested-by: Zeng Heng <zengheng4@huawei.com>
Tested-by: Jesse Chick <jessechick@os.amperecomputing.com>
Reviewed-by: Shaopeng Tan <tan.shaopeng@jp.fujitsu.com>
Reviewed-by: Jonathan Cameron <jonathan.cameron@huawei.com>
Reviewed-by: Gavin Shan <gshan@redhat.com>
Co-developed-by: Ben Horgan <ben.horgan@arm.com>
Signed-off-by: Ben Horgan <ben.horgan@arm.com>
Signed-off-by: James Morse <james.morse@arm.com>

+87
+82
drivers/resctrl/mpam_resctrl.c
··· 356 356 resctrl_arch_mon_ctx_free_no_wait(evtid, mon_idx); 357 357 } 358 358 359 + static int __read_mon(struct mpam_resctrl_mon *mon, struct mpam_component *mon_comp, 360 + enum mpam_device_features mon_type, 361 + int mon_idx, 362 + enum resctrl_conf_type cdp_type, u32 closid, u32 rmid, u64 *val) 363 + { 364 + struct mon_cfg cfg; 365 + 366 + if (!mpam_is_enabled()) 367 + return -EINVAL; 368 + 369 + /* Shift closid to account for CDP */ 370 + closid = resctrl_get_config_index(closid, cdp_type); 371 + 372 + if (irqs_disabled()) { 373 + /* Check if we can access this domain without an IPI */ 374 + return -EIO; 375 + } 376 + 377 + cfg = (struct mon_cfg) { 378 + .mon = mon_idx, 379 + .match_pmg = true, 380 + .partid = closid, 381 + .pmg = rmid, 382 + }; 383 + 384 + return mpam_msmon_read(mon_comp, &cfg, mon_type, val); 385 + } 386 + 387 + static int read_mon_cdp_safe(struct mpam_resctrl_mon *mon, struct mpam_component *mon_comp, 388 + enum mpam_device_features mon_type, 389 + int mon_idx, u32 closid, u32 rmid, u64 *val) 390 + { 391 + if (cdp_enabled) { 392 + u64 code_val = 0, data_val = 0; 393 + int err; 394 + 395 + err = __read_mon(mon, mon_comp, mon_type, mon_idx, 396 + CDP_CODE, closid, rmid, &code_val); 397 + if (err) 398 + return err; 399 + 400 + err = __read_mon(mon, mon_comp, mon_type, mon_idx, 401 + CDP_DATA, closid, rmid, &data_val); 402 + if (err) 403 + return err; 404 + 405 + *val += code_val + data_val; 406 + return 0; 407 + } 408 + 409 + return __read_mon(mon, mon_comp, mon_type, mon_idx, 410 + CDP_NONE, closid, rmid, val); 411 + } 412 + 413 + /* MBWU when not in ABMC mode (not supported), and CSU counters. */ 414 + int resctrl_arch_rmid_read(struct rdt_resource *r, struct rdt_domain_hdr *hdr, 415 + u32 closid, u32 rmid, enum resctrl_event_id eventid, 416 + void *arch_priv, u64 *val, void *arch_mon_ctx) 417 + { 418 + struct mpam_resctrl_dom *l3_dom; 419 + struct mpam_component *mon_comp; 420 + u32 mon_idx = *(u32 *)arch_mon_ctx; 421 + enum mpam_device_features mon_type; 422 + struct mpam_resctrl_mon *mon = &mpam_resctrl_counters[eventid]; 423 + 424 + resctrl_arch_rmid_read_context_check(); 425 + 426 + if (eventid >= QOS_NUM_EVENTS || !mon->class) 427 + return -EINVAL; 428 + 429 + l3_dom = container_of(hdr, struct mpam_resctrl_dom, resctrl_mon_dom.hdr); 430 + mon_comp = l3_dom->mon_comp[eventid]; 431 + 432 + if (eventid != QOS_L3_OCCUP_EVENT_ID) 433 + return -EINVAL; 434 + 435 + mon_type = mpam_feat_msmon_csu; 436 + 437 + return read_mon_cdp_safe(mon, mon_comp, mon_type, mon_idx, 438 + closid, rmid, val); 439 + } 440 + 359 441 static bool cache_has_usable_cpor(struct mpam_class *class) 360 442 { 361 443 struct mpam_props *cprops = &class->props;
+5
include/linux/arm_mpam.h
··· 67 67 void *resctrl_arch_mon_ctx_alloc(struct rdt_resource *r, enum resctrl_event_id evtid); 68 68 void resctrl_arch_mon_ctx_free(struct rdt_resource *r, enum resctrl_event_id evtid, void *ctx); 69 69 70 + static inline unsigned int resctrl_arch_round_mon_val(unsigned int val) 71 + { 72 + return val; 73 + } 74 + 70 75 /** 71 76 * mpam_register_requestor() - Register a requestor with the MPAM driver 72 77 * @partid_max: The maximum PARTID value the requestor can generate.