From: Reinette Chatre <reinette.chatre@intel.com>
To: Tony Luck <tony.luck@intel.com>, Fenghua Yu <fenghuay@nvidia.com>,
"Maciej Wieczor-Retman" <maciej.wieczor-retman@intel.com>,
Peter Newman <peternewman@google.com>,
James Morse <james.morse@arm.com>,
Babu Moger <babu.moger@amd.com>,
Drew Fustini <dfustini@baylibre.com>,
Dave Martin <Dave.Martin@arm.com>,
Anil Keshavamurthy <anil.s.keshavamurthy@intel.com>
Cc: <linux-kernel@vger.kernel.org>, <patches@lists.linux.dev>
Subject: Re: [PATCH v3 21/26] fs-x86/resctrl: Handle RDT_RESOURCE_PERF_PKG in domain create/delete
Date: Fri, 18 Apr 2025 22:22:36 -0700 [thread overview]
Message-ID: <d83e898a-4ac6-413d-8228-989d5395fde6@intel.com> (raw)
In-Reply-To: <20250407234032.241215-22-tony.luck@intel.com>
Hi Tony,
On 4/7/25 4:40 PM, Tony Luck wrote:
> 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 <tony.luck@intel.com>
> ---
> 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;
> };
>
> +/**
> + * struct rdt_perf_pkg_mon_domain - CPUs sharing an Intel-PMT-scoped resctrl monitor resource
It is a red flag when architecture specific things ("rdt" and "Intel-PMT-scoped") land
in include/linux/resctrl.h
> + * @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/resctrl/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, struct rdt_resource *r, struct
> }
> }
>
> +static void setup_intel_aet_mon_domain(int cpu, int id, struct rdt_resource *r,
> + struct list_head *add_pos)
> +{
> + struct rdt_perf_pkg_mon_domain *d;
> + int err;
> +
> + d = kzalloc_node(sizeof(*d), GFP_KERNEL, cpu_to_node(cpu));
> + if (!d)
> + return;
> +
> + d->hdr.id = id;
> + d->hdr.type = DOMTYPE(r->rid, DOMTYPE_MON);
> + cpumask_set_cpu(cpu, &d->hdr.cpu_mask);
> + list_add_tail_rcu(&d->hdr.list, add_pos);
> +
> + err = 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 = get_domain_id_from_scope(cpu, r->mon_scope);
> @@ -571,6 +594,9 @@ static void domain_add_cpu_mon(int cpu, struct rdt_resource *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);
Something should have complained about using an uninitialized variable here (d).
> + list_del_rcu(&hdr->list);
> + synchronize_rcu();
> + kfree(container_of(hdr, struct rdt_perf_pkg_mon_domain, hdr));
> + break;
> }
> }
>
> 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);
>
> + if (r->rid == RDT_RESOURCE_PERF_PKG)
> + goto done;
Could you please change this test to
if (r->rid != RDT_RESOURCE_L3)
this makes it clear about what the code that follows supports as opposed to one resource that it does
not support (and possibly cause issue in future when adding another monitoring resource).
> +
> 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
> }
>
> domain_destroy_mon_state(d);
> -
> +done:
> mutex_unlock(&rdtgroup_mutex);
> }
>
> @@ -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_hdr *hdr)
> {
> struct rdt_mon_domain *d;
> - int err;
> + int err = 0;
>
> WARN_ON_ONCE(hdr->type != DOMTYPE(r->rid, DOMTYPE_MON));
> d = container_of(hdr, struct rdt_mon_domain, hdr);
> mutex_lock(&rdtgroup_mutex);
>
> + if (r->rid == RDT_RESOURCE_PERF_PKG)
> + goto do_mkdir;
same
> +
> err = 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);
>
> +do_mkdir:
> /*
> * If the filesystem is not mounted then only the default resource group
> * exists. Creation of its directories is deferred until mount time
Reinette
next prev parent reply other threads:[~2025-04-19 5:23 UTC|newest]
Thread overview: 67+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-04-07 23:40 [PATCH v3 00/26] x86/resctrl telemetry monitoring Tony Luck
2025-04-07 23:40 ` [PATCH v3 01/26] fs/resctrl: Simplify allocation of mon_data structures Tony Luck
2025-04-18 21:13 ` Reinette Chatre
2025-04-07 23:40 ` [PATCH v3 02/26] fs-x86/resctrl: Prepare for more monitor events Tony Luck
2025-04-18 21:17 ` Reinette Chatre
2025-04-07 23:40 ` [PATCH v3 03/26] fs/resctrl: Change how events are initialized Tony Luck
2025-04-18 21:22 ` Reinette Chatre
2025-04-07 23:40 ` [PATCH v3 04/26] fs/resctrl: Set up Kconfig options for telemetry events Tony Luck
2025-04-18 21:23 ` Reinette Chatre
2025-04-07 23:40 ` [PATCH v3 05/26] x86/rectrl: Fake OOBMSM interface Tony Luck
2025-04-18 21:27 ` Reinette Chatre
2025-04-07 23:40 ` [PATCH v3 06/26] fs-x86/rectrl: Improve domain type checking Tony Luck
2025-04-18 21:40 ` Reinette Chatre
2025-04-07 23:40 ` [PATCH v3 07/26] x86/resctrl: Move L3 initialization out of domain_add_cpu_mon() Tony Luck
2025-04-18 21:51 ` Reinette Chatre
2025-04-21 20:01 ` Luck, Tony
2025-04-22 18:18 ` Reinette Chatre
2025-04-07 23:40 ` [PATCH v3 08/26] x86/resctrl: Refactor domain_remove_cpu_mon() ready for new domain types Tony Luck
2025-04-18 21:53 ` Reinette Chatre
2025-04-07 23:40 ` [PATCH v3 09/26] x86/resctrl: Change generic monitor functions to use struct rdt_domain_hdr Tony Luck
2025-04-18 22:42 ` Reinette Chatre
2025-04-07 23:40 ` [PATCH v3 10/26] fs/resctrl: Improve handling for events that can be read from any CPU Tony Luck
2025-04-18 22:54 ` Reinette Chatre
2025-04-21 20:28 ` Luck, Tony
2025-04-22 18:19 ` Reinette Chatre
2025-04-23 0:51 ` Luck, Tony
2025-04-23 3:37 ` Reinette Chatre
2025-04-23 13:27 ` Peter Newman
2025-04-23 15:47 ` Reinette Chatre
2025-04-07 23:40 ` [PATCH v3 11/26] fs/resctrl: Add support for additional monitor event display formats Tony Luck
2025-04-18 23:02 ` Reinette Chatre
2025-04-21 19:34 ` Luck, Tony
2025-04-22 18:20 ` Reinette Chatre
2025-04-07 23:40 ` [PATCH v3 12/26] fs/resctrl: Add hook for architecture code to set monitor event attributes Tony Luck
2025-04-18 23:11 ` Reinette Chatre
2025-04-21 19:50 ` Luck, Tony
2025-04-22 18:20 ` Reinette Chatre
2025-04-07 23:40 ` [PATCH v3 13/26] fs/resctrl: Add an architectural hook called for each mount Tony Luck
2025-04-18 23:47 ` Reinette Chatre
2025-04-07 23:40 ` [PATCH v3 14/26] x86/resctrl: Add first part of telemetry event enumeration Tony Luck
2025-04-19 0:08 ` Reinette Chatre
2025-04-07 23:40 ` [PATCH v3 15/26] x86/resctrl: Second stage " Tony Luck
2025-04-19 0:30 ` Reinette Chatre
2025-04-07 23:40 ` [PATCH v3 16/26] x86/resctrl: Third phase " Tony Luck
2025-04-19 0:45 ` Reinette Chatre
2025-04-07 23:40 ` [PATCH v3 17/26] x86/resctrl: Build a lookup table for each resctrl event id Tony Luck
2025-04-19 0:48 ` Reinette Chatre
2025-04-07 23:40 ` [PATCH v3 18/26] x86/resctrl: Add code to read core telemetry events Tony Luck
2025-04-19 1:53 ` Reinette Chatre
2025-04-07 23:40 ` [PATCH v3 19/26] x86/resctrl: Sanity check telemetry RMID values Tony Luck
2025-04-19 5:14 ` Reinette Chatre
2025-04-07 23:40 ` [PATCH v3 20/26] x86/resctrl: Add and initialize rdt_resource for package scope core monitor Tony Luck
2025-04-07 23:40 ` [PATCH v3 21/26] fs-x86/resctrl: Handle RDT_RESOURCE_PERF_PKG in domain create/delete Tony Luck
2025-04-19 5:22 ` Reinette Chatre [this message]
2025-04-07 23:40 ` [PATCH v3 22/26] fs/resctrl: Add type define for PERF_PKG files Tony Luck
2025-04-07 23:40 ` [PATCH v3 23/26] fs/resctrl: Add new telemetry event id and structures Tony Luck
2025-04-07 23:40 ` [PATCH v3 24/26] x86/resctrl: Final steps to enable RDT_RESOURCE_PERF_PKG Tony Luck
2025-04-07 23:40 ` [PATCH v3 25/26] fs-x86/resctrl: Add detailed descriptions for Clearwater Forest events Tony Luck
2025-04-19 5:30 ` Reinette Chatre
2025-04-07 23:40 ` [PATCH v3 26/26] x86/resctrl: Update Documentation for package events Tony Luck
2025-04-19 5:40 ` Reinette Chatre
2025-04-18 21:13 ` [PATCH v3 00/26] x86/resctrl telemetry monitoring Reinette Chatre
2025-04-21 18:57 ` Luck, Tony
2025-04-21 22:59 ` Reinette Chatre
2025-04-22 16:20 ` Luck, Tony
2025-04-22 21:30 ` Reinette Chatre
2025-04-19 5:47 ` Reinette Chatre
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=d83e898a-4ac6-413d-8228-989d5395fde6@intel.com \
--to=reinette.chatre@intel.com \
--cc=Dave.Martin@arm.com \
--cc=anil.s.keshavamurthy@intel.com \
--cc=babu.moger@amd.com \
--cc=dfustini@baylibre.com \
--cc=fenghuay@nvidia.com \
--cc=james.morse@arm.com \
--cc=linux-kernel@vger.kernel.org \
--cc=maciej.wieczor-retman@intel.com \
--cc=patches@lists.linux.dev \
--cc=peternewman@google.com \
--cc=tony.luck@intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox