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/resctrl: Move L3 initialization into new helper function

Carve out the resource monitoring domain init code into a separate helper in
order to be able to initialize new types of monitoring domains besides the
usual L3 ones.

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)
0d644762 03eb578b

+34 -30
+34 -30
arch/x86/kernel/cpu/resctrl/core.c
··· 501 501 } 502 502 } 503 503 504 - static void domain_add_cpu_mon(int cpu, struct rdt_resource *r) 504 + static void l3_mon_domain_setup(int cpu, int id, struct rdt_resource *r, struct list_head *add_pos) 505 505 { 506 - int id = get_domain_id_from_scope(cpu, r->mon_scope); 507 - struct list_head *add_pos = NULL; 508 506 struct rdt_hw_mon_domain *hw_dom; 509 - struct rdt_domain_hdr *hdr; 510 507 struct rdt_mon_domain *d; 511 508 struct cacheinfo *ci; 512 509 int err; 513 - 514 - lockdep_assert_held(&domain_list_lock); 515 - 516 - if (id < 0) { 517 - pr_warn_once("Can't find monitor domain id for CPU:%d scope:%d for resource %s\n", 518 - cpu, r->mon_scope, r->name); 519 - return; 520 - } 521 - 522 - hdr = resctrl_find_domain(&r->mon_domains, id, &add_pos); 523 - if (hdr) { 524 - if (!domain_header_is_valid(hdr, RESCTRL_MON_DOMAIN, r->rid)) 525 - return; 526 - d = container_of(hdr, struct rdt_mon_domain, hdr); 527 - 528 - cpumask_set_cpu(cpu, &d->hdr.cpu_mask); 529 - /* Update the mbm_assign_mode state for the CPU if supported */ 530 - if (r->mon.mbm_cntr_assignable) 531 - resctrl_arch_mbm_cntr_assign_set_one(r); 532 - return; 533 - } 534 510 535 511 hw_dom = kzalloc_node(sizeof(*hw_dom), GFP_KERNEL, cpu_to_node(cpu)); 536 512 if (!hw_dom) ··· 515 539 d = &hw_dom->d_resctrl; 516 540 d->hdr.id = id; 517 541 d->hdr.type = RESCTRL_MON_DOMAIN; 518 - d->hdr.rid = r->rid; 542 + d->hdr.rid = RDT_RESOURCE_L3; 519 543 ci = get_cpu_cacheinfo_level(cpu, RESCTRL_L3_CACHE); 520 544 if (!ci) { 521 545 pr_warn_once("Can't find L3 cache for CPU:%d resource %s\n", cpu, r->name); ··· 524 548 } 525 549 d->ci_id = ci->id; 526 550 cpumask_set_cpu(cpu, &d->hdr.cpu_mask); 527 - 528 - /* Update the mbm_assign_mode state for the CPU if supported */ 529 - if (r->mon.mbm_cntr_assignable) 530 - resctrl_arch_mbm_cntr_assign_set_one(r); 531 551 532 552 arch_mon_domain_online(r, d); 533 553 ··· 539 567 list_del_rcu(&d->hdr.list); 540 568 synchronize_rcu(); 541 569 mon_domain_free(hw_dom); 570 + } 571 + } 572 + 573 + static void domain_add_cpu_mon(int cpu, struct rdt_resource *r) 574 + { 575 + int id = get_domain_id_from_scope(cpu, r->mon_scope); 576 + struct list_head *add_pos = NULL; 577 + struct rdt_domain_hdr *hdr; 578 + 579 + lockdep_assert_held(&domain_list_lock); 580 + 581 + if (id < 0) { 582 + pr_warn_once("Can't find monitor domain id for CPU:%d scope:%d for resource %s\n", 583 + cpu, r->mon_scope, r->name); 584 + return; 585 + } 586 + 587 + hdr = resctrl_find_domain(&r->mon_domains, id, &add_pos); 588 + if (hdr) 589 + cpumask_set_cpu(cpu, &hdr->cpu_mask); 590 + 591 + switch (r->rid) { 592 + case RDT_RESOURCE_L3: 593 + /* Update the mbm_assign_mode state for the CPU if supported */ 594 + if (r->mon.mbm_cntr_assignable) 595 + resctrl_arch_mbm_cntr_assign_set_one(r); 596 + if (!hdr) 597 + l3_mon_domain_setup(cpu, id, r, add_pos); 598 + break; 599 + default: 600 + pr_warn_once("Unknown resource rid=%d\n", r->rid); 601 + break; 542 602 } 543 603 } 544 604