ANDROID: vendor_hooks: Add hooks for waking up and exiting control
Add hooks at process waking up and exiting routines so that oems can control these procedures. One possible benifit is the peak of system load can be shaved and load can be more smooth when a large number of threads is killed once upon a time, while a sudden peak of system load can probably lead to user junk issues. Bug: 296493318 Change-Id: Ide5f9e63a4f50d6a9e3ffbc9516de9ce48ededef Signed-off-by: xieliujie <xieliujie@oppo.com>
This commit is contained in:
parent
9ca47685c5
commit
7afa84fbb9
@ -321,3 +321,6 @@ EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_look_around);
|
||||
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_look_around_migrate_folio);
|
||||
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_test_clear_look_around_ref);
|
||||
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_tune_scan_type);
|
||||
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_exit_signal_whether_wake);
|
||||
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_exit_check);
|
||||
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_freeze_whether_wake);
|
||||
|
@ -105,6 +105,19 @@ DECLARE_HOOK(android_vh_task_blocks_on_rtmutex,
|
||||
DECLARE_HOOK(android_vh_rtmutex_waiter_prio,
|
||||
TP_PROTO(struct task_struct *task, int *waiter_prio),
|
||||
TP_ARGS(task, waiter_prio));
|
||||
|
||||
DECLARE_HOOK(android_vh_exit_signal_whether_wake,
|
||||
TP_PROTO(struct task_struct *p, bool *wake),
|
||||
TP_ARGS(p, wake));
|
||||
|
||||
DECLARE_HOOK(android_vh_exit_check,
|
||||
TP_PROTO(struct task_struct *p),
|
||||
TP_ARGS(p));
|
||||
|
||||
DECLARE_HOOK(android_vh_freeze_whether_wake,
|
||||
TP_PROTO(struct task_struct *t, bool *wake),
|
||||
TP_ARGS(t, wake));
|
||||
|
||||
#endif /* _TRACE_HOOK_DTASK_H */
|
||||
|
||||
/* This part must be outside protection */
|
||||
|
@ -7,6 +7,7 @@
|
||||
#include "cgroup-internal.h"
|
||||
|
||||
#include <trace/events/cgroup.h>
|
||||
#include <trace/hooks/dtask.h>
|
||||
|
||||
/*
|
||||
* Propagate the cgroup frozen state upwards by the cgroup tree.
|
||||
@ -155,17 +156,21 @@ void cgroup_leave_frozen(bool always_leave)
|
||||
static void cgroup_freeze_task(struct task_struct *task, bool freeze)
|
||||
{
|
||||
unsigned long flags;
|
||||
bool wake = true;
|
||||
|
||||
/* If the task is about to die, don't bother with freezing it. */
|
||||
if (!lock_task_sighand(task, &flags))
|
||||
return;
|
||||
|
||||
trace_android_vh_freeze_whether_wake(task, &wake);
|
||||
if (freeze) {
|
||||
task->jobctl |= JOBCTL_TRAP_FREEZE;
|
||||
signal_wake_up(task, false);
|
||||
if (wake)
|
||||
signal_wake_up(task, false);
|
||||
} else {
|
||||
task->jobctl &= ~JOBCTL_TRAP_FREEZE;
|
||||
wake_up_process(task);
|
||||
if (wake)
|
||||
wake_up_process(task);
|
||||
}
|
||||
|
||||
unlock_task_sighand(task, &flags);
|
||||
|
@ -73,6 +73,7 @@
|
||||
#include <asm/unistd.h>
|
||||
#include <asm/mmu_context.h>
|
||||
#include <trace/hooks/mm.h>
|
||||
#include <trace/hooks/dtask.h>
|
||||
|
||||
/*
|
||||
* The default value should be high enough to not crash a system that randomly
|
||||
@ -827,6 +828,8 @@ void __noreturn do_exit(long code)
|
||||
io_uring_files_cancel();
|
||||
exit_signals(tsk); /* sets PF_EXITING */
|
||||
|
||||
trace_android_vh_exit_check(current);
|
||||
|
||||
/* sync mm's RSS info before statistics gathering */
|
||||
if (tsk->mm)
|
||||
sync_mm_rss(tsk->mm);
|
||||
|
@ -4455,6 +4455,7 @@ int wake_up_state(struct task_struct *p, unsigned int state)
|
||||
{
|
||||
return try_to_wake_up(p, state, 0);
|
||||
}
|
||||
EXPORT_SYMBOL(wake_up_state);
|
||||
|
||||
/*
|
||||
* Perform scheduler related setup for a newly forked process p.
|
||||
@ -5364,6 +5365,7 @@ unsigned int nr_running(void)
|
||||
|
||||
return sum;
|
||||
}
|
||||
EXPORT_SYMBOL(nr_running);
|
||||
|
||||
/*
|
||||
* Check if only the current task is running on the CPU.
|
||||
|
@ -58,6 +58,7 @@
|
||||
|
||||
#undef CREATE_TRACE_POINTS
|
||||
#include <trace/hooks/signal.h>
|
||||
#include <trace/hooks/dtask.h>
|
||||
/*
|
||||
* SLAB caches for signal bits.
|
||||
*/
|
||||
@ -1001,6 +1002,7 @@ static void complete_signal(int sig, struct task_struct *p, enum pid_type type)
|
||||
{
|
||||
struct signal_struct *signal = p->signal;
|
||||
struct task_struct *t;
|
||||
bool wake;
|
||||
|
||||
/*
|
||||
* Now find a thread we can wake up to take the signal off the queue.
|
||||
@ -1060,7 +1062,10 @@ static void complete_signal(int sig, struct task_struct *p, enum pid_type type)
|
||||
trace_android_vh_exit_signal(t);
|
||||
task_clear_jobctl_pending(t, JOBCTL_PENDING_MASK);
|
||||
sigaddset(&t->pending.signal, SIGKILL);
|
||||
signal_wake_up(t, 1);
|
||||
wake = true;
|
||||
trace_android_vh_exit_signal_whether_wake(t, &wake);
|
||||
if (wake)
|
||||
signal_wake_up(t, 1);
|
||||
} while_each_thread(p, t);
|
||||
return;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user