From nobody Fri Dec 19 17:08:33 2025 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.13]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 29EDB1A08A8 for ; Mon, 7 Apr 2025 23:40:45 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.13 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1744069248; cv=none; b=d/ImuGkS8pypZ5YhSEEnoJ49q/yVPhqB0uXSrtIUrQmbV6gQIFrN2ni8+pS0tV2AerrbomlavpEiplCLZ2QdS22Y4UVi1e8V3sLSdAm4reg/c7bSoXkrQqzcSMny2KXWcx7uRrSKy4ucNtWnIn1m6PJSQLIMe/++KJdtLgubdOo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1744069248; c=relaxed/simple; bh=kAA1NPfA0qoxNeR5YO7tA3WBky/aNtheiKAM1Wb+ug8=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=b0NfRWxuXH6AHl7ipA3t+Vl1RyXmExCH0CPyl9R+Wzu5KQWL4JnjZr4ZKbM1uoP5+pkXQS9b2z3Lzjo/L3slqySVw5UCWm9VTEr1qreWpAe9E2L3hNP9R3e5XFqoMVCtOn3aFZih9c9S6Wuf6SJe/kLmqrMQqgVh4umNxCjr7u8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com; spf=pass smtp.mailfrom=intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=lGIGc7f1; arc=none smtp.client-ip=192.198.163.13 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="lGIGc7f1" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1744069246; x=1775605246; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=kAA1NPfA0qoxNeR5YO7tA3WBky/aNtheiKAM1Wb+ug8=; b=lGIGc7f1FwzqcjdtOGJPQY1MlXU1Zi7S662AXnZWq9h9gS1mHQNqgWzw lMbr1lHeGfiAGSFoAZ8LLyROrm2SrhmlVKtfvkK+rP7jnLyOEg9xpv1au Sj/4EIeIAn5H/77gT6rw0Yf3ZEZQgllARQSA4wvwBwMaVKSylyhrOVN8R 6px69ePDtq3bMCeb+HEkPHyb3tP7w24zbq6oCq+6cEuAsZZbnfAsi/UGC ZpUNOWnTziWpobAxsfNBWlFZw+Bewh1Yd4SiArcdLdb2uGdQWbanVf3jU Ww9Edd4wBJbFS3HgDyyQ9GCFPqTxnbY5VWCx6xllnxZPufUhcXInRD5Vt g==; X-CSE-ConnectionGUID: HfgspzKuQWGhfsL79uB6kg== X-CSE-MsgGUID: In5s+4crQzKdzhJlRqBq2g== X-IronPort-AV: E=McAfee;i="6700,10204,11397"; a="48193114" X-IronPort-AV: E=Sophos;i="6.15,196,1739865600"; d="scan'208";a="48193114" Received: from orviesa001.jf.intel.com ([10.64.159.141]) by fmvoesa107.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 07 Apr 2025 16:40:44 -0700 X-CSE-ConnectionGUID: qNyCGEiOSjOOr5h2w4IEYA== X-CSE-MsgGUID: XidpWL+OTq6NV5PDZP8MFA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.15,196,1739865600"; d="scan'208";a="165315444" Received: from agluck-desk3.sc.intel.com ([172.25.222.70]) by smtpauth.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 07 Apr 2025 16:40:44 -0700 From: Tony Luck To: Fenghua Yu , Reinette Chatre , Maciej Wieczor-Retman , Peter Newman , James Morse , Babu Moger , Drew Fustini , Dave Martin , Anil Keshavamurthy Cc: linux-kernel@vger.kernel.org, patches@lists.linux.dev, Tony Luck Subject: [PATCH v3 01/26] fs/resctrl: Simplify allocation of mon_data structures Date: Mon, 7 Apr 2025 16:40:03 -0700 Message-ID: <20250407234032.241215-2-tony.luck@intel.com> X-Mailer: git-send-email 2.48.1 In-Reply-To: <20250407234032.241215-1-tony.luck@intel.com> References: <20250407234032.241215-1-tony.luck@intel.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Instead of making a special case to allocate and attach these structures to kernfs files in the default control group, simply allocate a structure when a new combination of is needed and reuse existing structures when possible. Free all structures when resctrl filesystem is unmounted. Partial revert of commit fa563b5171e9 ("x86/resctrl: Expand the width of dom_id by replacing mon_data_bits") Signed-off-by: Tony Luck --- fs/resctrl/internal.h | 2 + fs/resctrl/rdtgroup.c | 138 ++++++++++++------------------------------ 2 files changed, 40 insertions(+), 100 deletions(-) diff --git a/fs/resctrl/internal.h b/fs/resctrl/internal.h index ec3863d18f68..e5976bd52a35 100644 --- a/fs/resctrl/internal.h +++ b/fs/resctrl/internal.h @@ -83,6 +83,7 @@ struct mon_evt { =20 /** * struct mon_data - Monitoring details for each event file. + * @list: List of all allocated structures. * @rid: Resource id associated with the event file. * @evtid: Event id associated with the event file. * @sum: Set when event must be summed across multiple @@ -96,6 +97,7 @@ struct mon_evt { * rdtgroup_mutex. */ struct mon_data { + struct list_head list; unsigned int rid; enum resctrl_event_id evtid; unsigned int sum; diff --git a/fs/resctrl/rdtgroup.c b/fs/resctrl/rdtgroup.c index 234ec9dbe5b3..338b70c7d302 100644 --- a/fs/resctrl/rdtgroup.c +++ b/fs/resctrl/rdtgroup.c @@ -69,6 +69,8 @@ static int rdtgroup_setup_root(struct rdt_fs_context *ctx= ); =20 static void rdtgroup_destroy_root(void); =20 +static void mon_put_kn_priv(void); + struct dentry *debugfs_resctrl; =20 /* @@ -2873,6 +2875,7 @@ static void rdt_kill_sb(struct super_block *sb) resctrl_arch_reset_all_ctrls(r); =20 rmdir_all_sub(); + mon_put_kn_priv(); rdt_pseudo_lock_release(); rdtgroup_default.mode =3D RDT_MODE_SHAREABLE; schemata_list_destroy(); @@ -2895,107 +2898,54 @@ static struct file_system_type rdt_fs_type =3D { .kill_sb =3D rdt_kill_sb, }; =20 +static LIST_HEAD(kn_priv_list); + /** - * mon_get_default_kn_priv() - Get the mon_data priv data for this event f= rom - * the default control group. + * mon_get_kn_priv() - Get the mon_data priv data for this event * Called when monitor event files are created for a domain. - * When called with the default control group, the structure will be alloc= ated. - * This happens at mount time, before other control or monitor groups are - * created. - * This simplifies the lifetime management for rmdir() versus domain-offli= ne - * as the default control group lives forever, and only one group needs to= be - * special cased. + * The same values are used in multiple directories. Keep a list + * of allocated structures and reuse an existing one with the same + * list of values for rid, domain, etc. * - * @r: The resource for the event type being created. - * @d: The domain for the event type being created. - * @mevt: The event type being created. - * @rdtgrp: The rdtgroup for which the monitor file is being created, - * used to determine if this is the default control group. - * @do_sum: Whether the SNC sub-numa node monitors are being created. + * @rid: The resource for the event type being created. + * @domid: The domain for the event type being created. + * @mevt: The event type being created. + * @do_sum: Whether the SNC sub-numa node monitors are being created. */ -static struct mon_data *mon_get_default_kn_priv(struct rdt_resource *r, - struct rdt_mon_domain *d, - struct mon_evt *mevt, - struct rdtgroup *rdtgrp, - bool do_sum) +static struct mon_data *mon_get_kn_priv(int rid, int domid, struct mon_evt= *mevt, bool do_sum) { - struct kernfs_node *kn_dom, *kn_evt; struct mon_data *priv; - bool snc_mode; - char name[32]; =20 - lockdep_assert_held(&rdtgroup_mutex); - - snc_mode =3D r->mon_scope =3D=3D RESCTRL_L3_NODE; - if (!do_sum) - sprintf(name, "mon_%s_%02d", r->name, snc_mode ? d->ci->id : d->hdr.id); - else - sprintf(name, "mon_sub_%s_%02d", r->name, d->hdr.id); - - kn_dom =3D kernfs_find_and_get(kn_mondata, name); - if (!kn_dom) - return NULL; - - kn_evt =3D kernfs_find_and_get(kn_dom, mevt->name); - - /* Is this the creation of the default groups monitor files? */ - if (!kn_evt && rdtgrp =3D=3D &rdtgroup_default) { - priv =3D kzalloc(sizeof(*priv), GFP_KERNEL); - if (!priv) - return NULL; - priv->rid =3D r->rid; - priv->domid =3D do_sum ? d->ci->id : d->hdr.id; - priv->sum =3D do_sum; - priv->evtid =3D mevt->evtid; - return priv; + list_for_each_entry(priv, &kn_priv_list, list) { + if (priv->rid =3D=3D rid && priv->domid =3D=3D domid && + priv->sum =3D=3D do_sum && priv->evtid =3D=3D mevt->evtid) + return priv; } =20 - if (!kn_evt) + priv =3D kzalloc(sizeof(*priv), GFP_KERNEL); + if (!priv) return NULL; =20 - return kn_evt->priv; + priv->rid =3D rid; + priv->domid =3D domid; + priv->sum =3D do_sum; + priv->evtid =3D mevt->evtid; + list_add_tail(&priv->list, &kn_priv_list); + + return priv; } =20 /** - * mon_put_default_kn_priv_all() - Potentially free the mon_data priv data= for - * all events from the default control gro= up. - * Put the mon_data priv data for all events for a particular domain. - * When called with the default control group, the priv structure previous= ly - * allocated will be kfree()d. This should only be done as part of taking a - * domain offline. - * Only a domain offline will 'rmdir' monitor files in the default control - * group. After domain offline releases rdtgrp_mutex, all references will - * have been removed. - * - * @rdtgrp: The rdtgroup for which the monitor files are being removed, - * used to determine if this is the default control group. - * @name: The name of the domain or SNC sub-numa domain which is being - * taken offline. + * mon_put_kn_priv() - Free all allocated mon_data structures + * Called when resctrl file system is unmounted. */ -static void mon_put_default_kn_priv_all(struct rdtgroup *rdtgrp, char *nam= e) +static void mon_put_kn_priv(void) { - struct rdt_resource *r =3D resctrl_arch_get_resource(RDT_RESOURCE_L3); - struct kernfs_node *kn_dom, *kn_evt; - struct mon_evt *mevt; + struct mon_data *priv, *tmp; =20 - lockdep_assert_held(&rdtgroup_mutex); - - if (rdtgrp !=3D &rdtgroup_default) - return; - - kn_dom =3D kernfs_find_and_get(kn_mondata, name); - if (!kn_dom) - return; - - list_for_each_entry(mevt, &r->evt_list, list) { - kn_evt =3D kernfs_find_and_get(kn_dom, mevt->name); - if (!kn_evt) - continue; - if (!kn_evt->priv) - continue; - - kfree(kn_evt->priv); - kn_evt->priv =3D NULL; + list_for_each_entry_safe(priv, tmp, &kn_priv_list, list) { + kfree(priv); + list_del(&priv->list); } } =20 @@ -3029,16 +2979,12 @@ static void mon_rmdir_one_subdir(struct rdtgroup *r= dtgrp, char *name, char *subn if (!kn) return; =20 - mon_put_default_kn_priv_all(rdtgrp, name); - kernfs_put(kn); =20 - if (kn->dir.subdirs <=3D 1) { + if (kn->dir.subdirs <=3D 1) kernfs_remove(kn); - } else { - mon_put_default_kn_priv_all(rdtgrp, subname); + else kernfs_remove_by_name(kn, subname); - } } =20 /* @@ -3081,7 +3027,7 @@ static int mon_add_all_files(struct kernfs_node *kn, = struct rdt_mon_domain *d, return -EPERM; =20 list_for_each_entry(mevt, &r->evt_list, list) { - priv =3D mon_get_default_kn_priv(r, d, mevt, prgrp, do_sum); + priv =3D mon_get_kn_priv(r->rid, do_sum ? d->ci->id : d->hdr.id, mevt, d= o_sum); if (WARN_ON_ONCE(!priv)) return -EINVAL; =20 @@ -3165,17 +3111,9 @@ static void mkdir_mondata_subdir_allrdtgrp(struct rd= t_resource *r, struct rdtgroup *prgrp, *crgrp; struct list_head *head; =20 - /* - * During domain-online create the default control group first - * so that mon_get_default_kn_priv() can find the allocated structure - * on subsequent calls. - */ - mkdir_mondata_subdir(kn_mondata, d, r, &rdtgroup_default); - list_for_each_entry(prgrp, &rdt_all_groups, rdtgroup_list) { parent_kn =3D prgrp->mon.mon_data_kn; - if (prgrp !=3D &rdtgroup_default) - mkdir_mondata_subdir(parent_kn, d, r, prgrp); + mkdir_mondata_subdir(parent_kn, d, r, prgrp); =20 head =3D &prgrp->mon.crdtgrp_list; list_for_each_entry(crgrp, head, mon.crdtgrp_list) { --=20 2.48.1 From nobody Fri Dec 19 17:08:33 2025 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.13]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id CAD2B21C9E0 for ; Mon, 7 Apr 2025 23:40:46 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.13 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1744069249; cv=none; b=WihqSJWoyWB7yivlf8D5EJZ0jNiSvrjqloVbFYjGUBdYHOEK2/ZkArV5hVnywd5Pq5NfrBSgrkFEvk2ulUJrzyxJSLvDL5f86uZ932L/S8r16/u0zbVQpf2lMA1wlQ3qgPajzXs0QotFcc7CjP2wN0GIPhGcGwirvI8F7+QlADM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1744069249; c=relaxed/simple; bh=0SsHkzJ+rKfwiQhKtqjOmpxI83+lcGEhE7JmP2gJ82k=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=ranKmSsaE5Dx7AgazDdPscFlYboiEvMni1PbtrPwC0klg4y2cg5WzVCJYKRsOilWt1r517lPG4oQGz0IYqeexjdw1IApeE/YI5wBVdHOYUknV9T4IOfe5V9gIrVmnRPsAEW9kL8YRhMeUXyMTYdKanuqbSNtOg4bh1xx0ub9IqQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com; spf=pass smtp.mailfrom=intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=WaG8jNyU; arc=none smtp.client-ip=192.198.163.13 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="WaG8jNyU" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1744069247; x=1775605247; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=0SsHkzJ+rKfwiQhKtqjOmpxI83+lcGEhE7JmP2gJ82k=; b=WaG8jNyUd65qMsehZLJDwfdy6GaLky4ATQvhOQyuFkqLm7qEOPMorxK1 W7mgM26k2m0Z9D4DFjUhbfq1kBxaz6lItfH3DcYD1996uvXTzPZV60nmW 6APpbtMWmx2Dg1VZn16qAcDlZQhNHJ2IXbLoYTx9Vuj9CF7ZMARBCPsUh QtSXVs2Aj5Cxi2VL+auVtp5A7IY8D75A0CgABPnXDPd+oS2RA1OaI/NB9 HQNnfkuFnWd1GAeyevlrgz/Vbc4a0Hd6mdqVdN+duM7DWARz1GyRLfl4W Na7gTPl+2arjHqS5j4RUag/SK4XfM/+DdCEdWzi1+hZiBtZCgH0ynMrRk w==; X-CSE-ConnectionGUID: rXB46zD8Sf+MD7noJNQ0Ig== X-CSE-MsgGUID: jhL1PQ+rRBiL3LtHwjGGzw== X-IronPort-AV: E=McAfee;i="6700,10204,11397"; a="48193122" X-IronPort-AV: E=Sophos;i="6.15,196,1739865600"; d="scan'208";a="48193122" Received: from orviesa001.jf.intel.com ([10.64.159.141]) by fmvoesa107.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 07 Apr 2025 16:40:45 -0700 X-CSE-ConnectionGUID: 9U8pZbmcR76OHq4QZV87sg== X-CSE-MsgGUID: tXpnbrOETv22aTV6+5sc+Q== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.15,196,1739865600"; d="scan'208";a="165315447" Received: from agluck-desk3.sc.intel.com ([172.25.222.70]) by smtpauth.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 07 Apr 2025 16:40:44 -0700 From: Tony Luck To: Fenghua Yu , Reinette Chatre , Maciej Wieczor-Retman , Peter Newman , James Morse , Babu Moger , Drew Fustini , Dave Martin , Anil Keshavamurthy Cc: linux-kernel@vger.kernel.org, patches@lists.linux.dev, Tony Luck Subject: [PATCH v3 02/26] fs-x86/resctrl: Prepare for more monitor events Date: Mon, 7 Apr 2025 16:40:04 -0700 Message-ID: <20250407234032.241215-3-tony.luck@intel.com> X-Mailer: git-send-email 2.48.1 In-Reply-To: <20250407234032.241215-1-tony.luck@intel.com> References: <20250407234032.241215-1-tony.luck@intel.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" There's a rule in computer programming that objects appear zero, once, or many times. So code accordingly. There are two MBM events and resctrl is coded with a lot of if (local) do one thing if (total) do a different thing Simplify the code by coding for many events using loops on which are enabled. Make rdt_mon_features a bitmap to allow for expansion. Move resctrl_is_mbm_event() to as it gets used by core.c Signed-off-by: Tony Luck --- include/linux/resctrl.h | 6 +-- include/linux/resctrl_types.h | 8 +++ arch/x86/include/asm/resctrl.h | 8 +-- arch/x86/kernel/cpu/resctrl/internal.h | 6 +-- fs/resctrl/internal.h | 4 ++ arch/x86/kernel/cpu/resctrl/core.c | 45 +++++++++-------- arch/x86/kernel/cpu/resctrl/monitor.c | 33 ++++++------ fs/resctrl/ctrlmondata.c | 41 ++++----------- fs/resctrl/monitor.c | 70 ++++++++++++++++---------- fs/resctrl/rdtgroup.c | 47 ++++++++--------- 10 files changed, 133 insertions(+), 135 deletions(-) diff --git a/include/linux/resctrl.h b/include/linux/resctrl.h index 5c7c8bf2c47f..d6a926b6fc0e 100644 --- a/include/linux/resctrl.h +++ b/include/linux/resctrl.h @@ -151,8 +151,7 @@ struct rdt_ctrl_domain { * @hdr: common header for different domain types * @ci: cache info for this domain * @rmid_busy_llc: bitmap of which limbo RMIDs are above threshold - * @mbm_total: saved state for MBM total bandwidth - * @mbm_local: saved state for MBM local bandwidth + * @mbm_states: saved state for each QOS MBM event * @mbm_over: worker to periodically read MBM h/w counters * @cqm_limbo: worker to periodically read CQM h/w counters * @mbm_work_cpu: worker CPU for MBM h/w counters @@ -162,8 +161,7 @@ struct rdt_mon_domain { struct rdt_domain_hdr hdr; struct cacheinfo *ci; unsigned long *rmid_busy_llc; - struct mbm_state *mbm_total; - struct mbm_state *mbm_local; + struct mbm_state *mbm_states[QOS_NUM_MBM_EVENTS]; struct delayed_work mbm_over; struct delayed_work cqm_limbo; int mbm_work_cpu; diff --git a/include/linux/resctrl_types.h b/include/linux/resctrl_types.h index a7faf2cd5406..898068a99ef7 100644 --- a/include/linux/resctrl_types.h +++ b/include/linux/resctrl_types.h @@ -55,5 +55,13 @@ enum resctrl_event_id { }; =20 #define QOS_NUM_EVENTS (QOS_L3_MBM_LOCAL_EVENT_ID + 1) +#define QOS_NUM_MBM_EVENTS (QOS_L3_MBM_LOCAL_EVENT_ID - QOS_L3_MBM_TOTAL_E= VENT_ID + 1) +#define MBM_EVENT_IDX(evt) ((evt) - QOS_L3_MBM_TOTAL_EVENT_ID) + +static inline bool resctrl_is_mbm_event(int e) +{ + return (e >=3D QOS_L3_MBM_TOTAL_EVENT_ID && + e <=3D QOS_L3_MBM_LOCAL_EVENT_ID); +} =20 #endif /* __LINUX_RESCTRL_TYPES_H */ diff --git a/arch/x86/include/asm/resctrl.h b/arch/x86/include/asm/resctrl.h index 6eb7d5c94c7a..4346de48eeab 100644 --- a/arch/x86/include/asm/resctrl.h +++ b/arch/x86/include/asm/resctrl.h @@ -42,7 +42,7 @@ DECLARE_PER_CPU(struct resctrl_pqr_state, pqr_state); =20 extern bool rdt_alloc_capable; extern bool rdt_mon_capable; -extern unsigned int rdt_mon_features; +extern DECLARE_BITMAP(rdt_mon_features, QOS_NUM_EVENTS); =20 DECLARE_STATIC_KEY_FALSE(rdt_enable_key); DECLARE_STATIC_KEY_FALSE(rdt_alloc_enable_key); @@ -84,17 +84,17 @@ static inline void resctrl_arch_disable_mon(void) =20 static inline bool resctrl_arch_is_llc_occupancy_enabled(void) { - return (rdt_mon_features & (1 << QOS_L3_OCCUP_EVENT_ID)); + return test_bit(QOS_L3_OCCUP_EVENT_ID, rdt_mon_features); } =20 static inline bool resctrl_arch_is_mbm_total_enabled(void) { - return (rdt_mon_features & (1 << QOS_L3_MBM_TOTAL_EVENT_ID)); + return test_bit(QOS_L3_MBM_TOTAL_EVENT_ID, rdt_mon_features); } =20 static inline bool resctrl_arch_is_mbm_local_enabled(void) { - return (rdt_mon_features & (1 << QOS_L3_MBM_LOCAL_EVENT_ID)); + return test_bit(QOS_L3_MBM_LOCAL_EVENT_ID, rdt_mon_features); } =20 /* diff --git a/arch/x86/kernel/cpu/resctrl/internal.h b/arch/x86/kernel/cpu/r= esctrl/internal.h index 521db28efb3f..45eabc7919c6 100644 --- a/arch/x86/kernel/cpu/resctrl/internal.h +++ b/arch/x86/kernel/cpu/resctrl/internal.h @@ -59,15 +59,13 @@ struct rdt_hw_ctrl_domain { * struct rdt_hw_mon_domain - Arch private attributes of a set of CPUs tha= t share * a resource for a monitor function * @d_resctrl: Properties exposed to the resctrl file system - * @arch_mbm_total: arch private state for MBM total bandwidth - * @arch_mbm_local: arch private state for MBM local bandwidth + * @arch_mbm_states: arch private state for each MBM event * * Members of this structure are accessed via helpers that provide abstrac= tion. */ struct rdt_hw_mon_domain { struct rdt_mon_domain d_resctrl; - struct arch_mbm_state *arch_mbm_total; - struct arch_mbm_state *arch_mbm_local; + struct arch_mbm_state *arch_mbm_states[QOS_NUM_MBM_EVENTS]; }; =20 static inline struct rdt_hw_ctrl_domain *resctrl_to_arch_ctrl_dom(struct r= dt_ctrl_domain *r) diff --git a/fs/resctrl/internal.h b/fs/resctrl/internal.h index e5976bd52a35..7a65ea02d442 100644 --- a/fs/resctrl/internal.h +++ b/fs/resctrl/internal.h @@ -386,6 +386,10 @@ bool closid_allocated(unsigned int closid); =20 int resctrl_find_cleanest_closid(void); =20 +int rdt_lookup_evtid_by_name(char *name); + +char *rdt_event_name(enum resctrl_event_id evt); + #ifdef CONFIG_RESCTRL_FS_PSEUDO_LOCK int rdtgroup_locksetup_enter(struct rdtgroup *rdtgrp); =20 diff --git a/arch/x86/kernel/cpu/resctrl/core.c b/arch/x86/kernel/cpu/resct= rl/core.c index 6ed0d4f5d6a3..6f4a3bd02a42 100644 --- a/arch/x86/kernel/cpu/resctrl/core.c +++ b/arch/x86/kernel/cpu/resctrl/core.c @@ -366,8 +366,8 @@ static void ctrl_domain_free(struct rdt_hw_ctrl_domain = *hw_dom) =20 static void mon_domain_free(struct rdt_hw_mon_domain *hw_dom) { - kfree(hw_dom->arch_mbm_total); - kfree(hw_dom->arch_mbm_local); + for (int i =3D 0; i < QOS_NUM_MBM_EVENTS; i++) + kfree(hw_dom->arch_mbm_states[i]); kfree(hw_dom); } =20 @@ -401,25 +401,26 @@ static int domain_setup_ctrlval(struct rdt_resource *= r, struct rdt_ctrl_domain * */ static int arch_domain_mbm_alloc(u32 num_rmid, struct rdt_hw_mon_domain *h= w_dom) { - size_t tsize; - - if (resctrl_arch_is_mbm_total_enabled()) { - tsize =3D sizeof(*hw_dom->arch_mbm_total); - hw_dom->arch_mbm_total =3D kcalloc(num_rmid, tsize, GFP_KERNEL); - if (!hw_dom->arch_mbm_total) - return -ENOMEM; - } - if (resctrl_arch_is_mbm_local_enabled()) { - tsize =3D sizeof(*hw_dom->arch_mbm_local); - hw_dom->arch_mbm_local =3D kcalloc(num_rmid, tsize, GFP_KERNEL); - if (!hw_dom->arch_mbm_local) { - kfree(hw_dom->arch_mbm_total); - hw_dom->arch_mbm_total =3D NULL; - return -ENOMEM; - } + size_t tsize =3D sizeof(struct arch_mbm_state); + int evt, idx; + + for_each_set_bit(evt, rdt_mon_features, QOS_NUM_EVENTS) { + if (!resctrl_is_mbm_event(evt)) + continue; + idx =3D MBM_EVENT_IDX(evt); + hw_dom->arch_mbm_states[idx] =3D kcalloc(num_rmid, tsize, GFP_KERNEL); + if (!hw_dom->arch_mbm_states[idx]) + goto cleanup; } =20 return 0; +cleanup: + for (idx =3D 0; idx < QOS_NUM_MBM_EVENTS; idx++) { + kfree(hw_dom->arch_mbm_states[idx]); + hw_dom->arch_mbm_states[idx] =3D NULL; + } + + return -ENOMEM; } =20 static int get_domain_id_from_scope(int cpu, enum resctrl_scope scope) @@ -864,13 +865,13 @@ static __init bool get_rdt_mon_resources(void) struct rdt_resource *r =3D &rdt_resources_all[RDT_RESOURCE_L3].r_resctrl; =20 if (rdt_cpu_has(X86_FEATURE_CQM_OCCUP_LLC)) - rdt_mon_features |=3D (1 << QOS_L3_OCCUP_EVENT_ID); + __set_bit(QOS_L3_OCCUP_EVENT_ID, rdt_mon_features); if (rdt_cpu_has(X86_FEATURE_CQM_MBM_TOTAL)) - rdt_mon_features |=3D (1 << QOS_L3_MBM_TOTAL_EVENT_ID); + __set_bit(QOS_L3_MBM_TOTAL_EVENT_ID, rdt_mon_features); if (rdt_cpu_has(X86_FEATURE_CQM_MBM_LOCAL)) - rdt_mon_features |=3D (1 << QOS_L3_MBM_LOCAL_EVENT_ID); + __set_bit(QOS_L3_MBM_LOCAL_EVENT_ID, rdt_mon_features); =20 - if (!rdt_mon_features) + if (find_first_bit(rdt_mon_features, QOS_NUM_EVENTS) =3D=3D QOS_NUM_EVENT= S) return false; =20 return !rdt_get_mon_l3_config(r); diff --git a/arch/x86/kernel/cpu/resctrl/monitor.c b/arch/x86/kernel/cpu/re= sctrl/monitor.c index 163174cc0d3e..06623d51d006 100644 --- a/arch/x86/kernel/cpu/resctrl/monitor.c +++ b/arch/x86/kernel/cpu/resctrl/monitor.c @@ -36,7 +36,7 @@ bool rdt_mon_capable; /* * Global to indicate which monitoring events are enabled. */ -unsigned int rdt_mon_features; +DECLARE_BITMAP(rdt_mon_features, QOS_NUM_EVENTS); =20 #define CF(cf) ((unsigned long)(1048576 * (cf) + 0.5)) =20 @@ -168,19 +168,14 @@ static struct arch_mbm_state *get_arch_mbm_state(stru= ct rdt_hw_mon_domain *hw_do u32 rmid, enum resctrl_event_id eventid) { - switch (eventid) { - case QOS_L3_OCCUP_EVENT_ID: + struct arch_mbm_state *state; + + if (!resctrl_is_mbm_event(eventid)) return NULL; - case QOS_L3_MBM_TOTAL_EVENT_ID: - return &hw_dom->arch_mbm_total[rmid]; - case QOS_L3_MBM_LOCAL_EVENT_ID: - return &hw_dom->arch_mbm_local[rmid]; - } =20 - /* Never expect to get here */ - WARN_ON_ONCE(1); + state =3D hw_dom->arch_mbm_states[MBM_EVENT_IDX(eventid)]; =20 - return NULL; + return state ? &state[rmid] : NULL; } =20 void resctrl_arch_reset_rmid(struct rdt_resource *r, struct rdt_mon_domain= *d, @@ -209,14 +204,16 @@ void resctrl_arch_reset_rmid(struct rdt_resource *r, = struct rdt_mon_domain *d, void resctrl_arch_reset_rmid_all(struct rdt_resource *r, struct rdt_mon_do= main *d) { struct rdt_hw_mon_domain *hw_dom =3D resctrl_to_arch_mon_dom(d); + int evt, idx; + + for_each_set_bit(evt, rdt_mon_features, QOS_NUM_EVENTS) { + idx =3D MBM_EVENT_IDX(evt); + if (!hw_dom->arch_mbm_states[idx]) + continue; + memset(hw_dom->arch_mbm_states[idx], 0, + sizeof(struct arch_mbm_state) * r->num_rmid); + } =20 - if (resctrl_arch_is_mbm_total_enabled()) - memset(hw_dom->arch_mbm_total, 0, - sizeof(*hw_dom->arch_mbm_total) * r->num_rmid); - - if (resctrl_arch_is_mbm_local_enabled()) - memset(hw_dom->arch_mbm_local, 0, - sizeof(*hw_dom->arch_mbm_local) * r->num_rmid); } =20 static u64 mbm_overflow_count(u64 prev_msr, u64 cur_msr, unsigned int widt= h) diff --git a/fs/resctrl/ctrlmondata.c b/fs/resctrl/ctrlmondata.c index d56b78450a99..ce02e961a6c3 100644 --- a/fs/resctrl/ctrlmondata.c +++ b/fs/resctrl/ctrlmondata.c @@ -458,7 +458,7 @@ ssize_t rdtgroup_mba_mbps_event_write(struct kernfs_ope= n_file *of, char *buf, size_t nbytes, loff_t off) { struct rdtgroup *rdtgrp; - int ret =3D 0; + int ret; =20 /* Valid input requires a trailing newline */ if (nbytes =3D=3D 0 || buf[nbytes - 1] !=3D '\n') @@ -472,26 +472,15 @@ ssize_t rdtgroup_mba_mbps_event_write(struct kernfs_o= pen_file *of, } rdt_last_cmd_clear(); =20 - if (!strcmp(buf, "mbm_local_bytes")) { - if (resctrl_arch_is_mbm_local_enabled()) - rdtgrp->mba_mbps_event =3D QOS_L3_MBM_LOCAL_EVENT_ID; - else - ret =3D -EINVAL; - } else if (!strcmp(buf, "mbm_total_bytes")) { - if (resctrl_arch_is_mbm_total_enabled()) - rdtgrp->mba_mbps_event =3D QOS_L3_MBM_TOTAL_EVENT_ID; - else - ret =3D -EINVAL; - } else { - ret =3D -EINVAL; - } - - if (ret) + ret =3D rdt_lookup_evtid_by_name(buf); + if (ret < 0) rdt_last_cmd_printf("Unsupported event id '%s'\n", buf); + else + rdtgrp->mba_mbps_event =3D ret; =20 rdtgroup_kn_unlock(of->kn); =20 - return ret ?: nbytes; + return ret < 0 ? ret : nbytes; } =20 int rdtgroup_mba_mbps_event_show(struct kernfs_open_file *of, @@ -502,22 +491,10 @@ int rdtgroup_mba_mbps_event_show(struct kernfs_open_f= ile *of, =20 rdtgrp =3D rdtgroup_kn_lock_live(of->kn); =20 - if (rdtgrp) { - switch (rdtgrp->mba_mbps_event) { - case QOS_L3_MBM_LOCAL_EVENT_ID: - seq_puts(s, "mbm_local_bytes\n"); - break; - case QOS_L3_MBM_TOTAL_EVENT_ID: - seq_puts(s, "mbm_total_bytes\n"); - break; - default: - pr_warn_once("Bad event %d\n", rdtgrp->mba_mbps_event); - ret =3D -EINVAL; - break; - } - } else { + if (rdtgrp) + seq_printf(s, "%s\n", rdt_event_name(rdtgrp->mba_mbps_event)); + else ret =3D -ENOENT; - } =20 rdtgroup_kn_unlock(of->kn); =20 diff --git a/fs/resctrl/monitor.c b/fs/resctrl/monitor.c index 3fe21dcf0fde..66e613906f3e 100644 --- a/fs/resctrl/monitor.c +++ b/fs/resctrl/monitor.c @@ -347,15 +347,14 @@ static struct mbm_state *get_mbm_state(struct rdt_mon= _domain *d, u32 closid, u32 rmid, enum resctrl_event_id evtid) { u32 idx =3D resctrl_arch_rmid_idx_encode(closid, rmid); + struct mbm_state *states; =20 - switch (evtid) { - case QOS_L3_MBM_TOTAL_EVENT_ID: - return &d->mbm_total[idx]; - case QOS_L3_MBM_LOCAL_EVENT_ID: - return &d->mbm_local[idx]; - default: + if (!resctrl_is_mbm_event(evtid)) return NULL; - } + + states =3D d->mbm_states[MBM_EVENT_IDX(evtid)]; + + return states ? &states[idx] : NULL; } =20 static int __mon_event_count(u32 closid, u32 rmid, struct rmid_read *rr) @@ -843,20 +842,40 @@ static void dom_data_exit(struct rdt_resource *r) mutex_unlock(&rdtgroup_mutex); } =20 -static struct mon_evt llc_occupancy_event =3D { - .name =3D "llc_occupancy", - .evtid =3D QOS_L3_OCCUP_EVENT_ID, +static struct mon_evt all_events[QOS_NUM_EVENTS] =3D { + [QOS_L3_OCCUP_EVENT_ID] =3D { + .name =3D "llc_occupancy", + .evtid =3D QOS_L3_OCCUP_EVENT_ID, + }, + [QOS_L3_MBM_TOTAL_EVENT_ID] =3D { + .name =3D "mbm_total_bytes", + .evtid =3D QOS_L3_MBM_TOTAL_EVENT_ID, + }, + [QOS_L3_MBM_LOCAL_EVENT_ID] =3D { + .name =3D "mbm_local_bytes", + .evtid =3D QOS_L3_MBM_LOCAL_EVENT_ID, + }, }; =20 -static struct mon_evt mbm_total_event =3D { - .name =3D "mbm_total_bytes", - .evtid =3D QOS_L3_MBM_TOTAL_EVENT_ID, -}; +int rdt_lookup_evtid_by_name(char *name) +{ + int evt; =20 -static struct mon_evt mbm_local_event =3D { - .name =3D "mbm_local_bytes", - .evtid =3D QOS_L3_MBM_LOCAL_EVENT_ID, -}; + for_each_set_bit(evt, rdt_mon_features, QOS_NUM_EVENTS) { + if (!strcmp(name, all_events[evt].name)) + return evt; + } + + return -EINVAL; +} + +char *rdt_event_name(enum resctrl_event_id evt) +{ + if (!test_bit(evt, rdt_mon_features)) + return "unknown"; + + return all_events[evt].name; +} =20 /* * Initialize the event list for the resource. @@ -870,14 +889,13 @@ static struct mon_evt mbm_local_event =3D { */ static void l3_mon_evt_init(struct rdt_resource *r) { + int evt; + INIT_LIST_HEAD(&r->evt_list); =20 - if (resctrl_arch_is_llc_occupancy_enabled()) - list_add_tail(&llc_occupancy_event.list, &r->evt_list); - if (resctrl_arch_is_mbm_total_enabled()) - list_add_tail(&mbm_total_event.list, &r->evt_list); - if (resctrl_arch_is_mbm_local_enabled()) - list_add_tail(&mbm_local_event.list, &r->evt_list); + for_each_set_bit(evt, rdt_mon_features, QOS_NUM_EVENTS) { + list_add_tail(&all_events[evt].list, &r->evt_list); + } } =20 /** @@ -907,12 +925,12 @@ int resctrl_mon_resource_init(void) l3_mon_evt_init(r); =20 if (resctrl_arch_is_evt_configurable(QOS_L3_MBM_TOTAL_EVENT_ID)) { - mbm_total_event.configurable =3D true; + all_events[QOS_L3_MBM_TOTAL_EVENT_ID].configurable =3D true; resctrl_file_fflags_init("mbm_total_bytes_config", RFTYPE_MON_INFO | RFTYPE_RES_CACHE); } if (resctrl_arch_is_evt_configurable(QOS_L3_MBM_LOCAL_EVENT_ID)) { - mbm_local_event.configurable =3D true; + all_events[QOS_L3_MBM_LOCAL_EVENT_ID].configurable =3D true; resctrl_file_fflags_init("mbm_local_bytes_config", RFTYPE_MON_INFO | RFTYPE_RES_CACHE); } diff --git a/fs/resctrl/rdtgroup.c b/fs/resctrl/rdtgroup.c index 338b70c7d302..8d15d53fae76 100644 --- a/fs/resctrl/rdtgroup.c +++ b/fs/resctrl/rdtgroup.c @@ -125,12 +125,6 @@ static bool resctrl_is_mbm_enabled(void) resctrl_arch_is_mbm_local_enabled()); } =20 -static bool resctrl_is_mbm_event(int e) -{ - return (e >=3D QOS_L3_MBM_TOTAL_EVENT_ID && - e <=3D QOS_L3_MBM_LOCAL_EVENT_ID); -} - /* * Trivial allocator for CLOSIDs. Use BITMAP APIs to manipulate a bitmap * of free CLOSIDs. @@ -3970,8 +3964,10 @@ static void rdtgroup_setup_default(void) static void domain_destroy_mon_state(struct rdt_mon_domain *d) { bitmap_free(d->rmid_busy_llc); - kfree(d->mbm_total); - kfree(d->mbm_local); + for (int i =3D 0; i < QOS_NUM_MBM_EVENTS; i++) { + kfree(d->mbm_states[i]); + d->mbm_states[i] =3D NULL; + } } =20 void resctrl_offline_ctrl_domain(struct rdt_resource *r, struct rdt_ctrl_d= omain *d) @@ -4031,32 +4027,33 @@ void resctrl_offline_mon_domain(struct rdt_resource= *r, struct rdt_mon_domain *d static int domain_setup_mon_state(struct rdt_resource *r, struct rdt_mon_d= omain *d) { u32 idx_limit =3D resctrl_arch_system_num_rmid_idx(); - size_t tsize; + size_t tsize =3D sizeof(struct mbm_state); + int evt, idx; =20 if (resctrl_arch_is_llc_occupancy_enabled()) { d->rmid_busy_llc =3D bitmap_zalloc(idx_limit, GFP_KERNEL); if (!d->rmid_busy_llc) return -ENOMEM; } - if (resctrl_arch_is_mbm_total_enabled()) { - tsize =3D sizeof(*d->mbm_total); - d->mbm_total =3D kcalloc(idx_limit, tsize, GFP_KERNEL); - if (!d->mbm_total) { - bitmap_free(d->rmid_busy_llc); - return -ENOMEM; - } - } - if (resctrl_arch_is_mbm_local_enabled()) { - tsize =3D sizeof(*d->mbm_local); - d->mbm_local =3D kcalloc(idx_limit, tsize, GFP_KERNEL); - if (!d->mbm_local) { - bitmap_free(d->rmid_busy_llc); - kfree(d->mbm_total); - return -ENOMEM; - } + + for_each_set_bit(evt, rdt_mon_features, QOS_NUM_EVENTS) { + if (!resctrl_is_mbm_event(evt)) + continue; + idx =3D MBM_EVENT_IDX(evt); + d->mbm_states[idx] =3D kcalloc(idx_limit, tsize, GFP_KERNEL); + if (!d->mbm_states[idx]) + goto cleanup; } =20 return 0; +cleanup: + bitmap_free(d->rmid_busy_llc); + for (idx =3D 0; idx < QOS_NUM_MBM_EVENTS; idx++) { + kfree(d->mbm_states[idx]); + d->mbm_states[idx] =3D NULL; + } + + return -ENOMEM; } =20 int resctrl_online_ctrl_domain(struct rdt_resource *r, struct rdt_ctrl_dom= ain *d) --=20 2.48.1 From nobody Fri Dec 19 17:08:33 2025 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.13]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D30A0228C9D for ; Mon, 7 Apr 2025 23:40:47 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.13 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1744069249; cv=none; b=h1UeFWrIeU/MSduhfoDP4YYUoq59ro4MiqPLwz7+2XdIf3Mfxan4xEcFBHAQggtqXABjtQm8BgKo0c5Fo8zFE7h4XPPwCyRq/4Dpp7cPzgQWyRokGXXd9Yd05L0EUUwH0+aCiFuk22PRV4U79EfKmYuoaW9hpdan69UDDdGjaO4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1744069249; c=relaxed/simple; bh=PbAmaYUfs3cYnTUyhKKObGUQYfLatjVDLhG5ft36Q3I=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=maq31Qitg/9mbuC908iUF23xBDOqKck+GUvHO388jcJuOo0K4iYSJA/IoztmnRQMB7mJOsh2dYl4FeVSJSkdUdz9p0hC9nogDMgAugojm2TMjzuR1wwGW8JnkPUdKvy++OqXQVSe6oxpzLgSSTCZ15rY/XJzMu1n5FEfT/DTjVc= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com; spf=pass smtp.mailfrom=intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=JEtS3K3f; arc=none smtp.client-ip=192.198.163.13 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="JEtS3K3f" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1744069248; x=1775605248; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=PbAmaYUfs3cYnTUyhKKObGUQYfLatjVDLhG5ft36Q3I=; b=JEtS3K3f0c4ifCuW/RVqTJVEh2TZgR+h1ILuxXqEPqiZDLhitOjrN5W8 hUOqcEu5lNhyc0tQ6dt/9vQnhtwsWH2CwOCtOHu2cjkfrxmLsh73wb5jG 3Hzn6dxhWdV1Ms6HxY4P4n7/LnoF0E7JoJjf7imYSE3OLPdJ5pPpuaGV/ cbhFGFqU8X58PBjhI3511t0RETHjIPmxRDsa9MU7kxnnTxltdFqMd+fRm MI+7XjhOUl+nXYuqoFBLu84Ywwr9xrE70b7sfAlGQaaRWY17cD57zjLDU gmEmZYTCmQuTIARFepZkj++pJ1ZrJ22jR3KRPDFJia+J3VBchU0wpoFPH A==; X-CSE-ConnectionGUID: ZzWIEwueRNqqSiGUetj0Ew== X-CSE-MsgGUID: FfXC6IjaSpSpHgNh1XgiTQ== X-IronPort-AV: E=McAfee;i="6700,10204,11397"; a="48193129" X-IronPort-AV: E=Sophos;i="6.15,196,1739865600"; d="scan'208";a="48193129" Received: from orviesa001.jf.intel.com ([10.64.159.141]) by fmvoesa107.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 07 Apr 2025 16:40:46 -0700 X-CSE-ConnectionGUID: EfZ3o3v/RZWENunGoIdVUw== X-CSE-MsgGUID: RIpgCKW+SHeYXq99PvsPjg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.15,196,1739865600"; d="scan'208";a="165315452" Received: from agluck-desk3.sc.intel.com ([172.25.222.70]) by smtpauth.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 07 Apr 2025 16:40:45 -0700 From: Tony Luck To: Fenghua Yu , Reinette Chatre , Maciej Wieczor-Retman , Peter Newman , James Morse , Babu Moger , Drew Fustini , Dave Martin , Anil Keshavamurthy Cc: linux-kernel@vger.kernel.org, patches@lists.linux.dev, Tony Luck Subject: [PATCH v3 03/26] fs/resctrl: Change how events are initialized Date: Mon, 7 Apr 2025 16:40:05 -0700 Message-ID: <20250407234032.241215-4-tony.luck@intel.com> X-Mailer: git-send-email 2.48.1 In-Reply-To: <20250407234032.241215-1-tony.luck@intel.com> References: <20250407234032.241215-1-tony.luck@intel.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" New monitor events break some assumptions: 1) New events can be in resources other than L3. 2) Enumeration of events may not be complete during early boot. Prepare for events in other resources. Delay building the event lists until first mount of the resctrl file system. Signed-off-by: Tony Luck --- fs/resctrl/internal.h | 3 +++ fs/resctrl/monitor.c | 30 +++++++++++++++++++----------- fs/resctrl/rdtgroup.c | 2 ++ 3 files changed, 24 insertions(+), 11 deletions(-) diff --git a/fs/resctrl/internal.h b/fs/resctrl/internal.h index 7a65ea02d442..08dbf89939ac 100644 --- a/fs/resctrl/internal.h +++ b/fs/resctrl/internal.h @@ -76,6 +76,7 @@ static inline struct rdt_fs_context *rdt_fc2context(struc= t fs_context *fc) */ struct mon_evt { enum resctrl_event_id evtid; + enum resctrl_res_level rid; char *name; bool configurable; struct list_head list; @@ -390,6 +391,8 @@ int rdt_lookup_evtid_by_name(char *name); =20 char *rdt_event_name(enum resctrl_event_id evt); =20 +void resctrl_init_mon_events(void); + #ifdef CONFIG_RESCTRL_FS_PSEUDO_LOCK int rdtgroup_locksetup_enter(struct rdtgroup *rdtgrp); =20 diff --git a/fs/resctrl/monitor.c b/fs/resctrl/monitor.c index 66e613906f3e..472754d082cb 100644 --- a/fs/resctrl/monitor.c +++ b/fs/resctrl/monitor.c @@ -846,14 +846,17 @@ static struct mon_evt all_events[QOS_NUM_EVENTS] =3D { [QOS_L3_OCCUP_EVENT_ID] =3D { .name =3D "llc_occupancy", .evtid =3D QOS_L3_OCCUP_EVENT_ID, + .rid =3D RDT_RESOURCE_L3, }, [QOS_L3_MBM_TOTAL_EVENT_ID] =3D { .name =3D "mbm_total_bytes", .evtid =3D QOS_L3_MBM_TOTAL_EVENT_ID, + .rid =3D RDT_RESOURCE_L3, }, [QOS_L3_MBM_LOCAL_EVENT_ID] =3D { .name =3D "mbm_local_bytes", .evtid =3D QOS_L3_MBM_LOCAL_EVENT_ID, + .rid =3D RDT_RESOURCE_L3, }, }; =20 @@ -878,22 +881,29 @@ char *rdt_event_name(enum resctrl_event_id evt) } =20 /* - * Initialize the event list for the resource. + * Initialize the event list for all mon_capable resources. * - * Note that MBM events are also part of RDT_RESOURCE_L3 resource - * because as per the SDM the total and local memory bandwidth - * are enumerated as part of L3 monitoring. - * - * mon_put_default_kn_priv_all() also assumes monitor events are only supp= orted - * on the L3 resource. + * Called on each mount of the resctrl file system when all + * events have been enumerated. Only needs to build the per-resource + * event lists once. */ -static void l3_mon_evt_init(struct rdt_resource *r) +void resctrl_init_mon_events(void) { + struct rdt_resource *r; + static bool only_once; int evt; =20 - INIT_LIST_HEAD(&r->evt_list); + if (only_once) + return; + only_once =3D true; + + for_each_mon_capable_rdt_resource(r) + INIT_LIST_HEAD(&r->evt_list); =20 for_each_set_bit(evt, rdt_mon_features, QOS_NUM_EVENTS) { + r =3D resctrl_arch_get_resource(all_events[evt].rid); + if (!r->mon_capable) + continue; list_add_tail(&all_events[evt].list, &r->evt_list); } } @@ -922,8 +932,6 @@ int resctrl_mon_resource_init(void) if (ret) return ret; =20 - l3_mon_evt_init(r); - if (resctrl_arch_is_evt_configurable(QOS_L3_MBM_TOTAL_EVENT_ID)) { all_events[QOS_L3_MBM_TOTAL_EVENT_ID].configurable =3D true; resctrl_file_fflags_init("mbm_total_bytes_config", diff --git a/fs/resctrl/rdtgroup.c b/fs/resctrl/rdtgroup.c index 8d15d53fae76..1433fc098a90 100644 --- a/fs/resctrl/rdtgroup.c +++ b/fs/resctrl/rdtgroup.c @@ -2574,6 +2574,8 @@ static int rdt_get_tree(struct fs_context *fc) goto out; } =20 + resctrl_init_mon_events(); + ret =3D rdtgroup_setup_root(ctx); if (ret) goto out; --=20 2.48.1 From nobody Fri Dec 19 17:08:33 2025 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.13]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A39D022A1E9 for ; Mon, 7 Apr 2025 23:40:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.13 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1744069250; cv=none; b=B0xKbsD+YY2UKH2mc5l5fXTmcQ5Oh7WcPXRcqJqLshKyS/e/DyGzzOEWgzazxxDG37/DSxe/W1eo06girHX1Vxg7QPmZRZshEXRD+ZDLR0uQG1HlVTYjrS3ahu2cctIgYdINuZonl71SFcb/ocJCGG6vB53LyS8G7gxBqCo6iVg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1744069250; c=relaxed/simple; bh=lnFgMXtArObRN3GbXncQyTuX28vMzGs5CIA3S4aIH1k=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=jqU87gu+HzNxW3aCmSfdSbx2B2aQVXtbUSilcSzpfL2AGdd/jUPKCrZdtvW625eGaBkpJmD+kdkk4b27VlRzNWYVoDhoXzmRebA7XuALTk4gB+8/mONMVdGgRhILP8lKZ5kbQuNm83Xf8GKkhu3ME2G9V5OUItBHVUQAWZVuz+w= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com; spf=pass smtp.mailfrom=intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=Cuk+L6fr; arc=none smtp.client-ip=192.198.163.13 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="Cuk+L6fr" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1744069249; x=1775605249; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=lnFgMXtArObRN3GbXncQyTuX28vMzGs5CIA3S4aIH1k=; b=Cuk+L6frH5FdixaCjXK8IZfO86APPk+UgzXuS5Z2WvfbmQ5zvwxJeV7A xA7DxFWShnt0WFGhxo9z2iteUCaZzkMQc7DxdFaK2RBV35TT+sImDB3bp wX3PnvixKmIkSScr+BRK0YYGcC9pd+4em9576TVt56HXwtwTtHVzbBgpy XDf8f06+hq8WP51f+HJ7Xwu2pjw0yeG1N00Fv7wXH9oDrTcVoO9sCDuyd im4FTi2BC+BQwiBtg9e5NlhV/ad5FjyfQZb8do2y5pNNZDABRsH03eZJT yEdl1S6XNkSQCQxxcwN1TADMpE3JWrB7llyVVKlg/P4nsj8id74vEWMab g==; X-CSE-ConnectionGUID: 1HxSu7axS7apOsXssJQirA== X-CSE-MsgGUID: pCIfNSrvT7ipMZfdxy1nWA== X-IronPort-AV: E=McAfee;i="6700,10204,11397"; a="48193136" X-IronPort-AV: E=Sophos;i="6.15,196,1739865600"; d="scan'208";a="48193136" Received: from orviesa001.jf.intel.com ([10.64.159.141]) by fmvoesa107.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 07 Apr 2025 16:40:46 -0700 X-CSE-ConnectionGUID: CDHgIGQ8Rc28HnppEKH+FQ== X-CSE-MsgGUID: 98pjoFMHSXKpMXZOdfKK7A== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.15,196,1739865600"; d="scan'208";a="165315455" Received: from agluck-desk3.sc.intel.com ([172.25.222.70]) by smtpauth.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 07 Apr 2025 16:40:45 -0700 From: Tony Luck To: Fenghua Yu , Reinette Chatre , Maciej Wieczor-Retman , Peter Newman , James Morse , Babu Moger , Drew Fustini , Dave Martin , Anil Keshavamurthy Cc: linux-kernel@vger.kernel.org, patches@lists.linux.dev, Tony Luck Subject: [PATCH v3 04/26] fs/resctrl: Set up Kconfig options for telemetry events Date: Mon, 7 Apr 2025 16:40:06 -0700 Message-ID: <20250407234032.241215-5-tony.luck@intel.com> X-Mailer: git-send-email 2.48.1 In-Reply-To: <20250407234032.241215-1-tony.luck@intel.com> References: <20250407234032.241215-1-tony.luck@intel.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Enumeration support is provided by the Intel PMT subsystem. arch/x86 selects this option based on: X86_64: Counter registers are in MMIO space. There is no readq() function on 32-bit. Emulation is possible with readl(), but there are races. Running 32-bit kernels on systems that support this feature seems pointless. CPU_SUP_INTEL: It is an Intel specific feature. Signed-off-by: Tony Luck --- arch/x86/Kconfig | 1 + drivers/platform/x86/intel/pmt/Kconfig | 6 ++++++ 2 files changed, 7 insertions(+) diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig index ea29d22a621f..44a195ee7a42 100644 --- a/arch/x86/Kconfig +++ b/arch/x86/Kconfig @@ -504,6 +504,7 @@ config X86_CPU_RESCTRL bool "x86 CPU resource control support" depends on X86 && (CPU_SUP_INTEL || CPU_SUP_AMD) depends on MISC_FILESYSTEMS + select INTEL_AET_RESCTRL if (X86_64 && CPU_SUP_INTEL) select ARCH_HAS_CPU_RESCTRL select RESCTRL_FS select RESCTRL_FS_PSEUDO_LOCK diff --git a/drivers/platform/x86/intel/pmt/Kconfig b/drivers/platform/x86/= intel/pmt/Kconfig index e916fc966221..b282910b49ef 100644 --- a/drivers/platform/x86/intel/pmt/Kconfig +++ b/drivers/platform/x86/intel/pmt/Kconfig @@ -38,3 +38,9 @@ config INTEL_PMT_CRASHLOG =20 To compile this driver as a module, choose M here: the module will be called intel_pmt_crashlog. + +config INTEL_AET_RESCTRL + bool + help + Architecture config should "select" this option to enable + support for RMID telemtry events in the resctrl file system. --=20 2.48.1 From nobody Fri Dec 19 17:08:33 2025 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.13]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 52D1322A4EE for ; Mon, 7 Apr 2025 23:40:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.13 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1744069251; cv=none; b=Anyoa0Zn7hiwRaKYg3O3X2bC+VmCWmcsz95zKm254HZlIg9hus8RHdLgLo4qzSf/NM4bnz4GpbFH0L2VC7x6SwYHeF50jzgiHJnPDAJ2QMFu5zWTTqxgmwZ/bO0BUaAAAkKrqxUBTefk5Yvhh2daHly5WZxbIidnRLAOOUSu3W8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1744069251; c=relaxed/simple; bh=vIVE737/XLTgSW+CksKOEBZ9uQoVTZtL1sfcscGRMRY=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=R+PvI+pP+EcR3L7XuV+cyCNdGCjKTqwO6J9RqVQ5KITb4VnQvX1v0GDFqu4GWET91oUy+LSeKdD3agIFfCqzhwr2bCbb9PIryjrimec5iUHn2KYPOERpuKxPFKBIXY6jBO1Etql2j346e6nnhwxwrqjneIWJn91VxDyocn0Frv0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com; spf=pass smtp.mailfrom=intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=ZZQwfZ8S; arc=none smtp.client-ip=192.198.163.13 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="ZZQwfZ8S" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1744069249; x=1775605249; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=vIVE737/XLTgSW+CksKOEBZ9uQoVTZtL1sfcscGRMRY=; b=ZZQwfZ8SnnLbiXnK7PlTcLqPMvGjgJAxmjqQQVs3WlSOoOI+yt6SUGjE UkN/NRo+8MRg33rEisrbFtlaI/W/HdQCNgOfJ1LTQT6p1MQAmmzFEQUH6 SbckvzUvnyKJgaHNKJbSMRoc0nM0gAHhjAsVeBZFv/VwE/WyKlQEz5CDe kJlPhkSnyAAXXiXNlYhKnCBuAS12Ue9ZqCv/4N8yoAKaYND6pdU1jDVVA J5GToducV9SdFAB3kXZ9nYnXALpx/d+eE9CfrmYhS+q3cP+wdwt511vYB HsmamHAEXU+0nGlkRXA4F/Y/ngnU4XwptDmV5/PLVGTt+z1KxacEW2nLg Q==; X-CSE-ConnectionGUID: Yc1/HRXyTLm9ixU5EW2A1A== X-CSE-MsgGUID: sxVfP5M7TGWDQ6nfrCGdXw== X-IronPort-AV: E=McAfee;i="6700,10204,11397"; a="48193143" X-IronPort-AV: E=Sophos;i="6.15,196,1739865600"; d="scan'208";a="48193143" Received: from orviesa001.jf.intel.com ([10.64.159.141]) by fmvoesa107.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 07 Apr 2025 16:40:47 -0700 X-CSE-ConnectionGUID: QYB/SaEcS+68bNZvBTmQqw== X-CSE-MsgGUID: 31o7XXgsRNCvV4VOvayxaQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.15,196,1739865600"; d="scan'208";a="165315459" Received: from agluck-desk3.sc.intel.com ([172.25.222.70]) by smtpauth.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 07 Apr 2025 16:40:46 -0700 From: Tony Luck To: Fenghua Yu , Reinette Chatre , Maciej Wieczor-Retman , Peter Newman , James Morse , Babu Moger , Drew Fustini , Dave Martin , Anil Keshavamurthy Cc: linux-kernel@vger.kernel.org, patches@lists.linux.dev, Tony Luck Subject: [PATCH v3 05/26] x86/rectrl: Fake OOBMSM interface Date: Mon, 7 Apr 2025 16:40:07 -0700 Message-ID: <20250407234032.241215-6-tony.luck@intel.com> X-Mailer: git-send-email 2.48.1 In-Reply-To: <20250407234032.241215-1-tony.luck@intel.com> References: <20250407234032.241215-1-tony.luck@intel.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Real version is coming soon ... this is here so the remaining parts will build (and run ... assuming a 2 socket system that supports RDT monitoring ... only missing part is that the event counters just report fixed values). Just for ease of testing and RFC discussion. Signed-off-by: Tony Luck --- .../cpu/resctrl/fake_intel_aet_features.h | 73 ++++++++++++++++ .../cpu/resctrl/fake_intel_aet_features.c | 87 +++++++++++++++++++ arch/x86/kernel/cpu/resctrl/Makefile | 1 + 3 files changed, 161 insertions(+) create mode 100644 arch/x86/kernel/cpu/resctrl/fake_intel_aet_features.h create mode 100644 arch/x86/kernel/cpu/resctrl/fake_intel_aet_features.c diff --git a/arch/x86/kernel/cpu/resctrl/fake_intel_aet_features.h b/arch/x= 86/kernel/cpu/resctrl/fake_intel_aet_features.h new file mode 100644 index 000000000000..c835c4108abc --- /dev/null +++ b/arch/x86/kernel/cpu/resctrl/fake_intel_aet_features.h @@ -0,0 +1,73 @@ +/* SPDX-License-Identifier: GPL-2.0 */ + +/* Bits stolen from OOBMSM VSEC discovery code */ + +enum pmt_feature_id { + FEATURE_INVALID =3D 0x0, + FEATURE_PER_CORE_PERF_TELEM =3D 0x1, + FEATURE_PER_CORE_ENV_TELEM =3D 0x2, + FEATURE_PER_RMID_PERF_TELEM =3D 0x3, + FEATURE_ACCEL_TELEM =3D 0x4, + FEATURE_UNCORE_TELEM =3D 0x5, + FEATURE_CRASH_LOG =3D 0x6, + FEATURE_PETE_LOG =3D 0x7, + FEATURE_TPMI_CTRL =3D 0x8, + FEATURE_RESERVED =3D 0x9, + FEATURE_TRACING =3D 0xA, + FEATURE_PER_RMID_ENERGY_TELEM =3D 0xB, + FEATURE_MAX =3D 0xB, +}; + +/** + * struct oobmsm_plat_info - Platform information for a device instance + * @cdie_mask: Mask of all compute dies in the partition + * @package_id: CPU Package id + * @partition: Package partition id when multiple VSEC PCI devices p= er package + * @segment: PCI segment ID + * @bus_number: PCI bus number + * @device_number: PCI device number + * @function_number: PCI function number + * + * Structure to store platform data for a OOBMSM device instance. + */ +struct oobmsm_plat_info { + u16 cdie_mask; + u8 package_id; + u8 partition; + u8 segment; + u8 bus_number; + u8 device_number; + u8 function_number; +}; + +enum oobmsm_supplier_type { + OOBMSM_SUP_PLAT_INFO, + OOBMSM_SUP_DISC_INFO, + OOBMSM_SUP_S3M_SIMICS, + OOBMSM_SUP_TYPE_MAX +}; + +struct oobmsm_mapping_supplier { + struct device *supplier_dev[OOBMSM_SUP_TYPE_MAX]; + struct oobmsm_plat_info plat_info; + unsigned long features; +}; + +struct telemetry_region { + struct oobmsm_plat_info plat_info; + void __iomem *addr; + size_t size; + u32 guid; + u32 num_rmids; +}; + +struct pmt_feature_group { + enum pmt_feature_id id; + int count; + struct kref kref; + struct telemetry_region regions[]; +}; + +struct pmt_feature_group *intel_pmt_get_regions_by_feature(enum pmt_featur= e_id id); + +void intel_pmt_put_feature_group(struct pmt_feature_group *feature_group); diff --git a/arch/x86/kernel/cpu/resctrl/fake_intel_aet_features.c b/arch/x= 86/kernel/cpu/resctrl/fake_intel_aet_features.c new file mode 100644 index 000000000000..5a16db67c7b8 --- /dev/null +++ b/arch/x86/kernel/cpu/resctrl/fake_intel_aet_features.c @@ -0,0 +1,87 @@ +// SPDX-License-Identifier: GPL-2.0-only +#include +#include +#include +#include "fake_intel_aet_features.h" +#include +#include + +#include "internal.h" + +/* Amount of memory for each fake MMIO space */ +#define ENERGY_QWORDS ((576 * 2) + 3) +#define ENERGY_SIZE (ENERGY_QWORDS * 8) +#define PERF_QWORDS ((576 * 7) + 3) +#define PERF_SIZE (PERF_QWORDS * 8) + +static long pg[4 * ENERGY_QWORDS + 2 * PERF_QWORDS]; + +/* + * Fill the fake MMIO space with all different values, + * all with BIT(63) set to indicate valid entries. + */ +static int __init fill(void) +{ + u64 val =3D 0; + + for (int i =3D 0; i < sizeof(pg); i +=3D sizeof(val)) { + pg[i / sizeof(val)] =3D BIT_ULL(63) + val; + val++; + } + return 0; +} +device_initcall(fill); + +#define PKG_REGION(_entry, _guid, _addr, _size, _pkg, _num_rmids) \ + [_entry] =3D { .guid =3D _guid, .addr =3D (void __iomem *)_addr, \ + .num_rmids =3D _num_rmids, \ + .size =3D _size, .plat_info =3D { .package_id =3D _pkg }} + +/* + * Set up a fake return for call to: + * intel_pmt_get_regions_by_feature(FEATURE_PER_RMID_ENERGY_TELEM); + * Pretend there are two aggregators on each of the sockets to test + * the code that sums over multiple aggregators. + */ +static struct pmt_feature_group fake_energy =3D { + .count =3D 4, + .regions =3D { + PKG_REGION(0, 0x26696143, &pg[0 * ENERGY_QWORDS], ENERGY_SIZE, 0, 64), + PKG_REGION(1, 0x26696143, &pg[1 * ENERGY_QWORDS], ENERGY_SIZE, 0, 64), + PKG_REGION(2, 0x26696143, &pg[2 * ENERGY_QWORDS], ENERGY_SIZE, 1, 64), + PKG_REGION(3, 0x26696143, &pg[3 * ENERGY_QWORDS], ENERGY_SIZE, 1, 64) + } +}; + +/* + * Fake return for: + * intel_pmt_get_regions_by_feature(FEATURE_PER_RMID_PERF_TELEM); + */ +static struct pmt_feature_group fake_perf =3D { + .count =3D 2, + .regions =3D { + PKG_REGION(0, 0x26557651, &pg[4 * ENERGY_QWORDS + 0 * PERF_QWORDS], PERF= _SIZE, 0, 576), + PKG_REGION(1, 0x26557651, &pg[4 * ENERGY_QWORDS + 1 * PERF_QWORDS], PERF= _SIZE, 1, 576) + } +}; + +struct pmt_feature_group * +intel_pmt_get_regions_by_feature(enum pmt_feature_id id) +{ + switch (id) { + case FEATURE_PER_RMID_ENERGY_TELEM: + return &fake_energy; + case FEATURE_PER_RMID_PERF_TELEM: + return &fake_perf; + default: + return ERR_PTR(-ENOENT); + } + return ERR_PTR(-ENOENT); +} + +/* + * Nothing needed for the "put" function. + */ +void intel_pmt_put_feature_group(struct pmt_feature_group *feature_group) +{ +} diff --git a/arch/x86/kernel/cpu/resctrl/Makefile b/arch/x86/kernel/cpu/res= ctrl/Makefile index 909be78ec6da..c56d3acf8ac7 100644 --- a/arch/x86/kernel/cpu/resctrl/Makefile +++ b/arch/x86/kernel/cpu/resctrl/Makefile @@ -1,6 +1,7 @@ # SPDX-License-Identifier: GPL-2.0 obj-$(CONFIG_X86_CPU_RESCTRL) +=3D core.o rdtgroup.o monitor.o obj-$(CONFIG_X86_CPU_RESCTRL) +=3D ctrlmondata.o +obj-$(CONFIG_INTEL_AET_RESCTRL) +=3D fake_intel_aet_features.o obj-$(CONFIG_RESCTRL_FS_PSEUDO_LOCK) +=3D pseudo_lock.o =20 # To allow define_trace.h's recursive include: --=20 2.48.1 From nobody Fri Dec 19 17:08:33 2025 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.13]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 0F9CB22A810 for ; Mon, 7 Apr 2025 23:40:50 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.13 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1744069251; cv=none; b=j7v60JYjKg6DQnFfPrYZLScPeo19Tk8UXbwe0dGCq+JgxO0eO6FOegBryRzqBjGL2FDT51+Iobor05IdDukFj2fycno5MvUx7ZEjvjrgewORDD5IYWXEXVMLTS4z9DYu4dTu3pkv9yV0PiFqgeBClUDjl3hHyWtaWHXjZYA7KQk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1744069251; c=relaxed/simple; bh=fOflmPEON7VNLFevfHomSgOTaVeafcUEUr7FELTDLyw=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=lE5nSI7UH8TenSRx+EKNp2A3V33GdoHDUi+c74PTZxBzIGK0qa4ZxRpaQ5jF85iSrZukUw8iM2MrwNBhP1IXOMEKCT0597brxQDveWq9WaBGajKMGwOG8BO1o8Q6LegTD6meCsz0nC2OaVAOR+RKJBuzUZmBAVBDm0RhttyIZj4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com; spf=pass smtp.mailfrom=intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=n6dc+rQw; arc=none smtp.client-ip=192.198.163.13 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="n6dc+rQw" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1744069250; x=1775605250; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=fOflmPEON7VNLFevfHomSgOTaVeafcUEUr7FELTDLyw=; b=n6dc+rQwa9eNs5foNE1ECYl/d8WhkvtrmQwAVWSDkOJdhvX4OuH0BbMQ IZVKHvb69t88aIQ7TSFoiiVX0N1RbJfhWZXaTELJvQ9VRiR8i4GNxpnm3 BfaugahcD+h5l0ZtxJTymSPD6fty7zvleOmdsl461b4iSskmgHX0QUEis aagVFGyMXmfRr+Ue9f00rHCv9lvOljn9KoIA6DU53KIP4fkgrBhobQy45 8lrnBKTXO5GYEcTgR6selW3aqTPV0SBjSJYTjFdAzwS6bWnZUSG81Aytw HMxwnIuUI2I6195nZw69ixLSAgMZ48SbocN5y67jHvws08jyPud43x1GS A==; X-CSE-ConnectionGUID: kT843onWR2WR5H1i9WizAA== X-CSE-MsgGUID: jaLkzztkSpSp5asjSo6GIA== X-IronPort-AV: E=McAfee;i="6700,10204,11397"; a="48193151" X-IronPort-AV: E=Sophos;i="6.15,196,1739865600"; d="scan'208";a="48193151" Received: from orviesa001.jf.intel.com ([10.64.159.141]) by fmvoesa107.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 07 Apr 2025 16:40:47 -0700 X-CSE-ConnectionGUID: K0UFichZQZ+MXLlBko4r0g== X-CSE-MsgGUID: Jt0TBXEUQsC+NQoujNg68g== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.15,196,1739865600"; d="scan'208";a="165315462" Received: from agluck-desk3.sc.intel.com ([172.25.222.70]) by smtpauth.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 07 Apr 2025 16:40:47 -0700 From: Tony Luck To: Fenghua Yu , Reinette Chatre , Maciej Wieczor-Retman , Peter Newman , James Morse , Babu Moger , Drew Fustini , Dave Martin , Anil Keshavamurthy Cc: linux-kernel@vger.kernel.org, patches@lists.linux.dev, Tony Luck Subject: [PATCH v3 06/26] fs-x86/rectrl: Improve domain type checking Date: Mon, 7 Apr 2025 16:40:08 -0700 Message-ID: <20250407234032.241215-7-tony.luck@intel.com> X-Mailer: git-send-email 2.48.1 In-Reply-To: <20250407234032.241215-1-tony.luck@intel.com> References: <20250407234032.241215-1-tony.luck@intel.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" The rdt_domain_hdr structure is used in both control and monitor domain structures to provide common methods for operations such as adding a CPU to a domain, removing a CPU from a domain, accessing the mask of all CPUs in a domain. The "type" field provides a simple check whether a domain is a control or monitor domain so that programming errors operating on domains will be quickly caught. To prepare for additional domain types that depend on the rdt_resource to which they are connected add the resource id into the type. Signed-off-by: Tony Luck --- include/linux/resctrl.h | 19 ++++++++++--------- arch/x86/kernel/cpu/resctrl/core.c | 12 ++++++------ fs/resctrl/ctrlmondata.c | 2 +- 3 files changed, 17 insertions(+), 16 deletions(-) diff --git a/include/linux/resctrl.h b/include/linux/resctrl.h index d6a926b6fc0e..177f9879bae1 100644 --- a/include/linux/resctrl.h +++ b/include/linux/resctrl.h @@ -111,11 +111,6 @@ struct resctrl_staged_config { bool have_new_ctrl; }; =20 -enum resctrl_domain_type { - RESCTRL_CTRL_DOMAIN, - RESCTRL_MON_DOMAIN, -}; - /** * struct rdt_domain_hdr - common header for different domain types * @list: all instances of this resource @@ -124,12 +119,18 @@ enum resctrl_domain_type { * @cpu_mask: which CPUs share this resource */ struct rdt_domain_hdr { - struct list_head list; - int id; - enum resctrl_domain_type type; - struct cpumask cpu_mask; + struct list_head list; + int id; + u32 type; + struct cpumask cpu_mask; }; =20 +/* Bitfields in rdt_domain_hdr.type */ +#define DOMTYPE_RID GENMASK(8, 0) +#define DOMTYPE_CTRL BIT(9) +#define DOMTYPE_MON BIT(10) +#define DOMTYPE(rid, type) (((rid) & DOMTYPE_RID) | (type)) + /** * struct rdt_ctrl_domain - group of CPUs sharing a resctrl control resour= ce * @hdr: common header for different domain types diff --git a/arch/x86/kernel/cpu/resctrl/core.c b/arch/x86/kernel/cpu/resct= rl/core.c index 6f4a3bd02a42..d82a4a2db699 100644 --- a/arch/x86/kernel/cpu/resctrl/core.c +++ b/arch/x86/kernel/cpu/resctrl/core.c @@ -457,7 +457,7 @@ static void domain_add_cpu_ctrl(int cpu, struct rdt_res= ource *r) =20 hdr =3D resctrl_find_domain(&r->ctrl_domains, id, &add_pos); if (hdr) { - if (WARN_ON_ONCE(hdr->type !=3D RESCTRL_CTRL_DOMAIN)) + if (WARN_ON_ONCE(hdr->type !=3D DOMTYPE(r->rid, DOMTYPE_CTRL))) return; d =3D container_of(hdr, struct rdt_ctrl_domain, hdr); =20 @@ -473,7 +473,7 @@ static void domain_add_cpu_ctrl(int cpu, struct rdt_res= ource *r) =20 d =3D &hw_dom->d_resctrl; d->hdr.id =3D id; - d->hdr.type =3D RESCTRL_CTRL_DOMAIN; + d->hdr.type =3D DOMTYPE(r->rid, DOMTYPE_CTRL); cpumask_set_cpu(cpu, &d->hdr.cpu_mask); =20 rdt_domain_reconfigure_cdp(r); @@ -512,7 +512,7 @@ static void domain_add_cpu_mon(int cpu, struct rdt_reso= urce *r) =20 hdr =3D resctrl_find_domain(&r->mon_domains, id, &add_pos); if (hdr) { - if (WARN_ON_ONCE(hdr->type !=3D RESCTRL_MON_DOMAIN)) + if (WARN_ON_ONCE(hdr->type !=3D DOMTYPE(r->rid, DOMTYPE_MON))) return; d =3D container_of(hdr, struct rdt_mon_domain, hdr); =20 @@ -526,7 +526,7 @@ static void domain_add_cpu_mon(int cpu, struct rdt_reso= urce *r) =20 d =3D &hw_dom->d_resctrl; d->hdr.id =3D id; - d->hdr.type =3D RESCTRL_MON_DOMAIN; + d->hdr.type =3D DOMTYPE(r->rid, DOMTYPE_MON); d->ci =3D get_cpu_cacheinfo_level(cpu, RESCTRL_L3_CACHE); if (!d->ci) { pr_warn_once("Can't find L3 cache for CPU:%d resource %s\n", cpu, r->nam= e); @@ -582,7 +582,7 @@ static void domain_remove_cpu_ctrl(int cpu, struct rdt_= resource *r) return; } =20 - if (WARN_ON_ONCE(hdr->type !=3D RESCTRL_CTRL_DOMAIN)) + if (WARN_ON_ONCE(hdr->type !=3D DOMTYPE(r->rid, DOMTYPE_CTRL))) return; =20 d =3D container_of(hdr, struct rdt_ctrl_domain, hdr); @@ -628,7 +628,7 @@ static void domain_remove_cpu_mon(int cpu, struct rdt_r= esource *r) return; } =20 - if (WARN_ON_ONCE(hdr->type !=3D RESCTRL_MON_DOMAIN)) + if (WARN_ON_ONCE(hdr->type !=3D DOMTYPE(r->rid, DOMTYPE_MON))) return; =20 d =3D container_of(hdr, struct rdt_mon_domain, hdr); diff --git a/fs/resctrl/ctrlmondata.c b/fs/resctrl/ctrlmondata.c index ce02e961a6c3..0c245af0ff42 100644 --- a/fs/resctrl/ctrlmondata.c +++ b/fs/resctrl/ctrlmondata.c @@ -614,7 +614,7 @@ int rdtgroup_mondata_show(struct seq_file *m, void *arg) * the resource to find the domain with "domid". */ hdr =3D resctrl_find_domain(&r->mon_domains, domid, NULL); - if (!hdr || WARN_ON_ONCE(hdr->type !=3D RESCTRL_MON_DOMAIN)) { + if (!hdr || WARN_ON_ONCE(hdr->type !=3D DOMTYPE(r->rid, DOMTYPE_MON))) { ret =3D -ENOENT; goto out; } --=20 2.48.1 From nobody Fri Dec 19 17:08:33 2025 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.13]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A66FC22ACEE for ; Mon, 7 Apr 2025 23:40:50 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.13 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1744069252; cv=none; b=PVlnSEY/q3pQzQTngS47vx9c3fZHER/+1jZeI06fnVVsBf/oYop16axx5XRZsK4zl9rjYWhlnWhueAQwj62LMh4mbUL9JjeyfUUz/3kVeHGqYG0x4N8dgA4VSe/tsJsc8VLwAL+08mn25PvGPu4qWe5uIrVQrLfPG5ghMJ+oLFk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1744069252; c=relaxed/simple; bh=g+/8Y2uc0TuA2I3bexR6A5aqjZ/2NdNAOcXDeZ/avNo=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=SdB/5+NwAYslK0cxK+UuIUypPK5wowDDkWQFBE3HYQ4nv/LXps1/pho7/UmwXpA+/9qoEz951KRAqLRxfYmQPbznGK2hWvT1P3vzzrn1rtyQIqsPF2jQ67GbresFpkjuxRDzRZ3EcoSRwMAC/ACM+jt8iDypVv3cbx9zMV+Cs5o= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com; spf=pass smtp.mailfrom=intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=NvZ0jmwJ; arc=none smtp.client-ip=192.198.163.13 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="NvZ0jmwJ" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1744069251; x=1775605251; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=g+/8Y2uc0TuA2I3bexR6A5aqjZ/2NdNAOcXDeZ/avNo=; b=NvZ0jmwJwX8qmzFdWlfj6lncelOhoUWhqGgL1s1bhr4NHulj8db4Ofit j6x6wucvYAe+83JE8knHD6eT+2E+FsvJKwqvSlNg9H4aNPi4aDOBWqM++ okhkCD+qBuyKQSBKi6sOcNaT4rs3UkXrz+BmppqaBYR0RMZ7Yg6vPXZH7 9IkBB1pIrSUuerIgM1Z7b60DWGENX0c2uiKd2D/o8X7BsmSkmiTMSzCJ4 JskMjtDR5NK9bPbnBhcUNMffP8ejTpkyjJtl9VThBS5tf3YMdg0++a6qP cNrO13KLPEfZoN3v15MV6J+o5pxRBjayPd1fskIFBawrCEabOFIXFtL91 Q==; X-CSE-ConnectionGUID: RiCFP1rHQTq/eALGm6JDGA== X-CSE-MsgGUID: 27O5/+2/QiGE/++HvlSNgA== X-IronPort-AV: E=McAfee;i="6700,10204,11397"; a="48193159" X-IronPort-AV: E=Sophos;i="6.15,196,1739865600"; d="scan'208";a="48193159" Received: from orviesa001.jf.intel.com ([10.64.159.141]) by fmvoesa107.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 07 Apr 2025 16:40:48 -0700 X-CSE-ConnectionGUID: ylIp3db+QfeTmHgfW12LqQ== X-CSE-MsgGUID: HSx07/NKTJGd7tJcayfqIA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.15,196,1739865600"; d="scan'208";a="165315465" Received: from agluck-desk3.sc.intel.com ([172.25.222.70]) by smtpauth.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 07 Apr 2025 16:40:47 -0700 From: Tony Luck To: Fenghua Yu , Reinette Chatre , Maciej Wieczor-Retman , Peter Newman , James Morse , Babu Moger , Drew Fustini , Dave Martin , Anil Keshavamurthy Cc: linux-kernel@vger.kernel.org, patches@lists.linux.dev, Tony Luck Subject: [PATCH v3 07/26] x86/resctrl: Move L3 initialization out of domain_add_cpu_mon() Date: Mon, 7 Apr 2025 16:40:09 -0700 Message-ID: <20250407234032.241215-8-tony.luck@intel.com> X-Mailer: git-send-email 2.48.1 In-Reply-To: <20250407234032.241215-1-tony.luck@intel.com> References: <20250407234032.241215-1-tony.luck@intel.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" To prepare for additional types of monitoring domains, move all the L3 specific initialization into a helper function. Signed-off-by: Tony Luck --- arch/x86/kernel/cpu/resctrl/core.c | 57 ++++++++++++++++++------------ 1 file changed, 35 insertions(+), 22 deletions(-) diff --git a/arch/x86/kernel/cpu/resctrl/core.c b/arch/x86/kernel/cpu/resct= rl/core.c index d82a4a2db699..703423b0be0e 100644 --- a/arch/x86/kernel/cpu/resctrl/core.c +++ b/arch/x86/kernel/cpu/resctrl/core.c @@ -493,33 +493,12 @@ static void domain_add_cpu_ctrl(int cpu, struct rdt_r= esource *r) } } =20 -static void domain_add_cpu_mon(int cpu, struct rdt_resource *r) +static void setup_l3_mon_domain(int cpu, int id, struct rdt_resource *r, s= truct list_head *add_pos) { - int id =3D get_domain_id_from_scope(cpu, r->mon_scope); - struct list_head *add_pos =3D NULL; struct rdt_hw_mon_domain *hw_dom; - struct rdt_domain_hdr *hdr; struct rdt_mon_domain *d; int err; =20 - lockdep_assert_held(&domain_list_lock); - - if (id < 0) { - pr_warn_once("Can't find monitor domain id for CPU:%d scope:%d for resou= rce %s\n", - cpu, r->mon_scope, r->name); - return; - } - - hdr =3D resctrl_find_domain(&r->mon_domains, id, &add_pos); - if (hdr) { - if (WARN_ON_ONCE(hdr->type !=3D DOMTYPE(r->rid, DOMTYPE_MON))) - return; - d =3D container_of(hdr, struct rdt_mon_domain, hdr); - - cpumask_set_cpu(cpu, &d->hdr.cpu_mask); - return; - } - hw_dom =3D kzalloc_node(sizeof(*hw_dom), GFP_KERNEL, cpu_to_node(cpu)); if (!hw_dom) return; @@ -552,6 +531,40 @@ static void domain_add_cpu_mon(int cpu, struct rdt_res= ource *r) } } =20 +static void domain_add_cpu_mon(int cpu, struct rdt_resource *r) +{ + int id =3D get_domain_id_from_scope(cpu, r->mon_scope); + struct list_head *add_pos =3D NULL; + struct rdt_domain_hdr *hdr; + struct rdt_mon_domain *d; + + lockdep_assert_held(&domain_list_lock); + + if (id < 0) { + pr_warn_once("Can't find monitor domain id for CPU:%d scope:%d for resou= rce %s\n", + cpu, r->mon_scope, r->name); + return; + } + + hdr =3D resctrl_find_domain(&r->mon_domains, id, &add_pos); + if (hdr) { + if (WARN_ON_ONCE(hdr->type !=3D DOMTYPE(r->rid, DOMTYPE_MON))) + return; + d =3D container_of(hdr, struct rdt_mon_domain, hdr); + + cpumask_set_cpu(cpu, &d->hdr.cpu_mask); + return; + } + + switch (r->rid) { + case RDT_RESOURCE_L3: + setup_l3_mon_domain(cpu, id, r, add_pos); + break; + default: + WARN_ON_ONCE(1); + } +} + static void domain_add_cpu(int cpu, struct rdt_resource *r) { if (r->alloc_capable) --=20 2.48.1 From nobody Fri Dec 19 17:08:33 2025 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.13]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 84DA922B5B8 for ; Mon, 7 Apr 2025 23:40:51 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.13 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1744069253; cv=none; b=So40oY5qDnfvQbQsIO933W6SWUO9/y6rAeKwRN27yEjETZoY+AzDSSx6DfWhXtCm4/ZGoLZChLV5GN5d8WWcNF3eZ52Q4oehxF9PS/s3AjoYh63LFrnqUiADzb+2SjpSu7cAGTJoKNLr6w/ZYOEtOo8TLbwtlobr2c1AHrvjOKM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1744069253; c=relaxed/simple; bh=ZcpL39/pJu+djv6xLTCjvr5JuzZQWBqesTDoiIZdfxo=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=tlNeuepO9RMoHiTjxsAwdsAfR/XMzttxdZYaAOMCNN2CUT93hkKI7MonoN4Oa4yUXZM/Se4ueUlzQYZRc4S+baRAWww+LGi4PpVh3CINqAkcOv7M6CFqB6ivzZ0wV0XgqPLOsYI/eqhMvCNh14rzrNyBxqPrQZxUf5qa+PE8oKE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com; spf=pass smtp.mailfrom=intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=eMD94Sod; arc=none smtp.client-ip=192.198.163.13 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="eMD94Sod" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1744069252; x=1775605252; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=ZcpL39/pJu+djv6xLTCjvr5JuzZQWBqesTDoiIZdfxo=; b=eMD94SodNU9akduUz+vTIoNE72cXH+lgtDf12jlXZn+JxYGl8QXFG+gm W2/TWBSJ+xFkb8pO5PPCpBjpC+n0JcFajYxeTd/nRJbE0bCxu6D685RYo 2IIGehFE0mJe+lWI1h0rUZQuJVAAkKsJ+5PTPhxiDYCQXr30+6Ig1mTkO rS5Yrg/NbmIVXjC80wKdmHRv+Z6qezA2ay48OPUmEmXazEEUXY4ODZBU0 i+u1plDFQ8ILasuaP1jviHWZLdZReueyaCtIt15P3AUMUpw0r061vBNt/ hBwV9XCoF4vAFzFj17e50m+nrkWXvoUbBtuce+KPAseHfkxd2WdD7vtyQ g==; X-CSE-ConnectionGUID: MzTgDdrTQ/yux1E0ACtBdw== X-CSE-MsgGUID: oTgEmLqOTUKmFOUeNcFBVw== X-IronPort-AV: E=McAfee;i="6700,10204,11397"; a="48193170" X-IronPort-AV: E=Sophos;i="6.15,196,1739865600"; d="scan'208";a="48193170" Received: from orviesa001.jf.intel.com ([10.64.159.141]) by fmvoesa107.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 07 Apr 2025 16:40:48 -0700 X-CSE-ConnectionGUID: 1O/BrV3AQ5eSgi+aq84kfA== X-CSE-MsgGUID: +FOU/zA1SvWWFsSmOql6MA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.15,196,1739865600"; d="scan'208";a="165315469" Received: from agluck-desk3.sc.intel.com ([172.25.222.70]) by smtpauth.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 07 Apr 2025 16:40:48 -0700 From: Tony Luck To: Fenghua Yu , Reinette Chatre , Maciej Wieczor-Retman , Peter Newman , James Morse , Babu Moger , Drew Fustini , Dave Martin , Anil Keshavamurthy Cc: linux-kernel@vger.kernel.org, patches@lists.linux.dev, Tony Luck Subject: [PATCH v3 08/26] x86/resctrl: Refactor domain_remove_cpu_mon() ready for new domain types Date: Mon, 7 Apr 2025 16:40:10 -0700 Message-ID: <20250407234032.241215-9-tony.luck@intel.com> X-Mailer: git-send-email 2.48.1 In-Reply-To: <20250407234032.241215-1-tony.luck@intel.com> References: <20250407234032.241215-1-tony.luck@intel.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Different types of domains require different actions when the last CPU in the domain is removed. Refactor to make it easy to add new actions for new types of domains. Signed-off-by: Tony Luck --- arch/x86/kernel/cpu/resctrl/core.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/arch/x86/kernel/cpu/resctrl/core.c b/arch/x86/kernel/cpu/resct= rl/core.c index 703423b0be0e..7080447028b0 100644 --- a/arch/x86/kernel/cpu/resctrl/core.c +++ b/arch/x86/kernel/cpu/resctrl/core.c @@ -644,17 +644,19 @@ static void domain_remove_cpu_mon(int cpu, struct rdt= _resource *r) if (WARN_ON_ONCE(hdr->type !=3D DOMTYPE(r->rid, DOMTYPE_MON))) return; =20 - d =3D container_of(hdr, struct rdt_mon_domain, hdr); - hw_dom =3D resctrl_to_arch_mon_dom(d); + cpumask_clear_cpu(cpu, &hdr->cpu_mask); + if (!cpumask_empty(&hdr->cpu_mask)) + return; =20 - cpumask_clear_cpu(cpu, &d->hdr.cpu_mask); - if (cpumask_empty(&d->hdr.cpu_mask)) { + switch (r->rid) { + case RDT_RESOURCE_L3: + d =3D container_of(hdr, struct rdt_mon_domain, hdr); + hw_dom =3D resctrl_to_arch_mon_dom(d); resctrl_offline_mon_domain(r, d); list_del_rcu(&d->hdr.list); synchronize_rcu(); mon_domain_free(hw_dom); - - return; + break; } } =20 --=20 2.48.1 From nobody Fri Dec 19 17:08:33 2025 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.13]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 0B49522B8D2 for ; Mon, 7 Apr 2025 23:40:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.13 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1744069254; cv=none; b=lH59GqNAf1Z3sU4laHJO9ifSRT9xsIkMoN2lvURoYBQcICIv6ZBO3SY/VWpZXwsIvvR629GMUXVPbjeYnQWKu5QplB7Bb++Pl7ulAcv+MabRYUuY3Mpmcxl0PDCOkkjwv/sEwqs/6eYYOfJVOUwccEw3qWoX8HNEnFqxEn458/o= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1744069254; c=relaxed/simple; bh=56I57dxP7nb1jp47Io3580er1f+z8I6bCf8dQ5DItMk=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=C8tNFRMiCWuefQRqBWgFGwW8L8+3UE3X6J+zKrCTtpWfHjc0h/QFa5A1DxsnP8NdUZ1KRHPwEVkWXhcRNBU78Ax4Ytpk+EU4zFoRuRrAdUmTMHJTQbxOIP1wfDdMS9JDtH3VI9Ma5OnDltQRHlQuQPO95SYOCElb7UxnYEZtuZ0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com; spf=pass smtp.mailfrom=intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=HXEdUdag; arc=none smtp.client-ip=192.198.163.13 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="HXEdUdag" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1744069252; x=1775605252; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=56I57dxP7nb1jp47Io3580er1f+z8I6bCf8dQ5DItMk=; b=HXEdUdag3W0Nc7+dGTFIo4qHOMdx58NRDBbrhrfNhKRK7nY+379/i9zP BkyGlxnjeQD2wMJ9exCxkpUjwN11wdsgUMtQew3Xx8fkrHtuLy4+PbfSO blARl6e2o7MvZ08/8/aGMt6366XW7Wc2a/+F8p5lNSAYgzrg5c2hxphR8 8veQFPwJ6XzzCz8xKjSA5VIwWLCRx5SVqaFehc/XyqruArYW2gGgOo7it +WKwW7dFc3zpY9T5+a85EwAzsE1Fqr7/hPWYTcnR08dZzd3Th35cErzRW gplGBWHtYL+tsTbt4CSQ9bCxXSkZheZ2bsWpFY0Cq6suXTIJiZr6SUZSR A==; X-CSE-ConnectionGUID: p4SF4/TCRoq/3ruFOr30XA== X-CSE-MsgGUID: azKii0f2Qy+VPJ8Ex9vVog== X-IronPort-AV: E=McAfee;i="6700,10204,11397"; a="48193180" X-IronPort-AV: E=Sophos;i="6.15,196,1739865600"; d="scan'208";a="48193180" Received: from orviesa001.jf.intel.com ([10.64.159.141]) by fmvoesa107.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 07 Apr 2025 16:40:49 -0700 X-CSE-ConnectionGUID: M7VIuIptTDi4ZhWYyxHB9A== X-CSE-MsgGUID: pBqPTrGVQ7yRMLZATntElg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.15,196,1739865600"; d="scan'208";a="165315472" Received: from agluck-desk3.sc.intel.com ([172.25.222.70]) by smtpauth.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 07 Apr 2025 16:40:48 -0700 From: Tony Luck To: Fenghua Yu , Reinette Chatre , Maciej Wieczor-Retman , Peter Newman , James Morse , Babu Moger , Drew Fustini , Dave Martin , Anil Keshavamurthy Cc: linux-kernel@vger.kernel.org, patches@lists.linux.dev, Tony Luck Subject: [PATCH v3 09/26] x86/resctrl: Change generic monitor functions to use struct rdt_domain_hdr Date: Mon, 7 Apr 2025 16:40:11 -0700 Message-ID: <20250407234032.241215-10-tony.luck@intel.com> X-Mailer: git-send-email 2.48.1 In-Reply-To: <20250407234032.241215-1-tony.luck@intel.com> References: <20250407234032.241215-1-tony.luck@intel.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Functions that don't need the internal details of the rdt_mon_domain can operate on just the rdt_domain_hdr. Add sanity checks where container_of() is used to find the surrounding domain structure that hdr has the expected type. Signed-off-by: Tony Luck --- include/linux/resctrl.h | 2 +- arch/x86/kernel/cpu/resctrl/core.c | 2 +- fs/resctrl/rdtgroup.c | 66 +++++++++++++++++++++--------- 3 files changed, 48 insertions(+), 22 deletions(-) diff --git a/include/linux/resctrl.h b/include/linux/resctrl.h index 177f9879bae1..0fce626605b9 100644 --- a/include/linux/resctrl.h +++ b/include/linux/resctrl.h @@ -412,7 +412,7 @@ int resctrl_arch_update_one(struct rdt_resource *r, str= uct rdt_ctrl_domain *d, u32 resctrl_arch_get_config(struct rdt_resource *r, struct rdt_ctrl_domain= *d, u32 closid, enum resctrl_conf_type type); int resctrl_online_ctrl_domain(struct rdt_resource *r, struct rdt_ctrl_dom= ain *d); -int resctrl_online_mon_domain(struct rdt_resource *r, struct rdt_mon_domai= n *d); +int resctrl_online_mon_domain(struct rdt_resource *r, struct rdt_domain_hd= r *hdr); void resctrl_offline_ctrl_domain(struct rdt_resource *r, struct rdt_ctrl_d= omain *d); void resctrl_offline_mon_domain(struct rdt_resource *r, struct rdt_mon_dom= ain *d); void resctrl_online_cpu(unsigned int cpu); diff --git a/arch/x86/kernel/cpu/resctrl/core.c b/arch/x86/kernel/cpu/resct= rl/core.c index 7080447028b0..59844fd7105f 100644 --- a/arch/x86/kernel/cpu/resctrl/core.c +++ b/arch/x86/kernel/cpu/resctrl/core.c @@ -523,7 +523,7 @@ static void setup_l3_mon_domain(int cpu, int id, struct= rdt_resource *r, struct =20 list_add_tail_rcu(&d->hdr.list, add_pos); =20 - err =3D resctrl_online_mon_domain(r, d); + err =3D resctrl_online_mon_domain(r, &d->hdr); if (err) { list_del_rcu(&d->hdr.list); synchronize_rcu(); diff --git a/fs/resctrl/rdtgroup.c b/fs/resctrl/rdtgroup.c index 1433fc098a90..5011e404798a 100644 --- a/fs/resctrl/rdtgroup.c +++ b/fs/resctrl/rdtgroup.c @@ -2990,7 +2990,7 @@ static void mon_rmdir_one_subdir(struct rdtgroup *rdt= grp, char *name, char *subn * when last domain being summed is removed. */ static void rmdir_mondata_subdir_allrdtgrp(struct rdt_resource *r, - struct rdt_mon_domain *d) + struct rdt_domain_hdr *hdr) { struct rdtgroup *prgrp, *crgrp; char subname[32]; @@ -2998,9 +2998,16 @@ static void rmdir_mondata_subdir_allrdtgrp(struct rd= t_resource *r, char name[32]; =20 snc_mode =3D r->mon_scope =3D=3D RESCTRL_L3_NODE; - sprintf(name, "mon_%s_%02d", r->name, snc_mode ? d->ci->id : d->hdr.id); - if (snc_mode) - sprintf(subname, "mon_sub_%s_%02d", r->name, d->hdr.id); + if (snc_mode) { + struct rdt_mon_domain *d; + + WARN_ON_ONCE(hdr->type !=3D DOMTYPE(r->rid, DOMTYPE_MON)); + d =3D container_of(hdr, struct rdt_mon_domain, hdr); + sprintf(name, "mon_%s_%02d", r->name, d->ci->id); + sprintf(subname, "mon_sub_%s_%02d", r->name, hdr->id); + } else { + sprintf(name, "mon_%s_%02d", r->name, hdr->id); + } =20 list_for_each_entry(prgrp, &rdt_all_groups, rdtgroup_list) { mon_rmdir_one_subdir(prgrp, name, subname); @@ -3010,20 +3017,29 @@ static void rmdir_mondata_subdir_allrdtgrp(struct r= dt_resource *r, } } =20 -static int mon_add_all_files(struct kernfs_node *kn, struct rdt_mon_domain= *d, +static int mon_add_all_files(struct kernfs_node *kn, struct rdt_domain_hdr= *hdr, struct rdt_resource *r, struct rdtgroup *prgrp, bool do_sum) { struct rmid_read rr =3D {0}; + struct rdt_mon_domain *d; struct mon_data *priv; struct mon_evt *mevt; + int domid; int ret; =20 if (WARN_ON(list_empty(&r->evt_list))) return -EPERM; =20 + if (r->rid =3D=3D RDT_RESOURCE_L3) { + d =3D container_of(hdr, struct rdt_mon_domain, hdr); + domid =3D do_sum ? d->ci->id : d->hdr.id; + } else { + domid =3D hdr->id; + } + list_for_each_entry(mevt, &r->evt_list, list) { - priv =3D mon_get_kn_priv(r->rid, do_sum ? d->ci->id : d->hdr.id, mevt, d= o_sum); + priv =3D mon_get_kn_priv(r->rid, domid, mevt, do_sum); if (WARN_ON_ONCE(!priv)) return -EINVAL; =20 @@ -3031,7 +3047,7 @@ static int mon_add_all_files(struct kernfs_node *kn, = struct rdt_mon_domain *d, if (ret) return ret; =20 - if (!do_sum && resctrl_is_mbm_event(mevt->evtid)) + if (r->rid =3D=3D RDT_RESOURCE_L3 && !do_sum && resctrl_is_mbm_event(mev= t->evtid)) mon_event_read(&rr, r, d, prgrp, &d->hdr.cpu_mask, mevt->evtid, true); } =20 @@ -3039,10 +3055,11 @@ static int mon_add_all_files(struct kernfs_node *kn= , struct rdt_mon_domain *d, } =20 static int mkdir_mondata_subdir(struct kernfs_node *parent_kn, - struct rdt_mon_domain *d, + struct rdt_domain_hdr *hdr, struct rdt_resource *r, struct rdtgroup *prgrp) { struct kernfs_node *kn, *ckn; + struct rdt_mon_domain *d; char name[32]; bool snc_mode; int ret =3D 0; @@ -3050,7 +3067,13 @@ static int mkdir_mondata_subdir(struct kernfs_node *= parent_kn, lockdep_assert_held(&rdtgroup_mutex); =20 snc_mode =3D r->mon_scope =3D=3D RESCTRL_L3_NODE; - sprintf(name, "mon_%s_%02d", r->name, snc_mode ? d->ci->id : d->hdr.id); + if (snc_mode) { + WARN_ON_ONCE(hdr->type !=3D DOMTYPE(r->rid, DOMTYPE_MON)); + d =3D container_of(hdr, struct rdt_mon_domain, hdr); + sprintf(name, "mon_%s_%02d", r->name, d->ci->id); + } else { + sprintf(name, "mon_%s_%02d", r->name, hdr->id); + } kn =3D kernfs_find_and_get(parent_kn, name); if (kn) { /* @@ -3066,7 +3089,7 @@ static int mkdir_mondata_subdir(struct kernfs_node *p= arent_kn, ret =3D rdtgroup_kn_set_ugid(kn); if (ret) goto out_destroy; - ret =3D mon_add_all_files(kn, d, r, prgrp, snc_mode); + ret =3D mon_add_all_files(kn, hdr, r, prgrp, snc_mode); if (ret) goto out_destroy; } @@ -3083,7 +3106,7 @@ static int mkdir_mondata_subdir(struct kernfs_node *p= arent_kn, if (ret) goto out_destroy; =20 - ret =3D mon_add_all_files(ckn, d, r, prgrp, false); + ret =3D mon_add_all_files(ckn, hdr, r, prgrp, false); if (ret) goto out_destroy; } @@ -3101,7 +3124,7 @@ static int mkdir_mondata_subdir(struct kernfs_node *p= arent_kn, * and "monitor" groups with given domain id. */ static void mkdir_mondata_subdir_allrdtgrp(struct rdt_resource *r, - struct rdt_mon_domain *d) + struct rdt_domain_hdr *hdr) { struct kernfs_node *parent_kn; struct rdtgroup *prgrp, *crgrp; @@ -3109,12 +3132,12 @@ static void mkdir_mondata_subdir_allrdtgrp(struct r= dt_resource *r, =20 list_for_each_entry(prgrp, &rdt_all_groups, rdtgroup_list) { parent_kn =3D prgrp->mon.mon_data_kn; - mkdir_mondata_subdir(parent_kn, d, r, prgrp); + mkdir_mondata_subdir(parent_kn, hdr, r, prgrp); =20 head =3D &prgrp->mon.crdtgrp_list; list_for_each_entry(crgrp, head, mon.crdtgrp_list) { parent_kn =3D crgrp->mon.mon_data_kn; - mkdir_mondata_subdir(parent_kn, d, r, crgrp); + mkdir_mondata_subdir(parent_kn, hdr, r, crgrp); } } } @@ -3123,14 +3146,14 @@ static int mkdir_mondata_subdir_alldom(struct kernf= s_node *parent_kn, struct rdt_resource *r, struct rdtgroup *prgrp) { - struct rdt_mon_domain *dom; + struct rdt_domain_hdr *hdr; int ret; =20 /* Walking r->domains, ensure it can't race with cpuhp */ lockdep_assert_cpus_held(); =20 - list_for_each_entry(dom, &r->mon_domains, hdr.list) { - ret =3D mkdir_mondata_subdir(parent_kn, dom, r, prgrp); + list_for_each_entry(hdr, &r->mon_domains, list) { + ret =3D mkdir_mondata_subdir(parent_kn, hdr, r, prgrp); if (ret) return ret; } @@ -3991,7 +4014,7 @@ void resctrl_offline_mon_domain(struct rdt_resource *= r, struct rdt_mon_domain *d * per domain monitor data directories. */ if (resctrl_mounted && resctrl_arch_mon_capable()) - rmdir_mondata_subdir_allrdtgrp(r, d); + rmdir_mondata_subdir_allrdtgrp(r, &d->hdr); =20 if (resctrl_is_mbm_enabled()) cancel_delayed_work(&d->mbm_over); @@ -4074,10 +4097,13 @@ int resctrl_online_ctrl_domain(struct rdt_resource = *r, struct rdt_ctrl_domain *d return err; } =20 -int resctrl_online_mon_domain(struct rdt_resource *r, struct rdt_mon_domai= n *d) +int resctrl_online_mon_domain(struct rdt_resource *r, struct rdt_domain_hd= r *hdr) { + struct rdt_mon_domain *d; int err; =20 + WARN_ON_ONCE(hdr->type !=3D DOMTYPE(r->rid, DOMTYPE_MON)); + d =3D container_of(hdr, struct rdt_mon_domain, hdr); mutex_lock(&rdtgroup_mutex); =20 err =3D domain_setup_mon_state(r, d); @@ -4100,7 +4126,7 @@ int resctrl_online_mon_domain(struct rdt_resource *r,= struct rdt_mon_domain *d) * If resctrl is mounted, add per domain monitor data directories. */ if (resctrl_mounted && resctrl_arch_mon_capable()) - mkdir_mondata_subdir_allrdtgrp(r, d); + mkdir_mondata_subdir_allrdtgrp(r, hdr); =20 out_unlock: mutex_unlock(&rdtgroup_mutex); --=20 2.48.1 From nobody Fri Dec 19 17:08:33 2025 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.13]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B11FA22ACC6 for ; Mon, 7 Apr 2025 23:40:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.13 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1744069255; cv=none; b=sR0KTKCm80EcB7J+KMP1jdCUDX8gCACObKNbbZQtiEV6kasxlPhxJXDbPMvq7X8bpa5yHNI+urSbOmOM2n8uWmzUV+oUtqRl03Uhr1K0EOVcjuGOLvuWk3AqlszGqR/NIueZnCBthoXUlub/QYMvL0TTht7tvlVtbBtz9USeEIo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1744069255; c=relaxed/simple; bh=8bSyQDBrTZBN7cp28ibrq0ETKIdFfTZjXF1wTd0d0Qg=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=J7CiY5VmakzM9lyfpYY5+ohTLJjyliaH/LRJ9fO5Ti8i3Ug/EXp0Vt07vgA/5NU/VxW7VIg3Fp1e+GcOr7dN1ghg0a0CV9FIh/3DICLf3xEcyJ2RsM0JoBEc8xmX7VinmUKNznIb6aFYYYY9uPfNmozAkqBbNN5XYuKQ+ACQ00w= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com; spf=pass smtp.mailfrom=intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=diOjcwz6; arc=none smtp.client-ip=192.198.163.13 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="diOjcwz6" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1744069253; x=1775605253; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=8bSyQDBrTZBN7cp28ibrq0ETKIdFfTZjXF1wTd0d0Qg=; b=diOjcwz6FaaM2dboS7a2bTKUVWhRtmkSd1gCif23l1ObXTGoyyovVDF+ +q0OZGzT9BJSIYu69YG+nKJ94VZRcToYkojO8jKfOW785vl4pjzTO7Qnb HRM6MD9yO1RBHkeTu/DwzRib4q9VVpkKVRKIKeE9eAt3TmbGyYLS/lmXW GZsP5ondXkmm9LY6vEnFJtduy+8y6EtqarlThL6UJCkVENt1idLV0Yty4 4fOQKJIYcekLP/lqt8BevdkSldih5F+aYv7vpbF/4bijt+7k2BX3olzrq 7kX8O8BAfpRBF/T0azaRix3twynBHqOD5ihyM+fVPQAm3pNBaQUNbsr4N w==; X-CSE-ConnectionGUID: bz5YQc7lTfWhK5nloTuoGg== X-CSE-MsgGUID: 71bDPaVzSaqerhFO2Zr57A== X-IronPort-AV: E=McAfee;i="6700,10204,11397"; a="48193187" X-IronPort-AV: E=Sophos;i="6.15,196,1739865600"; d="scan'208";a="48193187" Received: from orviesa001.jf.intel.com ([10.64.159.141]) by fmvoesa107.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 07 Apr 2025 16:40:49 -0700 X-CSE-ConnectionGUID: B8QZ5sIKQmKaPwtbpfRQIQ== X-CSE-MsgGUID: xJG7wdgvQO2gR/NL0VS+mQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.15,196,1739865600"; d="scan'208";a="165315476" Received: from agluck-desk3.sc.intel.com ([172.25.222.70]) by smtpauth.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 07 Apr 2025 16:40:49 -0700 From: Tony Luck To: Fenghua Yu , Reinette Chatre , Maciej Wieczor-Retman , Peter Newman , James Morse , Babu Moger , Drew Fustini , Dave Martin , Anil Keshavamurthy Cc: linux-kernel@vger.kernel.org, patches@lists.linux.dev, Tony Luck Subject: [PATCH v3 10/26] fs/resctrl: Improve handling for events that can be read from any CPU Date: Mon, 7 Apr 2025 16:40:12 -0700 Message-ID: <20250407234032.241215-11-tony.luck@intel.com> X-Mailer: git-send-email 2.48.1 In-Reply-To: <20250407234032.241215-1-tony.luck@intel.com> References: <20250407234032.241215-1-tony.luck@intel.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Add a flag to each instance of struct mon_event to indicate that there is no need for cross-processor interrupts to read this event from a CPU in a specific rdt_mon_domain. The flag is copied to struct mon_data for ease of access when a user reads an event file invoking rdtgroup_mondata_show(). Copied again into struct rmid_read in mon_event_read() for use by sanity checks in __mon_event_count(). When the flag is set allow choice from cpu_online_mask. This makes the smp_call*() functions default to the current CPU. Suggested-by: James Morse Signed-off-by: Tony Luck --- fs/resctrl/internal.h | 8 +++++++- fs/resctrl/ctrlmondata.c | 10 +++++++--- fs/resctrl/monitor.c | 4 ++-- fs/resctrl/rdtgroup.c | 1 + 4 files changed, 17 insertions(+), 6 deletions(-) diff --git a/fs/resctrl/internal.h b/fs/resctrl/internal.h index 08dbf89939ac..74a77794364d 100644 --- a/fs/resctrl/internal.h +++ b/fs/resctrl/internal.h @@ -72,6 +72,7 @@ static inline struct rdt_fs_context *rdt_fc2context(struc= t fs_context *fc) * @evtid: event id * @name: name of the event * @configurable: true if the event is configurable + * @any_cpu: true if this event can be read from any CPU * @list: entry in &rdt_resource->evt_list */ struct mon_evt { @@ -79,6 +80,7 @@ struct mon_evt { enum resctrl_res_level rid; char *name; bool configurable; + bool any_cpu; struct list_head list; }; =20 @@ -93,6 +95,7 @@ struct mon_evt { * the event file belongs. When @sum is one this * is the id of the L3 cache that all domains to be * summed share. + * @any_cpu: true if this event can be read from any CPU * * Stored in the kernfs kn->priv field, readers and writers must hold * rdtgroup_mutex. @@ -103,6 +106,7 @@ struct mon_data { enum resctrl_event_id evtid; unsigned int sum; unsigned int domid; + bool any_cpu; }; =20 /** @@ -115,6 +119,7 @@ struct mon_data { * domains in @r sharing L3 @ci.id * @evtid: Which monitor event to read. * @first: Initialize MBM counter when true. + * @any_cpu: When true read can be executed on any CPU. * @ci: Cacheinfo for L3. Only set when @d is NULL. Used when summing d= omains. * @err: Error encountered when reading counter. * @val: Returned value of event counter. If @rgrp is a parent resource = group, @@ -129,6 +134,7 @@ struct rmid_read { struct rdt_mon_domain *d; enum resctrl_event_id evtid; bool first; + bool any_cpu; struct cacheinfo *ci; int err; u64 val; @@ -358,7 +364,7 @@ int rdtgroup_mondata_show(struct seq_file *m, void *arg= ); =20 void mon_event_read(struct rmid_read *rr, struct rdt_resource *r, struct rdt_mon_domain *d, struct rdtgroup *rdtgrp, - cpumask_t *cpumask, int evtid, int first); + const cpumask_t *cpumask, int evtid, int first); =20 int resctrl_mon_resource_init(void); =20 diff --git a/fs/resctrl/ctrlmondata.c b/fs/resctrl/ctrlmondata.c index 0c245af0ff42..cd77960657f0 100644 --- a/fs/resctrl/ctrlmondata.c +++ b/fs/resctrl/ctrlmondata.c @@ -525,7 +525,7 @@ struct rdt_domain_hdr *resctrl_find_domain(struct list_= head *h, int id, =20 void mon_event_read(struct rmid_read *rr, struct rdt_resource *r, struct rdt_mon_domain *d, struct rdtgroup *rdtgrp, - cpumask_t *cpumask, int evtid, int first) + const cpumask_t *cpumask, int evtid, int first) { int cpu; =20 @@ -571,6 +571,7 @@ int rdtgroup_mondata_show(struct seq_file *m, void *arg) u32 resid, evtid, domid; struct rdtgroup *rdtgrp; struct rdt_resource *r; + const cpumask_t *mask; struct mon_data *md; int ret =3D 0; =20 @@ -589,6 +590,7 @@ int rdtgroup_mondata_show(struct seq_file *m, void *arg) resid =3D md->rid; domid =3D md->domid; evtid =3D md->evtid; + rr.any_cpu =3D md->any_cpu; r =3D resctrl_arch_get_resource(resid); =20 if (md->sum) { @@ -601,8 +603,9 @@ int rdtgroup_mondata_show(struct seq_file *m, void *arg) list_for_each_entry(d, &r->mon_domains, hdr.list) { if (d->ci->id =3D=3D domid) { rr.ci =3D d->ci; + mask =3D md->any_cpu ? cpu_online_mask : &d->ci->shared_cpu_map; mon_event_read(&rr, r, NULL, rdtgrp, - &d->ci->shared_cpu_map, evtid, false); + mask, evtid, false); goto checkresult; } } @@ -619,7 +622,8 @@ int rdtgroup_mondata_show(struct seq_file *m, void *arg) goto out; } d =3D container_of(hdr, struct rdt_mon_domain, hdr); - mon_event_read(&rr, r, d, rdtgrp, &d->hdr.cpu_mask, evtid, false); + mask =3D md->any_cpu ? cpu_online_mask : &d->hdr.cpu_mask; + mon_event_read(&rr, r, d, rdtgrp, mask, evtid, false); } =20 checkresult: diff --git a/fs/resctrl/monitor.c b/fs/resctrl/monitor.c index 472754d082cb..1cf0b085e07a 100644 --- a/fs/resctrl/monitor.c +++ b/fs/resctrl/monitor.c @@ -375,7 +375,7 @@ static int __mon_event_count(u32 closid, u32 rmid, stru= ct rmid_read *rr) =20 if (rr->d) { /* Reading a single domain, must be on a CPU in that domain. */ - if (!cpumask_test_cpu(cpu, &rr->d->hdr.cpu_mask)) + if (!rr->any_cpu && !cpumask_test_cpu(cpu, &rr->d->hdr.cpu_mask)) return -EINVAL; rr->err =3D resctrl_arch_rmid_read(rr->r, rr->d, closid, rmid, rr->evtid, &tval, rr->arch_mon_ctx); @@ -388,7 +388,7 @@ static int __mon_event_count(u32 closid, u32 rmid, stru= ct rmid_read *rr) } =20 /* Summing domains that share a cache, must be on a CPU for that cache. */ - if (!cpumask_test_cpu(cpu, &rr->ci->shared_cpu_map)) + if (!rr->any_cpu && !cpumask_test_cpu(cpu, &rr->ci->shared_cpu_map)) return -EINVAL; =20 /* diff --git a/fs/resctrl/rdtgroup.c b/fs/resctrl/rdtgroup.c index 5011e404798a..97c2ba8af930 100644 --- a/fs/resctrl/rdtgroup.c +++ b/fs/resctrl/rdtgroup.c @@ -2926,6 +2926,7 @@ static struct mon_data *mon_get_kn_priv(int rid, int = domid, struct mon_evt *mevt priv->domid =3D domid; priv->sum =3D do_sum; priv->evtid =3D mevt->evtid; + priv->any_cpu =3D mevt->any_cpu; list_add_tail(&priv->list, &kn_priv_list); =20 return priv; --=20 2.48.1 From nobody Fri Dec 19 17:08:33 2025 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.13]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id AB85122D4C6 for ; Mon, 7 Apr 2025 23:40:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.13 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1744069255; cv=none; b=Qdh37UKXgQzg+4RT4ySQelIJY4xvq7hFKMiddrWd+em3RURnX95/icmY7lwtUIRtUTVB+I0/7Nn2vYdm0K17TI868rK+mml7GqvlYJOne2hD0HpyAgaWXLzijdMX2qhGBmA93WMIENliWyKBGZ8+6KAFek8c8MiwYUlMPR1C7r0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1744069255; c=relaxed/simple; bh=1icKE0bniMiuJhJCyj7+IYsrPql8p3uvDM3vCIF6VoQ=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=I7Ti6CPjRk8irV8nZM+QWPGcBpjVzdwzLyT093M65Biw+xGp9jzACF/8c5hx5GsvBoNCb6RPi/SWXgRkPzUWUvPvxMvriOrIwtngLaACvNkSiXOXPHXwlZSwZPxwgvCfLYZfuiSqL7FErlCRJh4jElP3i08Lb8Jfb1YGaGQQlEY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com; spf=pass smtp.mailfrom=intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=Ja69zNJt; arc=none smtp.client-ip=192.198.163.13 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="Ja69zNJt" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1744069254; x=1775605254; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=1icKE0bniMiuJhJCyj7+IYsrPql8p3uvDM3vCIF6VoQ=; b=Ja69zNJteHQBu2GbUXGShfX5QYl6O/eJhOdIpDkTsJsjncHqx+sSzQ8R 9r0HG/JcV33gK5Tb0HZrtOdy2sLUbavSq4P3zo+cemaEAsPNCFLYgACVu Q74syiS/I8ziDHADB+/ZvC88NHx/uIayzNhzru8cu89e0Modw8BLJpzAW qL6/D7J66aYJubay2U9xanpGdxD/QGXueiMS3anPyJBahUilB6i5fScLx 0cvdzlbBbdxYynievQlCoOc84JjQo5BVEs3ufgVElbnPjVfH2gjObfcyM pEhoQMLtbCK4Z6axHwUWstNg1SDp/EqJCJaUFWcI9DO2TM583+2S3zdim g==; X-CSE-ConnectionGUID: iYbNwgMCQpKgOwbUtiWk8g== X-CSE-MsgGUID: jPJ71MLFSkGwhxdRL7EXfQ== X-IronPort-AV: E=McAfee;i="6700,10204,11397"; a="48193194" X-IronPort-AV: E=Sophos;i="6.15,196,1739865600"; d="scan'208";a="48193194" Received: from orviesa001.jf.intel.com ([10.64.159.141]) by fmvoesa107.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 07 Apr 2025 16:40:50 -0700 X-CSE-ConnectionGUID: 6w+55wZxQ6u9aSJ2wQfPRQ== X-CSE-MsgGUID: arwLGiF2RuOu/F4pxhPYiQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.15,196,1739865600"; d="scan'208";a="165315479" Received: from agluck-desk3.sc.intel.com ([172.25.222.70]) by smtpauth.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 07 Apr 2025 16:40:49 -0700 From: Tony Luck To: Fenghua Yu , Reinette Chatre , Maciej Wieczor-Retman , Peter Newman , James Morse , Babu Moger , Drew Fustini , Dave Martin , Anil Keshavamurthy Cc: linux-kernel@vger.kernel.org, patches@lists.linux.dev, Tony Luck Subject: [PATCH v3 11/26] fs/resctrl: Add support for additional monitor event display formats Date: Mon, 7 Apr 2025 16:40:13 -0700 Message-ID: <20250407234032.241215-12-tony.luck@intel.com> X-Mailer: git-send-email 2.48.1 In-Reply-To: <20250407234032.241215-1-tony.luck@intel.com> References: <20250407234032.241215-1-tony.luck@intel.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Add a type field to both the mon_evt and mon_data structures. Legacy monitor events are still all displayed as an unsigned decimal 64-bit integer. Add an additional format of fixed-point with 18 binary places displayed as a floating point value with six decimal places. Signed-off-by: Tony Luck --- include/linux/resctrl_types.h | 8 ++++++++ fs/resctrl/internal.h | 4 ++++ fs/resctrl/ctrlmondata.c | 23 ++++++++++++++++++++++- fs/resctrl/monitor.c | 3 +++ fs/resctrl/rdtgroup.c | 1 + 5 files changed, 38 insertions(+), 1 deletion(-) diff --git a/include/linux/resctrl_types.h b/include/linux/resctrl_types.h index 898068a99ef7..fbd4b55c41aa 100644 --- a/include/linux/resctrl_types.h +++ b/include/linux/resctrl_types.h @@ -58,6 +58,14 @@ enum resctrl_event_id { #define QOS_NUM_MBM_EVENTS (QOS_L3_MBM_LOCAL_EVENT_ID - QOS_L3_MBM_TOTAL_E= VENT_ID + 1) #define MBM_EVENT_IDX(evt) ((evt) - QOS_L3_MBM_TOTAL_EVENT_ID) =20 +/* + * Event value display types + */ +enum resctrl_event_type { + EVT_TYPE_U64, + EVT_TYPE_U46_18, +}; + static inline bool resctrl_is_mbm_event(int e) { return (e >=3D QOS_L3_MBM_TOTAL_EVENT_ID && diff --git a/fs/resctrl/internal.h b/fs/resctrl/internal.h index 74a77794364d..4a840e683e96 100644 --- a/fs/resctrl/internal.h +++ b/fs/resctrl/internal.h @@ -71,6 +71,7 @@ static inline struct rdt_fs_context *rdt_fc2context(struc= t fs_context *fc) * struct mon_evt - Entry in the event list of a resource * @evtid: event id * @name: name of the event + * @type: format for display to user * @configurable: true if the event is configurable * @any_cpu: true if this event can be read from any CPU * @list: entry in &rdt_resource->evt_list @@ -79,6 +80,7 @@ struct mon_evt { enum resctrl_event_id evtid; enum resctrl_res_level rid; char *name; + enum resctrl_event_type type; bool configurable; bool any_cpu; struct list_head list; @@ -89,6 +91,7 @@ struct mon_evt { * @list: List of all allocated structures. * @rid: Resource id associated with the event file. * @evtid: Event id associated with the event file. + * @type: Format for display to user * @sum: Set when event must be summed across multiple * domains. * @domid: When @sum is zero this is the domain to which @@ -104,6 +107,7 @@ struct mon_data { struct list_head list; unsigned int rid; enum resctrl_event_id evtid; + enum resctrl_event_type type; unsigned int sum; unsigned int domid; bool any_cpu; diff --git a/fs/resctrl/ctrlmondata.c b/fs/resctrl/ctrlmondata.c index cd77960657f0..5ea8113c96ac 100644 --- a/fs/resctrl/ctrlmondata.c +++ b/fs/resctrl/ctrlmondata.c @@ -562,6 +562,27 @@ void mon_event_read(struct rmid_read *rr, struct rdt_r= esource *r, resctrl_arch_mon_ctx_free(r, evtid, rr->arch_mon_ctx); } =20 +#define NUM_FRAC_BITS 18 +#define FRAC_MASK GENMASK(NUM_FRAC_BITS - 1, 0) + +static void show_value(struct seq_file *m, enum resctrl_event_type type, u= 64 val) +{ + u64 frac; + + switch (type) { + case EVT_TYPE_U64: + seq_printf(m, "%llu\n", val); + break; + case EVT_TYPE_U46_18: + frac =3D val & FRAC_MASK; + frac =3D frac * 1000000; + frac +=3D 1ul << (NUM_FRAC_BITS - 1); + frac >>=3D NUM_FRAC_BITS; + seq_printf(m, "%llu.%06llu\n", val >> NUM_FRAC_BITS, frac); + break; + } +} + int rdtgroup_mondata_show(struct seq_file *m, void *arg) { struct kernfs_open_file *of =3D m->private; @@ -633,7 +654,7 @@ int rdtgroup_mondata_show(struct seq_file *m, void *arg) else if (rr.err =3D=3D -EINVAL) seq_puts(m, "Unavailable\n"); else - seq_printf(m, "%llu\n", rr.val); + show_value(m, md->type, rr.val); =20 out: rdtgroup_kn_unlock(of->kn); diff --git a/fs/resctrl/monitor.c b/fs/resctrl/monitor.c index 1cf0b085e07a..1efad57d1d85 100644 --- a/fs/resctrl/monitor.c +++ b/fs/resctrl/monitor.c @@ -847,16 +847,19 @@ static struct mon_evt all_events[QOS_NUM_EVENTS] =3D { .name =3D "llc_occupancy", .evtid =3D QOS_L3_OCCUP_EVENT_ID, .rid =3D RDT_RESOURCE_L3, + .type =3D EVT_TYPE_U64, }, [QOS_L3_MBM_TOTAL_EVENT_ID] =3D { .name =3D "mbm_total_bytes", .evtid =3D QOS_L3_MBM_TOTAL_EVENT_ID, .rid =3D RDT_RESOURCE_L3, + .type =3D EVT_TYPE_U64, }, [QOS_L3_MBM_LOCAL_EVENT_ID] =3D { .name =3D "mbm_local_bytes", .evtid =3D QOS_L3_MBM_LOCAL_EVENT_ID, .rid =3D RDT_RESOURCE_L3, + .type =3D EVT_TYPE_U64, }, }; =20 diff --git a/fs/resctrl/rdtgroup.c b/fs/resctrl/rdtgroup.c index 97c2ba8af930..bd41f7a0f416 100644 --- a/fs/resctrl/rdtgroup.c +++ b/fs/resctrl/rdtgroup.c @@ -2927,6 +2927,7 @@ static struct mon_data *mon_get_kn_priv(int rid, int = domid, struct mon_evt *mevt priv->sum =3D do_sum; priv->evtid =3D mevt->evtid; priv->any_cpu =3D mevt->any_cpu; + priv->type =3D mevt->type; list_add_tail(&priv->list, &kn_priv_list); =20 return priv; --=20 2.48.1 From nobody Fri Dec 19 17:08:33 2025 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.13]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 9B5B222D786 for ; Mon, 7 Apr 2025 23:40:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.13 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1744069256; cv=none; b=D+b5esFW2l6Nq8iSwIBAs1xMdLz2XGh4eCRsihA7mcaHEvw5VIzy2kyyGPeWs9ycM4/QjXSckTBZIra+wrT4rVePL7lXrJv5uRPGTdSmtVQuH05YqIZTB2V2TaafA2AtTOViH2uCJaS+5liI/MJ9nA/QX8TSXDAnuKyTJ+Jn+Iw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1744069256; c=relaxed/simple; bh=VfHjgFdJazMMHE4237qTcYtk4/5M6s7Jls2ygjhzuhE=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=R3QvuGunMweHw5skpikYv8Ghxeh3XbDEtLkKeGwqLdx5MlrTlsj/y6JC7GIjSpoyomogilqH8nmFJBqg5GDj4gEYYrCg3OJYWvTW8z2qJ2ZXWawiupFv6zDXqx95x1UH/Rr4Z5heevoSqGNeqfE2sA9Vt9JvItf5kyXEtApcu3o= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com; spf=pass smtp.mailfrom=intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=YD5fsmcI; arc=none smtp.client-ip=192.198.163.13 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="YD5fsmcI" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1744069255; x=1775605255; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=VfHjgFdJazMMHE4237qTcYtk4/5M6s7Jls2ygjhzuhE=; b=YD5fsmcI1JimB4dX9phiXQ3tC8tscIxHNc9KgjSzD4AWzv6WunroZbgV mttNhjoUNmjJi93iQ4567gclo20X+FFuOWRB5hQtAEz95Rw24Wuq3OnSj G5KqP8FmP9PLyuIl+Z7QKy+nbk4GnZpji2mKFi2JxdLpA27bIcWc6z4Td aYrYIMdPkc6sDOgf2LeJAsGG5xrCTRFMJMxfdlri5Xj+LbGOYBitUvhal pHPZ9f9g8XokyjQYxPixkDKgCzE/k4Drs0RrQu6c4qTN8m0Lt+LeHfpRO /NlZUq/P24+YQu0bLab9gbSBZgLdjVJjt8b7mIPrV8oYDiLHBaOWRaNTe Q==; X-CSE-ConnectionGUID: lVYzGzxvRkaO7iQ5jKh83Q== X-CSE-MsgGUID: VkdM+GzHSw+gLQor+JHECQ== X-IronPort-AV: E=McAfee;i="6700,10204,11397"; a="48193201" X-IronPort-AV: E=Sophos;i="6.15,196,1739865600"; d="scan'208";a="48193201" Received: from orviesa001.jf.intel.com ([10.64.159.141]) by fmvoesa107.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 07 Apr 2025 16:40:51 -0700 X-CSE-ConnectionGUID: 6t46yy/eQMyJZyQ/RpVa7g== X-CSE-MsgGUID: ar7dh7HIRLOECgKO229nEg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.15,196,1739865600"; d="scan'208";a="165315483" Received: from agluck-desk3.sc.intel.com ([172.25.222.70]) by smtpauth.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 07 Apr 2025 16:40:50 -0700 From: Tony Luck To: Fenghua Yu , Reinette Chatre , Maciej Wieczor-Retman , Peter Newman , James Morse , Babu Moger , Drew Fustini , Dave Martin , Anil Keshavamurthy Cc: linux-kernel@vger.kernel.org, patches@lists.linux.dev, Tony Luck Subject: [PATCH v3 12/26] fs/resctrl: Add hook for architecture code to set monitor event attributes Date: Mon, 7 Apr 2025 16:40:14 -0700 Message-ID: <20250407234032.241215-13-tony.luck@intel.com> X-Mailer: git-send-email 2.48.1 In-Reply-To: <20250407234032.241215-1-tony.luck@intel.com> References: <20250407234032.241215-1-tony.luck@intel.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Architecture code knows whether an event can be read from any CPU, or from a CPU on a specific domain. It also knows what format to use when printing each event value. Add a hook to set mon_event.any_cpu and mon_event.type. Signed-off-by: Tony Luck --- include/linux/resctrl.h | 3 +++ fs/resctrl/monitor.c | 12 ++++++++++++ 2 files changed, 15 insertions(+) diff --git a/include/linux/resctrl.h b/include/linux/resctrl.h index 0fce626605b9..8ac77b738de5 100644 --- a/include/linux/resctrl.h +++ b/include/linux/resctrl.h @@ -418,6 +418,9 @@ void resctrl_offline_mon_domain(struct rdt_resource *r,= struct rdt_mon_domain *d void resctrl_online_cpu(unsigned int cpu); void resctrl_offline_cpu(unsigned int cpu); =20 +int resctrl_set_event_attributes(enum resctrl_event_id evt, + enum resctrl_event_type type, bool any_cpu); + /** * resctrl_arch_rmid_read() - Read the eventid counter corresponding to rm= id * for this resource and domain. diff --git a/fs/resctrl/monitor.c b/fs/resctrl/monitor.c index 1efad57d1d85..5846a13c631a 100644 --- a/fs/resctrl/monitor.c +++ b/fs/resctrl/monitor.c @@ -863,6 +863,18 @@ static struct mon_evt all_events[QOS_NUM_EVENTS] =3D { }, }; =20 +int resctrl_set_event_attributes(enum resctrl_event_id evt, + enum resctrl_event_type type, bool any_cpu) +{ + if (evt >=3D QOS_NUM_EVENTS) + return -ENOENT; + + all_events[evt].type =3D type; + all_events[evt].any_cpu =3D any_cpu; + + return 0; +} + int rdt_lookup_evtid_by_name(char *name) { int evt; --=20 2.48.1 From nobody Fri Dec 19 17:08:33 2025 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.13]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 278A322D7B0 for ; Mon, 7 Apr 2025 23:40:55 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.13 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1744069257; cv=none; b=dXt+IDy205nPh6RAlJd3gdwLRsP5l6qXoFS3UXnif0Qy8sO74FVA6dcYoGlbeHdZk1YOuHw+fJkWeC2dSCLQ+irKou+qOpxaKcXB5+wBRCBiAzCW+DhQpS1fmCudTM9rX5lH7jNBFcLl8M+tOrxSLeTGNTFzqRd1H7YZiybNffw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1744069257; c=relaxed/simple; bh=FH4fm+YFMpdxaCRCCGQAHD19eZAKYvKow7hQiaY7EVs=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=pc2Qq3F0MkZ21o2eyFUf9U6Ver7XA29DmBfVYrkIzFSY+djsL9Aq6lhanN/4lt2v1s2BO9Ou+gncTKChzlaIXa4s7gkWcfA91B/lq0dktl8LMAFNRoC/jp7jt+IkEYvLesqnlI9JJN7yn5rLhdyRTMzfo2T0csEHXHnI3h/n1dE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com; spf=pass smtp.mailfrom=intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=QNcM8hPc; arc=none smtp.client-ip=192.198.163.13 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="QNcM8hPc" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1744069255; x=1775605255; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=FH4fm+YFMpdxaCRCCGQAHD19eZAKYvKow7hQiaY7EVs=; b=QNcM8hPc5ZqPKmK8syuuTCOWcJDxzD9xszZFfkMiRShaQ/9vwhLikyeV +z6oktSpE5DPqla1rWyJhqg5jocbqKKeieLJ3q7Lt1iDk9sdNA9g6a/g4 e2VSHQAiqNtSRIw2YadkKJ6700NztU9OHFXQJl71yyWoDZww6cV4zJ5bg SOP/W8P1IShuJzaToK/y2uuP96R0CLs7G3PVaHoH6Ai5s2iAuDDh8LYQQ Nzz7dzc9W8thChOgMvkq0zZZ44mHZ8lZcSfW7ZIaDAi0D12Jd8yk6g+fw PbXYobU5Xy/ADoYseuWamtH4Z09sxwQL1ESco4rXeiQZkXID99a8TRnke A==; X-CSE-ConnectionGUID: fny42dJwQcOTd3x1q0QgPA== X-CSE-MsgGUID: AYXR0FWjQ06BQcID2ffk9g== X-IronPort-AV: E=McAfee;i="6700,10204,11397"; a="48193209" X-IronPort-AV: E=Sophos;i="6.15,196,1739865600"; d="scan'208";a="48193209" Received: from orviesa001.jf.intel.com ([10.64.159.141]) by fmvoesa107.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 07 Apr 2025 16:40:51 -0700 X-CSE-ConnectionGUID: uxzFegGjT0iniZpR9xejLw== X-CSE-MsgGUID: uP6oC0ZCRtanI5AHXAgjww== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.15,196,1739865600"; d="scan'208";a="165315487" Received: from agluck-desk3.sc.intel.com ([172.25.222.70]) by smtpauth.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 07 Apr 2025 16:40:51 -0700 From: Tony Luck To: Fenghua Yu , Reinette Chatre , Maciej Wieczor-Retman , Peter Newman , James Morse , Babu Moger , Drew Fustini , Dave Martin , Anil Keshavamurthy Cc: linux-kernel@vger.kernel.org, patches@lists.linux.dev, Tony Luck Subject: [PATCH v3 13/26] fs/resctrl: Add an architectural hook called for each mount Date: Mon, 7 Apr 2025 16:40:15 -0700 Message-ID: <20250407234032.241215-14-tony.luck@intel.com> X-Mailer: git-send-email 2.48.1 In-Reply-To: <20250407234032.241215-1-tony.luck@intel.com> References: <20250407234032.241215-1-tony.luck@intel.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Enumeration of Intel telemetry events is not complete when the resctrl "late_init" code is executed. Add a hook at the beginning of the mount code that will be used to check for telemetry events and initialize if any are found. The hook is called on every mount. But expectations are that most actions (like enumeration) will only need to be performed on the first call. Signed-off-by: Tony Luck --- include/linux/resctrl.h | 3 +++ arch/x86/kernel/cpu/resctrl/core.c | 9 +++++++++ fs/resctrl/rdtgroup.c | 2 ++ 3 files changed, 14 insertions(+) diff --git a/include/linux/resctrl.h b/include/linux/resctrl.h index 8ac77b738de5..25f51a57b0b7 100644 --- a/include/linux/resctrl.h +++ b/include/linux/resctrl.h @@ -421,6 +421,9 @@ void resctrl_offline_cpu(unsigned int cpu); int resctrl_set_event_attributes(enum resctrl_event_id evt, enum resctrl_event_type type, bool any_cpu); =20 +/* Architecture hook called for each file system mount */ +void resctrl_arch_mount(void); + /** * resctrl_arch_rmid_read() - Read the eventid counter corresponding to rm= id * for this resource and domain. diff --git a/arch/x86/kernel/cpu/resctrl/core.c b/arch/x86/kernel/cpu/resct= rl/core.c index 59844fd7105f..a066a9c54a1f 100644 --- a/arch/x86/kernel/cpu/resctrl/core.c +++ b/arch/x86/kernel/cpu/resctrl/core.c @@ -711,6 +711,15 @@ static int resctrl_arch_offline_cpu(unsigned int cpu) return 0; } =20 +void resctrl_arch_mount(void) +{ + static bool only_once; + + if (only_once) + return; + only_once =3D true; +} + enum { RDT_FLAG_CMT, RDT_FLAG_MBM_TOTAL, diff --git a/fs/resctrl/rdtgroup.c b/fs/resctrl/rdtgroup.c index bd41f7a0f416..5ca6de6a6e5c 100644 --- a/fs/resctrl/rdtgroup.c +++ b/fs/resctrl/rdtgroup.c @@ -2564,6 +2564,8 @@ static int rdt_get_tree(struct fs_context *fc) struct rdt_resource *r; int ret; =20 + resctrl_arch_mount(); + cpus_read_lock(); mutex_lock(&rdtgroup_mutex); /* --=20 2.48.1 From nobody Fri Dec 19 17:08:33 2025 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.13]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 0A60022E00E for ; Mon, 7 Apr 2025 23:40:55 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.13 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1744069258; cv=none; b=jtrszsOyBczifLLCQ7h6jzv/NxZpk8APTCOZ/+wyqzUoiU1IUnPgm78IY7Psm/RlSbIhmeAAmqMcRydzEQ3tLdRoMgr9I4YNZHIiTBaHSwhNUyPCzQjr4ykrrJCkanHRoTTETriYMve8deHV4bpIhABy5FBpdYI0yekjL3CxuBQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1744069258; c=relaxed/simple; bh=D+/doTh4X9NPl3WJ6EQtZZeiH6Fnf/tvGghmhvlFsHA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=jeX8EwyrRQ2+91hemFwXL8fTDHp37bmXQKCAeECKkBltnP/JERNok0/h/jza2DbRPgj9pORduNxZ0ndtGsXToobPMKH+Jw8uEbM5SiZlFxDLqv/vIC2MlQ/eciSIZ2xKEIBAsLa/JrrczHnE2uzdhUUDpBVPzfUb38YW8XTszQA= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com; spf=pass smtp.mailfrom=intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=ZFeb+SpB; arc=none smtp.client-ip=192.198.163.13 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="ZFeb+SpB" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1744069256; x=1775605256; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=D+/doTh4X9NPl3WJ6EQtZZeiH6Fnf/tvGghmhvlFsHA=; b=ZFeb+SpBTt1QNz9MAQCBn7nRyRsuaarquoT3sxt4pqoeQYXhvNpJnWfs AjZblcmV7vJlcRyJlAa6nzeH2ADrxPHAd8wSLQwZNZfTM5IS9yWAF7QCN OCP8GGpP+BF9a24Y6hbvQ/SnvkC4xCnStcMfglpPLzirekH6MONg+PgQc ZTtNfmSOh39c5LP9uLVfsRQ9xp6HP6dOrihYUQT1MaQT5S3qh9Hs+U3k+ FIplAez2FAkkIz8hPeX0eorpc4lNVVWW3laicl/97jV4/Ly7UZC7H6joA DcPBur8LONVbh5LGhXjgyEabYiET1eKmKf3CLX7erUigpo0eVkE2Jefbf A==; X-CSE-ConnectionGUID: KajURoEKSh6QdPWP8+dJSw== X-CSE-MsgGUID: axWj6mM8QXqiK4a38AWZig== X-IronPort-AV: E=McAfee;i="6700,10204,11397"; a="48193218" X-IronPort-AV: E=Sophos;i="6.15,196,1739865600"; d="scan'208";a="48193218" Received: from orviesa001.jf.intel.com ([10.64.159.141]) by fmvoesa107.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 07 Apr 2025 16:40:52 -0700 X-CSE-ConnectionGUID: rlirKGB4RkqHYn8NPUQh8A== X-CSE-MsgGUID: 20i26qUzTcSQGTPXoIylSA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.15,196,1739865600"; d="scan'208";a="165315491" Received: from agluck-desk3.sc.intel.com ([172.25.222.70]) by smtpauth.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 07 Apr 2025 16:40:51 -0700 From: Tony Luck To: Fenghua Yu , Reinette Chatre , Maciej Wieczor-Retman , Peter Newman , James Morse , Babu Moger , Drew Fustini , Dave Martin , Anil Keshavamurthy Cc: linux-kernel@vger.kernel.org, patches@lists.linux.dev, Tony Luck Subject: [PATCH v3 14/26] x86/resctrl: Add first part of telemetry event enumeration Date: Mon, 7 Apr 2025 16:40:16 -0700 Message-ID: <20250407234032.241215-15-tony.luck@intel.com> X-Mailer: git-send-email 2.48.1 In-Reply-To: <20250407234032.241215-1-tony.luck@intel.com> References: <20250407234032.241215-1-tony.luck@intel.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" The OOBMSM driver provides an interface to discover any RMID based events for "energy" and "perf" classes. Hold onto references to any pmt_feature_groups that resctrl uses until resctrl exit. Signed-off-by: Tony Luck --- arch/x86/kernel/cpu/resctrl/internal.h | 8 ++++ arch/x86/kernel/cpu/resctrl/core.c | 5 ++ arch/x86/kernel/cpu/resctrl/intel_aet.c | 62 +++++++++++++++++++++++++ arch/x86/kernel/cpu/resctrl/Makefile | 1 + 4 files changed, 76 insertions(+) create mode 100644 arch/x86/kernel/cpu/resctrl/intel_aet.c diff --git a/arch/x86/kernel/cpu/resctrl/internal.h b/arch/x86/kernel/cpu/r= esctrl/internal.h index 45eabc7919c6..70b63bbc429d 100644 --- a/arch/x86/kernel/cpu/resctrl/internal.h +++ b/arch/x86/kernel/cpu/resctrl/internal.h @@ -172,4 +172,12 @@ void __init intel_rdt_mbm_apply_quirk(void); =20 void rdt_domain_reconfigure_cdp(struct rdt_resource *r); =20 +#ifdef CONFIG_INTEL_AET_RESCTRL +bool intel_aet_get_events(void); +void __exit intel_aet_exit(void); +#else +static inline bool intel_aet_get_events(void) { return false; } +static inline void intel_aet_exit(void) { }; +#endif + #endif /* _ASM_X86_RESCTRL_INTERNAL_H */ diff --git a/arch/x86/kernel/cpu/resctrl/core.c b/arch/x86/kernel/cpu/resct= rl/core.c index a066a9c54a1f..f0f256a5ac66 100644 --- a/arch/x86/kernel/cpu/resctrl/core.c +++ b/arch/x86/kernel/cpu/resctrl/core.c @@ -718,6 +718,9 @@ void resctrl_arch_mount(void) if (only_once) return; only_once =3D true; + + if (!intel_aet_get_events()) + return; } =20 enum { @@ -1063,6 +1066,8 @@ late_initcall(resctrl_arch_late_init); =20 static void __exit resctrl_arch_exit(void) { + intel_aet_exit(); + cpuhp_remove_state(rdt_online); =20 resctrl_exit(); diff --git a/arch/x86/kernel/cpu/resctrl/intel_aet.c b/arch/x86/kernel/cpu/= resctrl/intel_aet.c new file mode 100644 index 000000000000..8e531ad279b5 --- /dev/null +++ b/arch/x86/kernel/cpu/resctrl/intel_aet.c @@ -0,0 +1,62 @@ +// SPDX-License-Identifier: GPL-2.0-only +/* + * Resource Director Technology(RDT) + * - Intel Application Energy Telemetry + * + * Copyright (C) 2025 Intel Corporation + * + * Author: + * Tony Luck + */ + +#define pr_fmt(fmt) "resctrl: " fmt + +#include +#include +#include "fake_intel_aet_features.h" +#include +#include +#include + +#include "internal.h" + +static struct pmt_feature_group *feat_energy; +static struct pmt_feature_group *feat_perf; + +DEFINE_FREE(intel_pmt_put_feature_group, struct pmt_feature_group *, \ + if (!IS_ERR_OR_NULL(_T)) \ + intel_pmt_put_feature_group(_T)) + +/* + * Ask OOBMSM discovery driver for all the RMID based telemetry groups + * that it supports. + */ +bool intel_aet_get_events(void) +{ + struct pmt_feature_group *p1 __free(intel_pmt_put_feature_group) =3D NULL; + struct pmt_feature_group *p2 __free(intel_pmt_put_feature_group) =3D NULL; + bool use_p1, use_p2; + + p1 =3D intel_pmt_get_regions_by_feature(FEATURE_PER_RMID_ENERGY_TELEM); + p2 =3D intel_pmt_get_regions_by_feature(FEATURE_PER_RMID_PERF_TELEM); + use_p1 =3D !IS_ERR_OR_NULL(p1); + use_p2 =3D !IS_ERR_OR_NULL(p2); + + if (!use_p1 && !use_p2) + return false; + + if (use_p1) + feat_energy =3D no_free_ptr(p1); + if (use_p2) + feat_perf =3D no_free_ptr(p2); + + return true; +} + +void __exit intel_aet_exit(void) +{ + if (feat_energy) + intel_pmt_put_feature_group(feat_energy); + if (feat_perf) + intel_pmt_put_feature_group(feat_perf); +} diff --git a/arch/x86/kernel/cpu/resctrl/Makefile b/arch/x86/kernel/cpu/res= ctrl/Makefile index c56d3acf8ac7..74c3b2333dde 100644 --- a/arch/x86/kernel/cpu/resctrl/Makefile +++ b/arch/x86/kernel/cpu/resctrl/Makefile @@ -1,6 +1,7 @@ # SPDX-License-Identifier: GPL-2.0 obj-$(CONFIG_X86_CPU_RESCTRL) +=3D core.o rdtgroup.o monitor.o obj-$(CONFIG_X86_CPU_RESCTRL) +=3D ctrlmondata.o +obj-$(CONFIG_INTEL_AET_RESCTRL) +=3D intel_aet.o obj-$(CONFIG_INTEL_AET_RESCTRL) +=3D fake_intel_aet_features.o obj-$(CONFIG_RESCTRL_FS_PSEUDO_LOCK) +=3D pseudo_lock.o =20 --=20 2.48.1 From nobody Fri Dec 19 17:08:33 2025 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.13]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E6F7922F39C for ; Mon, 7 Apr 2025 23:40:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.13 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1744069259; cv=none; b=XaafO8uczMSX9IrgmdzI81RdXhxD8YXGQfvA+HTzOONxnE1kxu+cnTnZ7LAkRgUjb05nXhwoU+3oXGHp8spEA3yolOy1wx9pko/udkfr6aoJ6kCK76+5oy8GK1OXDBTz6tM7TJqx2uO58Lv9DfU1fg71fxdupjBRfEVmzKaID7Q= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1744069259; c=relaxed/simple; bh=cCoPp+BXCw1rV6uzrlZHHakPTSCFwZaMenLMYXftMaA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=bD5VhezEuMV6N/7HZ6BOOPPm4N6dneSC8i7J1FDfDBJ/gWm76E/DAy8Hd4qwq9DDx/qDE74ZHUsLOxL6X7FlYLWIE4ZEyRZ+6hZ8cBPk+webFXAVdxskvMQ8JzL2X5NH1mEQWKTjiZY0qIP/4cnYJ7UM+vBJfGidMt3/zVyzecs= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com; spf=pass smtp.mailfrom=intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=bmHCRFpo; arc=none smtp.client-ip=192.198.163.13 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="bmHCRFpo" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1744069257; x=1775605257; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=cCoPp+BXCw1rV6uzrlZHHakPTSCFwZaMenLMYXftMaA=; b=bmHCRFpoO/TOfPL1B1cLCFj2vlN1YqYdYVB+8OqqXw3pMYs/FodEEK8i VXSUpbtSo/lFUpvQml0UUMgjAAu5mFEZB5SpGGem+BINyFGXgWGKquC5X APRl17Amubrh6T//WfvACdvF76wK9qCqgl3zbBqq9I9nVJDXsEu47FZWc cH6RAsroe5nXF+D92+ei/EETl86WcrUtSGiO2vcx59v/cX6rhTABvO5gY 8XohSAsY0PhiUxni+pvUikEQUDkLNtY8TZnbe79ZpOvLjPQ4cqaS7PVv6 Q2AgbwaE9t+BJR9ewyE9SOP9+0hmWIGDwHv+b8KFgzGFteCXr+fjYxtlr g==; X-CSE-ConnectionGUID: cNEEmVeRQCWbqVP9+Zx9Jg== X-CSE-MsgGUID: Agt5xV2gSYijhk+mvcWLGg== X-IronPort-AV: E=McAfee;i="6700,10204,11397"; a="48193226" X-IronPort-AV: E=Sophos;i="6.15,196,1739865600"; d="scan'208";a="48193226" Received: from orviesa001.jf.intel.com ([10.64.159.141]) by fmvoesa107.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 07 Apr 2025 16:40:52 -0700 X-CSE-ConnectionGUID: h2S8Z0sPQc+X5rjt84lfpA== X-CSE-MsgGUID: jD4a5KxpSoCSJWO9N8IiVQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.15,196,1739865600"; d="scan'208";a="165315495" Received: from agluck-desk3.sc.intel.com ([172.25.222.70]) by smtpauth.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 07 Apr 2025 16:40:52 -0700 From: Tony Luck To: Fenghua Yu , Reinette Chatre , Maciej Wieczor-Retman , Peter Newman , James Morse , Babu Moger , Drew Fustini , Dave Martin , Anil Keshavamurthy Cc: linux-kernel@vger.kernel.org, patches@lists.linux.dev, Tony Luck Subject: [PATCH v3 15/26] x86/resctrl: Second stage of telemetry event enumeration Date: Mon, 7 Apr 2025 16:40:17 -0700 Message-ID: <20250407234032.241215-16-tony.luck@intel.com> X-Mailer: git-send-email 2.48.1 In-Reply-To: <20250407234032.241215-1-tony.luck@intel.com> References: <20250407234032.241215-1-tony.luck@intel.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Scan the telemetry_region structures looking for recognised guid values. Count how many are found in each package. Note that telemetry support depends on at least one of the original RDT monitoring features being enabled (so that the CPU hotplug notifiers for resctrl are running). Signed-off-by: Tony Luck --- arch/x86/kernel/cpu/resctrl/intel_aet.c | 112 +++++++++++++++++++++++- 1 file changed, 110 insertions(+), 2 deletions(-) diff --git a/arch/x86/kernel/cpu/resctrl/intel_aet.c b/arch/x86/kernel/cpu/= resctrl/intel_aet.c index 8e531ad279b5..9d414dd40f8b 100644 --- a/arch/x86/kernel/cpu/resctrl/intel_aet.c +++ b/arch/x86/kernel/cpu/resctrl/intel_aet.c @@ -23,10 +23,100 @@ static struct pmt_feature_group *feat_energy; static struct pmt_feature_group *feat_perf; =20 +/* Per-package event groups active on this machine */ +static struct pkg_info { + int count; + struct telemetry_region *regions; +} *pkg_info; + +/** + * struct pmt_event - Telemetry event. + * @evtid: Resctrl event id + * @evt_offset: MMIO offset of counter + * @type: Type for format user display of event value + */ +struct pmt_event { + enum resctrl_event_id evtid; + int evt_offset; + enum resctrl_event_type type; +}; + +/** + * struct telem_entry - Summarized form from XML telemetry description + * @name: Name for this group of events + * @guid: Unique ID for this group + * @size: Size of MMIO mapped counter registers + * @num_rmids: Number of RMIDS supported + * @overflow_counter_off: Offset of overflow count + * @last_overflow_tstamp_off: Offset of overflow timestamp + * @last_update_tstamp_off: Offset of last update timestamp + * @active: Marks this group as active on this system + * @num_events: Size of @evts array + * @evts: Telemetry events in this group + */ +struct telem_entry { + char *name; + int guid; + int size; + int num_rmids; + int overflow_counter_off; + int last_overflow_tstamp_off; + int last_update_tstamp_off; + bool active; + int num_events; + struct pmt_event evts[]; +}; + +/* All known telemetry event groups */ +static struct telem_entry *telem_entry[] =3D { + NULL +}; + +/* + * Scan a feature group looking for guids recognized + * and update the per-package counts of known groups. + */ +static bool count_events(struct pkg_info *pkg, int max_pkgs, struct pmt_fe= ature_group *p) +{ + struct telem_entry **tentry; + bool found =3D false; + + if (IS_ERR_OR_NULL(p)) + return false; + + for (int i =3D 0; i < p->count; i++) { + struct telemetry_region *tr =3D &p->regions[i]; + + for (tentry =3D telem_entry; *tentry; tentry++) { + if (tr->guid =3D=3D (*tentry)->guid) { + if (tr->plat_info.package_id > max_pkgs) { + pr_warn_once("Bad package %d\n", tr->plat_info.package_id); + continue; + } + if (tr->size > (*tentry)->size) { + pr_warn_once("MMIO region for guid 0x%x too small\n", tr->guid); + continue; + } + found =3D true; + (*tentry)->active =3D true; + pkg[tr->plat_info.package_id].count++; + break; + } + } + } + + return found; +} + DEFINE_FREE(intel_pmt_put_feature_group, struct pmt_feature_group *, \ if (!IS_ERR_OR_NULL(_T)) \ intel_pmt_put_feature_group(_T)) =20 +DEFINE_FREE(free_pkg_info, struct pkg_info *, \ + if (_T) \ + for (int i =3D 0; i < topology_max_packages(); i++) \ + kfree(_T[i].regions); \ + kfree(_T)) /* * Ask OOBMSM discovery driver for all the RMID based telemetry groups * that it supports. @@ -35,20 +125,32 @@ bool intel_aet_get_events(void) { struct pmt_feature_group *p1 __free(intel_pmt_put_feature_group) =3D NULL; struct pmt_feature_group *p2 __free(intel_pmt_put_feature_group) =3D NULL; + struct pkg_info *pkg __free(free_pkg_info) =3D NULL; + int num_pkgs =3D topology_max_packages(); bool use_p1, use_p2; =20 + pkg =3D kcalloc(num_pkgs, sizeof(*pkg_info), GFP_KERNEL); + if (!pkg) + return false; + p1 =3D intel_pmt_get_regions_by_feature(FEATURE_PER_RMID_ENERGY_TELEM); p2 =3D intel_pmt_get_regions_by_feature(FEATURE_PER_RMID_PERF_TELEM); - use_p1 =3D !IS_ERR_OR_NULL(p1); - use_p2 =3D !IS_ERR_OR_NULL(p2); + use_p1 =3D count_events(pkg, num_pkgs, p1); + use_p2 =3D count_events(pkg, num_pkgs, p2); =20 if (!use_p1 && !use_p2) return false; =20 + if (!resctrl_arch_mon_capable()) { + pr_info("Telemetry available but monitor support disabled\n"); + return false; + } + if (use_p1) feat_energy =3D no_free_ptr(p1); if (use_p2) feat_perf =3D no_free_ptr(p2); + pkg_info =3D no_free_ptr(pkg); =20 return true; } @@ -59,4 +161,10 @@ void __exit intel_aet_exit(void) intel_pmt_put_feature_group(feat_energy); if (feat_perf) intel_pmt_put_feature_group(feat_perf); + + if (pkg_info) { + for (int i =3D 0; i < topology_max_packages(); i++) + kfree(pkg_info[i].regions); + } + kfree(pkg_info); } --=20 2.48.1 From nobody Fri Dec 19 17:08:33 2025 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.13]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 75122230242 for ; Mon, 7 Apr 2025 23:40:57 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.13 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1744069259; cv=none; b=Q62WDHNpiPI0PwiphAh2v+oOfE0kWkNBNLBU/bRtKe1mGlwgU8S+S+anCRG8NYFAyR+MUlJU/Tjp6hzgBP9qIgOAXO09o75/6eQFAPoJfWXsgKw2DHqj58mrVD9FrxxuONsqXHkNonl+jw/omOhpTFpOdqJenKZY+g3Lrhp/EZA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1744069259; c=relaxed/simple; bh=ay6kOKCacuZCn+XPR511HwTZVDvxxSctVUfQ7U+skIY=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=AOdQbv2SePqI75KZTcdRDrTe4Z2GbhLKCMKiJTqPQfGRTRZaNDVaPFaSSIwhebi9heaNSneyN2gtUc16NtD4iAF/pVB2eazCWNhTsazbJnS+yCvXFd5TskR8knyTjT3LiXDBDLHSqm+9W0n2xACK4Hhml5I/fM8+X2mOyIpVkOE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com; spf=pass smtp.mailfrom=intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=P3skExTw; arc=none smtp.client-ip=192.198.163.13 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="P3skExTw" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1744069257; x=1775605257; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=ay6kOKCacuZCn+XPR511HwTZVDvxxSctVUfQ7U+skIY=; b=P3skExTws283NpHffQVSRvxsxgaw71ka/OkHvYJ5zzyFOqSJQFLZSCvu N4dyhanz5IzovSQPxzkVt+TjLHYb67SruRQ7lepJqm9Un6MBtvxGTry2d 9usYzGIPZMvzsBJywL/dUfQMRWwv/nAYAOu3cUsupfxtVeSyKAwfAlNn3 uGFYZE5tZFOhwEFMN4+fYIttyRQo0CT/t8ngvqVZENMvoZJ5YEBO1g6uY bNYrm/kugKRbQnrppaV0LMtHiqKLV3NQ/+/uee6nIKJoYp0THXtPBKtBV EHoB3EoZAg8xDKV+gXYZlb8rowvp2ijNz0GQBpVPPdyd3ZKT6l38Adv6L w==; X-CSE-ConnectionGUID: fPWeNBpkRGisk3AXTRTQjQ== X-CSE-MsgGUID: +UGWeKq1Rk+pYdyb7wYFaw== X-IronPort-AV: E=McAfee;i="6700,10204,11397"; a="48193233" X-IronPort-AV: E=Sophos;i="6.15,196,1739865600"; d="scan'208";a="48193233" Received: from orviesa001.jf.intel.com ([10.64.159.141]) by fmvoesa107.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 07 Apr 2025 16:40:53 -0700 X-CSE-ConnectionGUID: GZ8TQAYCTFKf10lqF0nUOA== X-CSE-MsgGUID: CXBsjddQRCqv2lufLJy7Gw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.15,196,1739865600"; d="scan'208";a="165315498" Received: from agluck-desk3.sc.intel.com ([172.25.222.70]) by smtpauth.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 07 Apr 2025 16:40:52 -0700 From: Tony Luck To: Fenghua Yu , Reinette Chatre , Maciej Wieczor-Retman , Peter Newman , James Morse , Babu Moger , Drew Fustini , Dave Martin , Anil Keshavamurthy Cc: linux-kernel@vger.kernel.org, patches@lists.linux.dev, Tony Luck Subject: [PATCH v3 16/26] x86/resctrl: Third phase of telemetry event enumeration Date: Mon, 7 Apr 2025 16:40:18 -0700 Message-ID: <20250407234032.241215-17-tony.luck@intel.com> X-Mailer: git-send-email 2.48.1 In-Reply-To: <20250407234032.241215-1-tony.luck@intel.com> References: <20250407234032.241215-1-tony.luck@intel.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Allocate per-package arrays for the known telemetry_regions and initialize with pointers to the structures acquired from the intel_pmt_get_regions_by_feature() calls. Signed-off-by: Tony Luck --- arch/x86/kernel/cpu/resctrl/intel_aet.c | 38 +++++++++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/arch/x86/kernel/cpu/resctrl/intel_aet.c b/arch/x86/kernel/cpu/= resctrl/intel_aet.c index 9d414dd40f8b..fb03f2e76306 100644 --- a/arch/x86/kernel/cpu/resctrl/intel_aet.c +++ b/arch/x86/kernel/cpu/resctrl/intel_aet.c @@ -108,6 +108,30 @@ static bool count_events(struct pkg_info *pkg, int max= _pkgs, struct pmt_feature_ return found; } =20 +/* + * Copy the pointers to telemetry regions associated with a given package + * and with known guids over to the pkg_info structure for that package. + */ +static int setup(struct pkg_info *pkg, int pkgnum, struct pmt_feature_grou= p *p, int slot) +{ + struct telem_entry **tentry; + + for (int i =3D 0; i < p->count; i++) { + for (tentry =3D telem_entry; *tentry; tentry++) { + if (!(*tentry)->active) + continue; + if (pkgnum !=3D p->regions[i].plat_info.package_id) + continue; + if (p->regions[i].guid !=3D (*tentry)->guid) + continue; + + pkg[pkgnum].regions[slot++] =3D p->regions[i]; + } + } + + return slot; +} + DEFINE_FREE(intel_pmt_put_feature_group, struct pmt_feature_group *, \ if (!IS_ERR_OR_NULL(_T)) \ intel_pmt_put_feature_group(_T)) @@ -128,6 +152,7 @@ bool intel_aet_get_events(void) struct pkg_info *pkg __free(free_pkg_info) =3D NULL; int num_pkgs =3D topology_max_packages(); bool use_p1, use_p2; + int slot; =20 pkg =3D kcalloc(num_pkgs, sizeof(*pkg_info), GFP_KERNEL); if (!pkg) @@ -146,6 +171,19 @@ bool intel_aet_get_events(void) return false; } =20 + for (int i =3D 0; i < num_pkgs; i++) { + if (!pkg[i].count) + continue; + pkg[i].regions =3D kmalloc_array(pkg[i].count, sizeof(*pkg[i].regions), = GFP_KERNEL); + if (!pkg[i].regions) + return false; + slot =3D 0; + if (use_p1) + slot =3D setup(pkg, i, p1, slot); + if (use_p2) + slot =3D setup(pkg, i, p2, slot); + } + if (use_p1) feat_energy =3D no_free_ptr(p1); if (use_p2) --=20 2.48.1 From nobody Fri Dec 19 17:08:33 2025 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.13]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 4F8F523312E for ; Mon, 7 Apr 2025 23:40:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.13 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1744069260; cv=none; b=QYamop0zBv6Z3NloO40svBu2HGuV5ccd/7bS1esw8OXgFPONJZVynlw8+HWMlYKgc8D+44MAcwL3jv/rlWpAa30gxAVwI6TdrZxJiQyRGaaHTnPKBC9qP17ezRpmXi8/Ryd4Wk8+yaIWIkWdW+J4PV5YSH8mArcrqxfGMxTmZY8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1744069260; c=relaxed/simple; bh=Ge3dAPdKQ80XMbZaHlF/lf+oTDnmbQ7mOPJgItNLlTQ=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=OHEuKzFldlimHqPebqqGV28B6vLOpj2sgRZ+sM6wh9cCwV0PSNG+mjOvkZQ4GZhuvODt7W4h2joIAvAC5PMp8o8eDy0dfX5bC2VXJFVEwY2U8ngf9Mj+8pZNYN+9aFFh12CzJVD1UQPe8IukzDLE4mT12n40ZMppVvEmhty9XIw= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com; spf=pass smtp.mailfrom=intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=di492s1K; arc=none smtp.client-ip=192.198.163.13 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="di492s1K" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1744069258; x=1775605258; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=Ge3dAPdKQ80XMbZaHlF/lf+oTDnmbQ7mOPJgItNLlTQ=; b=di492s1KF65nnm+W7PZcmHehMIcfpWyFavQwczEfB96LDY3E2woFSkE3 YNhpBmmPFGyMHUY1ep1MHOXm8YDblxhJXY08VBbd9NnIuRIh97ZfH6uO6 ZqAZZX2yfb1xuxB1ewv/Waq0rz8Y4GPSN1q2MorPXpFyJ6VWhR5hflely 2qtkkk3KqmPrvqyX8vlUv+Yqa1kXQVwVrs1DrZsMTfa0yViGbcXdvKWwQ n+EHcfjG32cpqK0pEB8CaV5wces1w35OJ96TxQ5OiYdLrHlC8Si1yJn9U S+oWbz89UCWG/TQox2N6eB1zDc+v8lHV7qPrUTVDPEfWYOKrJSmnDsq+d Q==; X-CSE-ConnectionGUID: PswtBe7jTDKVB31LQITMVA== X-CSE-MsgGUID: QwloflYVSBinDK00FbpiQA== X-IronPort-AV: E=McAfee;i="6700,10204,11397"; a="48193241" X-IronPort-AV: E=Sophos;i="6.15,196,1739865600"; d="scan'208";a="48193241" Received: from orviesa001.jf.intel.com ([10.64.159.141]) by fmvoesa107.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 07 Apr 2025 16:40:54 -0700 X-CSE-ConnectionGUID: GB3ui4QQSAOgny1ciOx4oQ== X-CSE-MsgGUID: Yc2M/RnoR8C6OkVQKSvKlg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.15,196,1739865600"; d="scan'208";a="165315501" Received: from agluck-desk3.sc.intel.com ([172.25.222.70]) by smtpauth.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 07 Apr 2025 16:40:53 -0700 From: Tony Luck To: Fenghua Yu , Reinette Chatre , Maciej Wieczor-Retman , Peter Newman , James Morse , Babu Moger , Drew Fustini , Dave Martin , Anil Keshavamurthy Cc: linux-kernel@vger.kernel.org, patches@lists.linux.dev, Tony Luck Subject: [PATCH v3 17/26] x86/resctrl: Build a lookup table for each resctrl event id Date: Mon, 7 Apr 2025 16:40:19 -0700 Message-ID: <20250407234032.241215-18-tony.luck@intel.com> X-Mailer: git-send-email 2.48.1 In-Reply-To: <20250407234032.241215-1-tony.luck@intel.com> References: <20250407234032.241215-1-tony.luck@intel.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" User requests to read events arrive from the file system layer with a domain id, RMID, and resctrl event id. Responding to those requests needs information from various structures. Build a quick lookup table indexed by resctrl event id. Signed-off-by: Tony Luck --- arch/x86/kernel/cpu/resctrl/intel_aet.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/arch/x86/kernel/cpu/resctrl/intel_aet.c b/arch/x86/kernel/cpu/= resctrl/intel_aet.c index fb03f2e76306..44d2fe747ed8 100644 --- a/arch/x86/kernel/cpu/resctrl/intel_aet.c +++ b/arch/x86/kernel/cpu/resctrl/intel_aet.c @@ -67,6 +67,12 @@ struct telem_entry { struct pmt_event evts[]; }; =20 +/* Lookup table to get from resctrl event id to useful structures */ +static struct evtinfo { + struct telem_entry *telem_entry; + struct pmt_event *pmt_event; +} evtinfo[QOS_NUM_EVENTS]; + /* All known telemetry event groups */ static struct telem_entry *telem_entry[] =3D { NULL @@ -151,6 +157,7 @@ bool intel_aet_get_events(void) struct pmt_feature_group *p2 __free(intel_pmt_put_feature_group) =3D NULL; struct pkg_info *pkg __free(free_pkg_info) =3D NULL; int num_pkgs =3D topology_max_packages(); + struct telem_entry **tentry; bool use_p1, use_p2; int slot; =20 @@ -184,6 +191,17 @@ bool intel_aet_get_events(void) slot =3D setup(pkg, i, p2, slot); } =20 + for (tentry =3D telem_entry; *tentry; tentry++) { + if (!(*tentry)->active) + continue; + for (int i =3D 0; i < (*tentry)->num_events; i++) { + enum resctrl_event_id evtid =3D (*tentry)->evts[i].evtid; + + evtinfo[evtid].telem_entry =3D *tentry; + evtinfo[evtid].pmt_event =3D &(*tentry)->evts[i]; + } + } + if (use_p1) feat_energy =3D no_free_ptr(p1); if (use_p2) --=20 2.48.1 From nobody Fri Dec 19 17:08:33 2025 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.13]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 581D022A4E6 for ; Mon, 7 Apr 2025 23:40:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.13 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1744069261; cv=none; b=WLo8h3TcCw7soXVh78mlkPNTGntjlbp11IhbDEEyXGiw5BJ1tAzJZFMfK1jNNwizZWeMI7khFMyj3mQZRBnPg9BM/A8aPlOPbuql0wA/Nba6PXsUG2dC71NKOaKe4Mwx0vsVN9awUxlvgrMMOrl7aETePyjiXcSsm7vrdnJlLNI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1744069261; c=relaxed/simple; bh=VkAushiJg8PznmhNDfBTv79LiMm52vT2It3WEREb5A4=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=P69PMIVapRlRzsEHdmOtt7D6Ivo8KGdS4tG5vGBC3xlpHTeu8Y/IRVgJwAlrSHunETmx1nEZZkmSSNNHtUKR1d6P/oLbdqR5ivqa0lJ4BHyejrUt5vxGBgZ1OHXxR3qZts53FvCVBMlaCBF79MwS/UDcw8lIrKUhZv3newhNbX8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com; spf=pass smtp.mailfrom=intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=T/XuXTRo; arc=none smtp.client-ip=192.198.163.13 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="T/XuXTRo" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1744069259; x=1775605259; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=VkAushiJg8PznmhNDfBTv79LiMm52vT2It3WEREb5A4=; b=T/XuXTRoH/8m36Hkkjglz7EEHgR4JccrHImGS2MOstsLoIONbflCPJBW dtfIa4RlwmS4ZawaI/9fhl4gXsqeDKroQ8ht3RWUnPey5069aZWzQeUDV VJIMRGkY9Z6XRhLbaH+DRbQxIoErzXiwBMfi0fCGvQPhy4J1ZzlxgDedF LAAwiXWVb3vOM1EngIcMKjD/5SSl6VHQ8j7//mEuTUHCmDSkVnSEa1/G/ hO31jlTJw5O6+AzTdLzKYVK6BF6OlOXhNsptO71eLqAUD4SPxm8x/4u9h e6gDEbslJ9AqnzrdyAwN6x/4X/GoNhy5Q/6/wdjMP02zIvIxIevyEmn4l A==; X-CSE-ConnectionGUID: 3NsvWyIHSPGDxZppz+ji6g== X-CSE-MsgGUID: 0PcuWImFQIW3qbDxYdqcmw== X-IronPort-AV: E=McAfee;i="6700,10204,11397"; a="48193249" X-IronPort-AV: E=Sophos;i="6.15,196,1739865600"; d="scan'208";a="48193249" Received: from orviesa001.jf.intel.com ([10.64.159.141]) by fmvoesa107.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 07 Apr 2025 16:40:54 -0700 X-CSE-ConnectionGUID: KptcqHnaR0uqbfanru6Npg== X-CSE-MsgGUID: XZjxMP3RQ0Gvu4m5VYBGOA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.15,196,1739865600"; d="scan'208";a="165315505" Received: from agluck-desk3.sc.intel.com ([172.25.222.70]) by smtpauth.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 07 Apr 2025 16:40:54 -0700 From: Tony Luck To: Fenghua Yu , Reinette Chatre , Maciej Wieczor-Retman , Peter Newman , James Morse , Babu Moger , Drew Fustini , Dave Martin , Anil Keshavamurthy Cc: linux-kernel@vger.kernel.org, patches@lists.linux.dev, Tony Luck Subject: [PATCH v3 18/26] x86/resctrl: Add code to read core telemetry events Date: Mon, 7 Apr 2025 16:40:20 -0700 Message-ID: <20250407234032.241215-19-tony.luck@intel.com> X-Mailer: git-send-email 2.48.1 In-Reply-To: <20250407234032.241215-1-tony.luck@intel.com> References: <20250407234032.241215-1-tony.luck@intel.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" The new telemetry events will be part of a new resctrl resource. Add the RDT_RESOURCE_PERF_PKG to enum resctrl_res_level. Add hook resctrl_arch_rmid_read() to pass reads on this resource to the telemetry code. There may be multiple devices tracking each package, so scan all of them and add up counters. Signed-off-by: Tony Luck --- include/linux/resctrl_types.h | 1 + arch/x86/kernel/cpu/resctrl/internal.h | 5 +++ arch/x86/kernel/cpu/resctrl/intel_aet.c | 58 +++++++++++++++++++++++++ arch/x86/kernel/cpu/resctrl/monitor.c | 6 +++ 4 files changed, 70 insertions(+) diff --git a/include/linux/resctrl_types.h b/include/linux/resctrl_types.h index fbd4b55c41aa..3354f21e82ad 100644 --- a/include/linux/resctrl_types.h +++ b/include/linux/resctrl_types.h @@ -39,6 +39,7 @@ enum resctrl_res_level { RDT_RESOURCE_L2, RDT_RESOURCE_MBA, RDT_RESOURCE_SMBA, + RDT_RESOURCE_PERF_PKG, =20 /* Must be the last */ RDT_NUM_RESOURCES, diff --git a/arch/x86/kernel/cpu/resctrl/internal.h b/arch/x86/kernel/cpu/r= esctrl/internal.h index 70b63bbc429d..1b1cbb948a9a 100644 --- a/arch/x86/kernel/cpu/resctrl/internal.h +++ b/arch/x86/kernel/cpu/resctrl/internal.h @@ -175,9 +175,14 @@ void rdt_domain_reconfigure_cdp(struct rdt_resource *r= ); #ifdef CONFIG_INTEL_AET_RESCTRL bool intel_aet_get_events(void); void __exit intel_aet_exit(void); +int intel_aet_read_event(int domid, int rmid, int evtid, u64 *val); #else static inline bool intel_aet_get_events(void) { return false; } static inline void intel_aet_exit(void) { }; +static inline int intel_aet_read_event(int domid, int rmid, int evtid, u64= *val) +{ + return -EINVAL; +} #endif =20 #endif /* _ASM_X86_RESCTRL_INTERNAL_H */ diff --git a/arch/x86/kernel/cpu/resctrl/intel_aet.c b/arch/x86/kernel/cpu/= resctrl/intel_aet.c index 44d2fe747ed8..67a1245858dc 100644 --- a/arch/x86/kernel/cpu/resctrl/intel_aet.c +++ b/arch/x86/kernel/cpu/resctrl/intel_aet.c @@ -73,6 +73,12 @@ static struct evtinfo { struct pmt_event *pmt_event; } evtinfo[QOS_NUM_EVENTS]; =20 +#define EVT_NUM_RMIDS(evtid) (evtinfo[evtid].telem_entry->num_rmids) +#define EVT_NUM_EVENTS(evtid) (evtinfo[evtid].telem_entry->num_events) +#define EVT_GUID(evtid) (evtinfo[evtid].telem_entry->guid) + +#define EVT_OFFSET(evtid) (evtinfo[evtid].pmt_event->evt_offset) + /* All known telemetry event groups */ static struct telem_entry *telem_entry[] =3D { NULL @@ -224,3 +230,55 @@ void __exit intel_aet_exit(void) } kfree(pkg_info); } + +#define VALID_BIT BIT_ULL(63) +#define DATA_BITS GENMASK_ULL(62, 0) + +/* + * Walk the array of telemetry groups on a specific package. + * Read and sum values for a specific counter (described by + * guid and offset). + * Return failure (~0x0ull) if any counter isn't valid. + */ +static u64 scan_pmt_devs(int package, int guid, int offset) +{ + u64 rval, val; + int ndev =3D 0; + + rval =3D 0; + + for (int i =3D 0; i < pkg_info[package].count; i++) { + if (pkg_info[package].regions[i].guid !=3D guid) + continue; + ndev++; + val =3D readq(pkg_info[package].regions[i].addr + offset); + + if (!(val & VALID_BIT)) + return ~0ull; + rval +=3D val & DATA_BITS; + } + + return ndev ? rval : ~0ull; +} + +/* + * Read counter for an event on a domain (summing all aggregators + * on the domain). + */ +int intel_aet_read_event(int domid, int rmid, int evtid, u64 *val) +{ + u64 evtcount; + int offset; + + if (rmid >=3D EVT_NUM_RMIDS(evtid)) + return -ENOENT; + + offset =3D rmid * EVT_NUM_EVENTS(evtid) * sizeof(u64); + offset +=3D EVT_OFFSET(evtid); + evtcount =3D scan_pmt_devs(domid, EVT_GUID(evtid), offset); + + if (evtcount !=3D ~0ull || *val =3D=3D 0) + *val +=3D evtcount; + + return evtcount !=3D ~0ull ? 0 : -EINVAL; +} diff --git a/arch/x86/kernel/cpu/resctrl/monitor.c b/arch/x86/kernel/cpu/re= sctrl/monitor.c index 06623d51d006..4fa297d463ba 100644 --- a/arch/x86/kernel/cpu/resctrl/monitor.c +++ b/arch/x86/kernel/cpu/resctrl/monitor.c @@ -236,6 +236,12 @@ int resctrl_arch_rmid_read(struct rdt_resource *r, str= uct rdt_mon_domain *d, u32 prmid; int ret; =20 + if (r->rid =3D=3D RDT_RESOURCE_PERF_PKG) { + ret =3D intel_aet_read_event(d->hdr.id, rmid, eventid, val); + + return ret ? ret : 0; + } + resctrl_arch_rmid_read_context_check(); =20 prmid =3D logical_rmid_to_physical_rmid(cpu, rmid); --=20 2.48.1 From nobody Fri Dec 19 17:08:33 2025 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.13]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A6209235BF5 for ; Mon, 7 Apr 2025 23:40:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.13 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1744069261; cv=none; b=EhgtBbB3uruwNm+JBjEJZ5JN9D3uIXmJKEZvPslXTurHxXUPSlK/Qhv1Awhz0IA83BU22uGxyvZq4Zp2RqE0Nql6OamZYbc0k6+lNyqJoKpfCTviEnanZFJZ1DNXZjAnb7lI62wl/kmtKrcTjkdXPy+4kCtFGA+jxKeCjTKe69Y= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1744069261; c=relaxed/simple; bh=SUUftBtwxxFxmK3JdMowGHqFvP3+5TntU1UsnXpOCUo=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=IwjJpf97POI+BieXZQNf3GfMJr4q5h2VbZxnEYUToUXDe41rF36EYyIduRvs6q6IERs/B3Q2QcItTUjfzZ4Mo2nMmHQm/BEzp/SyAzYW2ecsE9xZxyRu+JCMpArAOVW95ClDfHBinLI7HaUtqJBe6cxMDk5ZWkMptAx90PxakNY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com; spf=pass smtp.mailfrom=intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=X5hHBKy9; arc=none smtp.client-ip=192.198.163.13 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="X5hHBKy9" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1744069260; x=1775605260; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=SUUftBtwxxFxmK3JdMowGHqFvP3+5TntU1UsnXpOCUo=; b=X5hHBKy9cFj5SzYI/zgDYBLtYKpLMf2SOXBu6a/zwaFBrpKoZwWRcMOd N9VNLSn1Sqo/R21hFO5Q8jujhjd3e18iUESrCjwsLfJ5OfgNGp6jndkdH FKnl93X3OhO+FRBKjzUULg5LqMUJOU/59hebY+8IJrXBAXu2G8KbY5gy0 +nrZPrWD+df4n2wTrBi1W6PRsE2amMERkNFjfregQ/NSRSusCLUkm/Anl HuQfDNSrkbSWSd+I3xN38Sqmq8NE008M9PelONUYLZnVDthPE60zZQb/t 93nVAejHTn0ajiU87likYD9BhQV10q4R1JVJ4Wsl7f+t8vTOLxnVZH4/e Q==; X-CSE-ConnectionGUID: 087ivOFkQ72a1Mw0b3wqlQ== X-CSE-MsgGUID: kp/TaWobSr+oYfR/qmljbg== X-IronPort-AV: E=McAfee;i="6700,10204,11397"; a="48193256" X-IronPort-AV: E=Sophos;i="6.15,196,1739865600"; d="scan'208";a="48193256" Received: from orviesa001.jf.intel.com ([10.64.159.141]) by fmvoesa107.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 07 Apr 2025 16:40:55 -0700 X-CSE-ConnectionGUID: cIex8e2YSSOvFi0TNWr+Qw== X-CSE-MsgGUID: hl+xutEBTeKnnTNrOykWZQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.15,196,1739865600"; d="scan'208";a="165315508" Received: from agluck-desk3.sc.intel.com ([172.25.222.70]) by smtpauth.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 07 Apr 2025 16:40:54 -0700 From: Tony Luck To: Fenghua Yu , Reinette Chatre , Maciej Wieczor-Retman , Peter Newman , James Morse , Babu Moger , Drew Fustini , Dave Martin , Anil Keshavamurthy Cc: linux-kernel@vger.kernel.org, patches@lists.linux.dev, Tony Luck Subject: [PATCH v3 19/26] x86/resctrl: Sanity check telemetry RMID values Date: Mon, 7 Apr 2025 16:40:21 -0700 Message-ID: <20250407234032.241215-20-tony.luck@intel.com> X-Mailer: git-send-email 2.48.1 In-Reply-To: <20250407234032.241215-1-tony.luck@intel.com> References: <20250407234032.241215-1-tony.luck@intel.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" There are three values of interest: 1) The number of RMIDs supported by the CPU core. This is enumerated by CPUID leaf 0xF. Linux saves the value in boot_cpu_data.x86_cache_max_rmi= d. 2) The number of counter registers in each telemetry region. This is described in the XML file for the region. Linux hard codes it into the struct telem_entry..num_rmids field. 3) The maximum number of RMIDs that can be tracked simultaneously for a telemetry region. This is provided in the structures received from the intel_pmt_get_regions_by_feature() calls. Print appropriate warnings if these values do not match. TODO: Need a better UI. The number of implemented counters can be different per telemetry region. Signed-off-by: Tony Luck --- arch/x86/kernel/cpu/resctrl/intel_aet.c | 31 +++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/arch/x86/kernel/cpu/resctrl/intel_aet.c b/arch/x86/kernel/cpu/= resctrl/intel_aet.c index 67a1245858dc..0bcbac326bee 100644 --- a/arch/x86/kernel/cpu/resctrl/intel_aet.c +++ b/arch/x86/kernel/cpu/resctrl/intel_aet.c @@ -13,6 +13,7 @@ =20 #include #include +#include #include "fake_intel_aet_features.h" #include #include @@ -51,6 +52,7 @@ struct pmt_event { * @last_overflow_tstamp_off: Offset of overflow timestamp * @last_update_tstamp_off: Offset of last update timestamp * @active: Marks this group as active on this system + * @rmid_warned: Set to stop multiple rmid sanity warnings * @num_events: Size of @evts array * @evts: Telemetry events in this group */ @@ -63,6 +65,7 @@ struct telem_entry { int last_overflow_tstamp_off; int last_update_tstamp_off; bool active; + bool rmid_warned; int num_events; struct pmt_event evts[]; }; @@ -84,6 +87,33 @@ static struct telem_entry *telem_entry[] =3D { NULL }; =20 +static void rmid_sanity_check(struct telemetry_region *tr, struct telem_en= try *tentry) +{ + struct rdt_resource *r =3D &rdt_resources_all[RDT_RESOURCE_PERF_PKG].r_re= sctrl; + int system_rmids =3D boot_cpu_data.x86_cache_max_rmid + 1; + + if (tentry->rmid_warned) + return; + + if (tentry->num_rmids !=3D system_rmids) { + pr_info("Telemetry region %s has %d RMIDs system supports %d\n", + tentry->name, tentry->num_rmids, system_rmids); + tentry->rmid_warned =3D true; + } + + if (tr->num_rmids < tentry->num_rmids) { + pr_info("Telemetry region %s only supports %d simultaneous RMIDS\n", + tentry->name, tr->num_rmids); + tentry->rmid_warned =3D true; + } + + /* info/PKG_PERF_MON/num_rmids reports number of guaranteed counters */ + if (!r->num_rmid) + r->num_rmid =3D tr->num_rmids; + else + r->num_rmid =3D min((u32)r->num_rmid, tr->num_rmids); +} + /* * Scan a feature group looking for guids recognized * and update the per-package counts of known groups. @@ -109,6 +139,7 @@ static bool count_events(struct pkg_info *pkg, int max_= pkgs, struct pmt_feature_ pr_warn_once("MMIO region for guid 0x%x too small\n", tr->guid); continue; } + rmid_sanity_check(tr, *tentry); found =3D true; (*tentry)->active =3D true; pkg[tr->plat_info.package_id].count++; --=20 2.48.1 From nobody Fri Dec 19 17:08:33 2025 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.13]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 86702237703 for ; Mon, 7 Apr 2025 23:41:00 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.13 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1744069262; cv=none; b=mhOvxq0ibnUefLHe+Rq2o+grFUvuBVxjX5WbbXbWKxWwFcsyaWB34wZHKzXSqNmtUof3xEDAE6lMJmsJvK+ofeFZj3z/dKgC4Ivdgk+hG2zGl9e5MA57/sOiAEZxEosWHto95kCKcmv/OsQw0UAlDDrOaSndHxqNBJpWwOd43EE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1744069262; c=relaxed/simple; bh=k2dKeDvK8ctetzdumGpNReFcjpN/c5jQdWJNXvokbFQ=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=SujJpfilU6IYpVabSNPqIWQ9xqtaHi5bVchACoBAQcYbpwm/MvrlJSnglmZxz6EuMGMNECUm++yQm8yZg70G7orK0RnDKYQCpAZPEQKaTSAOSVwTaOytPtGVvdxvwVGOXsbW/xeECPPEdUg1p1HhlQbqiwN4Zr90fT1RvnCD7Yo= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com; spf=pass smtp.mailfrom=intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=TYQs8chl; arc=none smtp.client-ip=192.198.163.13 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="TYQs8chl" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1744069261; x=1775605261; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=k2dKeDvK8ctetzdumGpNReFcjpN/c5jQdWJNXvokbFQ=; b=TYQs8chl1uTZ1sKEruemMh1ffwo5vLcdIxmvgpwJ+ehdRxVJb+teQF+2 R6XBp2ckFMU9ACfIf0mvkGZHFQAD+UZe9K3scd5eqm11Z0XVPcvOce7O3 JxOuFDzCz4d1fE7XrlKM/6VIx7aWM8gtsfYUFoDRNTi1MpoE6H3ml+NKJ iXVQ42Qtla7NefkUU6qPCS5xSEx98W7Os56TfgM/Pr3G56S1hNqnI5lLU K/SFmSk5zRFdQI/n+79eukR/ybFVQlF/cfufjpt0UqLpzdA1WlhYXCb65 sVHVpIDVD//V/ZgTF+1tpcFs6nci7u/gupOvOuhA+taONx/tZzwm119AN Q==; X-CSE-ConnectionGUID: 6OHd7NiDTB2rnFiEfDpMNQ== X-CSE-MsgGUID: NoJe/Wv8Ryyqx/nTqrQvoA== X-IronPort-AV: E=McAfee;i="6700,10204,11397"; a="48193263" X-IronPort-AV: E=Sophos;i="6.15,196,1739865600"; d="scan'208";a="48193263" Received: from orviesa001.jf.intel.com ([10.64.159.141]) by fmvoesa107.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 07 Apr 2025 16:40:55 -0700 X-CSE-ConnectionGUID: oAaIfCk3TLeF8pyli6FFsA== X-CSE-MsgGUID: /OcgcXIMQ6OFVvTuxk4MZQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.15,196,1739865600"; d="scan'208";a="165315512" Received: from agluck-desk3.sc.intel.com ([172.25.222.70]) by smtpauth.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 07 Apr 2025 16:40:55 -0700 From: Tony Luck To: Fenghua Yu , Reinette Chatre , Maciej Wieczor-Retman , Peter Newman , James Morse , Babu Moger , Drew Fustini , Dave Martin , Anil Keshavamurthy Cc: linux-kernel@vger.kernel.org, patches@lists.linux.dev, Tony Luck Subject: [PATCH v3 20/26] x86/resctrl: Add and initialize rdt_resource for package scope core monitor Date: Mon, 7 Apr 2025 16:40:22 -0700 Message-ID: <20250407234032.241215-21-tony.luck@intel.com> X-Mailer: git-send-email 2.48.1 In-Reply-To: <20250407234032.241215-1-tony.luck@intel.com> References: <20250407234032.241215-1-tony.luck@intel.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Counts for each Intel telemetry event are periodically sent to one or more aggregators on each package where accumulated totals are made available in MMIO registers. Add a new resource for monitoring these events with code to build domains at the package granularity. Signed-off-by: Tony Luck --- include/linux/resctrl.h | 1 + arch/x86/kernel/cpu/resctrl/core.c | 11 +++++++++++ 2 files changed, 12 insertions(+) diff --git a/include/linux/resctrl.h b/include/linux/resctrl.h index 25f51a57b0b7..c03e7dc1f009 100644 --- a/include/linux/resctrl.h +++ b/include/linux/resctrl.h @@ -232,6 +232,7 @@ enum resctrl_scope { RESCTRL_L2_CACHE =3D 2, RESCTRL_L3_CACHE =3D 3, RESCTRL_L3_NODE, + RESCTRL_PACKAGE, }; =20 /** diff --git a/arch/x86/kernel/cpu/resctrl/core.c b/arch/x86/kernel/cpu/resct= rl/core.c index f0f256a5ac66..9578d9c7260c 100644 --- a/arch/x86/kernel/cpu/resctrl/core.c +++ b/arch/x86/kernel/cpu/resctrl/core.c @@ -99,6 +99,15 @@ struct rdt_hw_resource rdt_resources_all[RDT_NUM_RESOURC= ES] =3D { .schema_fmt =3D RESCTRL_SCHEMA_RANGE, }, }, + [RDT_RESOURCE_PERF_PKG] =3D + { + .r_resctrl =3D { + .rid =3D RDT_RESOURCE_PERF_PKG, + .name =3D "PERF_PKG", + .mon_scope =3D RESCTRL_PACKAGE, + .mon_domains =3D mon_domain_init(RDT_RESOURCE_PERF_PKG), + }, + }, }; =20 u32 resctrl_arch_system_num_rmid_idx(void) @@ -431,6 +440,8 @@ static int get_domain_id_from_scope(int cpu, enum resct= rl_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; } --=20 2.48.1 From nobody Fri Dec 19 17:08:33 2025 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.13]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A24FE23AE83 for ; Mon, 7 Apr 2025 23:41:01 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.13 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1744069263; cv=none; b=RWPHPaK88Jh5lI4gVAORSBcAfrtLTSZORW3jieu9ut7nh/edWzDocVebySqJTlByvn3jLAIxp7d2k+5yL3CPwxspNMJAJfMyFOfL86GluIa3agnQOJn/NnZl2aiQuyLudp1lTK2QVRtBIYIunhNUPAFURH6pY+IQCGVXJjsRSKI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1744069263; c=relaxed/simple; bh=uPpyvGLmew8c8rVdcBQQM9qRJMHVlmbtLeyTb5Ivg1s=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=dwQvoUuaDpmoRCMTYJ26EMotP81H8lX85D+fy5Je5mNBi5DbeKNqezE8hzu+7bTcTnbMuCd6oFywMlJNFxX0tzY3z5EjChhwDrJ+mizZN9gxpZuQsS61e6iCXfGGiMD/bRsxpSJhtbxX1b3nxSvUyvblk428fSHB9N2R1y01LgI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com; spf=pass smtp.mailfrom=intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=DhtxHGZ6; arc=none smtp.client-ip=192.198.163.13 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="DhtxHGZ6" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1744069262; x=1775605262; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=uPpyvGLmew8c8rVdcBQQM9qRJMHVlmbtLeyTb5Ivg1s=; b=DhtxHGZ6wcXBAi+AplRxZh1LfVZUDMhMb1yOJvRNNx3SVoF1SB0oLVWF TbPjs5GA3mHjjbogRwWD7RuI2d6I7kst9Y6f7STkLBQz+odJFYW82HJRe dxg4Vb3ru52soVEjqPIZScShmaS84pzZBAGyFdRYmuc9d6KBVQOL7QIO3 zN6AhDJSTzSlNUnAwxjV/lZn+D9CI8pq1QMjoLu+Tkeqk0msVaT8NsAFP 1a9FiS7xfMnIdIWMh9lvXxcd9oQbmOlv4dvc2u+tGV7UrS2Ayu83kA+vv 6V9s014xxKsB1CeBfMOA10VLH1MmdUEreKtv+WY/+sY/rFcBHJnwnlgHz w==; X-CSE-ConnectionGUID: nzx+q76XSuKculYtOukpfA== X-CSE-MsgGUID: 6mfh0DbHSBe6S/cjQmtb7A== X-IronPort-AV: E=McAfee;i="6700,10204,11397"; a="48193270" X-IronPort-AV: E=Sophos;i="6.15,196,1739865600"; d="scan'208";a="48193270" Received: from orviesa001.jf.intel.com ([10.64.159.141]) by fmvoesa107.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 07 Apr 2025 16:40:56 -0700 X-CSE-ConnectionGUID: 8FW9qs64RKCH4VUyYl+8YA== X-CSE-MsgGUID: MggWdzOBToy4lbOOWVAuBA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.15,196,1739865600"; d="scan'208";a="165315515" Received: from agluck-desk3.sc.intel.com ([172.25.222.70]) by smtpauth.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 07 Apr 2025 16:40:55 -0700 From: Tony Luck To: Fenghua Yu , Reinette Chatre , Maciej Wieczor-Retman , Peter Newman , James Morse , Babu Moger , Drew Fustini , Dave Martin , Anil Keshavamurthy Cc: linux-kernel@vger.kernel.org, patches@lists.linux.dev, Tony Luck Subject: [PATCH v3 21/26] fs-x86/resctrl: Handle RDT_RESOURCE_PERF_PKG in domain create/delete Date: Mon, 7 Apr 2025 16:40:23 -0700 Message-ID: <20250407234032.241215-22-tony.luck@intel.com> X-Mailer: git-send-email 2.48.1 In-Reply-To: <20250407234032.241215-1-tony.luck@intel.com> References: <20250407234032.241215-1-tony.luck@intel.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Add a new rdt_perf_pkg_mon_domain structure. This only consists of the common rdt_domain_hdr as there is no need for any per-domain data structures. Use as much as possible of the existing domain setup and tear down infrastructure. In many cases the RDT_RESOURCE_PERF_PKG uses the same functions but just skips over the pieces it does not need. Signed-off-by: Tony Luck --- include/linux/resctrl.h | 8 ++++++++ arch/x86/kernel/cpu/resctrl/core.c | 32 ++++++++++++++++++++++++++++++ fs/resctrl/rdtgroup.c | 11 ++++++++-- 3 files changed, 49 insertions(+), 2 deletions(-) diff --git a/include/linux/resctrl.h b/include/linux/resctrl.h index c03e7dc1f009..6f598a64b192 100644 --- a/include/linux/resctrl.h +++ b/include/linux/resctrl.h @@ -169,6 +169,14 @@ struct rdt_mon_domain { int cqm_work_cpu; }; =20 +/** + * struct rdt_perf_pkg_mon_domain - CPUs sharing an Intel-PMT-scoped resct= rl monitor resource + * @hdr: common header for different domain types + */ +struct rdt_perf_pkg_mon_domain { + struct rdt_domain_hdr hdr; +}; + /** * struct resctrl_cache - Cache allocation related data * @cbm_len: Length of the cache bit mask diff --git a/arch/x86/kernel/cpu/resctrl/core.c b/arch/x86/kernel/cpu/resct= rl/core.c index 9578d9c7260c..6f5d52a8219b 100644 --- a/arch/x86/kernel/cpu/resctrl/core.c +++ b/arch/x86/kernel/cpu/resctrl/core.c @@ -542,6 +542,29 @@ static void setup_l3_mon_domain(int cpu, int id, struc= t rdt_resource *r, struct } } =20 +static void setup_intel_aet_mon_domain(int cpu, int id, struct rdt_resourc= e *r, + struct list_head *add_pos) +{ + struct rdt_perf_pkg_mon_domain *d; + int err; + + d =3D kzalloc_node(sizeof(*d), GFP_KERNEL, cpu_to_node(cpu)); + if (!d) + return; + + d->hdr.id =3D id; + d->hdr.type =3D DOMTYPE(r->rid, DOMTYPE_MON); + cpumask_set_cpu(cpu, &d->hdr.cpu_mask); + list_add_tail_rcu(&d->hdr.list, add_pos); + + err =3D resctrl_online_mon_domain(r, &d->hdr); + if (err) { + list_del_rcu(&d->hdr.list); + synchronize_rcu(); + kfree(d); + } +} + static void domain_add_cpu_mon(int cpu, struct rdt_resource *r) { int id =3D get_domain_id_from_scope(cpu, r->mon_scope); @@ -571,6 +594,9 @@ static void domain_add_cpu_mon(int cpu, struct rdt_reso= urce *r) case RDT_RESOURCE_L3: setup_l3_mon_domain(cpu, id, r, add_pos); break; + case RDT_RESOURCE_PERF_PKG: + setup_intel_aet_mon_domain(cpu, id, r, add_pos); + break; default: WARN_ON_ONCE(1); } @@ -668,6 +694,12 @@ static void domain_remove_cpu_mon(int cpu, struct rdt_= resource *r) synchronize_rcu(); mon_domain_free(hw_dom); break; + case RDT_RESOURCE_PERF_PKG: + resctrl_offline_mon_domain(r, d); + list_del_rcu(&hdr->list); + synchronize_rcu(); + kfree(container_of(hdr, struct rdt_perf_pkg_mon_domain, hdr)); + break; } } =20 diff --git a/fs/resctrl/rdtgroup.c b/fs/resctrl/rdtgroup.c index 5ca6de6a6e5c..34fcd20f8dd7 100644 --- a/fs/resctrl/rdtgroup.c +++ b/fs/resctrl/rdtgroup.c @@ -4020,6 +4020,9 @@ void resctrl_offline_mon_domain(struct rdt_resource *= r, struct rdt_mon_domain *d if (resctrl_mounted && resctrl_arch_mon_capable()) rmdir_mondata_subdir_allrdtgrp(r, &d->hdr); =20 + if (r->rid =3D=3D RDT_RESOURCE_PERF_PKG) + goto done; + if (resctrl_is_mbm_enabled()) cancel_delayed_work(&d->mbm_over); if (resctrl_arch_is_llc_occupancy_enabled() && has_busy_rmid(d)) { @@ -4036,7 +4039,7 @@ void resctrl_offline_mon_domain(struct rdt_resource *= r, struct rdt_mon_domain *d } =20 domain_destroy_mon_state(d); - +done: mutex_unlock(&rdtgroup_mutex); } =20 @@ -4104,12 +4107,15 @@ int resctrl_online_ctrl_domain(struct rdt_resource = *r, struct rdt_ctrl_domain *d int resctrl_online_mon_domain(struct rdt_resource *r, struct rdt_domain_hd= r *hdr) { struct rdt_mon_domain *d; - int err; + int err =3D 0; =20 WARN_ON_ONCE(hdr->type !=3D DOMTYPE(r->rid, DOMTYPE_MON)); d =3D container_of(hdr, struct rdt_mon_domain, hdr); mutex_lock(&rdtgroup_mutex); =20 + if (r->rid =3D=3D RDT_RESOURCE_PERF_PKG) + goto do_mkdir; + err =3D domain_setup_mon_state(r, d); if (err) goto out_unlock; @@ -4123,6 +4129,7 @@ int resctrl_online_mon_domain(struct rdt_resource *r,= struct rdt_domain_hdr *hdr if (resctrl_arch_is_llc_occupancy_enabled()) INIT_DELAYED_WORK(&d->cqm_limbo, cqm_handle_limbo); =20 +do_mkdir: /* * If the filesystem is not mounted then only the default resource group * exists. Creation of its directories is deferred until mount time --=20 2.48.1 From nobody Fri Dec 19 17:08:33 2025 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.13]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id CCC6023BFA9 for ; Mon, 7 Apr 2025 23:41:01 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.13 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1744069263; cv=none; b=HRsVgMcvhdRyPhLD6X2Amm744ZUWPh4dn4j2S3HnxxZX11yMCgpkhJObfsqshZrMN1npy9X9H3onw4kNfKdQhZ8n67E7VJuloSTOxRUpKPHxk7ANpjcNOIi33kZE5d2YaN2n8+ETaAdAtUfUp+7SnNXXFmsySbTLtWD4tmMAKEA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1744069263; c=relaxed/simple; bh=sJ8ho4sQaoe/V4caQsu5Rg0O+TjhTAyA8IQqtw/iH0U=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=udtowpyiK6evk1cynaVaW+6PuPy81afa7+vh2T0qcHZVZ2MS8cdimOaFDLsp4Fe/UD/XpLiuFhcY1dCGQIrzrYRpl8GIJWm1hAsKx+tK/E1ZVSv8YaXX12281XdIlWM1rJ1l7czmatJSrr3zniIO2GU4BYGcCBhda/PRLYAAdjU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com; spf=pass smtp.mailfrom=intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=RTyFMkBt; arc=none smtp.client-ip=192.198.163.13 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="RTyFMkBt" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1744069262; x=1775605262; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=sJ8ho4sQaoe/V4caQsu5Rg0O+TjhTAyA8IQqtw/iH0U=; b=RTyFMkBteym/QEhHaj5IiFYdYqXQWOxbtg0lmBva5qUpnHlj7BWXfqOB KcUL7KT1sgzeWv5tNLHjnyqOO1J4yBHlo617gN3qqaI2wMu6K5+/Ncr4X ED9H7tAG9hqBAPXTaQacfgE/PZ5dp422QnVOnO+a42am4odbbF21q+JXC CPhazd0liJ1xPdG40UVD4Kj3HsQlOKrBaClzUj1+qtRC4KpXayNcrdegm NHJkB7Wpo6ceOji4OJicYgXgPHGEqZ6UsPomgnR/1lfNZeH17kaROv4d8 uIamCTHckx5QCZFYj0JZ3h2BfQegd1TsIEE5Cj2CGa9TQImI2ZM/IYJSW w==; X-CSE-ConnectionGUID: 4AOBx8itSX+pHpxiVr0J2g== X-CSE-MsgGUID: KBkkquYaTRWPQlVNHP5Xcg== X-IronPort-AV: E=McAfee;i="6700,10204,11397"; a="48193277" X-IronPort-AV: E=Sophos;i="6.15,196,1739865600"; d="scan'208";a="48193277" Received: from orviesa001.jf.intel.com ([10.64.159.141]) by fmvoesa107.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 07 Apr 2025 16:40:56 -0700 X-CSE-ConnectionGUID: JNpsx4/FS8Gcy2CVvtLVAQ== X-CSE-MsgGUID: jAKkrK7HRy+j1Nr2T3NT1w== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.15,196,1739865600"; d="scan'208";a="165315518" Received: from agluck-desk3.sc.intel.com ([172.25.222.70]) by smtpauth.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 07 Apr 2025 16:40:56 -0700 From: Tony Luck To: Fenghua Yu , Reinette Chatre , Maciej Wieczor-Retman , Peter Newman , James Morse , Babu Moger , Drew Fustini , Dave Martin , Anil Keshavamurthy Cc: linux-kernel@vger.kernel.org, patches@lists.linux.dev, Tony Luck Subject: [PATCH v3 22/26] fs/resctrl: Add type define for PERF_PKG files Date: Mon, 7 Apr 2025 16:40:24 -0700 Message-ID: <20250407234032.241215-23-tony.luck@intel.com> X-Mailer: git-send-email 2.48.1 In-Reply-To: <20250407234032.241215-1-tony.luck@intel.com> References: <20250407234032.241215-1-tony.luck@intel.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Creation of the default info file for monitor resources requires an RFTYPE_RES_ define and mapping from the resource id. Add the define and case in fflags_from_resource(). Signed-off-by: Tony Luck --- fs/resctrl/internal.h | 2 ++ fs/resctrl/rdtgroup.c | 2 ++ 2 files changed, 4 insertions(+) diff --git a/fs/resctrl/internal.h b/fs/resctrl/internal.h index 4a840e683e96..b7bc820da726 100644 --- a/fs/resctrl/internal.h +++ b/fs/resctrl/internal.h @@ -253,6 +253,8 @@ struct rdtgroup { =20 #define RFTYPE_DEBUG BIT(10) =20 +#define RFTYPE_RES_PERF_PKG BIT(11) + #define RFTYPE_CTRL_INFO (RFTYPE_INFO | RFTYPE_CTRL) =20 #define RFTYPE_MON_INFO (RFTYPE_INFO | RFTYPE_MON) diff --git a/fs/resctrl/rdtgroup.c b/fs/resctrl/rdtgroup.c index 34fcd20f8dd7..cae68e8b9f86 100644 --- a/fs/resctrl/rdtgroup.c +++ b/fs/resctrl/rdtgroup.c @@ -2175,6 +2175,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; } =20 return WARN_ON_ONCE(1); --=20 2.48.1 From nobody Fri Dec 19 17:08:33 2025 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.13]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A108723E259 for ; Mon, 7 Apr 2025 23:41:02 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.13 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1744069264; cv=none; b=ZfLPExB0mhBUXZE9GR2b68bgmRyhX1tetjDIT+QH+5i+1KQKydV7ffxF94m8l+jg/7siRogscW25wqUVtjR3kkWpkRJEHyT6BpILBmIM2YG5H9YcmAcHPGIp448oii645Rx3BaI5vzFGGagY3B2XT1VzoAmA3OwTpRDyki+Dbls= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1744069264; c=relaxed/simple; bh=1i/8JSi+8RpbrWAm8clCMAtNcpyDmlI9pQJUCQrwPiQ=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=fjV9UA/7Gwo/Y5F6NQS6CD37660IJ7i2paSDaUdB4Q+mM+qLcMBifjXa/188wTcpl6egQU3CkVJb4Hw+YlNobTXYVVAH290VoIsoHIIFBaH4c+gsDhfJTYxcQzioZwoDQpGbsPigJ7qKcR8BdjINye5OhpEF1qI+bdKk1OpjQmg= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com; spf=pass smtp.mailfrom=intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=aBC+8RRW; arc=none smtp.client-ip=192.198.163.13 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="aBC+8RRW" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1744069263; x=1775605263; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=1i/8JSi+8RpbrWAm8clCMAtNcpyDmlI9pQJUCQrwPiQ=; b=aBC+8RRWpwzrZb7ypBI94QzFcBMDo2iKkfvSG6P9h++DFO8lZLBIotDY dX3L2ZLpYFs63o/yWukhFGapjwKjQ5vBy0S064+q6pW3UivYKbxZSpj6T D24FNGHrlM6zc26L57lTD/jIaEcfuXx8VAtVRKCTsSHqz9wjn9qL0d+A9 YtkgY1Z1Y35vKs+4ti/aKRpSN8mTBhWDKmW47zD68lRHUr5BFksLJQQx1 KDV8uGAXfYxpilhJzwhC5WkraVa3hVeDOLvrnPrM+g5rdl1wWsTdoDcfR VsOQydVuEx8B6ohQr8c249po5dAg2Rj4can+5vIbOHJ7M9JrTsXgqcCAh Q==; X-CSE-ConnectionGUID: jsIQdmanStOYzvCIXyZsLQ== X-CSE-MsgGUID: Hyz/LM2ESiyaYFaxw+xk3Q== X-IronPort-AV: E=McAfee;i="6700,10204,11397"; a="48193284" X-IronPort-AV: E=Sophos;i="6.15,196,1739865600"; d="scan'208";a="48193284" Received: from orviesa001.jf.intel.com ([10.64.159.141]) by fmvoesa107.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 07 Apr 2025 16:40:57 -0700 X-CSE-ConnectionGUID: HyM8rUmgQLi9YMMOGa9xnw== X-CSE-MsgGUID: rhkLX5R7RYK4cG/S/wSo5Q== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.15,196,1739865600"; d="scan'208";a="165315523" Received: from agluck-desk3.sc.intel.com ([172.25.222.70]) by smtpauth.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 07 Apr 2025 16:40:56 -0700 From: Tony Luck To: Fenghua Yu , Reinette Chatre , Maciej Wieczor-Retman , Peter Newman , James Morse , Babu Moger , Drew Fustini , Dave Martin , Anil Keshavamurthy Cc: linux-kernel@vger.kernel.org, patches@lists.linux.dev, Tony Luck Subject: [PATCH v3 23/26] fs/resctrl: Add new telemetry event id and structures Date: Mon, 7 Apr 2025 16:40:25 -0700 Message-ID: <20250407234032.241215-24-tony.luck@intel.com> X-Mailer: git-send-email 2.48.1 In-Reply-To: <20250407234032.241215-1-tony.luck@intel.com> References: <20250407234032.241215-1-tony.luck@intel.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Nine new events for energy and perf monitoring per-RMID. Signed-off-by: Tony Luck --- include/linux/resctrl_types.h | 19 ++++++++++++--- fs/resctrl/monitor.c | 45 +++++++++++++++++++++++++++++++++++ 2 files changed, 61 insertions(+), 3 deletions(-) diff --git a/include/linux/resctrl_types.h b/include/linux/resctrl_types.h index 3354f21e82ad..2c959e7233dd 100644 --- a/include/linux/resctrl_types.h +++ b/include/linux/resctrl_types.h @@ -46,16 +46,29 @@ enum resctrl_res_level { }; =20 /* - * Event IDs, the values match those used to program IA32_QM_EVTSEL before - * reading IA32_QM_CTR on RDT systems. + * Event IDs */ enum resctrl_event_id { + /* Legacy events. Values must match X86 IA32_QM_EVTSEL usage */ QOS_L3_OCCUP_EVENT_ID =3D 0x01, QOS_L3_MBM_TOTAL_EVENT_ID =3D 0x02, QOS_L3_MBM_LOCAL_EVENT_ID =3D 0x03, + + /* Intel Telemetry Events */ + PMT_EVENT_ENERGY, + PMT_EVENT_ACTIVITY, + PMT_EVENT_STALLS_LLC_HIT, + PMT_EVENT_C1_RES, + PMT_EVENT_UNHALTED_CORE_CYCLES, + PMT_EVENT_STALLS_LLC_MISS, + PMT_EVENT_AUTO_C6_RES, + PMT_EVENT_UNHALTED_REF_CYCLES, + PMT_EVENT_UOPS_RETIRED, + + /* Must be the last */ + QOS_NUM_EVENTS }; =20 -#define QOS_NUM_EVENTS (QOS_L3_MBM_LOCAL_EVENT_ID + 1) #define QOS_NUM_MBM_EVENTS (QOS_L3_MBM_LOCAL_EVENT_ID - QOS_L3_MBM_TOTAL_E= VENT_ID + 1) #define MBM_EVENT_IDX(evt) ((evt) - QOS_L3_MBM_TOTAL_EVENT_ID) =20 diff --git a/fs/resctrl/monitor.c b/fs/resctrl/monitor.c index 5846a13c631a..0207c9ed2d47 100644 --- a/fs/resctrl/monitor.c +++ b/fs/resctrl/monitor.c @@ -861,6 +861,51 @@ static struct mon_evt all_events[QOS_NUM_EVENTS] =3D { .rid =3D RDT_RESOURCE_L3, .type =3D EVT_TYPE_U64, }, + [PMT_EVENT_ENERGY] =3D { + .name =3D "core_energy", + .evtid =3D PMT_EVENT_ENERGY, + .rid =3D RDT_RESOURCE_PERF_PKG, + }, + [PMT_EVENT_ACTIVITY] =3D { + .name =3D "activity", + .evtid =3D PMT_EVENT_ACTIVITY, + .rid =3D RDT_RESOURCE_PERF_PKG, + }, + [PMT_EVENT_STALLS_LLC_HIT] =3D { + .name =3D "stalls_llc_hit", + .evtid =3D PMT_EVENT_STALLS_LLC_HIT, + .rid =3D RDT_RESOURCE_PERF_PKG, + }, + [PMT_EVENT_C1_RES] =3D { + .name =3D "c1_res", + .evtid =3D PMT_EVENT_C1_RES, + .rid =3D RDT_RESOURCE_PERF_PKG, + }, + [PMT_EVENT_UNHALTED_CORE_CYCLES] =3D { + .name =3D "unhalted_core_cycles", + .evtid =3D PMT_EVENT_UNHALTED_CORE_CYCLES, + .rid =3D RDT_RESOURCE_PERF_PKG, + }, + [PMT_EVENT_STALLS_LLC_MISS] =3D { + .name =3D "stalls_llc_miss", + .evtid =3D PMT_EVENT_STALLS_LLC_MISS, + .rid =3D RDT_RESOURCE_PERF_PKG, + }, + [PMT_EVENT_AUTO_C6_RES] =3D { + .name =3D "c6_res", + .evtid =3D PMT_EVENT_AUTO_C6_RES, + .rid =3D RDT_RESOURCE_PERF_PKG, + }, + [PMT_EVENT_UNHALTED_REF_CYCLES] =3D { + .name =3D "unhalted_ref_cycles", + .evtid =3D PMT_EVENT_UNHALTED_REF_CYCLES, + .rid =3D RDT_RESOURCE_PERF_PKG, + }, + [PMT_EVENT_UOPS_RETIRED] =3D { + .name =3D "uops_retired", + .evtid =3D PMT_EVENT_UOPS_RETIRED, + .rid =3D RDT_RESOURCE_PERF_PKG, + }, }; =20 int resctrl_set_event_attributes(enum resctrl_event_id evt, --=20 2.48.1 From nobody Fri Dec 19 17:08:33 2025 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.13]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D1451241685 for ; Mon, 7 Apr 2025 23:41:03 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.13 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1744069265; cv=none; b=lKja1mMYCBtiw8lLYEwEmyRy6Ng4M7IdeFn/LMEAFoo+RZ6cXFjewCPk3yaL0bQwuQ5YN+URqrCeTACQ789NbRmvEGrUSYaLh8wQ00NLLTgpTWe0X791Dp1EuwLeoDPdLgHJtWQ06dz7rw631En33ZcykPbMix/Dyy4XJ7u/z7k= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1744069265; c=relaxed/simple; bh=YPgBmaGFxAjBWQ1H7JPon+CBlWuuyIL/tEBYIMVCULo=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=SdWAEkpsWgVZP9uyHwP7/fCwWD7oG79+dktigU5lHLwY9NxW55ZC7tgG4vnU17EHkAJM/Onn9rMH1esLbTiroi8rLLKlE1iUSUtuwJnX/gh3GrP+wPoR/W/zN6MHr7HFuED2YDBEYTJiarartAuEFStw1Lr3f5CQgbrGM2J53Ho= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com; spf=pass smtp.mailfrom=intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=L2SiHqb+; arc=none smtp.client-ip=192.198.163.13 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="L2SiHqb+" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1744069264; x=1775605264; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=YPgBmaGFxAjBWQ1H7JPon+CBlWuuyIL/tEBYIMVCULo=; b=L2SiHqb+TyjCRHpRtpA4Gmr6x1IczUWCtSlGjHCFUzjlhPoqnOsoKDil Msxgb+bQsZGmD4jzbdgXaLTVoeREqkmoJff43PaIKf3v3S108hhtAUXRa ZLGkthagFTaW1Q7VBpM0u/QqNazySNT6Boo0v0U/+XJtP1nyx3AxwmymY rcG42jHXnn4tV6WN8IwE7U5l4ggRk0X/40Kzpr1Boq9QNFftgA/PRFbq2 rREYs+d9+IjmoiEJMaATKETb84Ftxr1ixONOi9nKjdtWrcPYeJAJCrr1q GrTNroFMDOwCmK3qYNZfVFF4MsEFNxcm1KJ/LYB/Ev3M8ivXQYj6CEjEv w==; X-CSE-ConnectionGUID: 1rAXAQEKTHe4PvMjOBsS5A== X-CSE-MsgGUID: P/pWXnvsRWudhBEFt0xHDw== X-IronPort-AV: E=McAfee;i="6700,10204,11397"; a="48193291" X-IronPort-AV: E=Sophos;i="6.15,196,1739865600"; d="scan'208";a="48193291" Received: from orviesa001.jf.intel.com ([10.64.159.141]) by fmvoesa107.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 07 Apr 2025 16:40:57 -0700 X-CSE-ConnectionGUID: 6ZRJfK9HQTig6tJ5vgiMSw== X-CSE-MsgGUID: 8IaI1KoAR5+RYI+M13hzkQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.15,196,1739865600"; d="scan'208";a="165315527" Received: from agluck-desk3.sc.intel.com ([172.25.222.70]) by smtpauth.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 07 Apr 2025 16:40:57 -0700 From: Tony Luck To: Fenghua Yu , Reinette Chatre , Maciej Wieczor-Retman , Peter Newman , James Morse , Babu Moger , Drew Fustini , Dave Martin , Anil Keshavamurthy Cc: linux-kernel@vger.kernel.org, patches@lists.linux.dev, Tony Luck Subject: [PATCH v3 24/26] x86/resctrl: Final steps to enable RDT_RESOURCE_PERF_PKG Date: Mon, 7 Apr 2025 16:40:26 -0700 Message-ID: <20250407234032.241215-25-tony.luck@intel.com> X-Mailer: git-send-email 2.48.1 In-Reply-To: <20250407234032.241215-1-tony.luck@intel.com> References: <20250407234032.241215-1-tony.luck@intel.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" For each of the discovered telemetry events: Mark as enabled in the rdt_mon_features bitmap. Set the value display type. Mark that the event can be read from any CPU. Because the resource was not marked as enabled during early initialization no domain discovery and allocation was done. Do that in the architecture first mount hook. Signed-off-by: Tony Luck --- arch/x86/kernel/cpu/resctrl/core.c | 14 ++++++++++++++ arch/x86/kernel/cpu/resctrl/intel_aet.c | 5 +++++ 2 files changed, 19 insertions(+) diff --git a/arch/x86/kernel/cpu/resctrl/core.c b/arch/x86/kernel/cpu/resct= rl/core.c index 6f5d52a8219b..83da63b24f45 100644 --- a/arch/x86/kernel/cpu/resctrl/core.c +++ b/arch/x86/kernel/cpu/resctrl/core.c @@ -756,7 +756,9 @@ static int resctrl_arch_offline_cpu(unsigned int cpu) =20 void resctrl_arch_mount(void) { + struct rdt_resource *r =3D &rdt_resources_all[RDT_RESOURCE_PERF_PKG].r_re= sctrl; static bool only_once; + int cpu; =20 if (only_once) return; @@ -764,6 +766,18 @@ void resctrl_arch_mount(void) =20 if (!intel_aet_get_events()) return; + + /* + * Late discovery of telemetry events means the domains for the + * resource were not built. Do that now. + */ + cpus_read_lock(); + mutex_lock(&domain_list_lock); + r->mon_capable =3D true; + for_each_online_cpu(cpu) + domain_add_cpu_mon(cpu, r); + mutex_unlock(&domain_list_lock); + cpus_read_unlock(); } =20 enum { diff --git a/arch/x86/kernel/cpu/resctrl/intel_aet.c b/arch/x86/kernel/cpu/= resctrl/intel_aet.c index 0bcbac326bee..529f6d49e3a3 100644 --- a/arch/x86/kernel/cpu/resctrl/intel_aet.c +++ b/arch/x86/kernel/cpu/resctrl/intel_aet.c @@ -233,9 +233,14 @@ bool intel_aet_get_events(void) continue; for (int i =3D 0; i < (*tentry)->num_events; i++) { enum resctrl_event_id evtid =3D (*tentry)->evts[i].evtid; + enum resctrl_event_type type; =20 evtinfo[evtid].telem_entry =3D *tentry; evtinfo[evtid].pmt_event =3D &(*tentry)->evts[i]; + + __set_bit(evtid, rdt_mon_features); + type =3D (*tentry)->evts[i].type; + resctrl_set_event_attributes(evtid, type, true); } } =20 --=20 2.48.1 From nobody Fri Dec 19 17:08:33 2025 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.13]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D8506241696 for ; Mon, 7 Apr 2025 23:41:03 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.13 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1744069266; cv=none; b=pS9iEqJAzj2e+I4mQVlw0Riwx885Aau3wT2Yku1dnAk9CMX9hRFBe0NRu6AZbDCQHQl8s/Y6wLKe8GXiHIqNBr4yVjQN+bWjskNx7pJdiFcz1QIKrs8hXNMVWDqV/W7VD0Iva38zezFQoHlfD6hOv5n7bbntOMSZR/U5Iu7xkyw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1744069266; c=relaxed/simple; bh=0vh9HuxcyMxqpMiFdEcg2+0e4DmDqzuVo7gAd3iUy4g=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=BneWr2oLpu8u+Qe9iFkMD0f/eCfqSUS7TELJqSw/6NE0yA4uCnLamNod/rgs8KtBKgGFgL4fsELiNHf7hgv5z39LgMQiNLRiCl6KhGj0VFeQioRSZMvaQHRImaGlcfFvHJGPMxEs15J5TXOLoOzfqJYX+FYfNIcpKDENq74Lp2s= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com; spf=pass smtp.mailfrom=intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=mQ99iHCT; arc=none smtp.client-ip=192.198.163.13 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="mQ99iHCT" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1744069264; x=1775605264; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=0vh9HuxcyMxqpMiFdEcg2+0e4DmDqzuVo7gAd3iUy4g=; b=mQ99iHCThLb0NpxKVVedJnwUmi1B/MABRRy0jqCJLWPMLCtGWsMhDRzT VuoOQRvhzC77MkuMUAxG1xcYo9oSp96MhK9hal6tuPBJhLAFnGwShB/Ee CuAJ7mVrm0YbkPyDIs1aINfO1Apf877jyLL720uaAScgaLG5UMKf6uRg4 4XTV84pYK3k8Rw5KtNjqBKoqPgxG/HGicUkIj85p+N4eBcnPUi4rRhb/A Lm/h3ZqZNuDOX4GUypJWqOQkg51azqKRkWs4wI7d3+1/Qh91jTFgpW1+F rT58DBz2TNmHMzG0yeviOCFMal5txMHb1D2LkEiirFm19WrTdltXz81G6 Q==; X-CSE-ConnectionGUID: 1/byRNyORJGUC6TnGnsJ2w== X-CSE-MsgGUID: iNHrHxzzRaCBxSdw15Zhgg== X-IronPort-AV: E=McAfee;i="6700,10204,11397"; a="48193298" X-IronPort-AV: E=Sophos;i="6.15,196,1739865600"; d="scan'208";a="48193298" Received: from orviesa001.jf.intel.com ([10.64.159.141]) by fmvoesa107.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 07 Apr 2025 16:40:58 -0700 X-CSE-ConnectionGUID: iih2M1wyTkGHvcCDv8Uc3w== X-CSE-MsgGUID: PIWC+5UDRSWEI0fW8Se0eQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.15,196,1739865600"; d="scan'208";a="165315532" Received: from agluck-desk3.sc.intel.com ([172.25.222.70]) by smtpauth.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 07 Apr 2025 16:40:57 -0700 From: Tony Luck To: Fenghua Yu , Reinette Chatre , Maciej Wieczor-Retman , Peter Newman , James Morse , Babu Moger , Drew Fustini , Dave Martin , Anil Keshavamurthy Cc: linux-kernel@vger.kernel.org, patches@lists.linux.dev, Tony Luck Subject: [PATCH v3 25/26] fs-x86/resctrl: Add detailed descriptions for Clearwater Forest events Date: Mon, 7 Apr 2025 16:40:27 -0700 Message-ID: <20250407234032.241215-26-tony.luck@intel.com> X-Mailer: git-send-email 2.48.1 In-Reply-To: <20250407234032.241215-1-tony.luck@intel.com> References: <20250407234032.241215-1-tony.luck@intel.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" There are two event groups one for energy reporting and another for "perf" events. See the XML description files in https://github.com/intel/Intel-PMT in the xml/CWF/OOBMSM/{RMID-ENERGY,RMID-PERF}/ for the detailed descriptions that were used to derive these descriptions. Signed-off-by: Tony Luck --- arch/x86/kernel/cpu/resctrl/intel_aet.c | 57 +++++++++++++++++++++++++ 1 file changed, 57 insertions(+) diff --git a/arch/x86/kernel/cpu/resctrl/intel_aet.c b/arch/x86/kernel/cpu/= resctrl/intel_aet.c index 529f6d49e3a3..e1097767009e 100644 --- a/arch/x86/kernel/cpu/resctrl/intel_aet.c +++ b/arch/x86/kernel/cpu/resctrl/intel_aet.c @@ -42,6 +42,8 @@ struct pmt_event { enum resctrl_event_type type; }; =20 +#define EVT(id, offset, _type) { .evtid =3D id, .evt_offset =3D offset, .t= ype =3D _type } + /** * struct telem_entry - Summarized form from XML telemetry description * @name: Name for this group of events @@ -82,8 +84,63 @@ static struct evtinfo { =20 #define EVT_OFFSET(evtid) (evtinfo[evtid].pmt_event->evt_offset) =20 +/* + * https://github.com/intel/Intel-PMT + * xml/CWF/OOBMSM/RMID-ENERGY *.xml + */ +#define NUM_RMIDS_0x26696143 576 +#define GUID_0x26696143 0x26696143 +#define NUM_EVENTS_0x26696143 2 +#define EVT_BYTES_0x26696143 (NUM_RMIDS_0x26696143 * NUM_EVENTS_0x26696143= * sizeof(u64)) + +static struct telem_entry energy_0x26696143 =3D { + .name =3D "energy", + .guid =3D GUID_0x26696143, + .size =3D EVT_BYTES_0x26696143 + sizeof(u64) * 3, + .num_rmids =3D NUM_RMIDS_0x26696143, + .overflow_counter_off =3D EVT_BYTES_0x26696143 + sizeof(u64) * 0, + .last_overflow_tstamp_off =3D EVT_BYTES_0x26696143 + sizeof(u64) * 1, + .last_update_tstamp_off =3D EVT_BYTES_0x26696143 + sizeof(u64) * 2, + .num_events =3D NUM_EVENTS_0x26696143, + .evts =3D { + EVT(PMT_EVENT_ENERGY, 0x0, EVT_TYPE_U46_18), + EVT(PMT_EVENT_ACTIVITY, 0x8, EVT_TYPE_U46_18), + } +}; + +/* + * https://github.com/intel/Intel-PMT + * xml/CWF/OOBMSM/RMID-PERF *.xml + */ +#define NUM_RMIDS_0x26557651 576 +#define GUID_0x26557651 0x26557651 +#define NUM_EVENTS_0x26557651 7 +#define EVT_BYTES_0x26557651 (NUM_RMIDS_0x26557651 * NUM_EVENTS_0x26557651= * sizeof(u64)) + +static struct telem_entry perf_0x26557651 =3D { + .name =3D "perf", + .guid =3D GUID_0x26557651, + .size =3D EVT_BYTES_0x26557651 + sizeof(u64) * 3, + .num_rmids =3D NUM_RMIDS_0x26557651, + .overflow_counter_off =3D EVT_BYTES_0x26557651 + sizeof(u64) * 0, + .last_overflow_tstamp_off =3D EVT_BYTES_0x26557651 + sizeof(u64) * 1, + .last_update_tstamp_off =3D EVT_BYTES_0x26557651 + sizeof(u64) * 2, + .num_events =3D NUM_EVENTS_0x26557651, + .evts =3D { + EVT(PMT_EVENT_STALLS_LLC_HIT, 0x0, EVT_TYPE_U64), + EVT(PMT_EVENT_C1_RES, 0x8, EVT_TYPE_U64), + EVT(PMT_EVENT_UNHALTED_CORE_CYCLES, 0x10, EVT_TYPE_U64), + EVT(PMT_EVENT_STALLS_LLC_MISS, 0x18, EVT_TYPE_U64), + EVT(PMT_EVENT_AUTO_C6_RES, 0x20, EVT_TYPE_U64), + EVT(PMT_EVENT_UNHALTED_REF_CYCLES, 0x28, EVT_TYPE_U64), + EVT(PMT_EVENT_UOPS_RETIRED, 0x30, EVT_TYPE_U64), + } +}; + /* All known telemetry event groups */ static struct telem_entry *telem_entry[] =3D { + &energy_0x26696143, + &perf_0x26557651, NULL }; =20 --=20 2.48.1 From nobody Fri Dec 19 17:08:33 2025 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.13]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C00F224886B for ; Mon, 7 Apr 2025 23:41:04 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.13 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1744069266; cv=none; b=PLC+vCIDYFl5vzEhhwP7BXUujZaNVC9ru1AgcKN7er9pc0xab6KF5pLaoz8vc6Fxc/IdaY8CWi5PGPasPLik08cp7b2mj1DDO8HZh9zQiSw2zkoKZPxgkilzlGNTf0Uphcko9sLH/TmAoskjeCQdpMxotJIg0Ad9x+tQh5wd70I= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1744069266; c=relaxed/simple; bh=yr5nHpaopd1NZz+g077gSUSbgIi4RWyZKVBYkSkwieQ=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=P71amORK7ulP8rSbFRmHtwnyDztl+wqvcDa4ps6pV5j/8A/BQ/HELQyipC/j0FoEJw8a3XAqWFNUqVnBL00yBwYB9L8J617y7UsuVa6ukfRZJ1Xfv/9CovemAI0Kzbqce3oa/36rIoxQJKJaacmFin0y2Tmvyr0J4BpirPX+3tk= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com; spf=pass smtp.mailfrom=intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=QlIznT5e; arc=none smtp.client-ip=192.198.163.13 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="QlIznT5e" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1744069265; x=1775605265; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=yr5nHpaopd1NZz+g077gSUSbgIi4RWyZKVBYkSkwieQ=; b=QlIznT5eaPS9orEvr0xw+eH7YtSwEbkJqPrHpDI6Sq4fmiWO6FUMa9OE 67LGI2/a4H16DGnjWyAMSyOHGW2HCGTN+SBbk+7UalR6RYnBZA4h24Ti8 EH7Pedp78EeeFS4BjexR6PymOnrLFyaqvvmSGIGlh+NI9xo2ywjvVLlv1 /lTxetcfk9hSRmhmioBUayuYq04gA4qM+lOgQC68IO/hZuj83Pq0vOYJ2 AawJMVEEjYlmI1bYmZqcbCyJbFLH+YQzZon53T2j3OOCT36pZFR9zuPWZ NYCzmgT0J/tqoO40/nXvWXMUvLp9PVMuf5Te9xaYGAYTGiCyd64qAgNM4 w==; X-CSE-ConnectionGUID: pACSuUvvSIW4ZzpbfHblQg== X-CSE-MsgGUID: rU9jSnq3Qea4f/6Iybxtrw== X-IronPort-AV: E=McAfee;i="6700,10204,11397"; a="48193306" X-IronPort-AV: E=Sophos;i="6.15,196,1739865600"; d="scan'208";a="48193306" Received: from orviesa001.jf.intel.com ([10.64.159.141]) by fmvoesa107.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 07 Apr 2025 16:40:59 -0700 X-CSE-ConnectionGUID: g6//5lGvSuqmbgGvUV8Onw== X-CSE-MsgGUID: pFmv8TNbTkaH0x04cfURpA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.15,196,1739865600"; d="scan'208";a="165315535" Received: from agluck-desk3.sc.intel.com ([172.25.222.70]) by smtpauth.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 07 Apr 2025 16:40:58 -0700 From: Tony Luck To: Fenghua Yu , Reinette Chatre , Maciej Wieczor-Retman , Peter Newman , James Morse , Babu Moger , Drew Fustini , Dave Martin , Anil Keshavamurthy Cc: linux-kernel@vger.kernel.org, patches@lists.linux.dev, Tony Luck Subject: [PATCH v3 26/26] x86/resctrl: Update Documentation for package events Date: Mon, 7 Apr 2025 16:40:28 -0700 Message-ID: <20250407234032.241215-27-tony.luck@intel.com> X-Mailer: git-send-email 2.48.1 In-Reply-To: <20250407234032.241215-1-tony.luck@intel.com> References: <20250407234032.241215-1-tony.luck@intel.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Each "mon_data" directory is now divided between L3 events and package events. The "info/PERF_PKG_MON" directory contains parameters for perf events. Signed-off-by: Tony Luck --- Documentation/filesystems/resctrl.rst | 38 ++++++++++++++++++++------- 1 file changed, 28 insertions(+), 10 deletions(-) diff --git a/Documentation/filesystems/resctrl.rst b/Documentation/filesyst= ems/resctrl.rst index 6768fc1fad16..b89a188b0321 100644 --- a/Documentation/filesystems/resctrl.rst +++ b/Documentation/filesystems/resctrl.rst @@ -167,7 +167,7 @@ with respect to allocation: bandwidth percentages are directly applied to the threads running on the core =20 -If RDT monitoring is available there will be an "L3_MON" directory +If RDT L3 monitoring is available there will be an "L3_MON" directory with the following files: =20 "num_rmids": @@ -261,6 +261,17 @@ with the following files: bytes) at which a previously used LLC_occupancy counter can be considered for re-use. =20 +If RDT PERF monitoring is available there will be an "L3_PERF_PKG" directo= ry +with the following files: + +"num_rmids": + The guaranteed number of hardware countes supporting RMIDs. + If more "CTRL_MON" + "MON" groups than this number are created, + the system may report that counters are "unavailable" when read. + +"mon_features": + Lists the perf monitoring events that are enabled on this system. + Finally, in the top level of the "info" directory there is a file named "last_cmd_status". This is reset with every "command" issued via the file system (making new directories or writing to any of the @@ -366,15 +377,22 @@ When control is enabled all CTRL_MON groups will also= contain: When monitoring is enabled all MON groups will also contain: =20 "mon_data": - This contains a set of files organized by L3 domain and by - RDT event. E.g. on a system with two L3 domains there will - be subdirectories "mon_L3_00" and "mon_L3_01". Each of these - directories have one file per event (e.g. "llc_occupancy", - "mbm_total_bytes", and "mbm_local_bytes"). In a MON group these - files provide a read out of the current value of the event for - all tasks in the group. In CTRL_MON groups these files provide - the sum for all tasks in the CTRL_MON group and all tasks in - MON groups. Please see example section for more details on usage. + This contains a set of directories, one for each instance + of an L3 cache, or of a processor package. The L3 cache + directories are named "mon_L3_00", "mon_L3_01" etc. The + package directories "mon_PERF_PKG_00", "mon_PERF_PKG_01" etc. + + Within each directory there is one file per event. In + the L3 directories: "llc_occupancy", "mbm_total_bytes", + and "mbm_local_bytes". In the PERF_PKG directories: "core_energy", + "activity", etc. + + In a MON group these files provide a read out of the current + value of the event for all tasks in the group. In CTRL_MON groups + these files provide the sum for all tasks in the CTRL_MON group + and all tasks in MON groups. Please see example section for more + details on usage. + On systems with Sub-NUMA Cluster (SNC) enabled there are extra directories for each node (located within the "mon_L3_XX" directory for the L3 cache they occupy). These are named "mon_sub_L3_YY" --=20 2.48.1