1 /* SPDX-License-Identifier: GPL-2.0 */ 2 #undef TRACE_SYSTEM 3 #define TRACE_SYSTEM oom 4 5 #if !defined(_TRACE_OOM_H) || defined(TRACE_HEADER_MULTI_READ) 6 #define _TRACE_OOM_H 7 #include <linux/tracepoint.h> 8 #include <trace/events/mmflags.h> 9 10 #define PG_COUNT_TO_KB(x) ((x) << (PAGE_SHIFT - 10)) 11 12 TRACE_EVENT(oom_score_adj_update, 13 14 TP_PROTO(struct task_struct *task), 15 16 TP_ARGS(task), 17 18 TP_STRUCT__entry( 19 __field( pid_t, pid) 20 __array( char, comm, TASK_COMM_LEN ) 21 __field( short, oom_score_adj) 22 ), 23 24 TP_fast_assign( 25 __entry->pid = task->pid; 26 memcpy(__entry->comm, task->comm, TASK_COMM_LEN); 27 __entry->oom_score_adj = task->signal->oom_score_adj; 28 ), 29 30 TP_printk("pid=%d comm=%s oom_score_adj=%hd", 31 __entry->pid, __entry->comm, __entry->oom_score_adj) 32 ); 33 34 TRACE_EVENT(reclaim_retry_zone, 35 36 TP_PROTO(struct zoneref *zoneref, 37 int order, 38 unsigned long reclaimable, 39 unsigned long available, 40 unsigned long min_wmark, 41 int no_progress_loops, 42 bool wmark_check), 43 44 TP_ARGS(zoneref, order, reclaimable, available, min_wmark, no_progress_loops, wmark_check), 45 46 TP_STRUCT__entry( 47 __field( int, node) 48 __field( int, zone_idx) 49 __field( int, order) 50 __field( unsigned long, reclaimable) 51 __field( unsigned long, available) 52 __field( unsigned long, min_wmark) 53 __field( int, no_progress_loops) 54 __field( bool, wmark_check) 55 ), 56 57 TP_fast_assign( 58 __entry->node = zone_to_nid(zoneref->zone); 59 __entry->zone_idx = zoneref->zone_idx; 60 __entry->order = order; 61 __entry->reclaimable = reclaimable; 62 __entry->available = available; 63 __entry->min_wmark = min_wmark; 64 __entry->no_progress_loops = no_progress_loops; 65 __entry->wmark_check = wmark_check; 66 ), 67 68 TP_printk("node=%d zone=%-8s order=%d reclaimable=%lu available=%lu min_wmark=%lu no_progress_loops=%d wmark_check=%d", 69 __entry->node, __print_symbolic(__entry->zone_idx, ZONE_TYPE), 70 __entry->order, 71 __entry->reclaimable, __entry->available, __entry->min_wmark, 72 __entry->no_progress_loops, 73 __entry->wmark_check) 74 ); 75 76 TRACE_EVENT(mark_victim, 77 TP_PROTO(struct task_struct *task, uid_t uid), 78 79 TP_ARGS(task, uid), 80 81 TP_STRUCT__entry( 82 __field(int, pid) 83 __string(comm, task->comm) 84 __field(unsigned long, total_vm) 85 __field(unsigned long, anon_rss) 86 __field(unsigned long, file_rss) 87 __field(unsigned long, shmem_rss) 88 __field(uid_t, uid) 89 __field(unsigned long, pgtables) 90 __field(short, oom_score_adj) 91 ), 92 93 TP_fast_assign( 94 __entry->pid = task->pid; 95 __assign_str(comm, task->comm); 96 __entry->total_vm = PG_COUNT_TO_KB(task->mm->total_vm); 97 __entry->anon_rss = PG_COUNT_TO_KB(get_mm_counter(task->mm, MM_ANONPAGES)); 98 __entry->file_rss = PG_COUNT_TO_KB(get_mm_counter(task->mm, MM_FILEPAGES)); 99 __entry->shmem_rss = PG_COUNT_TO_KB(get_mm_counter(task->mm, MM_SHMEMPAGES)); 100 __entry->uid = uid; 101 __entry->pgtables = mm_pgtables_bytes(task->mm) >> 10; 102 __entry->oom_score_adj = task->signal->oom_score_adj; 103 ), 104 105 TP_printk("pid=%d comm=%s total-vm=%lukB anon-rss=%lukB file-rss:%lukB shmem-rss:%lukB uid=%u pgtables=%lukB oom_score_adj=%hd", 106 __entry->pid, 107 __get_str(comm), 108 __entry->total_vm, 109 __entry->anon_rss, 110 __entry->file_rss, 111 __entry->shmem_rss, 112 __entry->uid, 113 __entry->pgtables, 114 __entry->oom_score_adj 115 ) 116 ); 117 118 TRACE_EVENT(wake_reaper, 119 TP_PROTO(int pid), 120 121 TP_ARGS(pid), 122 123 TP_STRUCT__entry( 124 __field(int, pid) 125 ), 126 127 TP_fast_assign( 128 __entry->pid = pid; 129 ), 130 131 TP_printk("pid=%d", __entry->pid) 132 ); 133 134 TRACE_EVENT(start_task_reaping, 135 TP_PROTO(int pid), 136 137 TP_ARGS(pid), 138 139 TP_STRUCT__entry( 140 __field(int, pid) 141 ), 142 143 TP_fast_assign( 144 __entry->pid = pid; 145 ), 146 147 TP_printk("pid=%d", __entry->pid) 148 ); 149 150 TRACE_EVENT(finish_task_reaping, 151 TP_PROTO(int pid), 152 153 TP_ARGS(pid), 154 155 TP_STRUCT__entry( 156 __field(int, pid) 157 ), 158 159 TP_fast_assign( 160 __entry->pid = pid; 161 ), 162 163 TP_printk("pid=%d", __entry->pid) 164 ); 165 166 TRACE_EVENT(skip_task_reaping, 167 TP_PROTO(int pid), 168 169 TP_ARGS(pid), 170 171 TP_STRUCT__entry( 172 __field(int, pid) 173 ), 174 175 TP_fast_assign( 176 __entry->pid = pid; 177 ), 178 179 TP_printk("pid=%d", __entry->pid) 180 ); 181 182 #ifdef CONFIG_COMPACTION 183 TRACE_EVENT(compact_retry, 184 185 TP_PROTO(int order, 186 enum compact_priority priority, 187 enum compact_result result, 188 int retries, 189 int max_retries, 190 bool ret), 191 192 TP_ARGS(order, priority, result, retries, max_retries, ret), 193 194 TP_STRUCT__entry( 195 __field( int, order) 196 __field( int, priority) 197 __field( int, result) 198 __field( int, retries) 199 __field( int, max_retries) 200 __field( bool, ret) 201 ), 202 203 TP_fast_assign( 204 __entry->order = order; 205 __entry->priority = priority; 206 __entry->result = compact_result_to_feedback(result); 207 __entry->retries = retries; 208 __entry->max_retries = max_retries; 209 __entry->ret = ret; 210 ), 211 212 TP_printk("order=%d priority=%s compaction_result=%s retries=%d max_retries=%d should_retry=%d", 213 __entry->order, 214 __print_symbolic(__entry->priority, COMPACTION_PRIORITY), 215 __print_symbolic(__entry->result, COMPACTION_FEEDBACK), 216 __entry->retries, __entry->max_retries, 217 __entry->ret) 218 ); 219 #endif /* CONFIG_COMPACTION */ 220 #endif 221 222 /* This part must be outside protection */ 223 #include <trace/define_trace.h> 224