ANDROID: fix incorrect TRACE_INCLUDE_PATH in sched/build_policy.c

The TRACE_INCLUDE_PATH is used by the tracing system to do
multiple inclusions of the trace related header for events.
In the upstream kernel, this normally points to "trace/events",
however since Android leverages the tracing system to implement
vendor hooks, the hook related headers set TRACE_INCLUDE_PATH
to "trace/hooks".

Since several schedule "c" files are now #include'd by
sched/build_policy.c, it is possible for the TRACE_INCLUDE_PATH
to point to the wrong path. For example, here is a fragment of
build_policy.c:

	#include "cputime.c"
	#include "deadline.c"

	#ifdef CONFIG_SCHED_CLASS_EXT
	# include "ext.c"
	#endif

if cputime.c has an inclusion of a hook, then TRACE_INCLUDE_PATH
may be set to "trace/hooks" when ext.c is included. This results
in errors like:

include/trace/define_trace.h:95:42: fatal error: trace/hooks/sched_ext.h: No such file or directory

Fix by #undef'ing TRACE_INCLUDE_PATH after inclusion of a hook
header for C files that are #include'd in sched/build_policy.c.

There is a related issue with CREATE_TRACE_POINTS which also
needs to be #undef'd if set by the included C file.

Fixes: 7f62740112 ("ANDROID: add support for vendor hooks")
Change-Id: I84fadfbba3d210d0d932a14fcfa5620a412992a9
Signed-off-by: Todd Kjos <tkjos@google.com>
(cherry picked from commit 24d20c9118)
This commit is contained in:
Todd Kjos
2024-11-15 20:08:49 +00:00
committed by Treehugger Robot
parent 6acfcba3de
commit 5a4c93e2f7
4 changed files with 4 additions and 0 deletions
+1
View File
@@ -4,6 +4,7 @@
*/
#include <linux/cpufreq_times.h>
#include <trace/hooks/sched.h>
#undef TRACE_INCLUDE_PATH
#ifdef CONFIG_VIRT_CPU_ACCOUNTING_NATIVE
#include <asm/cputime.h>
+1
View File
@@ -1002,6 +1002,7 @@ static struct kobject *scx_root_kobj;
#define CREATE_TRACE_POINTS
#include <trace/events/sched_ext.h>
#undef CREATE_TRACE_POINTS
static void process_ddsp_deferred_locals(struct rq *rq);
static void scx_bpf_kick_cpu(s32 cpu, u64 flags);
+1
View File
@@ -5,6 +5,7 @@
*/
#include <trace/hooks/sched.h>
#undef TRACE_INCLUDE_PATH
int sched_rr_timeslice = RR_TIMESLICE;
/* More than 4 hours if BW_SHIFT equals 20. */
+1
View File
@@ -17,6 +17,7 @@
#include "autogroup.h"
#include <trace/hooks/sched.h>
#undef TRACE_INCLUDE_PATH
static inline int __normal_prio(int policy, int rt_prio, int nice)
{