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 <wooy88.kim@samsung.com>
Signed-off-by: Jing-Ting Wu <Jing-Ting.Wu@mediatek.com>
This commit is contained in:
Jing-Ting Wu
2023-11-29 16:45:43 +08:00
committed by Treehugger Robot
parent d3ec16ca12
commit e8ac88bbf7
4 changed files with 27 additions and 0 deletions
+2
View File
@@ -31,6 +31,7 @@
#include <linux/stddef.h>
#include <linux/string.h>
#include <linux/thread_info.h>
#include <linux/android_vendor.h>
#include <vdso/processor.h>
@@ -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,
+3
View File
@@ -42,6 +42,7 @@
#include <linux/prctl.h>
#include <linux/stacktrace.h>
#include <trace/hooks/mpam.h>
#include <trace/hooks/fpsimd.h>
#include <asm/alternative.h>
#include <asm/compat.h>
@@ -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);
+2
View File
@@ -34,6 +34,7 @@
#include <trace/hooks/gic_v3.h>
#include <trace/hooks/remoteproc.h>
#include <trace/hooks/timer.h>
#include <trace/hooks/fpsimd.h>
/*
* 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);
+20
View File
@@ -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 <trace/hooks/vendor_hooks.h>
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 <trace/define_trace.h>