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))

Bug: 149632552

Signed-off-by: Wooyeon Kim <wooy88.kim@samsung.com>
Change-Id: I853e1b6a9a51e24f770423bbc39fdd84265d78fc
This commit is contained in:
Wooyeon Kim 2020-07-09 14:43:13 +09:00 committed by Todd Kjos
parent 1eb185541d
commit 74555f3992
4 changed files with 34 additions and 0 deletions

View File

@ -27,6 +27,7 @@
#include <linux/stddef.h>
#include <linux/string.h>
#include <linux/thread_info.h>
#include <linux/android_vendor.h>
#include <vdso/processor.h>
@ -140,6 +141,8 @@ struct thread_struct {
struct user_fpsimd_state fpsimd_state;
} uw;
ANDROID_VENDOR_DATA(1);
unsigned int fpsimd_cpu;
void *sve_state; /* SVE registers, if any */
unsigned int sve_vl; /* SVE vector length */

View File

@ -43,6 +43,7 @@
#include <linux/percpu.h>
#include <linux/thread_info.h>
#include <linux/prctl.h>
#include <trace/hooks/fpsimd.h>
#include <asm/alternative.h>
#include <asm/arch_gicv3.h>
@ -539,6 +540,8 @@ __notrace_funcgraph struct task_struct *__switch_to(struct task_struct *prev,
*/
dsb(ish);
trace_android_vh_is_fpsimd_save(prev, next);
/* the actual thread switch */
last = cpu_switch_to(prev, next);

View File

@ -9,9 +9,11 @@
#define CREATE_TRACE_POINTS
#include <trace/hooks/vendor_hooks.h>
#include <trace/hooks/sched.h>
#include <trace/hooks/fpsimd.h>
/*
* Export tracepoints that act as a bare tracehook (ie: have no trace event
* associated with them) to allow external modules to probe them.
*/
EXPORT_TRACEPOINT_SYMBOL_GPL(android_rvh_select_task_rq_fair);
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_is_fpsimd_save);

View File

@ -0,0 +1,26 @@
/* 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 <linux/tracepoint.h>
#include <trace/hooks/vendor_hooks.h>
#if defined(CONFIG_TRACEPOINTS) && defined(CONFIG_ANDROID_VENDOR_HOOKS)
struct task_struct;
DECLARE_HOOK(android_vh_is_fpsimd_save,
TP_PROTO(struct task_struct *prev, struct task_struct *next),
TP_ARGS(prev, next))
#else
#define trace_android_vh_is_fpsimd_save(prev, next)
#endif
#endif /* _TRACE_HOOK_FPSIMD_H */
/* This part must be outside protection */
#include <trace/define_trace.h>