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.

x86,fs/resctrl: Implement resctrl_arch_config_cntr() to assign a counter with ABMC

The ABMC feature allows users to assign a hardware counter to an RMID,
event pair and monitor bandwidth usage as long as it is assigned. The
hardware continues to track the assigned counter until it is explicitly
unassigned by the user.

Implement an x86 architecture-specific handler to configure a counter. This
architecture specific handler is called by resctrl fs when a counter is
assigned or unassigned as well as when an already assigned counter's
configuration should be updated. Configure counters by writing to the
L3_QOS_ABMC_CFG MSR, specifying the counter ID, bandwidth source (RMID),
and event configuration.

The ABMC feature details are documented in APM [1] available from [2].
[1] AMD64 Architecture Programmer's Manual Volume 2: System Programming
Publication # 24593 Revision 3.41 section 19.3.3.3 Assignable Bandwidth
Monitoring (ABMC).

Signed-off-by: Babu Moger <babu.moger@amd.com>
Signed-off-by: Borislav Petkov (AMD) <bp@alien8.de>
Reviewed-by: Reinette Chatre <reinette.chatre@intel.com>
Link: https://lore.kernel.org/cover.1757108044.git.babu.moger@amd.com
Link: https://bugzilla.kernel.org/show_bug.cgi?id=206537 # [2]

authored by

Babu Moger and committed by
Borislav Petkov (AMD)
f7a4fb22 ebebda85

+55
+36
arch/x86/kernel/cpu/resctrl/monitor.c
··· 444 444 { 445 445 return resctrl_to_arch_res(r)->mbm_cntr_assign_enabled; 446 446 } 447 + 448 + static void resctrl_abmc_config_one_amd(void *info) 449 + { 450 + union l3_qos_abmc_cfg *abmc_cfg = info; 451 + 452 + wrmsrl(MSR_IA32_L3_QOS_ABMC_CFG, abmc_cfg->full); 453 + } 454 + 455 + /* 456 + * Send an IPI to the domain to assign the counter to RMID, event pair. 457 + */ 458 + void resctrl_arch_config_cntr(struct rdt_resource *r, struct rdt_mon_domain *d, 459 + enum resctrl_event_id evtid, u32 rmid, u32 closid, 460 + u32 cntr_id, bool assign) 461 + { 462 + struct rdt_hw_mon_domain *hw_dom = resctrl_to_arch_mon_dom(d); 463 + union l3_qos_abmc_cfg abmc_cfg = { 0 }; 464 + struct arch_mbm_state *am; 465 + 466 + abmc_cfg.split.cfg_en = 1; 467 + abmc_cfg.split.cntr_en = assign ? 1 : 0; 468 + abmc_cfg.split.cntr_id = cntr_id; 469 + abmc_cfg.split.bw_src = rmid; 470 + if (assign) 471 + abmc_cfg.split.bw_type = resctrl_get_mon_evt_cfg(evtid); 472 + 473 + smp_call_function_any(&d->hdr.cpu_mask, resctrl_abmc_config_one_amd, &abmc_cfg, 1); 474 + 475 + /* 476 + * The hardware counter is reset (because cfg_en == 1) so there is no 477 + * need to record initial non-zero counts. 478 + */ 479 + am = get_arch_mbm_state(hw_dom, rmid, evtid); 480 + if (am) 481 + memset(am, 0, sizeof(*am)); 482 + }
+19
include/linux/resctrl.h
··· 594 594 */ 595 595 void resctrl_arch_reset_all_ctrls(struct rdt_resource *r); 596 596 597 + /** 598 + * resctrl_arch_config_cntr() - Configure the counter with its new RMID 599 + * and event details. 600 + * @r: Resource structure. 601 + * @d: The domain in which counter with ID @cntr_id should be configured. 602 + * @evtid: Monitoring event type (e.g., QOS_L3_MBM_TOTAL_EVENT_ID 603 + * or QOS_L3_MBM_LOCAL_EVENT_ID). 604 + * @rmid: RMID. 605 + * @closid: CLOSID. 606 + * @cntr_id: Counter ID to configure. 607 + * @assign: True to assign the counter or update an existing assignment, 608 + * false to unassign the counter. 609 + * 610 + * This can be called from any CPU. 611 + */ 612 + void resctrl_arch_config_cntr(struct rdt_resource *r, struct rdt_mon_domain *d, 613 + enum resctrl_event_id evtid, u32 rmid, u32 closid, 614 + u32 cntr_id, bool assign); 615 + 597 616 extern unsigned int resctrl_rmid_realloc_threshold; 598 617 extern unsigned int resctrl_rmid_realloc_limit; 599 618