Skip to content

Commit b0d2ae0

Browse files
authored
Merge pull request raspberrypi#83 from sched-ext/scx_print_info-updates
scx: Update print_scx_info()
2 parents 9a64d87 + f23fbab commit b0d2ae0

File tree

1 file changed

+13
-29
lines changed

1 file changed

+13
-29
lines changed

kernel/sched/ext.c

Lines changed: 13 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -3701,51 +3701,35 @@ static void kick_cpus_irq_workfn(struct irq_work *irq_work)
37013701
*/
37023702
void print_scx_info(const char *log_lvl, struct task_struct *p)
37033703
{
3704-
struct sched_class *class = NULL;
37053704
enum scx_ops_enable_state state = scx_ops_enable_state();
3706-
s64 delta = 0;
3707-
long ops_state = 0;
3708-
int task_cpu;
3709-
struct thread_info *thread_info;
37103705
const char *all = READ_ONCE(scx_switching_all) ? "+all" : "";
3706+
char runnable_at_buf[22] = "?";
3707+
struct sched_class *class;
3708+
unsigned long runnable_at;
37113709

3712-
if (!scx_enabled() || state == SCX_OPS_DISABLED)
3710+
if (state == SCX_OPS_DISABLED)
37133711
return;
37143712

37153713
/*
37163714
* Carefully check if the task was running on sched_ext, and then
37173715
* carefully copy the time it's been runnable, and its state.
37183716
*/
3719-
copy_from_kernel_nofault(&class, &p->sched_class, sizeof(class));
3720-
if (!class || class != &ext_sched_class) {
3721-
printk("%ssched_ext: %s (%s%s)", log_lvl, scx_ops.name,
3717+
if (copy_from_kernel_nofault(&class, &p->sched_class, sizeof(class)) ||
3718+
class != &ext_sched_class) {
3719+
printk("%sSched_ext: %s (%s%s)", log_lvl, scx_ops.name,
37223720
scx_ops_enable_state_str[state], all);
37233721
return;
37243722
}
37253723

3726-
copy_from_kernel_nofault(&thread_info, task_thread_info(p),
3727-
sizeof(thread_info));
3728-
copy_from_kernel_nofault(&task_cpu, &thread_info->cpu,
3729-
sizeof(task_cpu));
3730-
if (ops_cpu_valid(task_cpu)) {
3731-
struct rq *task_rq;
3732-
u64 rq_clock;
3733-
unsigned long runnable_at;
3734-
3735-
task_rq = cpu_rq(task_cpu);
3736-
copy_from_kernel_nofault(&rq_clock, &task_rq->clock,
3737-
sizeof(rq_clock));
3738-
copy_from_kernel_nofault(&ops_state, &p->scx.ops_state.counter,
3739-
sizeof(ops_state));
3740-
copy_from_kernel_nofault(&runnable_at, &p->scx.runnable_at,
3741-
sizeof(runnable_at));
3742-
delta = rq_clock - runnable_at;
3743-
}
3724+
if (!copy_from_kernel_nofault(&runnable_at, &p->scx.runnable_at,
3725+
sizeof(runnable_at)))
3726+
scnprintf(runnable_at_buf, sizeof(runnable_at_buf), "%+lldms",
3727+
(s64)(runnable_at - jiffies) * (HZ / MSEC_PER_SEC));
37443728

37453729
/* Print everything onto one line to conserve console spce. */
3746-
printk("%ssched_ext: %s (%s%s), task: runnable_at=%+lld state=%#lx",
3730+
printk("%sSched_ext: %s (%s%s), task: runnable_at=%s",
37473731
log_lvl, scx_ops.name, scx_ops_enable_state_str[state], all,
3748-
delta, ops_state);
3732+
runnable_at_buf);
37493733
}
37503734

37513735
void __init init_sched_ext_class(void)

0 commit comments

Comments
 (0)