1 /* SPDX-License-Identifier: GPL-2.0 */ 2 #undef TRACE_SYSTEM 3 #define TRACE_SYSTEM sched 4 #define TRACE_INCLUDE_PATH trace/hooks 5 #if !defined(_TRACE_HOOK_SCHED_H) || defined(TRACE_HEADER_MULTI_READ) 6 #define _TRACE_HOOK_SCHED_H 7 #include <trace/hooks/vendor_hooks.h> 8 /* 9 * Following tracepoints are not exported in tracefs and provide a 10 * mechanism for vendor modules to hook and extend functionality 11 */ 12 #ifdef __GENKSYMS__ 13 /* needed for KMI stability */ 14 #include <../kernel/cgroup/cgroup-internal.h> 15 #endif 16 17 DECLARE_RESTRICTED_HOOK(android_rvh_select_task_rq_fair, 18 TP_PROTO(struct task_struct *p, int prev_cpu, int sd_flag, int wake_flags, int *new_cpu), 19 TP_ARGS(p, prev_cpu, sd_flag, wake_flags, new_cpu), 1); 20 21 DECLARE_RESTRICTED_HOOK(android_rvh_select_task_rq_rt, 22 TP_PROTO(struct task_struct *p, int prev_cpu, int sd_flag, int wake_flags, int *new_cpu), 23 TP_ARGS(p, prev_cpu, sd_flag, wake_flags, new_cpu), 1); 24 25 DECLARE_RESTRICTED_HOOK(android_rvh_select_task_rq_dl, 26 TP_PROTO(struct task_struct *p, int prev_cpu, int sd_flag, int wake_flags, int *new_cpu), 27 TP_ARGS(p, prev_cpu, sd_flag, wake_flags, new_cpu), 1); 28 29 DECLARE_RESTRICTED_HOOK(android_rvh_select_fallback_rq, 30 TP_PROTO(int cpu, struct task_struct *p, int *new_cpu), 31 TP_ARGS(cpu, p, new_cpu), 1); 32 33 struct rq; 34 DECLARE_HOOK(android_vh_scheduler_tick, 35 TP_PROTO(struct rq *rq), 36 TP_ARGS(rq)); 37 38 DECLARE_RESTRICTED_HOOK(android_rvh_enqueue_task, 39 TP_PROTO(struct rq *rq, struct task_struct *p, int flags), 40 TP_ARGS(rq, p, flags), 1); 41 42 DECLARE_RESTRICTED_HOOK(android_rvh_dequeue_task, 43 TP_PROTO(struct rq *rq, struct task_struct *p, int flags), 44 TP_ARGS(rq, p, flags), 1); 45 46 DECLARE_RESTRICTED_HOOK(android_rvh_can_migrate_task, 47 TP_PROTO(struct task_struct *p, int dst_cpu, int *can_migrate), 48 TP_ARGS(p, dst_cpu, can_migrate), 1); 49 50 DECLARE_RESTRICTED_HOOK(android_rvh_find_lowest_rq, 51 TP_PROTO(struct task_struct *p, struct cpumask *local_cpu_mask, 52 int ret, int *lowest_cpu), 53 TP_ARGS(p, local_cpu_mask, ret, lowest_cpu), 1); 54 55 DECLARE_RESTRICTED_HOOK(android_rvh_prepare_prio_fork, 56 TP_PROTO(struct task_struct *p), 57 TP_ARGS(p), 1); 58 59 DECLARE_RESTRICTED_HOOK(android_rvh_finish_prio_fork, 60 TP_PROTO(struct task_struct *p), 61 TP_ARGS(p), 1); 62 63 DECLARE_RESTRICTED_HOOK(android_rvh_rtmutex_force_update, 64 TP_PROTO(struct task_struct *p, struct task_struct *pi_task, int *update), 65 TP_ARGS(p, pi_task, update), 1); 66 67 DECLARE_RESTRICTED_HOOK(android_rvh_rtmutex_prepare_setprio, 68 TP_PROTO(struct task_struct *p, struct task_struct *pi_task), 69 TP_ARGS(p, pi_task), 1); 70 71 DECLARE_RESTRICTED_HOOK(android_rvh_rto_next_cpu, 72 TP_PROTO(int rto_cpu, struct cpumask *rto_mask, int *cpu), 73 TP_ARGS(rto_cpu, rto_mask, cpu), 1); 74 75 DECLARE_RESTRICTED_HOOK(android_rvh_is_cpu_allowed, 76 TP_PROTO(struct task_struct *p, int cpu, bool *allowed), 77 TP_ARGS(p, cpu, allowed), 1); 78 79 DECLARE_RESTRICTED_HOOK(android_rvh_get_nohz_timer_target, 80 TP_PROTO(int *cpu, bool *done), 81 TP_ARGS(cpu, done), 1); 82 83 DECLARE_RESTRICTED_HOOK(android_rvh_set_user_nice, 84 TP_PROTO(struct task_struct *p, long *nice, bool *allowed), 85 TP_ARGS(p, nice, allowed), 1); 86 87 DECLARE_RESTRICTED_HOOK(android_rvh_setscheduler, 88 TP_PROTO(struct task_struct *p), 89 TP_ARGS(p), 1); 90 91 struct sched_group; 92 DECLARE_RESTRICTED_HOOK(android_rvh_find_busiest_group, 93 TP_PROTO(struct sched_group *busiest, struct rq *dst_rq, int *out_balance), 94 TP_ARGS(busiest, dst_rq, out_balance), 1); 95 96 DECLARE_HOOK(android_vh_dump_throttled_rt_tasks, 97 TP_PROTO(int cpu, u64 clock, ktime_t rt_period, u64 rt_runtime, 98 s64 rt_period_timer_expires), 99 TP_ARGS(cpu, clock, rt_period, rt_runtime, rt_period_timer_expires)); 100 101 DECLARE_HOOK(android_vh_jiffies_update, 102 TP_PROTO(void *unused), 103 TP_ARGS(unused)); 104 105 struct rq_flags; 106 DECLARE_RESTRICTED_HOOK(android_rvh_sched_newidle_balance, 107 TP_PROTO(struct rq *this_rq, struct rq_flags *rf, 108 int *pulled_task, int *done), 109 TP_ARGS(this_rq, rf, pulled_task, done), 1); 110 111 DECLARE_RESTRICTED_HOOK(android_rvh_sched_nohz_balancer_kick, 112 TP_PROTO(struct rq *rq, unsigned int *flags, int *done), 113 TP_ARGS(rq, flags, done), 1); 114 115 DECLARE_RESTRICTED_HOOK(android_rvh_sched_rebalance_domains, 116 TP_PROTO(struct rq *rq, int *continue_balancing), 117 TP_ARGS(rq, continue_balancing), 1); 118 119 DECLARE_RESTRICTED_HOOK(android_rvh_find_busiest_queue, 120 TP_PROTO(int dst_cpu, struct sched_group *group, 121 struct cpumask *env_cpus, struct rq **busiest, 122 int *done), 123 TP_ARGS(dst_cpu, group, env_cpus, busiest, done), 1); 124 125 DECLARE_RESTRICTED_HOOK(android_rvh_migrate_queued_task, 126 TP_PROTO(struct rq *rq, struct rq_flags *rf, 127 struct task_struct *p, int new_cpu, 128 int *detached), 129 TP_ARGS(rq, rf, p, new_cpu, detached), 1); 130 131 DECLARE_RESTRICTED_HOOK(android_rvh_find_energy_efficient_cpu, 132 TP_PROTO(struct task_struct *p, int prev_cpu, int sync, int *new_cpu), 133 TP_ARGS(p, prev_cpu, sync, new_cpu), 1); 134 135 DECLARE_HOOK(android_vh_set_sugov_sched_attr, 136 TP_PROTO(struct sched_attr *attr), 137 TP_ARGS(attr)); 138 139 DECLARE_RESTRICTED_HOOK(android_rvh_set_iowait, 140 TP_PROTO(struct task_struct *p, struct rq *rq, int *should_iowait_boost), 141 TP_ARGS(p, rq, should_iowait_boost), 1); 142 143 struct sugov_policy; 144 DECLARE_RESTRICTED_HOOK(android_rvh_set_sugov_update, 145 TP_PROTO(struct sugov_policy *sg_policy, unsigned int next_freq, bool *should_update), 146 TP_ARGS(sg_policy, next_freq, should_update), 1); 147 148 DECLARE_RESTRICTED_HOOK(android_rvh_cpu_overutilized, 149 TP_PROTO(int cpu, int *overutilized), 150 TP_ARGS(cpu, overutilized), 1); 151 152 DECLARE_RESTRICTED_HOOK(android_rvh_sched_setaffinity, 153 TP_PROTO(struct task_struct *p, const struct cpumask *in_mask, int *retval), 154 TP_ARGS(p, in_mask, retval), 1); 155 156 DECLARE_RESTRICTED_HOOK(android_rvh_sched_getaffinity, 157 TP_PROTO(struct task_struct *p, struct cpumask *in_mask), 158 TP_ARGS(p, in_mask), 1); 159 160 DECLARE_RESTRICTED_HOOK(android_rvh_update_cpus_allowed, 161 TP_PROTO(struct task_struct *p, cpumask_var_t cpus_requested, 162 const struct cpumask *new_mask, int *ret), 163 TP_ARGS(p, cpus_requested, new_mask, ret), 1); 164 165 DECLARE_RESTRICTED_HOOK(android_rvh_set_task_cpu, 166 TP_PROTO(struct task_struct *p, unsigned int new_cpu), 167 TP_ARGS(p, new_cpu), 1); 168 169 DECLARE_RESTRICTED_HOOK(android_rvh_try_to_wake_up, 170 TP_PROTO(struct task_struct *p), 171 TP_ARGS(p), 1); 172 173 DECLARE_RESTRICTED_HOOK(android_rvh_try_to_wake_up_success, 174 TP_PROTO(struct task_struct *p), 175 TP_ARGS(p), 1); 176 177 DECLARE_RESTRICTED_HOOK(android_rvh_sched_fork, 178 TP_PROTO(struct task_struct *p), 179 TP_ARGS(p), 1); 180 181 DECLARE_RESTRICTED_HOOK(android_rvh_wake_up_new_task, 182 TP_PROTO(struct task_struct *p), 183 TP_ARGS(p), 1); 184 185 DECLARE_RESTRICTED_HOOK(android_rvh_new_task_stats, 186 TP_PROTO(struct task_struct *p), 187 TP_ARGS(p), 1); 188 189 DECLARE_RESTRICTED_HOOK(android_rvh_flush_task, 190 TP_PROTO(struct task_struct *prev), 191 TP_ARGS(prev), 1); 192 193 DECLARE_RESTRICTED_HOOK(android_rvh_tick_entry, 194 TP_PROTO(struct rq *rq), 195 TP_ARGS(rq), 1); 196 197 DECLARE_RESTRICTED_HOOK(android_rvh_schedule, 198 TP_PROTO(struct task_struct *prev, struct task_struct *next, struct rq *rq), 199 TP_ARGS(prev, next, rq), 1); 200 201 DECLARE_RESTRICTED_HOOK(android_rvh_sched_cpu_starting, 202 TP_PROTO(int cpu), 203 TP_ARGS(cpu), 1); 204 205 DECLARE_RESTRICTED_HOOK(android_rvh_sched_cpu_dying, 206 TP_PROTO(int cpu), 207 TP_ARGS(cpu), 1); 208 209 DECLARE_RESTRICTED_HOOK(android_rvh_account_irq, 210 TP_PROTO(struct task_struct *curr, int cpu, s64 delta), 211 TP_ARGS(curr, cpu, delta), 1); 212 213 DECLARE_RESTRICTED_HOOK(android_rvh_account_irq_start, 214 TP_PROTO(struct task_struct *curr, int cpu, s64 delta), 215 TP_ARGS(curr, cpu, delta), 1); 216 217 DECLARE_RESTRICTED_HOOK(android_rvh_account_irq_end, 218 TP_PROTO(struct task_struct *curr, int cpu, s64 delta), 219 TP_ARGS(curr, cpu, delta), 1); 220 221 DECLARE_RESTRICTED_HOOK(android_rvh_place_entity, 222 TP_PROTO(struct cfs_rq *cfs_rq, struct sched_entity *se, int initial, u64 *vruntime), 223 TP_ARGS(cfs_rq, se, initial, vruntime), 1); 224 225 DECLARE_RESTRICTED_HOOK(android_rvh_build_perf_domains, 226 TP_PROTO(bool *eas_check), 227 TP_ARGS(eas_check), 1); 228 229 DECLARE_RESTRICTED_HOOK(android_rvh_update_cpu_capacity, 230 TP_PROTO(int cpu, unsigned long *capacity), 231 TP_ARGS(cpu, capacity), 1); 232 233 DECLARE_RESTRICTED_HOOK(android_rvh_update_misfit_status, 234 TP_PROTO(struct task_struct *p, struct rq *rq, bool *need_update), 235 TP_ARGS(p, rq, need_update), 1); 236 237 DECLARE_RESTRICTED_HOOK(android_rvh_sched_fork_init, 238 TP_PROTO(struct task_struct *p), 239 TP_ARGS(p), 1); 240 241 DECLARE_RESTRICTED_HOOK(android_rvh_ttwu_cond, 242 TP_PROTO(int cpu, bool *cond), 243 TP_ARGS(cpu, cond), 1); 244 245 DECLARE_RESTRICTED_HOOK(android_rvh_schedule_bug, 246 TP_PROTO(void *unused), 247 TP_ARGS(unused), 1); 248 249 DECLARE_RESTRICTED_HOOK(android_rvh_sched_exec, 250 TP_PROTO(bool *cond), 251 TP_ARGS(cond), 1); 252 253 DECLARE_HOOK(android_vh_map_util_freq, 254 TP_PROTO(unsigned long util, unsigned long freq, 255 unsigned long cap, unsigned long *next_freq), 256 TP_ARGS(util, freq, cap, next_freq)); 257 258 struct cpufreq_policy; 259 DECLARE_HOOK(android_vh_map_util_freq_new, 260 TP_PROTO(unsigned long util, unsigned long freq, 261 unsigned long cap, unsigned long *next_freq, struct cpufreq_policy *policy, 262 bool *need_freq_update), 263 TP_ARGS(util, freq, cap, next_freq, policy, need_freq_update)); 264 265 DECLARE_HOOK(android_vh_em_cpu_energy, 266 TP_PROTO(struct em_perf_domain *pd, 267 unsigned long max_util, unsigned long sum_util, 268 unsigned long *energy), 269 TP_ARGS(pd, max_util, sum_util, energy)); 270 271 DECLARE_HOOK(android_vh_build_sched_domains, 272 TP_PROTO(bool has_asym), 273 TP_ARGS(has_asym)); 274 275 DECLARE_RESTRICTED_HOOK(android_rvh_check_preempt_tick, 276 TP_PROTO(struct task_struct *p, unsigned long *ideal_runtime, bool *skip_preempt, 277 unsigned long delta_exec, struct cfs_rq *cfs_rq, struct sched_entity *curr, 278 unsigned int granularity), 279 TP_ARGS(p, ideal_runtime, skip_preempt, delta_exec, cfs_rq, curr, granularity), 1); 280 281 DECLARE_RESTRICTED_HOOK(android_rvh_check_preempt_wakeup_ignore, 282 TP_PROTO(struct task_struct *p, bool *ignore), 283 TP_ARGS(p, ignore), 1); 284 285 DECLARE_RESTRICTED_HOOK(android_rvh_replace_next_task_fair, 286 TP_PROTO(struct rq *rq, struct task_struct **p, struct sched_entity **se, bool *repick, 287 bool simple, struct task_struct *prev), 288 TP_ARGS(rq, p, se, repick, simple, prev), 1); 289 290 DECLARE_RESTRICTED_HOOK(android_rvh_sched_balance_rt, 291 TP_PROTO(struct rq *rq, struct task_struct *p, int *done), 292 TP_ARGS(rq, p, done), 1); 293 294 struct cfs_rq; 295 DECLARE_RESTRICTED_HOOK(android_rvh_pick_next_entity, 296 TP_PROTO(struct cfs_rq *cfs_rq, struct sched_entity *curr, 297 struct sched_entity **se), 298 TP_ARGS(cfs_rq, curr, se), 1); 299 300 DECLARE_RESTRICTED_HOOK(android_rvh_check_preempt_wakeup, 301 TP_PROTO(struct rq *rq, struct task_struct *p, bool *preempt, bool *nopreempt, 302 int wake_flags, struct sched_entity *se, struct sched_entity *pse, 303 int next_buddy_marked, unsigned int granularity), 304 TP_ARGS(rq, p, preempt, nopreempt, wake_flags, se, pse, next_buddy_marked, 305 granularity), 1); 306 307 DECLARE_RESTRICTED_HOOK(android_rvh_set_cpus_allowed_ptr_locked, 308 TP_PROTO(const struct cpumask *cpu_valid_mask, const struct cpumask *new_mask, 309 unsigned int *dest_cpu), 310 TP_ARGS(cpu_valid_mask, new_mask, dest_cpu), 1); 311 312 DECLARE_RESTRICTED_HOOK(android_rvh_set_cpus_allowed_by_task, 313 TP_PROTO(const struct cpumask *cpu_valid_mask, const struct cpumask *new_mask, 314 struct task_struct *p, unsigned int *dest_cpu), 315 TP_ARGS(cpu_valid_mask, new_mask, p, dest_cpu), 1); 316 317 DECLARE_RESTRICTED_HOOK(android_rvh_do_sched_yield, 318 TP_PROTO(struct rq *rq), 319 TP_ARGS(rq), 1); 320 321 DECLARE_HOOK(android_vh_free_task, 322 TP_PROTO(struct task_struct *p), 323 TP_ARGS(p)); 324 325 DECLARE_HOOK(android_vh_irqtime_account_process_tick, 326 TP_PROTO(struct task_struct *p, struct rq *rq, int user_tick, int ticks), 327 TP_ARGS(p, rq, user_tick, ticks)); 328 329 DECLARE_HOOK(android_vh_sched_pelt_multiplier, 330 TP_PROTO(unsigned int old, unsigned int cur, int *ret), 331 TP_ARGS(old, cur, ret)); 332 333 /* Conditionally defined upon CONFIG_UCLAMP_TASK */ 334 struct uclamp_se; 335 DECLARE_RESTRICTED_HOOK(android_rvh_uclamp_eff_get, 336 TP_PROTO(struct task_struct *p, enum uclamp_id clamp_id, 337 struct uclamp_se *uclamp_max, struct uclamp_se *uclamp_eff, int *ret), 338 TP_ARGS(p, clamp_id, uclamp_max, uclamp_eff, ret), 1); 339 340 DECLARE_RESTRICTED_HOOK(android_rvh_after_enqueue_task, 341 TP_PROTO(struct rq *rq, struct task_struct *p, int flags), 342 TP_ARGS(rq, p, flags), 1); 343 344 DECLARE_RESTRICTED_HOOK(android_rvh_after_dequeue_task, 345 TP_PROTO(struct rq *rq, struct task_struct *p, int flags), 346 TP_ARGS(rq, p, flags), 1); 347 348 struct cfs_rq; 349 struct rq_flags; 350 DECLARE_RESTRICTED_HOOK(android_rvh_enqueue_entity, 351 TP_PROTO(struct cfs_rq *cfs, struct sched_entity *se), 352 TP_ARGS(cfs, se), 1); 353 354 DECLARE_RESTRICTED_HOOK(android_rvh_dequeue_entity, 355 TP_PROTO(struct cfs_rq *cfs, struct sched_entity *se), 356 TP_ARGS(cfs, se), 1); 357 358 DECLARE_RESTRICTED_HOOK(android_rvh_entity_tick, 359 TP_PROTO(struct cfs_rq *cfs_rq, struct sched_entity *se), 360 TP_ARGS(cfs_rq, se), 1); 361 362 DECLARE_RESTRICTED_HOOK(android_rvh_enqueue_task_fair, 363 TP_PROTO(struct rq *rq, struct task_struct *p, int flags), 364 TP_ARGS(rq, p, flags), 1); 365 366 DECLARE_RESTRICTED_HOOK(android_rvh_dequeue_task_fair, 367 TP_PROTO(struct rq *rq, struct task_struct *p, int flags), 368 TP_ARGS(rq, p, flags), 1); 369 370 DECLARE_HOOK(android_vh_em_dev_register_pd, 371 TP_PROTO(bool *cond), 372 TP_ARGS(cond)); 373 374 DECLARE_HOOK(android_vh_sched_stat_runtime_rt, 375 TP_PROTO(struct task_struct *tsk, u64 delta), 376 TP_ARGS(tsk, delta)); 377 378 DECLARE_RESTRICTED_HOOK(android_rvh_post_init_entity_util_avg, 379 TP_PROTO(struct sched_entity *se), 380 TP_ARGS(se), 1); 381 382 DECLARE_RESTRICTED_HOOK(android_rvh_find_new_ilb, 383 TP_PROTO(struct cpumask *nohz_idle_cpus_mask, int *ilb), 384 TP_ARGS(nohz_idle_cpus_mask, ilb), 1); 385 386 DECLARE_RESTRICTED_HOOK(android_rvh_util_est_update, 387 TP_PROTO(struct cfs_rq *cfs_rq, struct task_struct *p, bool task_sleep, int *ret), 388 TP_ARGS(cfs_rq, p, task_sleep, ret), 1); 389 390 DECLARE_HOOK(android_vh_setscheduler_uclamp, 391 TP_PROTO(struct task_struct *tsk, int clamp_id, unsigned int value), 392 TP_ARGS(tsk, clamp_id, value)); 393 394 DECLARE_HOOK(android_vh_do_wake_up_sync, 395 TP_PROTO(struct wait_queue_head *wq_head, int *done), 396 TP_ARGS(wq_head, done)); 397 398 DECLARE_HOOK(android_vh_set_wake_flags, 399 TP_PROTO(int *wake_flags, unsigned int *mode), 400 TP_ARGS(wake_flags, mode)); 401 402 DECLARE_RESTRICTED_HOOK(android_rvh_effective_cpu_util, 403 TP_PROTO(int cpu, unsigned long util_cfs, unsigned long max, int type, 404 struct task_struct *p, unsigned long *new_util), 405 TP_ARGS(cpu, util_cfs, max, type, p, new_util), 1); 406 407 DECLARE_HOOK(android_vh_force_compatible_pre, 408 TP_PROTO(void *unused), 409 TP_ARGS(unused)); 410 411 DECLARE_HOOK(android_vh_force_compatible_post, 412 TP_PROTO(void *unused), 413 TP_ARGS(unused)); 414 415 DECLARE_HOOK(android_vh_dup_task_struct, 416 TP_PROTO(struct task_struct *tsk, struct task_struct *orig), 417 TP_ARGS(tsk, orig)); 418 419 DECLARE_HOOK(android_vh_account_task_time, 420 TP_PROTO(struct task_struct *p, struct rq *rq, int user_tick), 421 TP_ARGS(p, rq, user_tick)); 422 423 DECLARE_RESTRICTED_HOOK(android_rvh_set_cpus_allowed_comm, 424 TP_PROTO(struct task_struct *p, const struct cpumask *new_mask), 425 TP_ARGS(p, new_mask), 1); 426 427 DECLARE_HOOK(android_vh_sched_setaffinity_early, 428 TP_PROTO(struct task_struct *p, const struct cpumask *new_mask, int *retval), 429 TP_ARGS(p, new_mask, retval)); 430 431 DECLARE_RESTRICTED_HOOK(android_rvh_update_rt_rq_load_avg, 432 TP_PROTO(u64 now, struct rq *rq, struct task_struct *tsk, int running), 433 TP_ARGS(now, rq, tsk, running), 1); 434 435 DECLARE_RESTRICTED_HOOK(android_rvh_set_task_comm, 436 TP_PROTO(struct task_struct *tsk, bool exec), 437 TP_ARGS(tsk, exec), 1); 438 439 DECLARE_HOOK(android_vh_mmput, 440 TP_PROTO(struct mm_struct *mm), 441 TP_ARGS(mm)); 442 /* macro versions of hooks are no longer required */ 443 444 #endif /* _TRACE_HOOK_SCHED_H */ 445 /* This part must be outside protection */ 446 #include <trace/define_trace.h> 447