1 /* SPDX-License-Identifier: GPL-2.0 */ 2 #undef TRACE_SYSTEM 3 #define TRACE_SYSTEM rtg 4 5 #if !defined(_TRACE_RTG_H) || defined(TRACE_HEADER_MULTI_READ) 6 #define _TRACE_RTG_H 7 8 #include <linux/trace_seq.h> 9 #include <linux/tracepoint.h> 10 #include <linux/sched/frame_rtg.h> 11 #include <linux/sched/rtg.h> 12 13 struct rq; 14 15 TRACE_EVENT(find_rtg_cpu, 16 17 TP_PROTO(struct task_struct *p, const struct cpumask *perferred_cpumask, 18 char *msg, int cpu), 19 20 TP_ARGS(p, perferred_cpumask, msg, cpu), 21 22 TP_STRUCT__entry( 23 __array(char, comm, TASK_COMM_LEN) 24 __field(pid_t, pid) 25 __bitmask(cpus, num_possible_cpus()) 26 __array(char, msg, TASK_COMM_LEN) 27 __field(int, cpu) 28 ), 29 30 TP_fast_assign( 31 __entry->pid = p->pid; 32 memcpy(__entry->comm, p->comm, TASK_COMM_LEN); 33 __assign_bitmask(cpus, cpumask_bits(perferred_cpumask), num_possible_cpus()); 34 memcpy(__entry->msg, msg, min((size_t)TASK_COMM_LEN, strlen(msg)+1)); 35 __entry->cpu = cpu; 36 ), 37 38 TP_printk("comm=%s pid=%d perferred_cpus=%s reason=%s target_cpu=%d", 39 __entry->comm, __entry->pid, __get_bitmask(cpus), __entry->msg, __entry->cpu) 40 ); 41 42 TRACE_EVENT(sched_rtg_task_each, 43 44 TP_PROTO(unsigned int id, unsigned int nr_running, struct task_struct *task), 45 46 TP_ARGS(id, nr_running, task), 47 48 TP_STRUCT__entry( 49 __field(unsigned int, id) 50 __field(unsigned int, nr_running) 51 __array(char, comm, TASK_COMM_LEN) 52 __field(pid_t, pid) 53 __field(int, prio) 54 __bitmask(allowed, num_possible_cpus()) 55 __field(int, cpu) 56 __field(int, state) 57 __field(bool, on_rq) 58 __field(int, on_cpu) 59 ), 60 61 TP_fast_assign( 62 __entry->id = id; 63 __entry->nr_running = nr_running; 64 memcpy(__entry->comm, task->comm, TASK_COMM_LEN); 65 __entry->pid = task->pid; 66 __entry->prio = task->prio; 67 __assign_bitmask(allowed, cpumask_bits(&task->cpus_mask), num_possible_cpus()); 68 __entry->cpu = task_cpu(task); 69 __entry->state = task->__state; 70 __entry->on_rq = task->on_rq; 71 __entry->on_cpu = task->on_cpu; 72 ), 73 74 TP_printk("comm=%s pid=%d prio=%d allowed=%s cpu=%d state=%s%s on_rq=%d on_cpu=%d", 75 __entry->comm, __entry->pid, __entry->prio, __get_bitmask(allowed), __entry->cpu, 76 __entry->state & (TASK_REPORT_MAX) ? 77 __print_flags(__entry->state & (TASK_REPORT_MAX), "|", 78 { TASK_INTERRUPTIBLE, "S" }, 79 { TASK_UNINTERRUPTIBLE, "D" }, 80 { __TASK_STOPPED, "T" }, 81 { __TASK_TRACED, "t" }, 82 { EXIT_DEAD, "X" }, 83 { EXIT_ZOMBIE, "Z" }, 84 { TASK_DEAD, "x" }, 85 { TASK_WAKEKILL, "K"}, 86 { TASK_WAKING, "W"}) : "R", 87 __entry->state & TASK_STATE_MAX ? "+" : "", 88 __entry->on_rq, __entry->on_cpu) 89 ); 90 91 TRACE_EVENT(sched_rtg_valid_normalized_util, 92 93 TP_PROTO(unsigned int id, unsigned int nr_running, 94 const struct cpumask *rtg_cpus, unsigned int valid), 95 96 TP_ARGS(id, nr_running, rtg_cpus, valid), 97 98 TP_STRUCT__entry( 99 __field(unsigned int, id) 100 __field(unsigned int, nr_running) 101 __bitmask(cpus, num_possible_cpus()) 102 __field(unsigned int, valid) 103 ), 104 105 TP_fast_assign( 106 __entry->id = id; 107 __entry->nr_running = nr_running; 108 __assign_bitmask(cpus, cpumask_bits(rtg_cpus), num_possible_cpus()); 109 __entry->valid = valid; 110 ), 111 112 TP_printk("id=%d nr_running=%d cpus=%s valid=%d", 113 __entry->id, __entry->nr_running, 114 __get_bitmask(cpus), __entry->valid) 115 ); 116 117 #ifdef CONFIG_SCHED_RTG_FRAME 118 TRACE_EVENT(rtg_frame_sched, 119 120 TP_PROTO(int rtgid, const char *s, s64 value), 121 122 TP_ARGS(rtgid, s, value), 123 TP_STRUCT__entry( 124 __field(int, rtgid) 125 __field(struct frame_info *, frame) 126 __field(pid_t, pid) 127 __string(str, s) 128 __field(s64, value) 129 ), 130 131 TP_fast_assign( 132 __assign_str(str, s); 133 __entry->rtgid = rtgid != -1 ? rtgid : (current->grp ? current->grp->id : 0); 134 __entry->frame = rtg_frame_info(rtgid); 135 __entry->pid = __entry->frame ? ((__entry->frame->thread[0]) ? 136 ((__entry->frame->thread[0])->pid) : 137 current->tgid) : current->tgid; 138 __entry->value = value; 139 ), 140 TP_printk("C|%d|%s_%d|%lld", __entry->pid, __get_str(str), __entry->rtgid, __entry->value) 141 ); 142 #endif 143 #endif /* _TRACE_RTG_H */ 144 145 /* This part must be outside protection */ 146 #include <trace/define_trace.h> 147