ANDROID: vendor_hooks: add two hooks for lazy preemption

add some changes to achieve the lazy preemption feature in our baseline.
- android_vh_read_lazy_flag
- android_vh_set_tsk_need_resched_lazy
Bug: 336982374

Change-Id: I09f1110a2a11da4dbf0d4d0cca3500d1a6ee6a74
Signed-off-by: xieliujie <xieliujie@oppo.com>
This commit is contained in:
xieliujie 2024-04-26 10:02:17 +08:00 committed by Todd Kjos
parent 6364d59412
commit 14f07c1db0
4 changed files with 21 additions and 2 deletions

View file

@ -20,6 +20,8 @@
#include <linux/ratelimit.h>
#include <linux/syscalls.h>
#include <trace/hooks/dtask.h>
#include <asm/daifflags.h>
#include <asm/debug-monitors.h>
#include <asm/elf.h>
@ -1107,8 +1109,11 @@ static void do_signal(struct pt_regs *regs)
void do_notify_resume(struct pt_regs *regs, unsigned long thread_flags)
{
int thread_lazy_flag = 0;
do {
if (thread_flags & _TIF_NEED_RESCHED) {
trace_android_vh_read_lazy_flag(&thread_lazy_flag, &thread_flags);
if ((thread_flags & _TIF_NEED_RESCHED) || thread_lazy_flag) {
/* Unmask Debug and SError for the next task */
local_daif_restore(DAIF_PROCCTX_NOIRQ);

View file

@ -410,3 +410,5 @@ EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_usb_dev_resume);
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_sound_usb_support_cpu_suspend);
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_hibernated_do_mem_alloc);
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_hibernate_save_cmp_len);
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_read_lazy_flag);
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_set_tsk_need_resched_lazy);

View file

@ -124,6 +124,14 @@ DECLARE_HOOK(android_vh_freeze_whether_wake,
TP_PROTO(struct task_struct *t, bool *wake),
TP_ARGS(t, wake));
DECLARE_HOOK(android_vh_read_lazy_flag,
TP_PROTO(int *thread_lazy_flag, unsigned long *thread_flags),
TP_ARGS(thread_lazy_flag, thread_flags));
DECLARE_HOOK(android_vh_set_tsk_need_resched_lazy,
TP_PROTO(struct task_struct *p, struct rq *rq, int *need_lazy),
TP_ARGS(p, rq, need_lazy));
#endif /* _TRACE_HOOK_DTASK_H */
/* This part must be outside protection */

View file

@ -1043,13 +1043,17 @@ void wake_up_q(struct wake_q_head *head)
void resched_curr(struct rq *rq)
{
struct task_struct *curr = rq->curr;
int cpu;
int cpu, need_lazy = 0;
lockdep_assert_rq_held(rq);
if (test_tsk_need_resched(curr))
return;
trace_android_vh_set_tsk_need_resched_lazy(curr, rq, &need_lazy);
if (need_lazy)
return;
cpu = cpu_of(rq);
if (cpu == smp_processor_id()) {