]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
x86,fs/resctrl: Add and initialize a resource for package scope monitoring
authorTony Luck <tony.luck@intel.com>
Wed, 17 Dec 2025 17:21:01 +0000 (09:21 -0800)
committerBorislav Petkov (AMD) <bp@alien8.de>
Fri, 9 Jan 2026 15:37:07 +0000 (16:37 +0100)
Add a new PERF_PKG resource and introduce package level scope for monitoring
telemetry events so that CPU hotplug notifiers can build domains at the
package granularity.

Use the physical package ID available via topology_physical_package_id()
to identify the monitoring domains with package level scope. This enables
user space to use:

  /sys/devices/system/cpu/cpuX/topology/physical_package_id

to identify the monitoring domain a CPU is associated with.

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
arch/x86/kernel/cpu/resctrl/core.c
fs/resctrl/internal.h
fs/resctrl/rdtgroup.c
include/linux/resctrl.h

index a2b7f869b4b0e3ac819c5227127a6cf614569a6c..f3d7e2263630cb00e99898984d1161d462cbc094 100644 (file)
@@ -100,6 +100,14 @@ struct rdt_hw_resource rdt_resources_all[RDT_NUM_RESOURCES] = {
                        .schema_fmt             = RESCTRL_SCHEMA_RANGE,
                },
        },
+       [RDT_RESOURCE_PERF_PKG] =
+       {
+               .r_resctrl = {
+                       .name                   = "PERF_PKG",
+                       .mon_scope              = RESCTRL_PACKAGE,
+                       .mon_domains            = mon_domain_init(RDT_RESOURCE_PERF_PKG),
+               },
+       },
 };
 
 u32 resctrl_arch_system_num_rmid_idx(void)
@@ -440,6 +448,8 @@ static int get_domain_id_from_scope(int cpu, enum resctrl_scope scope)
                return get_cpu_cacheinfo_id(cpu, scope);
        case RESCTRL_L3_NODE:
                return cpu_to_node(cpu);
+       case RESCTRL_PACKAGE:
+               return topology_physical_package_id(cpu);
        default:
                break;
        }
index 14e5a9ed1fbd352175dec2413b8c50bd0f9a4801..0110d1175398c1ee6d556fbff71a31ed7df9c633 100644 (file)
@@ -255,6 +255,8 @@ struct rdtgroup {
 
 #define RFTYPE_ASSIGN_CONFIG           BIT(11)
 
+#define RFTYPE_RES_PERF_PKG            BIT(12)
+
 #define RFTYPE_CTRL_INFO               (RFTYPE_INFO | RFTYPE_CTRL)
 
 #define RFTYPE_MON_INFO                        (RFTYPE_INFO | RFTYPE_MON)
index 0e3b8bcf4e53e84c6c9ea82ab37a51946d254272..a06cefd2a09e8155fc32435247dea7784a61b669 100644 (file)
@@ -2396,6 +2396,8 @@ static unsigned long fflags_from_resource(struct rdt_resource *r)
        case RDT_RESOURCE_MBA:
        case RDT_RESOURCE_SMBA:
                return RFTYPE_RES_MB;
+       case RDT_RESOURCE_PERF_PKG:
+               return RFTYPE_RES_PERF_PKG;
        }
 
        return WARN_ON_ONCE(1);
index 2f938a5a16f81d407a2a583cd7f516750c033ce0..861e63e868a1963b49e1606c74631c95010fd569 100644 (file)
@@ -53,6 +53,7 @@ enum resctrl_res_level {
        RDT_RESOURCE_L2,
        RDT_RESOURCE_MBA,
        RDT_RESOURCE_SMBA,
+       RDT_RESOURCE_PERF_PKG,
 
        /* Must be the last */
        RDT_NUM_RESOURCES,
@@ -270,6 +271,7 @@ enum resctrl_scope {
        RESCTRL_L2_CACHE = 2,
        RESCTRL_L3_CACHE = 3,
        RESCTRL_L3_NODE,
+       RESCTRL_PACKAGE,
 };
 
 /**