[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <db76238c-253f-4cc8-a761-6548be76f862@intel.com>
Date: Wed, 9 Jul 2025 15:18:24 -0700
From: Reinette Chatre <reinette.chatre@...el.com>
To: Tony Luck <tony.luck@...el.com>, Fenghua Yu <fenghuay@...dia.com>, "Maciej
Wieczor-Retman" <maciej.wieczor-retman@...el.com>, Peter Newman
<peternewman@...gle.com>, James Morse <james.morse@....com>, Babu Moger
<babu.moger@....com>, Drew Fustini <dfustini@...libre.com>, Dave Martin
<Dave.Martin@....com>, Anil Keshavamurthy <anil.s.keshavamurthy@...el.com>,
Chen Yu <yu.c.chen@...el.com>
CC: <x86@...nel.org>, <linux-kernel@...r.kernel.org>,
<patches@...ts.linux.dev>
Subject: Re: [PATCH v6 26/30] x86,fs/resctrl: Move RMID initialization to
first mount
Hi Tony,
On 6/26/25 9:49 AM, Tony Luck wrote:
> The resctrl file system code assumed that the only monitor events were
> tied to the RDT_RESOURCE_L3 resource. Also that the number of supported
> RMIDs was enumerated during early initialization.
>
> RDT_RESOURCE_PERF_PKG breaks both of those assumptions.
>
> Delay the final enumeration of the number of RMIDs and subsequent
> allocation of structures until first mount of the resctrl file system.
>
> Signed-off-by: Tony Luck <tony.luck@...el.com>
> ---
...
> diff --git a/fs/resctrl/monitor.c b/fs/resctrl/monitor.c
> index c4b092aec9f8..e877f5b97d18 100644
> --- a/fs/resctrl/monitor.c
> +++ b/fs/resctrl/monitor.c
> @@ -796,15 +796,27 @@ void mbm_setup_overflow_handler(struct rdt_l3_mon_domain *dom, unsigned long del
> schedule_delayed_work_on(cpu, &dom->mbm_over, delay);
> }
>
> -static int dom_data_init(struct rdt_resource *r)
> +/*
> + * resctrl_dom_data_init() - Initialise global monitoring structures.
> + *
> + * Allocate and initialise global monitor resources that do not belong to a
> + * specific domain. i.e. the rmid_ptrs[] used for the limbo and free lists.
> + * Called once during boot after the struct rdt_resource's have been configured
> + * but before the filesystem is mounted.
> + * Resctrl's cpuhp callbacks may be called before this point to bring a domain
> + * online.
> + *
> + * Returns 0 for success, or -ENOMEM.
> + */
As per changelog and the goal the intention of this change is to move RMID
related allocation to first mount ...
> +int resctrl_mon_dom_data_init(void)
> {
> + struct rdt_resource *r = resctrl_arch_get_resource(RDT_RESOURCE_L3);
... this is a red flag ...
> u32 idx_limit = resctrl_arch_system_num_rmid_idx();
> u32 num_closid = resctrl_arch_get_num_closid(r);
> struct rmid_entry *entry = NULL;
> - int err = 0, i;
> u32 idx;
> + int i;
>
> - mutex_lock(&rdtgroup_mutex);
> if (IS_ENABLED(CONFIG_RESCTRL_RMID_DEPENDS_ON_CLOSID)) {
> u32 *tmp;
>
> @@ -815,10 +827,8 @@ static int dom_data_init(struct rdt_resource *r)
> * use.
> */
> tmp = kcalloc(num_closid, sizeof(*tmp), GFP_KERNEL);
> - if (!tmp) {
> - err = -ENOMEM;
> - goto out_unlock;
> - }
> + if (!tmp)
> + return -ENOMEM;
>
> closid_num_dirty_rmid = tmp;
... looks like this L3 specific initialization got caught up in this move, resulting
in L3 specific monitoring initialization unnecessarily split between
resctrl initialization and first mount.
I think this can be simplified by moving closid_num_dirty_rmid initialization to
resctrl_mon_l3_resource_init() where it seems to belong to be with other L3 initialization.
Doing so will make resctrl_mon_dom_data_init() dedicated to the RMID related
allocation that the changelog describes. As part of this the function could
also receive a more specific name.
...
> diff --git a/fs/resctrl/rdtgroup.c b/fs/resctrl/rdtgroup.c
> index d9bb01edd582..3d87e6c4c600 100644
> --- a/fs/resctrl/rdtgroup.c
> +++ b/fs/resctrl/rdtgroup.c
> @@ -2585,6 +2585,7 @@ static int rdt_get_tree(struct fs_context *fc)
> unsigned long flags = RFTYPE_CTRL_BASE;
> struct rdt_l3_mon_domain *dom;
> struct rdt_resource *r;
> + static bool once;
> int ret;
>
> resctrl_arch_pre_mount();
> @@ -2599,6 +2600,13 @@ static int rdt_get_tree(struct fs_context *fc)
> goto out;
> }
>
> + if (resctrl_arch_mon_capable() && !once) {
> + ret = resctrl_mon_dom_data_init();
> + if (ret)
> + goto out;
> + once = true;
Instead of the caller needing to keep track of this the function
self can just not allocate the RMID structures if it already exists.
> + }
> +
> ret = rdtgroup_setup_root(ctx);
> if (ret)
> goto out;
> @@ -4298,9 +4306,7 @@ int resctrl_init(void)
>
> thread_throttle_mode_init();
>
> - ret = resctrl_mon_resource_init();
> - if (ret)
> - return ret;
> + resctrl_mon_l3_resource_init();
>
> ret = sysfs_create_mount_point(fs_kobj, "resctrl");
> if (ret) {
Reinette
Powered by blists - more mailing lists