| 1 | // SPDX-License-Identifier: GPL-2.0-only | 
|---|
| 2 | /* | 
|---|
| 3 | * kernel/sched/debug.c | 
|---|
| 4 | * | 
|---|
| 5 | * Print the CFS rbtree and other debugging details | 
|---|
| 6 | * | 
|---|
| 7 | * Copyright(C) 2007, Red Hat, Inc., Ingo Molnar | 
|---|
| 8 | */ | 
|---|
| 9 | #include <linux/debugfs.h> | 
|---|
| 10 | #include <linux/nmi.h> | 
|---|
| 11 | #include "sched.h" | 
|---|
| 12 |  | 
|---|
| 13 | /* | 
|---|
| 14 | * This allows printing both to /sys/kernel/debug/sched/debug and | 
|---|
| 15 | * to the console | 
|---|
| 16 | */ | 
|---|
| 17 | #define SEQ_printf(m, x...)			\ | 
|---|
| 18 | do {						\ | 
|---|
| 19 | if (m)					\ | 
|---|
| 20 | seq_printf(m, x);		\ | 
|---|
| 21 | else					\ | 
|---|
| 22 | pr_cont(x);			\ | 
|---|
| 23 | } while (0) | 
|---|
| 24 |  | 
|---|
| 25 | /* | 
|---|
| 26 | * Ease the printing of nsec fields: | 
|---|
| 27 | */ | 
|---|
| 28 | static long long nsec_high(unsigned long long nsec) | 
|---|
| 29 | { | 
|---|
| 30 | if ((long long)nsec < 0) { | 
|---|
| 31 | nsec = -nsec; | 
|---|
| 32 | do_div(nsec, 1000000); | 
|---|
| 33 | return -nsec; | 
|---|
| 34 | } | 
|---|
| 35 | do_div(nsec, 1000000); | 
|---|
| 36 |  | 
|---|
| 37 | return nsec; | 
|---|
| 38 | } | 
|---|
| 39 |  | 
|---|
| 40 | static unsigned long nsec_low(unsigned long long nsec) | 
|---|
| 41 | { | 
|---|
| 42 | if ((long long)nsec < 0) | 
|---|
| 43 | nsec = -nsec; | 
|---|
| 44 |  | 
|---|
| 45 | return do_div(nsec, 1000000); | 
|---|
| 46 | } | 
|---|
| 47 |  | 
|---|
| 48 | #define SPLIT_NS(x) nsec_high(x), nsec_low(x) | 
|---|
| 49 |  | 
|---|
| 50 | #define SCHED_FEAT(name, enabled)	\ | 
|---|
| 51 | #name , | 
|---|
| 52 |  | 
|---|
| 53 | static const char * const sched_feat_names[] = { | 
|---|
| 54 | #include "features.h" | 
|---|
| 55 | }; | 
|---|
| 56 |  | 
|---|
| 57 | #undef SCHED_FEAT | 
|---|
| 58 |  | 
|---|
| 59 | static int sched_feat_show(struct seq_file *m, void *v) | 
|---|
| 60 | { | 
|---|
| 61 | int i; | 
|---|
| 62 |  | 
|---|
| 63 | for (i = 0; i < __SCHED_FEAT_NR; i++) { | 
|---|
| 64 | if (!(sysctl_sched_features & (1UL << i))) | 
|---|
| 65 | seq_puts(m, s: "NO_"); | 
|---|
| 66 | seq_printf(m, fmt: "%s ", sched_feat_names[i]); | 
|---|
| 67 | } | 
|---|
| 68 | seq_puts(m, s: "\n"); | 
|---|
| 69 |  | 
|---|
| 70 | return 0; | 
|---|
| 71 | } | 
|---|
| 72 |  | 
|---|
| 73 | #ifdef CONFIG_JUMP_LABEL | 
|---|
| 74 |  | 
|---|
| 75 | #define jump_label_key__true  STATIC_KEY_INIT_TRUE | 
|---|
| 76 | #define jump_label_key__false STATIC_KEY_INIT_FALSE | 
|---|
| 77 |  | 
|---|
| 78 | #define SCHED_FEAT(name, enabled)	\ | 
|---|
| 79 | jump_label_key__##enabled , | 
|---|
| 80 |  | 
|---|
| 81 | struct static_key sched_feat_keys[__SCHED_FEAT_NR] = { | 
|---|
| 82 | #include "features.h" | 
|---|
| 83 | }; | 
|---|
| 84 |  | 
|---|
| 85 | #undef SCHED_FEAT | 
|---|
| 86 |  | 
|---|
| 87 | static void sched_feat_disable(int i) | 
|---|
| 88 | { | 
|---|
| 89 | static_key_disable_cpuslocked(key: &sched_feat_keys[i]); | 
|---|
| 90 | } | 
|---|
| 91 |  | 
|---|
| 92 | static void sched_feat_enable(int i) | 
|---|
| 93 | { | 
|---|
| 94 | static_key_enable_cpuslocked(key: &sched_feat_keys[i]); | 
|---|
| 95 | } | 
|---|
| 96 | #else /* !CONFIG_JUMP_LABEL: */ | 
|---|
| 97 | static void sched_feat_disable(int i) { }; | 
|---|
| 98 | static void sched_feat_enable(int i) { }; | 
|---|
| 99 | #endif /* !CONFIG_JUMP_LABEL */ | 
|---|
| 100 |  | 
|---|
| 101 | static int sched_feat_set(char *cmp) | 
|---|
| 102 | { | 
|---|
| 103 | int i; | 
|---|
| 104 | int neg = 0; | 
|---|
| 105 |  | 
|---|
| 106 | if (strncmp(cmp, "NO_", 3) == 0) { | 
|---|
| 107 | neg = 1; | 
|---|
| 108 | cmp += 3; | 
|---|
| 109 | } | 
|---|
| 110 |  | 
|---|
| 111 | i = match_string(array: sched_feat_names, n: __SCHED_FEAT_NR, string: cmp); | 
|---|
| 112 | if (i < 0) | 
|---|
| 113 | return i; | 
|---|
| 114 |  | 
|---|
| 115 | if (neg) { | 
|---|
| 116 | sysctl_sched_features &= ~(1UL << i); | 
|---|
| 117 | sched_feat_disable(i); | 
|---|
| 118 | } else { | 
|---|
| 119 | sysctl_sched_features |= (1UL << i); | 
|---|
| 120 | sched_feat_enable(i); | 
|---|
| 121 | } | 
|---|
| 122 |  | 
|---|
| 123 | return 0; | 
|---|
| 124 | } | 
|---|
| 125 |  | 
|---|
| 126 | static ssize_t | 
|---|
| 127 | sched_feat_write(struct file *filp, const char __user *ubuf, | 
|---|
| 128 | size_t cnt, loff_t *ppos) | 
|---|
| 129 | { | 
|---|
| 130 | char buf[64]; | 
|---|
| 131 | char *cmp; | 
|---|
| 132 | int ret; | 
|---|
| 133 | struct inode *inode; | 
|---|
| 134 |  | 
|---|
| 135 | if (cnt > 63) | 
|---|
| 136 | cnt = 63; | 
|---|
| 137 |  | 
|---|
| 138 | if (copy_from_user(to: &buf, from: ubuf, n: cnt)) | 
|---|
| 139 | return -EFAULT; | 
|---|
| 140 |  | 
|---|
| 141 | buf[cnt] = 0; | 
|---|
| 142 | cmp = strstrip(str: buf); | 
|---|
| 143 |  | 
|---|
| 144 | /* Ensure the static_key remains in a consistent state */ | 
|---|
| 145 | inode = file_inode(f: filp); | 
|---|
| 146 | cpus_read_lock(); | 
|---|
| 147 | inode_lock(inode); | 
|---|
| 148 | ret = sched_feat_set(cmp); | 
|---|
| 149 | inode_unlock(inode); | 
|---|
| 150 | cpus_read_unlock(); | 
|---|
| 151 | if (ret < 0) | 
|---|
| 152 | return ret; | 
|---|
| 153 |  | 
|---|
| 154 | *ppos += cnt; | 
|---|
| 155 |  | 
|---|
| 156 | return cnt; | 
|---|
| 157 | } | 
|---|
| 158 |  | 
|---|
| 159 | static int sched_feat_open(struct inode *inode, struct file *filp) | 
|---|
| 160 | { | 
|---|
| 161 | return single_open(filp, sched_feat_show, NULL); | 
|---|
| 162 | } | 
|---|
| 163 |  | 
|---|
| 164 | static const struct file_operations sched_feat_fops = { | 
|---|
| 165 | .open		= sched_feat_open, | 
|---|
| 166 | .write		= sched_feat_write, | 
|---|
| 167 | .read		= seq_read, | 
|---|
| 168 | .llseek		= seq_lseek, | 
|---|
| 169 | .release	= single_release, | 
|---|
| 170 | }; | 
|---|
| 171 |  | 
|---|
| 172 | static ssize_t sched_scaling_write(struct file *filp, const char __user *ubuf, | 
|---|
| 173 | size_t cnt, loff_t *ppos) | 
|---|
| 174 | { | 
|---|
| 175 | char buf[16]; | 
|---|
| 176 | unsigned int scaling; | 
|---|
| 177 |  | 
|---|
| 178 | if (cnt > 15) | 
|---|
| 179 | cnt = 15; | 
|---|
| 180 |  | 
|---|
| 181 | if (copy_from_user(to: &buf, from: ubuf, n: cnt)) | 
|---|
| 182 | return -EFAULT; | 
|---|
| 183 | buf[cnt] = '\0'; | 
|---|
| 184 |  | 
|---|
| 185 | if (kstrtouint(s: buf, base: 10, res: &scaling)) | 
|---|
| 186 | return -EINVAL; | 
|---|
| 187 |  | 
|---|
| 188 | if (scaling >= SCHED_TUNABLESCALING_END) | 
|---|
| 189 | return -EINVAL; | 
|---|
| 190 |  | 
|---|
| 191 | sysctl_sched_tunable_scaling = scaling; | 
|---|
| 192 | if (sched_update_scaling()) | 
|---|
| 193 | return -EINVAL; | 
|---|
| 194 |  | 
|---|
| 195 | *ppos += cnt; | 
|---|
| 196 | return cnt; | 
|---|
| 197 | } | 
|---|
| 198 |  | 
|---|
| 199 | static int sched_scaling_show(struct seq_file *m, void *v) | 
|---|
| 200 | { | 
|---|
| 201 | seq_printf(m, fmt: "%d\n", sysctl_sched_tunable_scaling); | 
|---|
| 202 | return 0; | 
|---|
| 203 | } | 
|---|
| 204 |  | 
|---|
| 205 | static int sched_scaling_open(struct inode *inode, struct file *filp) | 
|---|
| 206 | { | 
|---|
| 207 | return single_open(filp, sched_scaling_show, NULL); | 
|---|
| 208 | } | 
|---|
| 209 |  | 
|---|
| 210 | static const struct file_operations sched_scaling_fops = { | 
|---|
| 211 | .open		= sched_scaling_open, | 
|---|
| 212 | .write		= sched_scaling_write, | 
|---|
| 213 | .read		= seq_read, | 
|---|
| 214 | .llseek		= seq_lseek, | 
|---|
| 215 | .release	= single_release, | 
|---|
| 216 | }; | 
|---|
| 217 |  | 
|---|
| 218 | #ifdef CONFIG_PREEMPT_DYNAMIC | 
|---|
| 219 |  | 
|---|
| 220 | static ssize_t sched_dynamic_write(struct file *filp, const char __user *ubuf, | 
|---|
| 221 | size_t cnt, loff_t *ppos) | 
|---|
| 222 | { | 
|---|
| 223 | char buf[16]; | 
|---|
| 224 | int mode; | 
|---|
| 225 |  | 
|---|
| 226 | if (cnt > 15) | 
|---|
| 227 | cnt = 15; | 
|---|
| 228 |  | 
|---|
| 229 | if (copy_from_user(to: &buf, from: ubuf, n: cnt)) | 
|---|
| 230 | return -EFAULT; | 
|---|
| 231 |  | 
|---|
| 232 | buf[cnt] = 0; | 
|---|
| 233 | mode = sched_dynamic_mode(str: strstrip(str: buf)); | 
|---|
| 234 | if (mode < 0) | 
|---|
| 235 | return mode; | 
|---|
| 236 |  | 
|---|
| 237 | sched_dynamic_update(mode); | 
|---|
| 238 |  | 
|---|
| 239 | *ppos += cnt; | 
|---|
| 240 |  | 
|---|
| 241 | return cnt; | 
|---|
| 242 | } | 
|---|
| 243 |  | 
|---|
| 244 | static int sched_dynamic_show(struct seq_file *m, void *v) | 
|---|
| 245 | { | 
|---|
| 246 | int i = IS_ENABLED(CONFIG_PREEMPT_RT) * 2; | 
|---|
| 247 | int j; | 
|---|
| 248 |  | 
|---|
| 249 | /* Count entries in NULL terminated preempt_modes */ | 
|---|
| 250 | for (j = 0; preempt_modes[j]; j++) | 
|---|
| 251 | ; | 
|---|
| 252 | j -= !IS_ENABLED(CONFIG_ARCH_HAS_PREEMPT_LAZY); | 
|---|
| 253 |  | 
|---|
| 254 | for (; i < j; i++) { | 
|---|
| 255 | if (preempt_dynamic_mode == i) | 
|---|
| 256 | seq_puts(m, s: "("); | 
|---|
| 257 | seq_puts(m, s: preempt_modes[i]); | 
|---|
| 258 | if (preempt_dynamic_mode == i) | 
|---|
| 259 | seq_puts(m, s: ")"); | 
|---|
| 260 |  | 
|---|
| 261 | seq_puts(m, s: " "); | 
|---|
| 262 | } | 
|---|
| 263 |  | 
|---|
| 264 | seq_puts(m, s: "\n"); | 
|---|
| 265 | return 0; | 
|---|
| 266 | } | 
|---|
| 267 |  | 
|---|
| 268 | static int sched_dynamic_open(struct inode *inode, struct file *filp) | 
|---|
| 269 | { | 
|---|
| 270 | return single_open(filp, sched_dynamic_show, NULL); | 
|---|
| 271 | } | 
|---|
| 272 |  | 
|---|
| 273 | static const struct file_operations sched_dynamic_fops = { | 
|---|
| 274 | .open		= sched_dynamic_open, | 
|---|
| 275 | .write		= sched_dynamic_write, | 
|---|
| 276 | .read		= seq_read, | 
|---|
| 277 | .llseek		= seq_lseek, | 
|---|
| 278 | .release	= single_release, | 
|---|
| 279 | }; | 
|---|
| 280 |  | 
|---|
| 281 | #endif /* CONFIG_PREEMPT_DYNAMIC */ | 
|---|
| 282 |  | 
|---|
| 283 | __read_mostly bool sched_debug_verbose; | 
|---|
| 284 |  | 
|---|
| 285 | static struct dentry           *sd_dentry; | 
|---|
| 286 |  | 
|---|
| 287 |  | 
|---|
| 288 | static ssize_t sched_verbose_write(struct file *filp, const char __user *ubuf, | 
|---|
| 289 | size_t cnt, loff_t *ppos) | 
|---|
| 290 | { | 
|---|
| 291 | ssize_t result; | 
|---|
| 292 | bool orig; | 
|---|
| 293 |  | 
|---|
| 294 | cpus_read_lock(); | 
|---|
| 295 | sched_domains_mutex_lock(); | 
|---|
| 296 |  | 
|---|
| 297 | orig = sched_debug_verbose; | 
|---|
| 298 | result = debugfs_write_file_bool(file: filp, user_buf: ubuf, count: cnt, ppos); | 
|---|
| 299 |  | 
|---|
| 300 | if (sched_debug_verbose && !orig) | 
|---|
| 301 | update_sched_domain_debugfs(); | 
|---|
| 302 | else if (!sched_debug_verbose && orig) { | 
|---|
| 303 | debugfs_remove(dentry: sd_dentry); | 
|---|
| 304 | sd_dentry = NULL; | 
|---|
| 305 | } | 
|---|
| 306 |  | 
|---|
| 307 | sched_domains_mutex_unlock(); | 
|---|
| 308 | cpus_read_unlock(); | 
|---|
| 309 |  | 
|---|
| 310 | return result; | 
|---|
| 311 | } | 
|---|
| 312 |  | 
|---|
| 313 | static const struct file_operations sched_verbose_fops = { | 
|---|
| 314 | .read =         debugfs_read_file_bool, | 
|---|
| 315 | .write =        sched_verbose_write, | 
|---|
| 316 | .open =         simple_open, | 
|---|
| 317 | .llseek =       default_llseek, | 
|---|
| 318 | }; | 
|---|
| 319 |  | 
|---|
| 320 | static const struct seq_operations sched_debug_sops; | 
|---|
| 321 |  | 
|---|
| 322 | static int sched_debug_open(struct inode *inode, struct file *filp) | 
|---|
| 323 | { | 
|---|
| 324 | return seq_open(filp, &sched_debug_sops); | 
|---|
| 325 | } | 
|---|
| 326 |  | 
|---|
| 327 | static const struct file_operations sched_debug_fops = { | 
|---|
| 328 | .open		= sched_debug_open, | 
|---|
| 329 | .read		= seq_read, | 
|---|
| 330 | .llseek		= seq_lseek, | 
|---|
| 331 | .release	= seq_release, | 
|---|
| 332 | }; | 
|---|
| 333 |  | 
|---|
| 334 | enum dl_param { | 
|---|
| 335 | DL_RUNTIME = 0, | 
|---|
| 336 | DL_PERIOD, | 
|---|
| 337 | }; | 
|---|
| 338 |  | 
|---|
| 339 | static unsigned long fair_server_period_max = (1UL << 22) * NSEC_PER_USEC; /* ~4 seconds */ | 
|---|
| 340 | static unsigned long fair_server_period_min = (100) * NSEC_PER_USEC;     /* 100 us */ | 
|---|
| 341 |  | 
|---|
| 342 | static ssize_t sched_fair_server_write(struct file *filp, const char __user *ubuf, | 
|---|
| 343 | size_t cnt, loff_t *ppos, enum dl_param param) | 
|---|
| 344 | { | 
|---|
| 345 | long cpu = (long) ((struct seq_file *) filp->private_data)->private; | 
|---|
| 346 | struct rq *rq = cpu_rq(cpu); | 
|---|
| 347 | u64 runtime, period; | 
|---|
| 348 | size_t err; | 
|---|
| 349 | int retval; | 
|---|
| 350 | u64 value; | 
|---|
| 351 |  | 
|---|
| 352 | err = kstrtoull_from_user(s: ubuf, count: cnt, base: 10, res: &value); | 
|---|
| 353 | if (err) | 
|---|
| 354 | return err; | 
|---|
| 355 |  | 
|---|
| 356 | scoped_guard (rq_lock_irqsave, rq) { | 
|---|
| 357 | runtime  = rq->fair_server.dl_runtime; | 
|---|
| 358 | period = rq->fair_server.dl_period; | 
|---|
| 359 |  | 
|---|
| 360 | switch (param) { | 
|---|
| 361 | case DL_RUNTIME: | 
|---|
| 362 | if (runtime == value) | 
|---|
| 363 | break; | 
|---|
| 364 | runtime = value; | 
|---|
| 365 | break; | 
|---|
| 366 | case DL_PERIOD: | 
|---|
| 367 | if (value == period) | 
|---|
| 368 | break; | 
|---|
| 369 | period = value; | 
|---|
| 370 | break; | 
|---|
| 371 | } | 
|---|
| 372 |  | 
|---|
| 373 | if (runtime > period || | 
|---|
| 374 | period > fair_server_period_max || | 
|---|
| 375 | period < fair_server_period_min) { | 
|---|
| 376 | return  -EINVAL; | 
|---|
| 377 | } | 
|---|
| 378 |  | 
|---|
| 379 | update_rq_clock(rq); | 
|---|
| 380 | dl_server_stop(dl_se: &rq->fair_server); | 
|---|
| 381 |  | 
|---|
| 382 | retval = dl_server_apply_params(dl_se: &rq->fair_server, runtime, period, init: 0); | 
|---|
| 383 | if (retval) | 
|---|
| 384 | cnt = retval; | 
|---|
| 385 |  | 
|---|
| 386 | if (!runtime) | 
|---|
| 387 | printk_deferred( "Fair server disabled in CPU %d, system may crash due to starvation.\n", | 
|---|
| 388 | cpu_of(rq)); | 
|---|
| 389 |  | 
|---|
| 390 | if (rq->cfs.h_nr_queued) | 
|---|
| 391 | dl_server_start(dl_se: &rq->fair_server); | 
|---|
| 392 | } | 
|---|
| 393 |  | 
|---|
| 394 | *ppos += cnt; | 
|---|
| 395 | return cnt; | 
|---|
| 396 | } | 
|---|
| 397 |  | 
|---|
| 398 | static size_t sched_fair_server_show(struct seq_file *m, void *v, enum dl_param param) | 
|---|
| 399 | { | 
|---|
| 400 | unsigned long cpu = (unsigned long) m->private; | 
|---|
| 401 | struct rq *rq = cpu_rq(cpu); | 
|---|
| 402 | u64 value; | 
|---|
| 403 |  | 
|---|
| 404 | switch (param) { | 
|---|
| 405 | case DL_RUNTIME: | 
|---|
| 406 | value = rq->fair_server.dl_runtime; | 
|---|
| 407 | break; | 
|---|
| 408 | case DL_PERIOD: | 
|---|
| 409 | value = rq->fair_server.dl_period; | 
|---|
| 410 | break; | 
|---|
| 411 | } | 
|---|
| 412 |  | 
|---|
| 413 | seq_printf(m, fmt: "%llu\n", value); | 
|---|
| 414 | return 0; | 
|---|
| 415 |  | 
|---|
| 416 | } | 
|---|
| 417 |  | 
|---|
| 418 | static ssize_t | 
|---|
| 419 | sched_fair_server_runtime_write(struct file *filp, const char __user *ubuf, | 
|---|
| 420 | size_t cnt, loff_t *ppos) | 
|---|
| 421 | { | 
|---|
| 422 | return sched_fair_server_write(filp, ubuf, cnt, ppos, param: DL_RUNTIME); | 
|---|
| 423 | } | 
|---|
| 424 |  | 
|---|
| 425 | static int sched_fair_server_runtime_show(struct seq_file *m, void *v) | 
|---|
| 426 | { | 
|---|
| 427 | return sched_fair_server_show(m, v, param: DL_RUNTIME); | 
|---|
| 428 | } | 
|---|
| 429 |  | 
|---|
| 430 | static int sched_fair_server_runtime_open(struct inode *inode, struct file *filp) | 
|---|
| 431 | { | 
|---|
| 432 | return single_open(filp, sched_fair_server_runtime_show, inode->i_private); | 
|---|
| 433 | } | 
|---|
| 434 |  | 
|---|
| 435 | static const struct file_operations fair_server_runtime_fops = { | 
|---|
| 436 | .open		= sched_fair_server_runtime_open, | 
|---|
| 437 | .write		= sched_fair_server_runtime_write, | 
|---|
| 438 | .read		= seq_read, | 
|---|
| 439 | .llseek		= seq_lseek, | 
|---|
| 440 | .release	= single_release, | 
|---|
| 441 | }; | 
|---|
| 442 |  | 
|---|
| 443 | static ssize_t | 
|---|
| 444 | sched_fair_server_period_write(struct file *filp, const char __user *ubuf, | 
|---|
| 445 | size_t cnt, loff_t *ppos) | 
|---|
| 446 | { | 
|---|
| 447 | return sched_fair_server_write(filp, ubuf, cnt, ppos, param: DL_PERIOD); | 
|---|
| 448 | } | 
|---|
| 449 |  | 
|---|
| 450 | static int sched_fair_server_period_show(struct seq_file *m, void *v) | 
|---|
| 451 | { | 
|---|
| 452 | return sched_fair_server_show(m, v, param: DL_PERIOD); | 
|---|
| 453 | } | 
|---|
| 454 |  | 
|---|
| 455 | static int sched_fair_server_period_open(struct inode *inode, struct file *filp) | 
|---|
| 456 | { | 
|---|
| 457 | return single_open(filp, sched_fair_server_period_show, inode->i_private); | 
|---|
| 458 | } | 
|---|
| 459 |  | 
|---|
| 460 | static const struct file_operations fair_server_period_fops = { | 
|---|
| 461 | .open		= sched_fair_server_period_open, | 
|---|
| 462 | .write		= sched_fair_server_period_write, | 
|---|
| 463 | .read		= seq_read, | 
|---|
| 464 | .llseek		= seq_lseek, | 
|---|
| 465 | .release	= single_release, | 
|---|
| 466 | }; | 
|---|
| 467 |  | 
|---|
| 468 | static struct dentry *debugfs_sched; | 
|---|
| 469 |  | 
|---|
| 470 | static void debugfs_fair_server_init(void) | 
|---|
| 471 | { | 
|---|
| 472 | struct dentry *d_fair; | 
|---|
| 473 | unsigned long cpu; | 
|---|
| 474 |  | 
|---|
| 475 | d_fair = debugfs_create_dir(name: "fair_server", parent: debugfs_sched); | 
|---|
| 476 | if (!d_fair) | 
|---|
| 477 | return; | 
|---|
| 478 |  | 
|---|
| 479 | for_each_possible_cpu(cpu) { | 
|---|
| 480 | struct dentry *d_cpu; | 
|---|
| 481 | char buf[32]; | 
|---|
| 482 |  | 
|---|
| 483 | snprintf(buf, size: sizeof(buf), fmt: "cpu%lu", cpu); | 
|---|
| 484 | d_cpu = debugfs_create_dir(name: buf, parent: d_fair); | 
|---|
| 485 |  | 
|---|
| 486 | debugfs_create_file( "runtime", 0644, d_cpu, (void *) cpu, &fair_server_runtime_fops); | 
|---|
| 487 | debugfs_create_file( "period", 0644, d_cpu, (void *) cpu, &fair_server_period_fops); | 
|---|
| 488 | } | 
|---|
| 489 | } | 
|---|
| 490 |  | 
|---|
| 491 | static __init int sched_init_debug(void) | 
|---|
| 492 | { | 
|---|
| 493 | struct dentry __maybe_unused *numa; | 
|---|
| 494 |  | 
|---|
| 495 | debugfs_sched = debugfs_create_dir(name: "sched", NULL); | 
|---|
| 496 |  | 
|---|
| 497 | debugfs_create_file( "features", 0644, debugfs_sched, NULL, &sched_feat_fops); | 
|---|
| 498 | debugfs_create_file_unsafe(name: "verbose", mode: 0644, parent: debugfs_sched, data: &sched_debug_verbose, fops: &sched_verbose_fops); | 
|---|
| 499 | #ifdef CONFIG_PREEMPT_DYNAMIC | 
|---|
| 500 | debugfs_create_file( "preempt", 0644, debugfs_sched, NULL, &sched_dynamic_fops); | 
|---|
| 501 | #endif | 
|---|
| 502 |  | 
|---|
| 503 | debugfs_create_u32(name: "base_slice_ns", mode: 0644, parent: debugfs_sched, value: &sysctl_sched_base_slice); | 
|---|
| 504 |  | 
|---|
| 505 | debugfs_create_u32(name: "latency_warn_ms", mode: 0644, parent: debugfs_sched, value: &sysctl_resched_latency_warn_ms); | 
|---|
| 506 | debugfs_create_u32(name: "latency_warn_once", mode: 0644, parent: debugfs_sched, value: &sysctl_resched_latency_warn_once); | 
|---|
| 507 |  | 
|---|
| 508 | debugfs_create_file( "tunable_scaling", 0644, debugfs_sched, NULL, &sched_scaling_fops); | 
|---|
| 509 | debugfs_create_u32(name: "migration_cost_ns", mode: 0644, parent: debugfs_sched, value: &sysctl_sched_migration_cost); | 
|---|
| 510 | debugfs_create_u32(name: "nr_migrate", mode: 0644, parent: debugfs_sched, value: &sysctl_sched_nr_migrate); | 
|---|
| 511 |  | 
|---|
| 512 | sched_domains_mutex_lock(); | 
|---|
| 513 | update_sched_domain_debugfs(); | 
|---|
| 514 | sched_domains_mutex_unlock(); | 
|---|
| 515 |  | 
|---|
| 516 | #ifdef CONFIG_NUMA_BALANCING | 
|---|
| 517 | numa = debugfs_create_dir( "numa_balancing", debugfs_sched); | 
|---|
| 518 |  | 
|---|
| 519 | debugfs_create_u32( "scan_delay_ms", 0644, numa, &sysctl_numa_balancing_scan_delay); | 
|---|
| 520 | debugfs_create_u32( "scan_period_min_ms", 0644, numa, &sysctl_numa_balancing_scan_period_min); | 
|---|
| 521 | debugfs_create_u32( "scan_period_max_ms", 0644, numa, &sysctl_numa_balancing_scan_period_max); | 
|---|
| 522 | debugfs_create_u32( "scan_size_mb", 0644, numa, &sysctl_numa_balancing_scan_size); | 
|---|
| 523 | debugfs_create_u32( "hot_threshold_ms", 0644, numa, &sysctl_numa_balancing_hot_threshold); | 
|---|
| 524 | #endif /* CONFIG_NUMA_BALANCING */ | 
|---|
| 525 |  | 
|---|
| 526 | debugfs_create_file( "debug", 0444, debugfs_sched, NULL, &sched_debug_fops); | 
|---|
| 527 |  | 
|---|
| 528 | debugfs_fair_server_init(); | 
|---|
| 529 |  | 
|---|
| 530 | return 0; | 
|---|
| 531 | } | 
|---|
| 532 | late_initcall(sched_init_debug); | 
|---|
| 533 |  | 
|---|
| 534 | static cpumask_var_t		sd_sysctl_cpus; | 
|---|
| 535 |  | 
|---|
| 536 | static int sd_flags_show(struct seq_file *m, void *v) | 
|---|
| 537 | { | 
|---|
| 538 | unsigned long flags = *(unsigned int *)m->private; | 
|---|
| 539 | int idx; | 
|---|
| 540 |  | 
|---|
| 541 | for_each_set_bit(idx, &flags, __SD_FLAG_CNT) { | 
|---|
| 542 | seq_puts(m, s: sd_flag_debug[idx].name); | 
|---|
| 543 | seq_puts(m, s: " "); | 
|---|
| 544 | } | 
|---|
| 545 | seq_puts(m, s: "\n"); | 
|---|
| 546 |  | 
|---|
| 547 | return 0; | 
|---|
| 548 | } | 
|---|
| 549 |  | 
|---|
| 550 | static int sd_flags_open(struct inode *inode, struct file *file) | 
|---|
| 551 | { | 
|---|
| 552 | return single_open(file, sd_flags_show, inode->i_private); | 
|---|
| 553 | } | 
|---|
| 554 |  | 
|---|
| 555 | static const struct file_operations sd_flags_fops = { | 
|---|
| 556 | .open		= sd_flags_open, | 
|---|
| 557 | .read		= seq_read, | 
|---|
| 558 | .llseek		= seq_lseek, | 
|---|
| 559 | .release	= single_release, | 
|---|
| 560 | }; | 
|---|
| 561 |  | 
|---|
| 562 | static void register_sd(struct sched_domain *sd, struct dentry *parent) | 
|---|
| 563 | { | 
|---|
| 564 | #define SDM(type, mode, member)	\ | 
|---|
| 565 | debugfs_create_##type(#member, mode, parent, &sd->member) | 
|---|
| 566 |  | 
|---|
| 567 | SDM(ulong, 0644, min_interval); | 
|---|
| 568 | SDM(ulong, 0644, max_interval); | 
|---|
| 569 | SDM(u64,   0644, max_newidle_lb_cost); | 
|---|
| 570 | SDM(u32,   0644, busy_factor); | 
|---|
| 571 | SDM(u32,   0644, imbalance_pct); | 
|---|
| 572 | SDM(u32,   0644, cache_nice_tries); | 
|---|
| 573 | SDM(str,   0444, name); | 
|---|
| 574 |  | 
|---|
| 575 | #undef SDM | 
|---|
| 576 |  | 
|---|
| 577 | debugfs_create_file( "flags", 0444, parent, &sd->flags, &sd_flags_fops); | 
|---|
| 578 | debugfs_create_file( "groups_flags", 0444, parent, &sd->groups->flags, &sd_flags_fops); | 
|---|
| 579 | debugfs_create_u32(name: "level", mode: 0444, parent, value: (u32 *)&sd->level); | 
|---|
| 580 |  | 
|---|
| 581 | if (sd->flags & SD_ASYM_PACKING) | 
|---|
| 582 | debugfs_create_u32(name: "group_asym_prefer_cpu", mode: 0444, parent, | 
|---|
| 583 | value: (u32 *)&sd->groups->asym_prefer_cpu); | 
|---|
| 584 | } | 
|---|
| 585 |  | 
|---|
| 586 | void update_sched_domain_debugfs(void) | 
|---|
| 587 | { | 
|---|
| 588 | int cpu, i; | 
|---|
| 589 |  | 
|---|
| 590 | /* | 
|---|
| 591 | * This can unfortunately be invoked before sched_debug_init() creates | 
|---|
| 592 | * the debug directory. Don't touch sd_sysctl_cpus until then. | 
|---|
| 593 | */ | 
|---|
| 594 | if (!debugfs_sched) | 
|---|
| 595 | return; | 
|---|
| 596 |  | 
|---|
| 597 | if (!sched_debug_verbose) | 
|---|
| 598 | return; | 
|---|
| 599 |  | 
|---|
| 600 | if (!cpumask_available(mask: sd_sysctl_cpus)) { | 
|---|
| 601 | if (!alloc_cpumask_var(mask: &sd_sysctl_cpus, GFP_KERNEL)) | 
|---|
| 602 | return; | 
|---|
| 603 | cpumask_copy(dstp: sd_sysctl_cpus, cpu_possible_mask); | 
|---|
| 604 | } | 
|---|
| 605 |  | 
|---|
| 606 | if (!sd_dentry) { | 
|---|
| 607 | sd_dentry = debugfs_create_dir(name: "domains", parent: debugfs_sched); | 
|---|
| 608 |  | 
|---|
| 609 | /* rebuild sd_sysctl_cpus if empty since it gets cleared below */ | 
|---|
| 610 | if (cpumask_empty(srcp: sd_sysctl_cpus)) | 
|---|
| 611 | cpumask_copy(dstp: sd_sysctl_cpus, cpu_online_mask); | 
|---|
| 612 | } | 
|---|
| 613 |  | 
|---|
| 614 | for_each_cpu(cpu, sd_sysctl_cpus) { | 
|---|
| 615 | struct sched_domain *sd; | 
|---|
| 616 | struct dentry *d_cpu; | 
|---|
| 617 | char buf[32]; | 
|---|
| 618 |  | 
|---|
| 619 | snprintf(buf, size: sizeof(buf), fmt: "cpu%d", cpu); | 
|---|
| 620 | debugfs_lookup_and_remove(name: buf, parent: sd_dentry); | 
|---|
| 621 | d_cpu = debugfs_create_dir(name: buf, parent: sd_dentry); | 
|---|
| 622 |  | 
|---|
| 623 | i = 0; | 
|---|
| 624 | for_each_domain(cpu, sd) { | 
|---|
| 625 | struct dentry *d_sd; | 
|---|
| 626 |  | 
|---|
| 627 | snprintf(buf, size: sizeof(buf), fmt: "domain%d", i); | 
|---|
| 628 | d_sd = debugfs_create_dir(name: buf, parent: d_cpu); | 
|---|
| 629 |  | 
|---|
| 630 | register_sd(sd, parent: d_sd); | 
|---|
| 631 | i++; | 
|---|
| 632 | } | 
|---|
| 633 |  | 
|---|
| 634 | __cpumask_clear_cpu(cpu, dstp: sd_sysctl_cpus); | 
|---|
| 635 | } | 
|---|
| 636 | } | 
|---|
| 637 |  | 
|---|
| 638 | void dirty_sched_domain_sysctl(int cpu) | 
|---|
| 639 | { | 
|---|
| 640 | if (cpumask_available(mask: sd_sysctl_cpus)) | 
|---|
| 641 | __cpumask_set_cpu(cpu, dstp: sd_sysctl_cpus); | 
|---|
| 642 | } | 
|---|
| 643 |  | 
|---|
| 644 | #ifdef CONFIG_FAIR_GROUP_SCHED | 
|---|
| 645 | static void print_cfs_group_stats(struct seq_file *m, int cpu, struct task_group *tg) | 
|---|
| 646 | { | 
|---|
| 647 | struct sched_entity *se = tg->se[cpu]; | 
|---|
| 648 |  | 
|---|
| 649 | #define P(F)		SEQ_printf(m, "  .%-30s: %lld\n",	#F, (long long)F) | 
|---|
| 650 | #define P_SCHEDSTAT(F)	SEQ_printf(m, "  .%-30s: %lld\n",	\ | 
|---|
| 651 | #F, (long long)schedstat_val(stats->F)) | 
|---|
| 652 | #define PN(F)		SEQ_printf(m, "  .%-30s: %lld.%06ld\n", #F, SPLIT_NS((long long)F)) | 
|---|
| 653 | #define PN_SCHEDSTAT(F)	SEQ_printf(m, "  .%-30s: %lld.%06ld\n", \ | 
|---|
| 654 | #F, SPLIT_NS((long long)schedstat_val(stats->F))) | 
|---|
| 655 |  | 
|---|
| 656 | if (!se) | 
|---|
| 657 | return; | 
|---|
| 658 |  | 
|---|
| 659 | PN(se->exec_start); | 
|---|
| 660 | PN(se->vruntime); | 
|---|
| 661 | PN(se->sum_exec_runtime); | 
|---|
| 662 |  | 
|---|
| 663 | if (schedstat_enabled()) { | 
|---|
| 664 | struct sched_statistics *stats; | 
|---|
| 665 | stats = __schedstats_from_se(se); | 
|---|
| 666 |  | 
|---|
| 667 | PN_SCHEDSTAT(wait_start); | 
|---|
| 668 | PN_SCHEDSTAT(sleep_start); | 
|---|
| 669 | PN_SCHEDSTAT(block_start); | 
|---|
| 670 | PN_SCHEDSTAT(sleep_max); | 
|---|
| 671 | PN_SCHEDSTAT(block_max); | 
|---|
| 672 | PN_SCHEDSTAT(exec_max); | 
|---|
| 673 | PN_SCHEDSTAT(slice_max); | 
|---|
| 674 | PN_SCHEDSTAT(wait_max); | 
|---|
| 675 | PN_SCHEDSTAT(wait_sum); | 
|---|
| 676 | P_SCHEDSTAT(wait_count); | 
|---|
| 677 | } | 
|---|
| 678 |  | 
|---|
| 679 | P(se->load.weight); | 
|---|
| 680 | P(se->avg.load_avg); | 
|---|
| 681 | P(se->avg.util_avg); | 
|---|
| 682 | P(se->avg.runnable_avg); | 
|---|
| 683 |  | 
|---|
| 684 | #undef PN_SCHEDSTAT | 
|---|
| 685 | #undef PN | 
|---|
| 686 | #undef P_SCHEDSTAT | 
|---|
| 687 | #undef P | 
|---|
| 688 | } | 
|---|
| 689 | #endif /* CONFIG_FAIR_GROUP_SCHED */ | 
|---|
| 690 |  | 
|---|
| 691 | #ifdef CONFIG_CGROUP_SCHED | 
|---|
| 692 | static DEFINE_SPINLOCK(sched_debug_lock); | 
|---|
| 693 | static char group_path[PATH_MAX]; | 
|---|
| 694 |  | 
|---|
| 695 | static void task_group_path(struct task_group *tg, char *path, int plen) | 
|---|
| 696 | { | 
|---|
| 697 | if (autogroup_path(tg, buf: path, buflen: plen)) | 
|---|
| 698 | return; | 
|---|
| 699 |  | 
|---|
| 700 | cgroup_path(cgrp: tg->css.cgroup, buf: path, buflen: plen); | 
|---|
| 701 | } | 
|---|
| 702 |  | 
|---|
| 703 | /* | 
|---|
| 704 | * Only 1 SEQ_printf_task_group_path() caller can use the full length | 
|---|
| 705 | * group_path[] for cgroup path. Other simultaneous callers will have | 
|---|
| 706 | * to use a shorter stack buffer. A "..." suffix is appended at the end | 
|---|
| 707 | * of the stack buffer so that it will show up in case the output length | 
|---|
| 708 | * matches the given buffer size to indicate possible path name truncation. | 
|---|
| 709 | */ | 
|---|
| 710 | #define SEQ_printf_task_group_path(m, tg, fmt...)			\ | 
|---|
| 711 | {									\ | 
|---|
| 712 | if (spin_trylock(&sched_debug_lock)) {				\ | 
|---|
| 713 | task_group_path(tg, group_path, sizeof(group_path));	\ | 
|---|
| 714 | SEQ_printf(m, fmt, group_path);				\ | 
|---|
| 715 | spin_unlock(&sched_debug_lock);				\ | 
|---|
| 716 | } else {							\ | 
|---|
| 717 | char buf[128];						\ | 
|---|
| 718 | char *bufend = buf + sizeof(buf) - 3;			\ | 
|---|
| 719 | task_group_path(tg, buf, bufend - buf);			\ | 
|---|
| 720 | strcpy(bufend - 1, "...");				\ | 
|---|
| 721 | SEQ_printf(m, fmt, buf);				\ | 
|---|
| 722 | }								\ | 
|---|
| 723 | } | 
|---|
| 724 | #endif | 
|---|
| 725 |  | 
|---|
| 726 | static void | 
|---|
| 727 | print_task(struct seq_file *m, struct rq *rq, struct task_struct *p) | 
|---|
| 728 | { | 
|---|
| 729 | if (task_current(rq, p)) | 
|---|
| 730 | SEQ_printf(m, ">R"); | 
|---|
| 731 | else | 
|---|
| 732 | SEQ_printf(m, " %c", task_state_to_char(p)); | 
|---|
| 733 |  | 
|---|
| 734 | SEQ_printf(m, " %15s %5d %9Ld.%06ld   %c   %9Ld.%06ld %c %9Ld.%06ld %9Ld.%06ld %9Ld   %5d ", | 
|---|
| 735 | p->comm, task_pid_nr(p), | 
|---|
| 736 | SPLIT_NS(p->se.vruntime), | 
|---|
| 737 | entity_eligible(cfs_rq_of(&p->se), &p->se) ? 'E' : 'N', | 
|---|
| 738 | SPLIT_NS(p->se.deadline), | 
|---|
| 739 | p->se.custom_slice ? 'S' : ' ', | 
|---|
| 740 | SPLIT_NS(p->se.slice), | 
|---|
| 741 | SPLIT_NS(p->se.sum_exec_runtime), | 
|---|
| 742 | (long long)(p->nvcsw + p->nivcsw), | 
|---|
| 743 | p->prio); | 
|---|
| 744 |  | 
|---|
| 745 | SEQ_printf(m, "%9lld.%06ld %9lld.%06ld %9lld.%06ld", | 
|---|
| 746 | SPLIT_NS(schedstat_val_or_zero(p->stats.wait_sum)), | 
|---|
| 747 | SPLIT_NS(schedstat_val_or_zero(p->stats.sum_sleep_runtime)), | 
|---|
| 748 | SPLIT_NS(schedstat_val_or_zero(p->stats.sum_block_runtime))); | 
|---|
| 749 |  | 
|---|
| 750 | #ifdef CONFIG_NUMA_BALANCING | 
|---|
| 751 | SEQ_printf(m, "   %d      %d", task_node(p), task_numa_group_id(p)); | 
|---|
| 752 | #endif | 
|---|
| 753 | #ifdef CONFIG_CGROUP_SCHED | 
|---|
| 754 | SEQ_printf_task_group_path(m, task_group(p), "        %s") | 
|---|
| 755 | #endif | 
|---|
| 756 |  | 
|---|
| 757 | SEQ_printf(m, "\n"); | 
|---|
| 758 | } | 
|---|
| 759 |  | 
|---|
| 760 | static void print_rq(struct seq_file *m, struct rq *rq, int rq_cpu) | 
|---|
| 761 | { | 
|---|
| 762 | struct task_struct *g, *p; | 
|---|
| 763 |  | 
|---|
| 764 | SEQ_printf(m, "\n"); | 
|---|
| 765 | SEQ_printf(m, "runnable tasks:\n"); | 
|---|
| 766 | SEQ_printf(m, " S            task   PID       vruntime   eligible    " | 
|---|
| 767 | "deadline             slice          sum-exec      switches  " | 
|---|
| 768 | "prio         wait-time        sum-sleep       sum-block" | 
|---|
| 769 | #ifdef CONFIG_NUMA_BALANCING | 
|---|
| 770 | "  node   group-id" | 
|---|
| 771 | #endif | 
|---|
| 772 | #ifdef CONFIG_CGROUP_SCHED | 
|---|
| 773 | "  group-path" | 
|---|
| 774 | #endif | 
|---|
| 775 | "\n"); | 
|---|
| 776 | SEQ_printf(m, "-------------------------------------------------------" | 
|---|
| 777 | "------------------------------------------------------" | 
|---|
| 778 | "------------------------------------------------------" | 
|---|
| 779 | #ifdef CONFIG_NUMA_BALANCING | 
|---|
| 780 | "--------------" | 
|---|
| 781 | #endif | 
|---|
| 782 | #ifdef CONFIG_CGROUP_SCHED | 
|---|
| 783 | "--------------" | 
|---|
| 784 | #endif | 
|---|
| 785 | "\n"); | 
|---|
| 786 |  | 
|---|
| 787 | rcu_read_lock(); | 
|---|
| 788 | for_each_process_thread(g, p) { | 
|---|
| 789 | if (task_cpu(p) != rq_cpu) | 
|---|
| 790 | continue; | 
|---|
| 791 |  | 
|---|
| 792 | print_task(m, rq, p); | 
|---|
| 793 | } | 
|---|
| 794 | rcu_read_unlock(); | 
|---|
| 795 | } | 
|---|
| 796 |  | 
|---|
| 797 | void print_cfs_rq(struct seq_file *m, int cpu, struct cfs_rq *cfs_rq) | 
|---|
| 798 | { | 
|---|
| 799 | s64 left_vruntime = -1, min_vruntime, right_vruntime = -1, left_deadline = -1, spread; | 
|---|
| 800 | struct sched_entity *last, *first, *root; | 
|---|
| 801 | struct rq *rq = cpu_rq(cpu); | 
|---|
| 802 | unsigned long flags; | 
|---|
| 803 |  | 
|---|
| 804 | #ifdef CONFIG_FAIR_GROUP_SCHED | 
|---|
| 805 | SEQ_printf(m, "\n"); | 
|---|
| 806 | SEQ_printf_task_group_path(m, cfs_rq->tg, "cfs_rq[%d]:%s\n", cpu); | 
|---|
| 807 | #else | 
|---|
| 808 | SEQ_printf(m, "\n"); | 
|---|
| 809 | SEQ_printf(m, "cfs_rq[%d]:\n", cpu); | 
|---|
| 810 | #endif | 
|---|
| 811 |  | 
|---|
| 812 | raw_spin_rq_lock_irqsave(rq, flags); | 
|---|
| 813 | root = __pick_root_entity(cfs_rq); | 
|---|
| 814 | if (root) | 
|---|
| 815 | left_vruntime = root->min_vruntime; | 
|---|
| 816 | first = __pick_first_entity(cfs_rq); | 
|---|
| 817 | if (first) | 
|---|
| 818 | left_deadline = first->deadline; | 
|---|
| 819 | last = __pick_last_entity(cfs_rq); | 
|---|
| 820 | if (last) | 
|---|
| 821 | right_vruntime = last->vruntime; | 
|---|
| 822 | min_vruntime = cfs_rq->min_vruntime; | 
|---|
| 823 | raw_spin_rq_unlock_irqrestore(rq, flags); | 
|---|
| 824 |  | 
|---|
| 825 | SEQ_printf(m, "  .%-30s: %Ld.%06ld\n", "left_deadline", | 
|---|
| 826 | SPLIT_NS(left_deadline)); | 
|---|
| 827 | SEQ_printf(m, "  .%-30s: %Ld.%06ld\n", "left_vruntime", | 
|---|
| 828 | SPLIT_NS(left_vruntime)); | 
|---|
| 829 | SEQ_printf(m, "  .%-30s: %Ld.%06ld\n", "min_vruntime", | 
|---|
| 830 | SPLIT_NS(min_vruntime)); | 
|---|
| 831 | SEQ_printf(m, "  .%-30s: %Ld.%06ld\n", "avg_vruntime", | 
|---|
| 832 | SPLIT_NS(avg_vruntime(cfs_rq))); | 
|---|
| 833 | SEQ_printf(m, "  .%-30s: %Ld.%06ld\n", "right_vruntime", | 
|---|
| 834 | SPLIT_NS(right_vruntime)); | 
|---|
| 835 | spread = right_vruntime - left_vruntime; | 
|---|
| 836 | SEQ_printf(m, "  .%-30s: %Ld.%06ld\n", "spread", SPLIT_NS(spread)); | 
|---|
| 837 | SEQ_printf(m, "  .%-30s: %d\n", "nr_queued", cfs_rq->nr_queued); | 
|---|
| 838 | SEQ_printf(m, "  .%-30s: %d\n", "h_nr_runnable", cfs_rq->h_nr_runnable); | 
|---|
| 839 | SEQ_printf(m, "  .%-30s: %d\n", "h_nr_queued", cfs_rq->h_nr_queued); | 
|---|
| 840 | SEQ_printf(m, "  .%-30s: %d\n", "h_nr_idle", cfs_rq->h_nr_idle); | 
|---|
| 841 | SEQ_printf(m, "  .%-30s: %ld\n", "load", cfs_rq->load.weight); | 
|---|
| 842 | SEQ_printf(m, "  .%-30s: %lu\n", "load_avg", | 
|---|
| 843 | cfs_rq->avg.load_avg); | 
|---|
| 844 | SEQ_printf(m, "  .%-30s: %lu\n", "runnable_avg", | 
|---|
| 845 | cfs_rq->avg.runnable_avg); | 
|---|
| 846 | SEQ_printf(m, "  .%-30s: %lu\n", "util_avg", | 
|---|
| 847 | cfs_rq->avg.util_avg); | 
|---|
| 848 | SEQ_printf(m, "  .%-30s: %u\n", "util_est", | 
|---|
| 849 | cfs_rq->avg.util_est); | 
|---|
| 850 | SEQ_printf(m, "  .%-30s: %ld\n", "removed.load_avg", | 
|---|
| 851 | cfs_rq->removed.load_avg); | 
|---|
| 852 | SEQ_printf(m, "  .%-30s: %ld\n", "removed.util_avg", | 
|---|
| 853 | cfs_rq->removed.util_avg); | 
|---|
| 854 | SEQ_printf(m, "  .%-30s: %ld\n", "removed.runnable_avg", | 
|---|
| 855 | cfs_rq->removed.runnable_avg); | 
|---|
| 856 | #ifdef CONFIG_FAIR_GROUP_SCHED | 
|---|
| 857 | SEQ_printf(m, "  .%-30s: %lu\n", "tg_load_avg_contrib", | 
|---|
| 858 | cfs_rq->tg_load_avg_contrib); | 
|---|
| 859 | SEQ_printf(m, "  .%-30s: %ld\n", "tg_load_avg", | 
|---|
| 860 | atomic_long_read(&cfs_rq->tg->load_avg)); | 
|---|
| 861 | #endif /* CONFIG_FAIR_GROUP_SCHED */ | 
|---|
| 862 | #ifdef CONFIG_CFS_BANDWIDTH | 
|---|
| 863 | SEQ_printf(m, "  .%-30s: %d\n", "throttled", | 
|---|
| 864 | cfs_rq->throttled); | 
|---|
| 865 | SEQ_printf(m, "  .%-30s: %d\n", "throttle_count", | 
|---|
| 866 | cfs_rq->throttle_count); | 
|---|
| 867 | #endif | 
|---|
| 868 |  | 
|---|
| 869 | #ifdef CONFIG_FAIR_GROUP_SCHED | 
|---|
| 870 | print_cfs_group_stats(m, cpu, tg: cfs_rq->tg); | 
|---|
| 871 | #endif | 
|---|
| 872 | } | 
|---|
| 873 |  | 
|---|
| 874 | void print_rt_rq(struct seq_file *m, int cpu, struct rt_rq *rt_rq) | 
|---|
| 875 | { | 
|---|
| 876 | #ifdef CONFIG_RT_GROUP_SCHED | 
|---|
| 877 | SEQ_printf(m, "\n"); | 
|---|
| 878 | SEQ_printf_task_group_path(m, rt_rq->tg, "rt_rq[%d]:%s\n", cpu); | 
|---|
| 879 | #else | 
|---|
| 880 | SEQ_printf(m, "\n"); | 
|---|
| 881 | SEQ_printf(m, "rt_rq[%d]:\n", cpu); | 
|---|
| 882 | #endif | 
|---|
| 883 |  | 
|---|
| 884 | #define P(x) \ | 
|---|
| 885 | SEQ_printf(m, "  .%-30s: %Ld\n", #x, (long long)(rt_rq->x)) | 
|---|
| 886 | #define PU(x) \ | 
|---|
| 887 | SEQ_printf(m, "  .%-30s: %lu\n", #x, (unsigned long)(rt_rq->x)) | 
|---|
| 888 | #define PN(x) \ | 
|---|
| 889 | SEQ_printf(m, "  .%-30s: %Ld.%06ld\n", #x, SPLIT_NS(rt_rq->x)) | 
|---|
| 890 |  | 
|---|
| 891 | PU(rt_nr_running); | 
|---|
| 892 |  | 
|---|
| 893 | #ifdef CONFIG_RT_GROUP_SCHED | 
|---|
| 894 | P(rt_throttled); | 
|---|
| 895 | PN(rt_time); | 
|---|
| 896 | PN(rt_runtime); | 
|---|
| 897 | #endif | 
|---|
| 898 |  | 
|---|
| 899 | #undef PN | 
|---|
| 900 | #undef PU | 
|---|
| 901 | #undef P | 
|---|
| 902 | } | 
|---|
| 903 |  | 
|---|
| 904 | void print_dl_rq(struct seq_file *m, int cpu, struct dl_rq *dl_rq) | 
|---|
| 905 | { | 
|---|
| 906 | struct dl_bw *dl_bw; | 
|---|
| 907 |  | 
|---|
| 908 | SEQ_printf(m, "\n"); | 
|---|
| 909 | SEQ_printf(m, "dl_rq[%d]:\n", cpu); | 
|---|
| 910 |  | 
|---|
| 911 | #define PU(x) \ | 
|---|
| 912 | SEQ_printf(m, "  .%-30s: %lu\n", #x, (unsigned long)(dl_rq->x)) | 
|---|
| 913 |  | 
|---|
| 914 | PU(dl_nr_running); | 
|---|
| 915 | dl_bw = &cpu_rq(cpu)->rd->dl_bw; | 
|---|
| 916 | SEQ_printf(m, "  .%-30s: %lld\n", "dl_bw->bw", dl_bw->bw); | 
|---|
| 917 | SEQ_printf(m, "  .%-30s: %lld\n", "dl_bw->total_bw", dl_bw->total_bw); | 
|---|
| 918 |  | 
|---|
| 919 | #undef PU | 
|---|
| 920 | } | 
|---|
| 921 |  | 
|---|
| 922 | static void print_cpu(struct seq_file *m, int cpu) | 
|---|
| 923 | { | 
|---|
| 924 | struct rq *rq = cpu_rq(cpu); | 
|---|
| 925 |  | 
|---|
| 926 | #ifdef CONFIG_X86 | 
|---|
| 927 | { | 
|---|
| 928 | unsigned int freq = cpu_khz ? : 1; | 
|---|
| 929 |  | 
|---|
| 930 | SEQ_printf(m, "cpu#%d, %u.%03u MHz\n", | 
|---|
| 931 | cpu, freq / 1000, (freq % 1000)); | 
|---|
| 932 | } | 
|---|
| 933 | #else /* !CONFIG_X86: */ | 
|---|
| 934 | SEQ_printf(m, "cpu#%d\n", cpu); | 
|---|
| 935 | #endif /* !CONFIG_X86 */ | 
|---|
| 936 |  | 
|---|
| 937 | #define P(x)								\ | 
|---|
| 938 | do {									\ | 
|---|
| 939 | if (sizeof(rq->x) == 4)						\ | 
|---|
| 940 | SEQ_printf(m, "  .%-30s: %d\n", #x, (int)(rq->x));	\ | 
|---|
| 941 | else								\ | 
|---|
| 942 | SEQ_printf(m, "  .%-30s: %Ld\n", #x, (long long)(rq->x));\ | 
|---|
| 943 | } while (0) | 
|---|
| 944 |  | 
|---|
| 945 | #define PN(x) \ | 
|---|
| 946 | SEQ_printf(m, "  .%-30s: %Ld.%06ld\n", #x, SPLIT_NS(rq->x)) | 
|---|
| 947 |  | 
|---|
| 948 | P(nr_running); | 
|---|
| 949 | P(nr_switches); | 
|---|
| 950 | P(nr_uninterruptible); | 
|---|
| 951 | PN(next_balance); | 
|---|
| 952 | SEQ_printf(m, "  .%-30s: %ld\n", "curr->pid", (long)(task_pid_nr(rq->curr))); | 
|---|
| 953 | PN(clock); | 
|---|
| 954 | PN(clock_task); | 
|---|
| 955 | #undef P | 
|---|
| 956 | #undef PN | 
|---|
| 957 |  | 
|---|
| 958 | #define P64(n) SEQ_printf(m, "  .%-30s: %Ld\n", #n, rq->n); | 
|---|
| 959 | P64(avg_idle); | 
|---|
| 960 | P64(max_idle_balance_cost); | 
|---|
| 961 | #undef P64 | 
|---|
| 962 |  | 
|---|
| 963 | #define P(n) SEQ_printf(m, "  .%-30s: %d\n", #n, schedstat_val(rq->n)); | 
|---|
| 964 | if (schedstat_enabled()) { | 
|---|
| 965 | P(yld_count); | 
|---|
| 966 | P(sched_count); | 
|---|
| 967 | P(sched_goidle); | 
|---|
| 968 | P(ttwu_count); | 
|---|
| 969 | P(ttwu_local); | 
|---|
| 970 | } | 
|---|
| 971 | #undef P | 
|---|
| 972 |  | 
|---|
| 973 | print_cfs_stats(m, cpu); | 
|---|
| 974 | print_rt_stats(m, cpu); | 
|---|
| 975 | print_dl_stats(m, cpu); | 
|---|
| 976 |  | 
|---|
| 977 | print_rq(m, rq, rq_cpu: cpu); | 
|---|
| 978 | SEQ_printf(m, "\n"); | 
|---|
| 979 | } | 
|---|
| 980 |  | 
|---|
| 981 | static const char *sched_tunable_scaling_names[] = { | 
|---|
| 982 | "none", | 
|---|
| 983 | "logarithmic", | 
|---|
| 984 | "linear" | 
|---|
| 985 | }; | 
|---|
| 986 |  | 
|---|
| 987 | static void (struct seq_file *m) | 
|---|
| 988 | { | 
|---|
| 989 | u64 ktime, sched_clk, cpu_clk; | 
|---|
| 990 | unsigned long flags; | 
|---|
| 991 |  | 
|---|
| 992 | local_irq_save(flags); | 
|---|
| 993 | ktime = ktime_to_ns(kt: ktime_get()); | 
|---|
| 994 | sched_clk = sched_clock(); | 
|---|
| 995 | cpu_clk = local_clock(); | 
|---|
| 996 | local_irq_restore(flags); | 
|---|
| 997 |  | 
|---|
| 998 | SEQ_printf(m, "Sched Debug Version: v0.11, %s %.*s\n", | 
|---|
| 999 | init_utsname()->release, | 
|---|
| 1000 | (int)strcspn(init_utsname()->version, " "), | 
|---|
| 1001 | init_utsname()->version); | 
|---|
| 1002 |  | 
|---|
| 1003 | #define P(x) \ | 
|---|
| 1004 | SEQ_printf(m, "%-40s: %Ld\n", #x, (long long)(x)) | 
|---|
| 1005 | #define PN(x) \ | 
|---|
| 1006 | SEQ_printf(m, "%-40s: %Ld.%06ld\n", #x, SPLIT_NS(x)) | 
|---|
| 1007 | PN(ktime); | 
|---|
| 1008 | PN(sched_clk); | 
|---|
| 1009 | PN(cpu_clk); | 
|---|
| 1010 | P(jiffies); | 
|---|
| 1011 | #ifdef CONFIG_HAVE_UNSTABLE_SCHED_CLOCK | 
|---|
| 1012 | P(sched_clock_stable()); | 
|---|
| 1013 | #endif | 
|---|
| 1014 | #undef PN | 
|---|
| 1015 | #undef P | 
|---|
| 1016 |  | 
|---|
| 1017 | SEQ_printf(m, "\n"); | 
|---|
| 1018 | SEQ_printf(m, "sysctl_sched\n"); | 
|---|
| 1019 |  | 
|---|
| 1020 | #define P(x) \ | 
|---|
| 1021 | SEQ_printf(m, "  .%-40s: %Ld\n", #x, (long long)(x)) | 
|---|
| 1022 | #define PN(x) \ | 
|---|
| 1023 | SEQ_printf(m, "  .%-40s: %Ld.%06ld\n", #x, SPLIT_NS(x)) | 
|---|
| 1024 | PN(sysctl_sched_base_slice); | 
|---|
| 1025 | P(sysctl_sched_features); | 
|---|
| 1026 | #undef PN | 
|---|
| 1027 | #undef P | 
|---|
| 1028 |  | 
|---|
| 1029 | SEQ_printf(m, "  .%-40s: %d (%s)\n", | 
|---|
| 1030 | "sysctl_sched_tunable_scaling", | 
|---|
| 1031 | sysctl_sched_tunable_scaling, | 
|---|
| 1032 | sched_tunable_scaling_names[sysctl_sched_tunable_scaling]); | 
|---|
| 1033 | SEQ_printf(m, "\n"); | 
|---|
| 1034 | } | 
|---|
| 1035 |  | 
|---|
| 1036 | static int sched_debug_show(struct seq_file *m, void *v) | 
|---|
| 1037 | { | 
|---|
| 1038 | int cpu = (unsigned long)(v - 2); | 
|---|
| 1039 |  | 
|---|
| 1040 | if (cpu != -1) | 
|---|
| 1041 | print_cpu(m, cpu); | 
|---|
| 1042 | else | 
|---|
| 1043 | sched_debug_header(m); | 
|---|
| 1044 |  | 
|---|
| 1045 | return 0; | 
|---|
| 1046 | } | 
|---|
| 1047 |  | 
|---|
| 1048 | void sysrq_sched_debug_show(void) | 
|---|
| 1049 | { | 
|---|
| 1050 | int cpu; | 
|---|
| 1051 |  | 
|---|
| 1052 | sched_debug_header(NULL); | 
|---|
| 1053 | for_each_online_cpu(cpu) { | 
|---|
| 1054 | /* | 
|---|
| 1055 | * Need to reset softlockup watchdogs on all CPUs, because | 
|---|
| 1056 | * another CPU might be blocked waiting for us to process | 
|---|
| 1057 | * an IPI or stop_machine. | 
|---|
| 1058 | */ | 
|---|
| 1059 | touch_nmi_watchdog(); | 
|---|
| 1060 | touch_all_softlockup_watchdogs(); | 
|---|
| 1061 | print_cpu(NULL, cpu); | 
|---|
| 1062 | } | 
|---|
| 1063 | } | 
|---|
| 1064 |  | 
|---|
| 1065 | /* | 
|---|
| 1066 | * This iterator needs some explanation. | 
|---|
| 1067 | * It returns 1 for the header position. | 
|---|
| 1068 | * This means 2 is CPU 0. | 
|---|
| 1069 | * In a hotplugged system some CPUs, including CPU 0, may be missing so we have | 
|---|
| 1070 | * to use cpumask_* to iterate over the CPUs. | 
|---|
| 1071 | */ | 
|---|
| 1072 | static void *sched_debug_start(struct seq_file *file, loff_t *offset) | 
|---|
| 1073 | { | 
|---|
| 1074 | unsigned long n = *offset; | 
|---|
| 1075 |  | 
|---|
| 1076 | if (n == 0) | 
|---|
| 1077 | return (void *) 1; | 
|---|
| 1078 |  | 
|---|
| 1079 | n--; | 
|---|
| 1080 |  | 
|---|
| 1081 | if (n > 0) | 
|---|
| 1082 | n = cpumask_next(n: n - 1, cpu_online_mask); | 
|---|
| 1083 | else | 
|---|
| 1084 | n = cpumask_first(cpu_online_mask); | 
|---|
| 1085 |  | 
|---|
| 1086 | *offset = n + 1; | 
|---|
| 1087 |  | 
|---|
| 1088 | if (n < nr_cpu_ids) | 
|---|
| 1089 | return (void *)(unsigned long)(n + 2); | 
|---|
| 1090 |  | 
|---|
| 1091 | return NULL; | 
|---|
| 1092 | } | 
|---|
| 1093 |  | 
|---|
| 1094 | static void *sched_debug_next(struct seq_file *file, void *data, loff_t *offset) | 
|---|
| 1095 | { | 
|---|
| 1096 | (*offset)++; | 
|---|
| 1097 | return sched_debug_start(file, offset); | 
|---|
| 1098 | } | 
|---|
| 1099 |  | 
|---|
| 1100 | static void sched_debug_stop(struct seq_file *file, void *data) | 
|---|
| 1101 | { | 
|---|
| 1102 | } | 
|---|
| 1103 |  | 
|---|
| 1104 | static const struct seq_operations sched_debug_sops = { | 
|---|
| 1105 | .start		= sched_debug_start, | 
|---|
| 1106 | .next		= sched_debug_next, | 
|---|
| 1107 | .stop		= sched_debug_stop, | 
|---|
| 1108 | .show		= sched_debug_show, | 
|---|
| 1109 | }; | 
|---|
| 1110 |  | 
|---|
| 1111 | #define __PS(S, F) SEQ_printf(m, "%-45s:%21Ld\n", S, (long long)(F)) | 
|---|
| 1112 | #define __P(F) __PS(#F, F) | 
|---|
| 1113 | #define   P(F) __PS(#F, p->F) | 
|---|
| 1114 | #define   PM(F, M) __PS(#F, p->F & (M)) | 
|---|
| 1115 | #define __PSN(S, F) SEQ_printf(m, "%-45s:%14Ld.%06ld\n", S, SPLIT_NS((long long)(F))) | 
|---|
| 1116 | #define __PN(F) __PSN(#F, F) | 
|---|
| 1117 | #define   PN(F) __PSN(#F, p->F) | 
|---|
| 1118 |  | 
|---|
| 1119 |  | 
|---|
| 1120 | #ifdef CONFIG_NUMA_BALANCING | 
|---|
| 1121 | void print_numa_stats(struct seq_file *m, int node, unsigned long tsf, | 
|---|
| 1122 | unsigned long tpf, unsigned long gsf, unsigned long gpf) | 
|---|
| 1123 | { | 
|---|
| 1124 | SEQ_printf(m, "numa_faults node=%d ", node); | 
|---|
| 1125 | SEQ_printf(m, "task_private=%lu task_shared=%lu ", tpf, tsf); | 
|---|
| 1126 | SEQ_printf(m, "group_private=%lu group_shared=%lu\n", gpf, gsf); | 
|---|
| 1127 | } | 
|---|
| 1128 | #endif | 
|---|
| 1129 |  | 
|---|
| 1130 |  | 
|---|
| 1131 | static void sched_show_numa(struct task_struct *p, struct seq_file *m) | 
|---|
| 1132 | { | 
|---|
| 1133 | #ifdef CONFIG_NUMA_BALANCING | 
|---|
| 1134 | if (p->mm) | 
|---|
| 1135 | P(mm->numa_scan_seq); | 
|---|
| 1136 |  | 
|---|
| 1137 | P(numa_pages_migrated); | 
|---|
| 1138 | P(numa_preferred_nid); | 
|---|
| 1139 | P(total_numa_faults); | 
|---|
| 1140 | SEQ_printf(m, "current_node=%d, numa_group_id=%d\n", | 
|---|
| 1141 | task_node(p), task_numa_group_id(p)); | 
|---|
| 1142 | show_numa_stats(p, m); | 
|---|
| 1143 | #endif /* CONFIG_NUMA_BALANCING */ | 
|---|
| 1144 | } | 
|---|
| 1145 |  | 
|---|
| 1146 | void proc_sched_show_task(struct task_struct *p, struct pid_namespace *ns, | 
|---|
| 1147 | struct seq_file *m) | 
|---|
| 1148 | { | 
|---|
| 1149 | unsigned long nr_switches; | 
|---|
| 1150 |  | 
|---|
| 1151 | SEQ_printf(m, "%s (%d, #threads: %d)\n", p->comm, task_pid_nr_ns(p, ns), | 
|---|
| 1152 | get_nr_threads(p)); | 
|---|
| 1153 | SEQ_printf(m, | 
|---|
| 1154 | "---------------------------------------------------------" | 
|---|
| 1155 | "----------\n"); | 
|---|
| 1156 |  | 
|---|
| 1157 | #define P_SCHEDSTAT(F)  __PS(#F, schedstat_val(p->stats.F)) | 
|---|
| 1158 | #define PN_SCHEDSTAT(F) __PSN(#F, schedstat_val(p->stats.F)) | 
|---|
| 1159 |  | 
|---|
| 1160 | PN(se.exec_start); | 
|---|
| 1161 | PN(se.vruntime); | 
|---|
| 1162 | PN(se.sum_exec_runtime); | 
|---|
| 1163 |  | 
|---|
| 1164 | nr_switches = p->nvcsw + p->nivcsw; | 
|---|
| 1165 |  | 
|---|
| 1166 | P(se.nr_migrations); | 
|---|
| 1167 |  | 
|---|
| 1168 | if (schedstat_enabled()) { | 
|---|
| 1169 | u64 avg_atom, avg_per_cpu; | 
|---|
| 1170 |  | 
|---|
| 1171 | PN_SCHEDSTAT(sum_sleep_runtime); | 
|---|
| 1172 | PN_SCHEDSTAT(sum_block_runtime); | 
|---|
| 1173 | PN_SCHEDSTAT(wait_start); | 
|---|
| 1174 | PN_SCHEDSTAT(sleep_start); | 
|---|
| 1175 | PN_SCHEDSTAT(block_start); | 
|---|
| 1176 | PN_SCHEDSTAT(sleep_max); | 
|---|
| 1177 | PN_SCHEDSTAT(block_max); | 
|---|
| 1178 | PN_SCHEDSTAT(exec_max); | 
|---|
| 1179 | PN_SCHEDSTAT(slice_max); | 
|---|
| 1180 | PN_SCHEDSTAT(wait_max); | 
|---|
| 1181 | PN_SCHEDSTAT(wait_sum); | 
|---|
| 1182 | P_SCHEDSTAT(wait_count); | 
|---|
| 1183 | PN_SCHEDSTAT(iowait_sum); | 
|---|
| 1184 | P_SCHEDSTAT(iowait_count); | 
|---|
| 1185 | P_SCHEDSTAT(nr_migrations_cold); | 
|---|
| 1186 | P_SCHEDSTAT(nr_failed_migrations_affine); | 
|---|
| 1187 | P_SCHEDSTAT(nr_failed_migrations_running); | 
|---|
| 1188 | P_SCHEDSTAT(nr_failed_migrations_hot); | 
|---|
| 1189 | P_SCHEDSTAT(nr_forced_migrations); | 
|---|
| 1190 | P_SCHEDSTAT(nr_wakeups); | 
|---|
| 1191 | P_SCHEDSTAT(nr_wakeups_sync); | 
|---|
| 1192 | P_SCHEDSTAT(nr_wakeups_migrate); | 
|---|
| 1193 | P_SCHEDSTAT(nr_wakeups_local); | 
|---|
| 1194 | P_SCHEDSTAT(nr_wakeups_remote); | 
|---|
| 1195 | P_SCHEDSTAT(nr_wakeups_affine); | 
|---|
| 1196 | P_SCHEDSTAT(nr_wakeups_affine_attempts); | 
|---|
| 1197 | P_SCHEDSTAT(nr_wakeups_passive); | 
|---|
| 1198 | P_SCHEDSTAT(nr_wakeups_idle); | 
|---|
| 1199 |  | 
|---|
| 1200 | avg_atom = p->se.sum_exec_runtime; | 
|---|
| 1201 | if (nr_switches) | 
|---|
| 1202 | avg_atom = div64_ul(avg_atom, nr_switches); | 
|---|
| 1203 | else | 
|---|
| 1204 | avg_atom = -1LL; | 
|---|
| 1205 |  | 
|---|
| 1206 | avg_per_cpu = p->se.sum_exec_runtime; | 
|---|
| 1207 | if (p->se.nr_migrations) { | 
|---|
| 1208 | avg_per_cpu = div64_u64(dividend: avg_per_cpu, | 
|---|
| 1209 | divisor: p->se.nr_migrations); | 
|---|
| 1210 | } else { | 
|---|
| 1211 | avg_per_cpu = -1LL; | 
|---|
| 1212 | } | 
|---|
| 1213 |  | 
|---|
| 1214 | __PN(avg_atom); | 
|---|
| 1215 | __PN(avg_per_cpu); | 
|---|
| 1216 |  | 
|---|
| 1217 | #ifdef CONFIG_SCHED_CORE | 
|---|
| 1218 | PN_SCHEDSTAT(core_forceidle_sum); | 
|---|
| 1219 | #endif | 
|---|
| 1220 | } | 
|---|
| 1221 |  | 
|---|
| 1222 | __P(nr_switches); | 
|---|
| 1223 | __PS( "nr_voluntary_switches", p->nvcsw); | 
|---|
| 1224 | __PS( "nr_involuntary_switches", p->nivcsw); | 
|---|
| 1225 |  | 
|---|
| 1226 | P(se.load.weight); | 
|---|
| 1227 | P(se.avg.load_sum); | 
|---|
| 1228 | P(se.avg.runnable_sum); | 
|---|
| 1229 | P(se.avg.util_sum); | 
|---|
| 1230 | P(se.avg.load_avg); | 
|---|
| 1231 | P(se.avg.runnable_avg); | 
|---|
| 1232 | P(se.avg.util_avg); | 
|---|
| 1233 | P(se.avg.last_update_time); | 
|---|
| 1234 | PM(se.avg.util_est, ~UTIL_AVG_UNCHANGED); | 
|---|
| 1235 | #ifdef CONFIG_UCLAMP_TASK | 
|---|
| 1236 | __PS( "uclamp.min", p->uclamp_req[UCLAMP_MIN].value); | 
|---|
| 1237 | __PS( "uclamp.max", p->uclamp_req[UCLAMP_MAX].value); | 
|---|
| 1238 | __PS( "effective uclamp.min", uclamp_eff_value(p, UCLAMP_MIN)); | 
|---|
| 1239 | __PS( "effective uclamp.max", uclamp_eff_value(p, UCLAMP_MAX)); | 
|---|
| 1240 | #endif /* CONFIG_UCLAMP_TASK */ | 
|---|
| 1241 | P(policy); | 
|---|
| 1242 | P(prio); | 
|---|
| 1243 | if (task_has_dl_policy(p)) { | 
|---|
| 1244 | P(dl.runtime); | 
|---|
| 1245 | P(dl.deadline); | 
|---|
| 1246 | } else if (fair_policy(policy: p->policy)) { | 
|---|
| 1247 | P(se.slice); | 
|---|
| 1248 | } | 
|---|
| 1249 | #ifdef CONFIG_SCHED_CLASS_EXT | 
|---|
| 1250 | __PS( "ext.enabled", task_on_scx(p)); | 
|---|
| 1251 | #endif | 
|---|
| 1252 | #undef PN_SCHEDSTAT | 
|---|
| 1253 | #undef P_SCHEDSTAT | 
|---|
| 1254 |  | 
|---|
| 1255 | { | 
|---|
| 1256 | unsigned int this_cpu = raw_smp_processor_id(); | 
|---|
| 1257 | u64 t0, t1; | 
|---|
| 1258 |  | 
|---|
| 1259 | t0 = cpu_clock(cpu: this_cpu); | 
|---|
| 1260 | t1 = cpu_clock(cpu: this_cpu); | 
|---|
| 1261 | __PS( "clock-delta", t1-t0); | 
|---|
| 1262 | } | 
|---|
| 1263 |  | 
|---|
| 1264 | sched_show_numa(p, m); | 
|---|
| 1265 | } | 
|---|
| 1266 |  | 
|---|
| 1267 | void proc_sched_set_task(struct task_struct *p) | 
|---|
| 1268 | { | 
|---|
| 1269 | #ifdef CONFIG_SCHEDSTATS | 
|---|
| 1270 | memset(s: &p->stats, c: 0, n: sizeof(p->stats)); | 
|---|
| 1271 | #endif | 
|---|
| 1272 | } | 
|---|
| 1273 |  | 
|---|
| 1274 | void resched_latency_warn(int cpu, u64 latency) | 
|---|
| 1275 | { | 
|---|
| 1276 | static DEFINE_RATELIMIT_STATE(latency_check_ratelimit, 60 * 60 * HZ, 1); | 
|---|
| 1277 |  | 
|---|
| 1278 | if (likely(!__ratelimit(&latency_check_ratelimit))) | 
|---|
| 1279 | return; | 
|---|
| 1280 |  | 
|---|
| 1281 | pr_err( "sched: CPU %d need_resched set for > %llu ns (%d ticks) without schedule\n", | 
|---|
| 1282 | cpu, latency, cpu_rq(cpu)->ticks_without_resched); | 
|---|
| 1283 | dump_stack(); | 
|---|
| 1284 | } | 
|---|
| 1285 |  | 
|---|