From the Linux source code, we know that get_avenrun()
is called in fs/proc/loadavg.c
to take the average load average for 1 minute, 5 minutes and 15 minutes (for example, cat/proc/loadavg
).And if you look at the source code [*2] of get_avenrun()
in kernel/sched/loadavg.c
, you can see that avenrun[i]
is simply substituted for the first argument.Calling this function periodically is because you cannot update /proc/loadavg
.
kernel/sched/loadavg.c
has only two functions to write the unsigned long avenrun[3]
global variable.
static void calc_global_nohz(void)
void calc_global_load (unsigned long ticks)
Which internal process or thread periodically invokes the above functions, or can avenrun[3]
be updated periodically in a different way?
Also, what is the distinction between the two functions?
linux
I'm not sure about the Linux kernel, so it's appropriate, but the comments in calc_global_load()
on the link are as follows, so I think it's a timer interrupt.
/*
* calc_load-update the avenrun load estimates 10 ticks after the
* CPU have updated calc_load_tasks.
*
* Called from the global timer code.
*/
So calc_global_nohz()
is a Tickless process by name.
© 2024 OneMinuteCode. All rights reserved.