Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

tools/sched_ext: scx_qmap: Make debug output quieter by default

scx_qmap currently outputs verbose debug messages including cgroup operations
and CPU online/offline events by default, which can be noisy during normal
operation. While the existing -P option controls DSQ dumps and event
statistics, there's no way to suppress the other debug messages.

Split the debug output controls to make scx_qmap quieter by default. The -P
option continues to control DSQ dumps and event statistics
(print_dsqs_and_events), while a new -M option controls debug messages like
cgroup operations and CPU events (print_msgs). This allows users to run
scx_qmap with minimal output and selectively enable debug information as
needed.

Acked-by: Andrea Righi <arighi@nvidia.com>
Signed-off-by: Tejun Heo <tj@kernel.org>

Tejun Heo 7852e0fd d4529728

+52 -38
+44 -34
tools/sched_ext/scx_qmap.bpf.c
··· 39 39 const volatile u32 dsp_inf_loop_after; 40 40 const volatile u32 dsp_batch; 41 41 const volatile bool highpri_boosting; 42 - const volatile bool print_shared_dsq; 42 + const volatile bool print_dsqs_and_events; 43 + const volatile bool print_msgs; 43 44 const volatile s32 disallow_tgid; 44 45 const volatile bool suppress_dump; 45 46 ··· 634 633 635 634 s32 BPF_STRUCT_OPS(qmap_cgroup_init, struct cgroup *cgrp, struct scx_cgroup_init_args *args) 636 635 { 637 - bpf_printk("CGRP INIT %llu weight=%u period=%lu quota=%ld burst=%lu", 638 - cgrp->kn->id, args->weight, args->bw_period_us, 639 - args->bw_quota_us, args->bw_burst_us); 636 + if (print_msgs) 637 + bpf_printk("CGRP INIT %llu weight=%u period=%lu quota=%ld burst=%lu", 638 + cgrp->kn->id, args->weight, args->bw_period_us, 639 + args->bw_quota_us, args->bw_burst_us); 640 640 return 0; 641 641 } 642 642 643 643 void BPF_STRUCT_OPS(qmap_cgroup_set_weight, struct cgroup *cgrp, u32 weight) 644 644 { 645 - bpf_printk("CGRP SET %llu weight=%u", cgrp->kn->id, weight); 645 + if (print_msgs) 646 + bpf_printk("CGRP SET %llu weight=%u", cgrp->kn->id, weight); 646 647 } 647 648 648 649 void BPF_STRUCT_OPS(qmap_cgroup_set_bandwidth, struct cgroup *cgrp, 649 650 u64 period_us, u64 quota_us, u64 burst_us) 650 651 { 651 - bpf_printk("CGRP SET %llu period=%lu quota=%ld burst=%lu", cgrp->kn->id, 652 - period_us, quota_us, burst_us); 652 + if (print_msgs) 653 + bpf_printk("CGRP SET %llu period=%lu quota=%ld burst=%lu", 654 + cgrp->kn->id, period_us, quota_us, burst_us); 653 655 } 654 656 655 657 /* ··· 696 692 697 693 void BPF_STRUCT_OPS(qmap_cpu_online, s32 cpu) 698 694 { 699 - bpf_printk("CPU %d coming online", cpu); 700 - /* @cpu is already online at this point */ 701 - print_cpus(); 695 + if (print_msgs) { 696 + bpf_printk("CPU %d coming online", cpu); 697 + /* @cpu is already online at this point */ 698 + print_cpus(); 699 + } 702 700 } 703 701 704 702 void BPF_STRUCT_OPS(qmap_cpu_offline, s32 cpu) 705 703 { 706 - bpf_printk("CPU %d going offline", cpu); 707 - /* @cpu is still online at this point */ 708 - print_cpus(); 704 + if (print_msgs) { 705 + bpf_printk("CPU %d going offline", cpu); 706 + /* @cpu is still online at this point */ 707 + print_cpus(); 708 + } 709 709 } 710 710 711 711 struct monitor_timer { ··· 807 799 808 800 static int monitor_timerfn(void *map, int *key, struct bpf_timer *timer) 809 801 { 810 - struct scx_event_stats events; 811 - 812 802 bpf_rcu_read_lock(); 813 803 dispatch_highpri(true); 814 804 bpf_rcu_read_unlock(); 815 805 816 806 monitor_cpuperf(); 817 807 818 - if (print_shared_dsq) 808 + if (print_dsqs_and_events) { 809 + struct scx_event_stats events; 810 + 819 811 dump_shared_dsq(); 820 812 821 - __COMPAT_scx_bpf_events(&events, sizeof(events)); 813 + __COMPAT_scx_bpf_events(&events, sizeof(events)); 822 814 823 - bpf_printk("%35s: %lld", "SCX_EV_SELECT_CPU_FALLBACK", 824 - scx_read_event(&events, SCX_EV_SELECT_CPU_FALLBACK)); 825 - bpf_printk("%35s: %lld", "SCX_EV_DISPATCH_LOCAL_DSQ_OFFLINE", 826 - scx_read_event(&events, SCX_EV_DISPATCH_LOCAL_DSQ_OFFLINE)); 827 - bpf_printk("%35s: %lld", "SCX_EV_DISPATCH_KEEP_LAST", 828 - scx_read_event(&events, SCX_EV_DISPATCH_KEEP_LAST)); 829 - bpf_printk("%35s: %lld", "SCX_EV_ENQ_SKIP_EXITING", 830 - scx_read_event(&events, SCX_EV_ENQ_SKIP_EXITING)); 831 - bpf_printk("%35s: %lld", "SCX_EV_REFILL_SLICE_DFL", 832 - scx_read_event(&events, SCX_EV_REFILL_SLICE_DFL)); 833 - bpf_printk("%35s: %lld", "SCX_EV_BYPASS_DURATION", 834 - scx_read_event(&events, SCX_EV_BYPASS_DURATION)); 835 - bpf_printk("%35s: %lld", "SCX_EV_BYPASS_DISPATCH", 836 - scx_read_event(&events, SCX_EV_BYPASS_DISPATCH)); 837 - bpf_printk("%35s: %lld", "SCX_EV_BYPASS_ACTIVATE", 838 - scx_read_event(&events, SCX_EV_BYPASS_ACTIVATE)); 815 + bpf_printk("%35s: %lld", "SCX_EV_SELECT_CPU_FALLBACK", 816 + scx_read_event(&events, SCX_EV_SELECT_CPU_FALLBACK)); 817 + bpf_printk("%35s: %lld", "SCX_EV_DISPATCH_LOCAL_DSQ_OFFLINE", 818 + scx_read_event(&events, SCX_EV_DISPATCH_LOCAL_DSQ_OFFLINE)); 819 + bpf_printk("%35s: %lld", "SCX_EV_DISPATCH_KEEP_LAST", 820 + scx_read_event(&events, SCX_EV_DISPATCH_KEEP_LAST)); 821 + bpf_printk("%35s: %lld", "SCX_EV_ENQ_SKIP_EXITING", 822 + scx_read_event(&events, SCX_EV_ENQ_SKIP_EXITING)); 823 + bpf_printk("%35s: %lld", "SCX_EV_REFILL_SLICE_DFL", 824 + scx_read_event(&events, SCX_EV_REFILL_SLICE_DFL)); 825 + bpf_printk("%35s: %lld", "SCX_EV_BYPASS_DURATION", 826 + scx_read_event(&events, SCX_EV_BYPASS_DURATION)); 827 + bpf_printk("%35s: %lld", "SCX_EV_BYPASS_DISPATCH", 828 + scx_read_event(&events, SCX_EV_BYPASS_DISPATCH)); 829 + bpf_printk("%35s: %lld", "SCX_EV_BYPASS_ACTIVATE", 830 + scx_read_event(&events, SCX_EV_BYPASS_ACTIVATE)); 831 + } 839 832 840 833 bpf_timer_start(timer, ONE_SEC_IN_NS, 0); 841 834 return 0; ··· 848 839 struct bpf_timer *timer; 849 840 s32 ret; 850 841 851 - print_cpus(); 842 + if (print_msgs) 843 + print_cpus(); 852 844 853 845 ret = scx_bpf_create_dsq(SHARED_DSQ, -1); 854 846 if (ret)
+8 -4
tools/sched_ext/scx_qmap.c
··· 20 20 "See the top-level comment in .bpf.c for more details.\n" 21 21 "\n" 22 22 "Usage: %s [-s SLICE_US] [-e COUNT] [-t COUNT] [-T COUNT] [-l COUNT] [-b COUNT]\n" 23 - " [-P] [-d PID] [-D LEN] [-p] [-v]\n" 23 + " [-P] [-M] [-d PID] [-D LEN] [-p] [-v]\n" 24 24 "\n" 25 25 " -s SLICE_US Override slice duration\n" 26 26 " -e COUNT Trigger scx_bpf_error() after COUNT enqueues\n" ··· 28 28 " -T COUNT Stall every COUNT'th kernel thread\n" 29 29 " -l COUNT Trigger dispatch infinite looping after COUNT dispatches\n" 30 30 " -b COUNT Dispatch upto COUNT tasks together\n" 31 - " -P Print out DSQ content to trace_pipe every second, use with -b\n" 31 + " -P Print out DSQ content and event counters to trace_pipe every second\n" 32 + " -M Print out debug messages to trace_pipe\n" 32 33 " -H Boost nice -20 tasks in SHARED_DSQ, use with -b\n" 33 34 " -d PID Disallow a process from switching into SCHED_EXT (-1 for self)\n" 34 35 " -D LEN Set scx_exit_info.dump buffer length\n" ··· 67 66 68 67 skel->rodata->slice_ns = __COMPAT_ENUM_OR_ZERO("scx_public_consts", "SCX_SLICE_DFL"); 69 68 70 - while ((opt = getopt(argc, argv, "s:e:t:T:l:b:PHd:D:Spvh")) != -1) { 69 + while ((opt = getopt(argc, argv, "s:e:t:T:l:b:PMHd:D:Spvh")) != -1) { 71 70 switch (opt) { 72 71 case 's': 73 72 skel->rodata->slice_ns = strtoull(optarg, NULL, 0) * 1000; ··· 88 87 skel->rodata->dsp_batch = strtoul(optarg, NULL, 0); 89 88 break; 90 89 case 'P': 91 - skel->rodata->print_shared_dsq = true; 90 + skel->rodata->print_dsqs_and_events = true; 91 + break; 92 + case 'M': 93 + skel->rodata->print_msgs = true; 92 94 break; 93 95 case 'H': 94 96 skel->rodata->highpri_boosting = true;