Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 93e07373 authored by Yun Hsiang's avatar Yun Hsiang
Browse files

ANDROID: sched: add restrict vendor hook to modify task placement policy in EAS



For modifying task placement policy, we add the hook on the top of
select_task_rq_fair(). It allows us to modify wakeup/fork/exec balance
paths.

Bug: 165660734
Signed-off-by: default avatarYun Hsiang <yun.hsiang@mediatek.com>
Change-Id: I80ff870453472e183ab2aae7381bff91e49ae296
(cherry picked from commit a1fc1fba460be48dff2484b438888ede557930d4)
parent 026b8142
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -8,6 +8,7 @@

#define CREATE_TRACE_POINTS
#include <trace/hooks/vendor_hooks.h>
#include <trace/hooks/sched.h>
#include <trace/hooks/dtask.h>
#include <trace/hooks/net.h>

@@ -15,6 +16,7 @@
 * 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_mutex_wait_start);
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_mutex_wait_finish);
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_rwsem_read_wait_start);
@@ -24,4 +26,3 @@ EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_rwsem_write_wait_finish);
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_sched_show_task);
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_ptype_head);
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_kfree_skb);
+23 −0
Original line number Diff line number Diff line
/* SPDX-License-Identifier: GPL-2.0 */
#undef TRACE_SYSTEM
#define TRACE_SYSTEM sched
#define TRACE_INCLUDE_PATH trace/hooks
#if !defined(_TRACE_HOOK_SCHED_H) || defined(TRACE_HEADER_MULTI_READ)
#define _TRACE_HOOK_SCHED_H
#include <linux/tracepoint.h>
#include <trace/hooks/vendor_hooks.h>
/*
 * Following tracepoints are not exported in tracefs and provide a
 * mechanism for vendor modules to hook and extend functionality
 */
#if defined(CONFIG_TRACEPOINTS) && defined(CONFIG_ANDROID_VENDOR_HOOKS)
struct task_struct;
DECLARE_RESTRICTED_HOOK(android_rvh_select_task_rq_fair,
	TP_PROTO(struct task_struct *p, int prev_cpu, int sd_flag, int wake_flags, int *new_cpu),
	TP_ARGS(p, prev_cpu, sd_flag, wake_flags, new_cpu), 1);
#else
#define trace_android_rvh_select_task_rq_fair(p, prev_cpu, sd_flag, wake_flags, new_cpu)
#endif
#endif /* _TRACE_HOOK_SCHED_H */
/* This part must be outside protection */
#include <trace/define_trace.h>
+7 −0
Original line number Diff line number Diff line
@@ -23,6 +23,7 @@
#include "sched.h"

#include <trace/events/sched.h>
#include <trace/hooks/sched.h>

/*
 * Targeted preemption latency for CPU-bound tasks:
@@ -6571,6 +6572,12 @@ select_task_rq_fair(struct task_struct *p, int prev_cpu, int sd_flag, int wake_f
	int new_cpu = prev_cpu;
	int want_affine = 0;
	int sync = (wake_flags & WF_SYNC) && !(current->flags & PF_EXITING);
	int target_cpu = -1;

	trace_android_rvh_select_task_rq_fair(p, prev_cpu, sd_flag,
			wake_flags, &target_cpu);
	if (target_cpu >= 0)
		return target_cpu;

	if (sd_flag & SD_BALANCE_WAKE) {
		record_wakee(p);