From: Reinette Chatre <reinette.chatre@intel.com>
To: James Morse <james.morse@arm.com>, <x86@kernel.org>,
<linux-kernel@vger.kernel.org>
Cc: Fenghua Yu <fenghua.yu@intel.com>,
Thomas Gleixner <tglx@linutronix.de>,
Ingo Molnar <mingo@redhat.com>, Borislav Petkov <bp@alien8.de>,
H Peter Anvin <hpa@zytor.com>, Babu Moger <Babu.Moger@amd.com>,
<shameerali.kolothum.thodi@huawei.com>,
D Scott Phillips OS <scott@os.amperecomputing.com>,
<carl@os.amperecomputing.com>, <lcherian@marvell.com>,
<bobo.shaobowang@huawei.com>, <tan.shaopeng@fujitsu.com>,
<baolin.wang@linux.alibaba.com>,
Jamie Iles <quic_jiles@quicinc.com>,
Xin Hao <xhao@linux.alibaba.com>, <peternewman@google.com>,
<dfustini@baylibre.com>, <amitsinght@marvell.com>
Subject: Re: [PATCH v8 02/24] x86/resctrl: kfree() rmid_ptrs from resctrl_exit()
Date: Fri, 15 Dec 2023 20:57:49 -0800 [thread overview]
Message-ID: <6ebf108a-49e7-4fc7-a61e-b993ab696c6c@intel.com> (raw)
In-Reply-To: <20231215174343.13872-3-james.morse@arm.com>
Hi James,
On 12/15/2023 9:43 AM, James Morse wrote:
> rmid_ptrs[] is allocated from dom_data_init() but never free()d.
>
> While the exit text ends up in the linker script's DISCARD section,
> the direction of travel is for resctrl to be/have loadable modules.
>
> Add resctrl_put_mon_l3_config() to cleanup any memory allocated
> by rdt_get_mon_l3_config().
>
> There is no reason to backport this to a stable kernel.
>
> Signed-off-by: James Morse <james.morse@arm.com>
> Tested-by: Babu Moger <babu.moger@amd.com>
> Reviewed-by: Babu Moger <babu.moger@amd.com>
> ---
> Changes since v5:
> * This patch is new
>
> Changes since v6:
> * Removed struct rdt_resource argument, added __exit markers to match the
> only caller.
> * Adedd a whole stack of functions to maintain symmetry.
>
> Changes since v7:
> * Moved the eventual kfree() call to be after rdtgroup_exit()
> ---
> arch/x86/kernel/cpu/resctrl/core.c | 6 ++++++
> arch/x86/kernel/cpu/resctrl/internal.h | 1 +
> arch/x86/kernel/cpu/resctrl/monitor.c | 15 +++++++++++++++
> 3 files changed, 22 insertions(+)
>
> diff --git a/arch/x86/kernel/cpu/resctrl/core.c b/arch/x86/kernel/cpu/resctrl/core.c
> index 19e0681f0435..b5d4b76f97c5 100644
> --- a/arch/x86/kernel/cpu/resctrl/core.c
> +++ b/arch/x86/kernel/cpu/resctrl/core.c
> @@ -992,8 +992,14 @@ late_initcall(resctrl_late_init);
>
> static void __exit resctrl_exit(void)
> {
> + struct rdt_resource *r = &rdt_resources_all[RDT_RESOURCE_L3].r_resctrl;
> +
> cpuhp_remove_state(rdt_online);
> +
> rdtgroup_exit();
> +
> + if (r->mon_capable)
> + rdt_put_mon_l3_config(r);
> }
>
> __exitcall(resctrl_exit);
> diff --git a/arch/x86/kernel/cpu/resctrl/internal.h b/arch/x86/kernel/cpu/resctrl/internal.h
> index a4f1aa15f0a2..f68c6aecfa66 100644
> --- a/arch/x86/kernel/cpu/resctrl/internal.h
> +++ b/arch/x86/kernel/cpu/resctrl/internal.h
> @@ -546,6 +546,7 @@ void closid_free(int closid);
> int alloc_rmid(void);
> void free_rmid(u32 rmid);
> int rdt_get_mon_l3_config(struct rdt_resource *r);
> +void __exit rdt_put_mon_l3_config(struct rdt_resource *r);
> 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 f136ac046851..5d9864919f1c 100644
> --- a/arch/x86/kernel/cpu/resctrl/monitor.c
> +++ b/arch/x86/kernel/cpu/resctrl/monitor.c
> @@ -741,6 +741,16 @@ static int dom_data_init(struct rdt_resource *r)
> return 0;
> }
>
> +static void __exit dom_data_exit(struct rdt_resource *r)
> +{
> + mutex_lock(&rdtgroup_mutex);
> +
> + kfree(rmid_ptrs);
> + rmid_ptrs = NULL;
> +
> + mutex_unlock(&rdtgroup_mutex);
> +}
> +
> static struct mon_evt llc_occupancy_event = {
> .name = "llc_occupancy",
> .evtid = QOS_L3_OCCUP_EVENT_ID,
> @@ -830,6 +840,11 @@ int __init rdt_get_mon_l3_config(struct rdt_resource *r)
> return 0;
> }
>
> +void __exit rdt_put_mon_l3_config(struct rdt_resource *r)
> +{
> + dom_data_exit(r);
> +}
> +
I expected the unused resource parameter to be removed because you said ([1]) it would.
> void __init intel_rdt_mbm_apply_quirk(void)
> {
> int cf_index;
Reinette
[1] https://lore.kernel.org/lkml/c4157536-7e57-0250-dc44-8914f5965ce6@arm.com/
next prev parent reply other threads:[~2023-12-16 4:59 UTC|newest]
Thread overview: 50+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-12-15 17:43 [PATCH v8 00/24] x86/resctrl: monitored closid+rmid together, separate arch/fs locking James Morse
2023-12-15 17:43 ` [PATCH v8 01/24] tick/nohz: Move tick_nohz_full_mask declaration outside the #ifdef James Morse
2023-12-15 20:31 ` Thomas Gleixner
2024-01-22 18:05 ` James Morse
2023-12-15 17:43 ` [PATCH v8 02/24] x86/resctrl: kfree() rmid_ptrs from resctrl_exit() James Morse
2023-12-16 4:57 ` Reinette Chatre [this message]
2023-12-15 17:43 ` [PATCH v8 03/24] x86/resctrl: Create helper for RMID allocation and mondata dir creation James Morse
2023-12-15 17:43 ` [PATCH v8 04/24] x86/resctrl: Move rmid allocation out of mkdir_rdt_prepare() James Morse
2023-12-15 17:43 ` [PATCH v8 05/24] x86/resctrl: Track the closid with the rmid James Morse
2023-12-16 4:58 ` Reinette Chatre
2024-01-22 18:05 ` James Morse
2023-12-15 17:43 ` [PATCH v8 06/24] x86/resctrl: Access per-rmid structures by index James Morse
2023-12-16 4:58 ` Reinette Chatre
2024-01-22 18:05 ` James Morse
2023-12-15 17:43 ` [PATCH v8 07/24] x86/resctrl: Allow RMID allocation to be scoped by CLOSID James Morse
2023-12-15 17:43 ` [PATCH v8 08/24] x86/resctrl: Track the number of dirty RMID a CLOSID has James Morse
2024-01-03 19:43 ` Moger, Babu
2024-01-22 18:05 ` James Morse
2024-01-04 19:13 ` Peter Newman
2024-01-22 18:05 ` James Morse
2023-12-15 17:43 ` [PATCH v8 09/24] x86/resctrl: Use __set_bit()/__clear_bit() instead of open coding James Morse
2023-12-15 17:43 ` [PATCH v8 10/24] x86/resctrl: Allocate the cleanest CLOSID by searching closid_num_dirty_rmid James Morse
2023-12-16 5:01 ` Reinette Chatre
2024-01-22 18:06 ` James Morse
2023-12-15 17:43 ` [PATCH v8 11/24] x86/resctrl: Move CLOSID/RMID matching and setting to use helpers James Morse
2023-12-15 17:43 ` [PATCH v8 12/24] x86/resctrl: Add cpumask_any_housekeeping() for limbo/overflow James Morse
2023-12-15 17:43 ` [PATCH v8 13/24] x86/resctrl: Queue mon_event_read() instead of sending an IPI James Morse
2024-01-03 19:43 ` Moger, Babu
2024-01-22 18:06 ` James Morse
2023-12-15 17:43 ` [PATCH v8 14/24] x86/resctrl: Allow resctrl_arch_rmid_read() to sleep James Morse
2024-01-03 19:43 ` Moger, Babu
2024-01-22 18:06 ` James Morse
2023-12-15 17:43 ` [PATCH v8 15/24] x86/resctrl: Allow arch to allocate memory needed in resctrl_arch_rmid_read() James Morse
2023-12-15 17:43 ` [PATCH v8 16/24] x86/resctrl: Make resctrl_mounted checks explicit James Morse
2023-12-15 17:43 ` [PATCH v8 17/24] x86/resctrl: Move alloc/mon static keys into helpers James Morse
2023-12-15 17:43 ` [PATCH v8 18/24] x86/resctrl: Make rdt_enable_key the arch's decision to switch James Morse
2023-12-15 17:43 ` [PATCH v8 19/24] x86/resctrl: Add helpers for system wide mon/alloc capable James Morse
2024-01-03 19:43 ` Moger, Babu
2024-01-22 18:06 ` James Morse
2023-12-15 17:43 ` [PATCH v8 20/24] x86/resctrl: Add CPU online callback for resctrl work James Morse
2023-12-15 17:43 ` [PATCH v8 21/24] x86/resctrl: Allow overflow/limbo handlers to be scheduled on any-but cpu James Morse
2023-12-16 5:02 ` Reinette Chatre
2024-01-22 18:06 ` James Morse
2023-12-15 17:43 ` [PATCH v8 22/24] x86/resctrl: Add CPU offline callback for resctrl work James Morse
2023-12-15 17:43 ` [PATCH v8 23/24] x86/resctrl: Move domain helper migration into resctrl_offline_cpu() James Morse
2023-12-15 17:43 ` [PATCH v8 24/24] x86/resctrl: Separate arch and fs resctrl locks James Morse
2023-12-22 22:43 ` [PATCH v8 00/24] x86/resctrl: monitored closid+rmid together, separate arch/fs locking Carl Worth
2024-01-22 18:06 ` James Morse
2024-01-03 19:42 ` Moger, Babu
2024-01-22 18:06 ` James Morse
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=6ebf108a-49e7-4fc7-a61e-b993ab696c6c@intel.com \
--to=reinette.chatre@intel.com \
--cc=Babu.Moger@amd.com \
--cc=amitsinght@marvell.com \
--cc=baolin.wang@linux.alibaba.com \
--cc=bobo.shaobowang@huawei.com \
--cc=bp@alien8.de \
--cc=carl@os.amperecomputing.com \
--cc=dfustini@baylibre.com \
--cc=fenghua.yu@intel.com \
--cc=hpa@zytor.com \
--cc=james.morse@arm.com \
--cc=lcherian@marvell.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@redhat.com \
--cc=peternewman@google.com \
--cc=quic_jiles@quicinc.com \
--cc=scott@os.amperecomputing.com \
--cc=shameerali.kolothum.thodi@huawei.com \
--cc=tan.shaopeng@fujitsu.com \
--cc=tglx@linutronix.de \
--cc=x86@kernel.org \
--cc=xhao@linux.alibaba.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;
as well as URLs for NNTP newsgroup(s).