From e8ac88bbf71ba8c59a0fde1034cc9fddb17f9441 Mon Sep 17 00:00:00 2001 From: Jing-Ting Wu Date: Wed, 29 Nov 2023 16:45:43 +0800 Subject: [PATCH] ANDROID: vendor_hooks: FPSIMD save/restore by using vendor_hooks - To use fpsimd in kernel task, vendor_hook call is needed to save/restore fpsimd at scheduling time. - ANDROID_VENDOR_DATA added to thread_struct. - Vendor_hooks is called when thread is switching for save/restore fpsimd states. (trace_android_vh_is_fpsimd_save(prev, next)) This patch was previously in android-mainline, but was reverted due to conflicts in the 6.2-rc1 merge (aosp/2365029). Adding back. Bug: 149632552 Bug: 313805669 Change-Id: Ibaa13484d1251fc53c304972f46e8e8a2c1df7fa Signed-off-by: Wooyeon Kim Signed-off-by: Jing-Ting Wu --- arch/arm64/include/asm/processor.h | 2 ++ arch/arm64/kernel/process.c | 3 +++ drivers/android/vendor_hooks.c | 2 ++ include/trace/hooks/fpsimd.h | 20 ++++++++++++++++++++ 4 files changed, 27 insertions(+) create mode 100644 include/trace/hooks/fpsimd.h diff --git a/arch/arm64/include/asm/processor.h b/arch/arm64/include/asm/processor.h index f77371232d8c..a87fca8cdf39 100644 --- a/arch/arm64/include/asm/processor.h +++ b/arch/arm64/include/asm/processor.h @@ -31,6 +31,7 @@ #include #include #include +#include #include @@ -184,6 +185,7 @@ struct thread_struct { u64 sctlr_user; u64 svcr; u64 tpidr2_el0; + ANDROID_VENDOR_DATA(1); }; static inline unsigned int thread_get_vl(struct thread_struct *thread, diff --git a/arch/arm64/kernel/process.c b/arch/arm64/kernel/process.c index 740e11ccd44c..c4988cf140ff 100644 --- a/arch/arm64/kernel/process.c +++ b/arch/arm64/kernel/process.c @@ -42,6 +42,7 @@ #include #include #include +#include #include #include @@ -557,6 +558,8 @@ struct task_struct *__switch_to(struct task_struct *prev, if (prev->thread.sctlr_user != next->thread.sctlr_user) update_sctlr_el1(next->thread.sctlr_user); + trace_android_vh_is_fpsimd_save(prev, next); + /* the actual thread switch */ last = cpu_switch_to(prev, next); diff --git a/drivers/android/vendor_hooks.c b/drivers/android/vendor_hooks.c index ac264e499464..67b7dc16262d 100644 --- a/drivers/android/vendor_hooks.c +++ b/drivers/android/vendor_hooks.c @@ -34,6 +34,7 @@ #include #include #include +#include /* * Export tracepoints that act as a bare tracehook (ie: have no trace event @@ -90,3 +91,4 @@ EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_check_bpf_syscall); EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_rproc_recovery); EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_rproc_recovery_set); EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_timer_calc_index); +EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_is_fpsimd_save); diff --git a/include/trace/hooks/fpsimd.h b/include/trace/hooks/fpsimd.h new file mode 100644 index 000000000000..10337180a7be --- /dev/null +++ b/include/trace/hooks/fpsimd.h @@ -0,0 +1,20 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +#undef TRACE_SYSTEM +#define TRACE_SYSTEM fpsimd + +#define TRACE_INCLUDE_PATH trace/hooks + +#if !defined(_TRACE_HOOK_FPSIMD_H) || defined(TRACE_HEADER_MULTI_READ) +#define _TRACE_HOOK_FPSIMD_H + +#include + +struct task_struct; + +DECLARE_HOOK(android_vh_is_fpsimd_save, + TP_PROTO(struct task_struct *prev, struct task_struct *next), + TP_ARGS(prev, next)) + +#endif /* _TRACE_HOOK_FPSIMD_H */ +/* This part must be outside protection */ +#include