Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

what is clock-delta in /proc/pid/sched?

main (xxxxx, #threads: xxxxx)
---------------------------------------------------------
se.exec_start                      :                 xxxx
se.vruntime                        :                 xxxx
se.sum_exec_runtime                :                 xxxx
se.wait_start                      :                 xxxx
...
policy                             :                 xxxx
prio                               :                 xxxx
clock-delta                        :                   58 <== this one
like image 618
bobah Avatar asked Feb 17 '23 10:02

bobah


1 Answers

I was lurking into kernel source to find out what clock-delta represent.

I found the function that print it out when /proc/pid/sched is read.

It is proc_sched_show_task and it is into kernel/sched/debug.c file.

Going deeply i found the part of code that printout the clock-delta... Here it is:

unsigned int this_cpu = raw_smp_processor_id();
u64 t0, t1;

t0 = cpu_clock(this_cpu);
t1 = cpu_clock(this_cpu);
SEQ_printf(m, "%-35s:%21Ld\n",
           "clock-delta", (long long)(t1-t0));

raw_smp_processor_id returns the id of the CPU running the current thread.

so... clock-delta is the difference between two values returned by cpu_clock() called twice.

Into kernel/sched/clock.c I found the description of this function:

cpu_clock(i) provides a fast (execution time) high resolution
clock with bounded drift between CPUs. The value of cpu_clock(i) is monotonic for constant i. The timestamp returned is in nanoseconds.

like image 180
Davide Berra Avatar answered Feb 28 '23 13:02

Davide Berra