[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <c4807d24-10ea-4baf-8477-4d876deff4c1@intel.com>
Date: Tue, 13 Aug 2024 21:01:33 -0700
From: Reinette Chatre <reinette.chatre@...el.com>
To: James Morse <james.morse@....com>, <x86@...nel.org>,
<linux-kernel@...r.kernel.org>
CC: Fenghua Yu <fenghua.yu@...el.com>, Thomas Gleixner <tglx@...utronix.de>,
Ingo Molnar <mingo@...hat.com>, Borislav Petkov <bp@...en8.de>, H Peter Anvin
<hpa@...or.com>, Babu Moger <Babu.Moger@....com>,
<shameerali.kolothum.thodi@...wei.com>, D Scott Phillips OS
<scott@...amperecomputing.com>, <carl@...amperecomputing.com>,
<lcherian@...vell.com>, <bobo.shaobowang@...wei.com>,
<tan.shaopeng@...itsu.com>, <baolin.wang@...ux.alibaba.com>, Jamie Iles
<quic_jiles@...cinc.com>, Xin Hao <xhao@...ux.alibaba.com>,
<peternewman@...gle.com>, <dfustini@...libre.com>, <amitsinght@...vell.com>,
David Hildenbrand <david@...hat.com>, Rex Nie <rex.nie@...uarmicro.com>, Dave
Martin <dave.martin@....com>
Subject: Re: [PATCH v4 15/39] x86/resctrl: Move monitor exit work to a resctrl
exit call
Hi James,
On 8/2/24 10:28 AM, James Morse wrote:
> rdt_put_mon_l3_config() is called via the architecture's
> resctrl_arch_exit() call, and appears to free the rmid_ptrs[]
> and closid_num_dirty_rmid[] arrays. In reality this code is marked
> __exit, and is removed by the linker as resctrl can't be built
> as a module.
>
> To separate the filesystem and architecture parts of resctrl,
> this free()ing work needs to be triggered by the filesystem,
> as these structures belong to the filesystem code.
>
> Rename rdt_put_mon_l3_config() resctrl_mon_resource_exit()
> and call it from resctrl_exit(). The kfree() is currently
> dependent on r->mon_capable.
>
> Signed-off-by: James Morse <james.morse@....com>
> Tested-by: Carl Worth <carl@...amperecomputing.com> # arm64
> ---
> Changes since v3:
> * Moved r->mon_capable check under the lock.
> * Dropped references to resctrl_mon_resource_init() from the commit message.
> * Fixed more resctrl typos,
>
> Changes since v2:
> * Dropped __exit as needed in the next patch.
Is this still relevant? It is unclear to me why __exit is dropped here.
>
> Change since v1:
> * [Commit message only] Typo fixes:
> s/restrl/resctrl/g
> s/resctl/resctrl/g
>
> * [Commit message only] Reword second paragraph to remove reference to
> the MPAM error interrupt, which provides background rationale for a
> later patch rather than for this patch, and so it is not really
> relevant here.
> ---
> arch/x86/kernel/cpu/resctrl/core.c | 5 -----
> arch/x86/kernel/cpu/resctrl/internal.h | 2 +-
> arch/x86/kernel/cpu/resctrl/monitor.c | 12 +++++++++---
> arch/x86/kernel/cpu/resctrl/rdtgroup.c | 2 ++
> 4 files changed, 12 insertions(+), 9 deletions(-)
>
> diff --git a/arch/x86/kernel/cpu/resctrl/core.c b/arch/x86/kernel/cpu/resctrl/core.c
> index 4a0dbdc2da4d..9d4d64b4e357 100644
> --- a/arch/x86/kernel/cpu/resctrl/core.c
> +++ b/arch/x86/kernel/cpu/resctrl/core.c
> @@ -1101,14 +1101,9 @@ late_initcall(resctrl_arch_late_init);
>
> static void __exit resctrl_arch_exit(void)
> {
> - struct rdt_resource *r = &rdt_resources_all[RDT_RESOURCE_L3].r_resctrl;
> -
> cpuhp_remove_state(rdt_online);
>
> resctrl_exit();
> -
> - if (r->mon_capable)
> - rdt_put_mon_l3_config();
> }
>
> __exitcall(resctrl_arch_exit);
> diff --git a/arch/x86/kernel/cpu/resctrl/internal.h b/arch/x86/kernel/cpu/resctrl/internal.h
> index d355aa676158..3fdeca6e3d21 100644
> --- a/arch/x86/kernel/cpu/resctrl/internal.h
> +++ b/arch/x86/kernel/cpu/resctrl/internal.h
> @@ -579,7 +579,7 @@ void closid_free(int closid);
> int alloc_rmid(u32 closid);
> void free_rmid(u32 closid, u32 rmid);
> int rdt_get_mon_l3_config(struct rdt_resource *r);
> -void __exit rdt_put_mon_l3_config(void);
> +void resctrl_mon_resource_exit(void);
> bool __init rdt_cpu_has(int flag);
> void mon_event_count(void *info);
> int rdtgroup_mondata_show(struct seq_file *m, void *arg);
> diff --git a/arch/x86/kernel/cpu/resctrl/monitor.c b/arch/x86/kernel/cpu/resctrl/monitor.c
> index 9cdca9d2bbde..afbda09aacf5 100644
> --- a/arch/x86/kernel/cpu/resctrl/monitor.c
> +++ b/arch/x86/kernel/cpu/resctrl/monitor.c
> @@ -1044,10 +1044,13 @@ static int dom_data_init(struct rdt_resource *r)
> return err;
> }
>
> -static void __exit dom_data_exit(void)
> +static void dom_data_exit(struct rdt_resource *r)
> {
> mutex_lock(&rdtgroup_mutex);
>
> + if (!r->mon_capable)
> + goto out_unlock;
> +
> if (IS_ENABLED(CONFIG_RESCTRL_RMID_DEPENDS_ON_CLOSID)) {
> kfree(closid_num_dirty_rmid);
> closid_num_dirty_rmid = NULL;
> @@ -1056,6 +1059,7 @@ static void __exit dom_data_exit(void)
> kfree(rmid_ptrs);
> rmid_ptrs = NULL;
>
> +out_unlock:
> mutex_unlock(&rdtgroup_mutex);
> }
>
> @@ -1238,9 +1242,11 @@ int __init rdt_get_mon_l3_config(struct rdt_resource *r)
> return 0;
> }
>
> -void __exit rdt_put_mon_l3_config(void)
> +void resctrl_mon_resource_exit(void)
> {
> - dom_data_exit();
> + struct rdt_resource *r = resctrl_arch_get_resource(RDT_RESOURCE_L3);
> +
> + dom_data_exit(r);
> }
>
> void __init intel_rdt_mbm_apply_quirk(void)
> diff --git a/arch/x86/kernel/cpu/resctrl/rdtgroup.c b/arch/x86/kernel/cpu/resctrl/rdtgroup.c
> index 1597add37b97..576f6b183980 100644
> --- a/arch/x86/kernel/cpu/resctrl/rdtgroup.c
> +++ b/arch/x86/kernel/cpu/resctrl/rdtgroup.c
> @@ -4291,4 +4291,6 @@ void __exit resctrl_exit(void)
> debugfs_remove_recursive(debugfs_resctrl);
> unregister_filesystem(&rdt_fs_type);
> sysfs_remove_mount_point(fs_kobj, "resctrl");
> +
> + resctrl_mon_resource_exit();
> }
Reinette
Powered by blists - more mailing lists