From 5a4c93e2f794001a5efa13c0dec931235240d384 Mon Sep 17 00:00:00 2001 From: Todd Kjos Date: Fri, 15 Nov 2024 20:08:49 +0000 Subject: [PATCH] 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: 7f62740112ef ("ANDROID: add support for vendor hooks") Change-Id: I84fadfbba3d210d0d932a14fcfa5620a412992a9 Signed-off-by: Todd Kjos (cherry picked from commit 24d20c9118a44adf58602d60854afb37795a4657) --- kernel/sched/cputime.c | 1 + kernel/sched/ext.c | 1 + kernel/sched/rt.c | 1 + kernel/sched/syscalls.c | 1 + 4 files changed, 4 insertions(+) diff --git a/kernel/sched/cputime.c b/kernel/sched/cputime.c index 864b58bc0acb..28d272560f87 100644 --- a/kernel/sched/cputime.c +++ b/kernel/sched/cputime.c @@ -4,6 +4,7 @@ */ #include #include +#undef TRACE_INCLUDE_PATH #ifdef CONFIG_VIRT_CPU_ACCOUNTING_NATIVE #include diff --git a/kernel/sched/ext.c b/kernel/sched/ext.c index 5900b06fd036..878314b50f29 100644 --- a/kernel/sched/ext.c +++ b/kernel/sched/ext.c @@ -1002,6 +1002,7 @@ static struct kobject *scx_root_kobj; #define CREATE_TRACE_POINTS #include +#undef CREATE_TRACE_POINTS static void process_ddsp_deferred_locals(struct rq *rq); static void scx_bpf_kick_cpu(s32 cpu, u64 flags); diff --git a/kernel/sched/rt.c b/kernel/sched/rt.c index 619e2420fe3f..cdfbddbd58c6 100644 --- a/kernel/sched/rt.c +++ b/kernel/sched/rt.c @@ -5,6 +5,7 @@ */ #include +#undef TRACE_INCLUDE_PATH int sched_rr_timeslice = RR_TIMESLICE; /* More than 4 hours if BW_SHIFT equals 20. */ diff --git a/kernel/sched/syscalls.c b/kernel/sched/syscalls.c index a12199546769..2f916c79c52a 100644 --- a/kernel/sched/syscalls.c +++ b/kernel/sched/syscalls.c @@ -17,6 +17,7 @@ #include "autogroup.h" #include +#undef TRACE_INCLUDE_PATH static inline int __normal_prio(int policy, int rt_prio, int nice) {