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.

fs/resctrl: Make event details accessible to functions when reading events

Reading monitoring event data from MMIO requires more context than the event id
to be able to read the correct memory location. struct mon_evt is the appropriate
place for this event specific context.

Prepare for addition of extra fields to struct mon_evt by changing the calling
conventions to pass a pointer to the mon_evt structure instead of just the
event id.

Signed-off-by: Tony Luck <tony.luck@intel.com>
Signed-off-by: Borislav Petkov (AMD) <bp@alien8.de>
Reviewed-by: Reinette Chatre <reinette.chatre@intel.com>
Link: https://lore.kernel.org/20251217172121.12030-1-tony.luck@intel.com

authored by

Tony Luck and committed by
Borislav Petkov (AMD)
dd110880 9c214d10

+28 -28
+9 -9
fs/resctrl/ctrlmondata.c
··· 552 552 553 553 void mon_event_read(struct rmid_read *rr, struct rdt_resource *r, 554 554 struct rdt_domain_hdr *hdr, struct rdtgroup *rdtgrp, 555 - cpumask_t *cpumask, int evtid, int first) 555 + cpumask_t *cpumask, struct mon_evt *evt, int first) 556 556 { 557 557 int cpu; 558 558 ··· 563 563 * Setup the parameters to pass to mon_event_count() to read the data. 564 564 */ 565 565 rr->rgrp = rdtgrp; 566 - rr->evtid = evtid; 566 + rr->evt = evt; 567 567 rr->r = r; 568 568 rr->hdr = hdr; 569 569 rr->first = first; 570 570 if (resctrl_arch_mbm_cntr_assign_enabled(r) && 571 - resctrl_is_mbm_event(evtid)) { 571 + resctrl_is_mbm_event(evt->evtid)) { 572 572 rr->is_mbm_cntr = true; 573 573 } else { 574 - rr->arch_mon_ctx = resctrl_arch_mon_ctx_alloc(r, evtid); 574 + rr->arch_mon_ctx = resctrl_arch_mon_ctx_alloc(r, evt->evtid); 575 575 if (IS_ERR(rr->arch_mon_ctx)) { 576 576 rr->err = -EINVAL; 577 577 return; ··· 592 592 smp_call_on_cpu(cpu, smp_mon_event_count, rr, false); 593 593 594 594 if (rr->arch_mon_ctx) 595 - resctrl_arch_mon_ctx_free(r, evtid, rr->arch_mon_ctx); 595 + resctrl_arch_mon_ctx_free(r, evt->evtid, rr->arch_mon_ctx); 596 596 } 597 597 598 598 int rdtgroup_mondata_show(struct seq_file *m, void *arg) 599 599 { 600 600 struct kernfs_open_file *of = m->private; 601 601 enum resctrl_res_level resid; 602 - enum resctrl_event_id evtid; 603 602 struct rdt_l3_mon_domain *d; 604 603 struct rdt_domain_hdr *hdr; 605 604 struct rmid_read rr = {0}; ··· 606 607 int domid, cpu, ret = 0; 607 608 struct rdt_resource *r; 608 609 struct cacheinfo *ci; 610 + struct mon_evt *evt; 609 611 struct mon_data *md; 610 612 611 613 rdtgrp = rdtgroup_kn_lock_live(of->kn); ··· 623 623 624 624 resid = md->rid; 625 625 domid = md->domid; 626 - evtid = md->evtid; 626 + evt = md->evt; 627 627 r = resctrl_arch_get_resource(resid); 628 628 629 629 if (md->sum) { ··· 641 641 continue; 642 642 rr.ci = ci; 643 643 mon_event_read(&rr, r, NULL, rdtgrp, 644 - &ci->shared_cpu_map, evtid, false); 644 + &ci->shared_cpu_map, evt, false); 645 645 goto checkresult; 646 646 } 647 647 } ··· 657 657 ret = -ENOENT; 658 658 goto out; 659 659 } 660 - mon_event_read(&rr, r, hdr, rdtgrp, &hdr->cpu_mask, evtid, false); 660 + mon_event_read(&rr, r, hdr, rdtgrp, &hdr->cpu_mask, evt, false); 661 661 } 662 662 663 663 checkresult:
+5 -5
fs/resctrl/internal.h
··· 81 81 * struct mon_data - Monitoring details for each event file. 82 82 * @list: Member of the global @mon_data_kn_priv_list list. 83 83 * @rid: Resource id associated with the event file. 84 - * @evtid: Event id associated with the event file. 84 + * @evt: Event structure associated with the event file. 85 85 * @sum: Set when event must be summed across multiple 86 86 * domains. 87 87 * @domid: When @sum is zero this is the domain to which ··· 95 95 struct mon_data { 96 96 struct list_head list; 97 97 enum resctrl_res_level rid; 98 - enum resctrl_event_id evtid; 98 + struct mon_evt *evt; 99 99 int domid; 100 100 bool sum; 101 101 }; ··· 108 108 * @r: Resource describing the properties of the event being read. 109 109 * @hdr: Header of domain that the counter should be read from. If NULL then 110 110 * sum all domains in @r sharing L3 @ci.id 111 - * @evtid: Which monitor event to read. 111 + * @evt: Which monitor event to read. 112 112 * @first: Initialize MBM counter when true. 113 113 * @ci: Cacheinfo for L3. Only set when @hdr is NULL. Used when summing 114 114 * domains. ··· 126 126 struct rdtgroup *rgrp; 127 127 struct rdt_resource *r; 128 128 struct rdt_domain_hdr *hdr; 129 - enum resctrl_event_id evtid; 129 + struct mon_evt *evt; 130 130 bool first; 131 131 struct cacheinfo *ci; 132 132 bool is_mbm_cntr; ··· 367 367 368 368 void mon_event_read(struct rmid_read *rr, struct rdt_resource *r, 369 369 struct rdt_domain_hdr *hdr, struct rdtgroup *rdtgrp, 370 - cpumask_t *cpumask, int evtid, int first); 370 + cpumask_t *cpumask, struct mon_evt *evt, int first); 371 371 372 372 void mbm_setup_overflow_handler(struct rdt_l3_mon_domain *dom, 373 373 unsigned long delay_ms,
+11 -11
fs/resctrl/monitor.c
··· 430 430 d = container_of(rr->hdr, struct rdt_l3_mon_domain, hdr); 431 431 432 432 if (rr->is_mbm_cntr) { 433 - cntr_id = mbm_cntr_get(rr->r, d, rdtgrp, rr->evtid); 433 + cntr_id = mbm_cntr_get(rr->r, d, rdtgrp, rr->evt->evtid); 434 434 if (cntr_id < 0) { 435 435 rr->err = -ENOENT; 436 436 return -EINVAL; ··· 439 439 440 440 if (rr->first) { 441 441 if (rr->is_mbm_cntr) 442 - resctrl_arch_reset_cntr(rr->r, d, closid, rmid, cntr_id, rr->evtid); 442 + resctrl_arch_reset_cntr(rr->r, d, closid, rmid, cntr_id, rr->evt->evtid); 443 443 else 444 - resctrl_arch_reset_rmid(rr->r, d, closid, rmid, rr->evtid); 445 - m = get_mbm_state(d, closid, rmid, rr->evtid); 444 + resctrl_arch_reset_rmid(rr->r, d, closid, rmid, rr->evt->evtid); 445 + m = get_mbm_state(d, closid, rmid, rr->evt->evtid); 446 446 if (m) 447 447 memset(m, 0, sizeof(struct mbm_state)); 448 448 return 0; ··· 453 453 return -EINVAL; 454 454 if (rr->is_mbm_cntr) 455 455 rr->err = resctrl_arch_cntr_read(rr->r, d, closid, rmid, cntr_id, 456 - rr->evtid, &tval); 456 + rr->evt->evtid, &tval); 457 457 else 458 458 rr->err = resctrl_arch_rmid_read(rr->r, rr->hdr, closid, rmid, 459 - rr->evtid, &tval, rr->arch_mon_ctx); 459 + rr->evt->evtid, &tval, rr->arch_mon_ctx); 460 460 if (rr->err) 461 461 return rr->err; 462 462 ··· 501 501 if (d->ci_id != rr->ci->id) 502 502 continue; 503 503 err = resctrl_arch_rmid_read(rr->r, &d->hdr, closid, rmid, 504 - rr->evtid, &tval, rr->arch_mon_ctx); 504 + rr->evt->evtid, &tval, rr->arch_mon_ctx); 505 505 if (!err) { 506 506 rr->val += tval; 507 507 ret = 0; ··· 551 551 if (!domain_header_is_valid(rr->hdr, RESCTRL_MON_DOMAIN, RDT_RESOURCE_L3)) 552 552 return; 553 553 d = container_of(rr->hdr, struct rdt_l3_mon_domain, hdr); 554 - m = get_mbm_state(d, closid, rmid, rr->evtid); 554 + m = get_mbm_state(d, closid, rmid, rr->evt->evtid); 555 555 if (WARN_ON_ONCE(!m)) 556 556 return; 557 557 ··· 725 725 726 726 rr.r = r; 727 727 rr.hdr = &d->hdr; 728 - rr.evtid = evtid; 728 + rr.evt = &mon_event_all[evtid]; 729 729 if (resctrl_arch_mbm_cntr_assign_enabled(r)) { 730 730 rr.is_mbm_cntr = true; 731 731 } else { 732 - rr.arch_mon_ctx = resctrl_arch_mon_ctx_alloc(rr.r, rr.evtid); 732 + rr.arch_mon_ctx = resctrl_arch_mon_ctx_alloc(rr.r, evtid); 733 733 if (IS_ERR(rr.arch_mon_ctx)) { 734 734 pr_warn_ratelimited("Failed to allocate monitor context: %ld", 735 735 PTR_ERR(rr.arch_mon_ctx)); ··· 747 747 mbm_bw_count(rdtgrp, &rr); 748 748 749 749 if (rr.arch_mon_ctx) 750 - resctrl_arch_mon_ctx_free(rr.r, rr.evtid, rr.arch_mon_ctx); 750 + resctrl_arch_mon_ctx_free(rr.r, evtid, rr.arch_mon_ctx); 751 751 } 752 752 753 753 static void mbm_update(struct rdt_resource *r, struct rdt_l3_mon_domain *d,
+3 -3
fs/resctrl/rdtgroup.c
··· 3103 3103 3104 3104 list_for_each_entry(priv, &mon_data_kn_priv_list, list) { 3105 3105 if (priv->rid == rid && priv->domid == domid && 3106 - priv->sum == do_sum && priv->evtid == mevt->evtid) 3106 + priv->sum == do_sum && priv->evt == mevt) 3107 3107 return priv; 3108 3108 } 3109 3109 ··· 3114 3114 priv->rid = rid; 3115 3115 priv->domid = domid; 3116 3116 priv->sum = do_sum; 3117 - priv->evtid = mevt->evtid; 3117 + priv->evt = mevt; 3118 3118 list_add_tail(&priv->list, &mon_data_kn_priv_list); 3119 3119 3120 3120 return priv; ··· 3281 3281 return ret; 3282 3282 3283 3283 if (!do_sum && resctrl_is_mbm_event(mevt->evtid)) 3284 - mon_event_read(&rr, r, hdr, prgrp, &hdr->cpu_mask, mevt->evtid, true); 3284 + mon_event_read(&rr, r, hdr, prgrp, &hdr->cpu_mask, mevt, true); 3285 3285 } 3286 3286 3287 3287 return 0;