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: Handle domain creation/deletion for RDT_RESOURCE_PERF_PKG

The L3 resource has several requirements for domains. There are per-domain
structures that hold the 64-bit values of counters, and elements to keep
track of the overflow and limbo threads.

None of these are needed for the PERF_PKG resource. The hardware counters
are wide enough that they do not wrap around for decades.

Define a new rdt_perf_pkg_mon_domain structure which just consists of the
standard rdt_domain_hdr to keep track of domain id and CPU mask.

Update resctrl_online_mon_domain() for RDT_RESOURCE_PERF_PKG. The only action
needed for this resource is to create and populate domain directories if a
domain is added while resctrl is mounted.

Similarly resctrl_offline_mon_domain() only needs to remove domain directories.

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)
f4e0cd80 93d9fd89

+71 -5
+17
arch/x86/kernel/cpu/resctrl/core.c
··· 580 580 if (!hdr) 581 581 l3_mon_domain_setup(cpu, id, r, add_pos); 582 582 break; 583 + case RDT_RESOURCE_PERF_PKG: 584 + if (!hdr) 585 + intel_aet_mon_domain_setup(cpu, id, r, add_pos); 586 + break; 583 587 default: 584 588 pr_warn_once("Unknown resource rid=%d\n", r->rid); 585 589 break; ··· 681 677 list_del_rcu(&hdr->list); 682 678 synchronize_rcu(); 683 679 l3_mon_domain_free(hw_dom); 680 + break; 681 + } 682 + case RDT_RESOURCE_PERF_PKG: { 683 + struct rdt_perf_pkg_mon_domain *pkgd; 684 + 685 + if (!domain_header_is_valid(hdr, RESCTRL_MON_DOMAIN, RDT_RESOURCE_PERF_PKG)) 686 + return; 687 + 688 + pkgd = container_of(hdr, struct rdt_perf_pkg_mon_domain, hdr); 689 + resctrl_offline_mon_domain(r, hdr); 690 + list_del_rcu(&hdr->list); 691 + synchronize_rcu(); 692 + kfree(pkgd); 684 693 break; 685 694 } 686 695 default:
+29
arch/x86/kernel/cpu/resctrl/intel_aet.c
··· 14 14 #include <linux/bits.h> 15 15 #include <linux/compiler_types.h> 16 16 #include <linux/container_of.h> 17 + #include <linux/cpumask.h> 17 18 #include <linux/err.h> 18 19 #include <linux/errno.h> 20 + #include <linux/gfp_types.h> 19 21 #include <linux/init.h> 20 22 #include <linux/intel_pmt_features.h> 21 23 #include <linux/intel_vsec.h> 22 24 #include <linux/io.h> 23 25 #include <linux/printk.h> 26 + #include <linux/rculist.h> 27 + #include <linux/rcupdate.h> 24 28 #include <linux/resctrl.h> 25 29 #include <linux/resctrl_types.h> 30 + #include <linux/slab.h> 26 31 #include <linux/stddef.h> 27 32 #include <linux/topology.h> 28 33 #include <linux/types.h> ··· 287 282 *val = total; 288 283 289 284 return valid ? 0 : -EINVAL; 285 + } 286 + 287 + void intel_aet_mon_domain_setup(int cpu, int id, struct rdt_resource *r, 288 + struct list_head *add_pos) 289 + { 290 + struct rdt_perf_pkg_mon_domain *d; 291 + int err; 292 + 293 + d = kzalloc_node(sizeof(*d), GFP_KERNEL, cpu_to_node(cpu)); 294 + if (!d) 295 + return; 296 + 297 + d->hdr.id = id; 298 + d->hdr.type = RESCTRL_MON_DOMAIN; 299 + d->hdr.rid = RDT_RESOURCE_PERF_PKG; 300 + cpumask_set_cpu(cpu, &d->hdr.cpu_mask); 301 + list_add_tail_rcu(&d->hdr.list, add_pos); 302 + 303 + err = resctrl_online_mon_domain(r, &d->hdr); 304 + if (err) { 305 + list_del_rcu(&d->hdr.list); 306 + synchronize_rcu(); 307 + kfree(d); 308 + } 290 309 }
+13
arch/x86/kernel/cpu/resctrl/internal.h
··· 88 88 } 89 89 90 90 /** 91 + * struct rdt_perf_pkg_mon_domain - CPUs sharing an package scoped resctrl monitor resource 92 + * @hdr: common header for different domain types 93 + */ 94 + struct rdt_perf_pkg_mon_domain { 95 + struct rdt_domain_hdr hdr; 96 + }; 97 + 98 + /** 91 99 * struct msr_param - set a range of MSRs from a domain 92 100 * @res: The resource to use 93 101 * @dom: The domain to update ··· 234 226 bool intel_aet_get_events(void); 235 227 void __exit intel_aet_exit(void); 236 228 int intel_aet_read_event(int domid, u32 rmid, void *arch_priv, u64 *val); 229 + void intel_aet_mon_domain_setup(int cpu, int id, struct rdt_resource *r, 230 + struct list_head *add_pos); 237 231 #else 238 232 static inline bool intel_aet_get_events(void) { return false; } 239 233 static inline void __exit intel_aet_exit(void) { } ··· 243 233 { 244 234 return -EINVAL; 245 235 } 236 + 237 + static inline void intel_aet_mon_domain_setup(int cpu, int id, struct rdt_resource *r, 238 + struct list_head *add_pos) { } 246 239 #endif 247 240 248 241 #endif /* _ASM_X86_RESCTRL_INTERNAL_H */
+12 -5
fs/resctrl/rdtgroup.c
··· 4308 4308 4309 4309 mutex_lock(&rdtgroup_mutex); 4310 4310 4311 - if (!domain_header_is_valid(hdr, RESCTRL_MON_DOMAIN, RDT_RESOURCE_L3)) 4312 - goto out_unlock; 4313 - 4314 - d = container_of(hdr, struct rdt_l3_mon_domain, hdr); 4315 - 4316 4311 /* 4317 4312 * If resctrl is mounted, remove all the 4318 4313 * per domain monitor data directories. ··· 4315 4320 if (resctrl_mounted && resctrl_arch_mon_capable()) 4316 4321 rmdir_mondata_subdir_allrdtgrp(r, hdr); 4317 4322 4323 + if (r->rid != RDT_RESOURCE_L3) 4324 + goto out_unlock; 4325 + 4326 + if (!domain_header_is_valid(hdr, RESCTRL_MON_DOMAIN, RDT_RESOURCE_L3)) 4327 + goto out_unlock; 4328 + 4329 + d = container_of(hdr, struct rdt_l3_mon_domain, hdr); 4318 4330 if (resctrl_is_mbm_enabled()) 4319 4331 cancel_delayed_work(&d->mbm_over); 4320 4332 if (resctrl_is_mon_event_enabled(QOS_L3_OCCUP_EVENT_ID) && has_busy_rmid(d)) { ··· 4418 4416 4419 4417 mutex_lock(&rdtgroup_mutex); 4420 4418 4419 + if (r->rid != RDT_RESOURCE_L3) 4420 + goto mkdir; 4421 + 4421 4422 if (!domain_header_is_valid(hdr, RESCTRL_MON_DOMAIN, RDT_RESOURCE_L3)) 4422 4423 goto out_unlock; 4423 4424 ··· 4438 4433 if (resctrl_is_mon_event_enabled(QOS_L3_OCCUP_EVENT_ID)) 4439 4434 INIT_DELAYED_WORK(&d->cqm_limbo, cqm_handle_limbo); 4440 4435 4436 + mkdir: 4437 + err = 0; 4441 4438 /* 4442 4439 * If the filesystem is not mounted then only the default resource group 4443 4440 * exists. Creation of its directories is deferred until mount time