Skip to content

Commit a1259dd

Browse files
Sebastian Andrzej Siewiorctmarinas
authored andcommitted
arm64/sve: Delay freeing memory in fpsimd_flush_thread()
fpsimd_flush_thread() invokes kfree() via sve_free()+sme_free() within a preempt disabled section which is not working on -RT. Delay freeing of memory until preemption is enabled again. Signed-off-by: Sebastian Andrzej Siewior <[email protected]> Reviewed-by: Mark Brown <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Catalin Marinas <[email protected]>
1 parent d158a06 commit a1259dd

File tree

1 file changed

+15
-2
lines changed

1 file changed

+15
-2
lines changed

arch/arm64/kernel/fpsimd.c

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1562,6 +1562,9 @@ static void fpsimd_flush_thread_vl(enum vec_type type)
15621562

15631563
void fpsimd_flush_thread(void)
15641564
{
1565+
void *sve_state = NULL;
1566+
void *za_state = NULL;
1567+
15651568
if (!system_supports_fpsimd())
15661569
return;
15671570

@@ -1573,18 +1576,28 @@ void fpsimd_flush_thread(void)
15731576

15741577
if (system_supports_sve()) {
15751578
clear_thread_flag(TIF_SVE);
1576-
sve_free(current);
1579+
1580+
/* Defer kfree() while in atomic context */
1581+
sve_state = current->thread.sve_state;
1582+
current->thread.sve_state = NULL;
1583+
15771584
fpsimd_flush_thread_vl(ARM64_VEC_SVE);
15781585
}
15791586

15801587
if (system_supports_sme()) {
15811588
clear_thread_flag(TIF_SME);
1582-
sme_free(current);
1589+
1590+
/* Defer kfree() while in atomic context */
1591+
za_state = current->thread.za_state;
1592+
current->thread.za_state = NULL;
1593+
15831594
fpsimd_flush_thread_vl(ARM64_VEC_SME);
15841595
current->thread.svcr = 0;
15851596
}
15861597

15871598
put_cpu_fpsimd_context();
1599+
kfree(sve_state);
1600+
kfree(za_state);
15881601
}
15891602

15901603
/*

0 commit comments

Comments
 (0)