From 401c054dd71bd3f969fd7dc733b4b7d30ca80933 Mon Sep 17 00:00:00 2001 From: David Carlier Date: Thu, 16 Oct 2025 22:55:08 +0100 Subject: [PATCH] scx_userland: refreshing output option. Signed-off-by: David Carlier --- scheds/c/scx_userland.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/scheds/c/scx_userland.c b/scheds/c/scx_userland.c index f1cd07ff52..01a106912f 100644 --- a/scheds/c/scx_userland.c +++ b/scheds/c/scx_userland.c @@ -41,6 +41,7 @@ const char help_fmt[] = "Usage: %s [-b BATCH]\n" "\n" " -b BATCH The number of tasks to batch when dispatching (default: 8)\n" +" -r Refresh the output instead of printing new lines\n" " -v Print libbpf debug messages\n" " -h Display this help and exit\n"; @@ -51,6 +52,7 @@ const char help_fmt[] = static __u32 batch_size = 8; static bool verbose; +static bool refresh; static volatile int exit_req; static int enqueued_fd, dispatched_fd; @@ -309,7 +311,10 @@ static void *run_stats_printer(void *arg) printf("| disp: %10llu |\n", nr_vruntime_dispatches); printf("| failed: %10llu |\n", nr_vruntime_failed); printf("o-----------------------o\n"); - printf("\n\n"); + if (refresh) + printf("\033[16A"); + else + printf("\n\n"); fflush(stdout); sleep(1); } @@ -372,7 +377,7 @@ static void pre_bootstrap(int argc, char **argv) err = syscall(__NR_sched_setscheduler, getpid(), SCHED_EXT, &sched_param); SCX_BUG_ON(err, "Failed to set scheduler to SCHED_EXT"); - while ((opt = getopt(argc, argv, "b:vh")) != -1) { + while ((opt = getopt(argc, argv, "b:vrh")) != -1) { switch (opt) { case 'b': batch_size = strtoul(optarg, NULL, 0); @@ -380,6 +385,9 @@ static void pre_bootstrap(int argc, char **argv) case 'v': verbose = true; break; + case 'r': + refresh = true; + break; default: fprintf(stderr, help_fmt, basename(argv[0])); exit(opt != 'h');