* [PATCH v2] arm64/gcs: Don't call gcs_free() when releasing task_struct
@ 2025-07-14 11:21 Mark Brown
2025-07-17 10:46 ` Will Deacon
0 siblings, 1 reply; 2+ messages in thread
From: Mark Brown @ 2025-07-14 11:21 UTC (permalink / raw)
To: Catalin Marinas, Will Deacon; +Cc: linux-arm-kernel, linux-kernel, Mark Brown
Currently we call gcs_free() when releasing task_struct but this is
redundant, it attempts to deallocate any kernel managed userspace GCS
which should no longer be relevant and resets values in the struct we're
in the process of freeing.
By the time arch_release_task_struct() is called the mm will have been
disassociated from the task so the check for a mm in gcs_free() will
always be false, for threads that are exiting leaving the mm active
deactivate_mm() will have been called previously and freed any kernel
managed GCS.
Signed-off-by: Mark Brown <broonie@kernel.org>
---
Changes in v2:
- Remove stale comment in gcs_free().
- Link to v1: https://lore.kernel.org/r/20250625-arm64-gcs-release-task-v1-1-54cbdc2db416@kernel.org
---
arch/arm64/kernel/process.c | 1 -
arch/arm64/mm/gcs.c | 6 ------
2 files changed, 7 deletions(-)
diff --git a/arch/arm64/kernel/process.c b/arch/arm64/kernel/process.c
index 5954cec19660..5dcfab9ce012 100644
--- a/arch/arm64/kernel/process.c
+++ b/arch/arm64/kernel/process.c
@@ -341,7 +341,6 @@ void flush_thread(void)
void arch_release_task_struct(struct task_struct *tsk)
{
fpsimd_release_task(tsk);
- gcs_free(tsk);
}
int arch_dup_task_struct(struct task_struct *dst, struct task_struct *src)
diff --git a/arch/arm64/mm/gcs.c b/arch/arm64/mm/gcs.c
index 5c46ec527b1c..6e93f78de79b 100644
--- a/arch/arm64/mm/gcs.c
+++ b/arch/arm64/mm/gcs.c
@@ -157,12 +157,6 @@ void gcs_free(struct task_struct *task)
if (!system_supports_gcs())
return;
- /*
- * When fork() with CLONE_VM fails, the child (tsk) already
- * has a GCS allocated, and exit_thread() calls this function
- * to free it. In this case the parent (current) and the
- * child share the same mm struct.
- */
if (!task->mm || task->mm != current->mm)
return;
---
base-commit: 86731a2a651e58953fc949573895f2fa6d456841
change-id: 20250610-arm64-gcs-release-task-307db60fa1b4
Best regards,
--
Mark Brown <broonie@kernel.org>
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH v2] arm64/gcs: Don't call gcs_free() when releasing task_struct
2025-07-14 11:21 [PATCH v2] arm64/gcs: Don't call gcs_free() when releasing task_struct Mark Brown
@ 2025-07-17 10:46 ` Will Deacon
0 siblings, 0 replies; 2+ messages in thread
From: Will Deacon @ 2025-07-17 10:46 UTC (permalink / raw)
To: Catalin Marinas, Mark Brown
Cc: kernel-team, Will Deacon, linux-arm-kernel, linux-kernel
On Mon, 14 Jul 2025 12:21:27 +0100, Mark Brown wrote:
> Currently we call gcs_free() when releasing task_struct but this is
> redundant, it attempts to deallocate any kernel managed userspace GCS
> which should no longer be relevant and resets values in the struct we're
> in the process of freeing.
>
> By the time arch_release_task_struct() is called the mm will have been
> disassociated from the task so the check for a mm in gcs_free() will
> always be false, for threads that are exiting leaving the mm active
> deactivate_mm() will have been called previously and freed any kernel
> managed GCS.
>
> [...]
Applied to arm64 (for-next/misc), thanks!
[1/1] arm64/gcs: Don't call gcs_free() when releasing task_struct
https://git.kernel.org/arm64/c/75fdf823f94b
Cheers,
--
Will
https://fixes.arm64.dev
https://next.arm64.dev
https://will.arm64.dev
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2025-07-17 10:46 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-07-14 11:21 [PATCH v2] arm64/gcs: Don't call gcs_free() when releasing task_struct Mark Brown
2025-07-17 10:46 ` Will Deacon
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).