'\" t .\" Title: cpu_load_update .\" Author: [FIXME: author] [see http://docbook.sf.net/el/author] .\" Generator: DocBook XSL Stylesheets v1.79.1 .\" Date: January 2017 .\" Manual: Driver Basics .\" Source: Kernel Hackers Manual 4.8.15 .\" Language: English .\" .TH "CPU_LOAD_UPDATE" "9" "January 2017" "Kernel Hackers Manual 4\&.8\&." "Driver Basics" .\" ----------------------------------------------------------------- .\" * Define some portability stuff .\" ----------------------------------------------------------------- .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ .\" http://bugs.debian.org/507673 .\" http://lists.gnu.org/archive/html/groff/2009-02/msg00013.html .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" ----------------------------------------------------------------- .\" * set default formatting .\" ----------------------------------------------------------------- .\" disable hyphenation .nh .\" disable justification (adjust text to left margin only) .ad l .\" ----------------------------------------------------------------- .\" * MAIN CONTENT STARTS HERE * .\" ----------------------------------------------------------------- .SH "NAME" cpu_load_update \- update the rq\->cpu_load[] statistics .SH "SYNOPSIS" .HP \w'void\ cpu_load_update('u .BI "void cpu_load_update(struct\ rq\ *\ " "this_rq" ", unsigned\ long\ " "this_load" ", unsigned\ long\ " "pending_updates" ");" .SH "ARGUMENTS" .PP \fIthis_rq\fR .RS 4 The rq to update statistics for .RE .PP \fIthis_load\fR .RS 4 The current load .RE .PP \fIpending_updates\fR .RS 4 The number of missed updates .RE .SH "DESCRIPTION" .PP Update rq\->cpu_load[] statistics\&. This function is usually called every scheduler tick (TICK_NSEC)\&. .PP This function computes a decaying average: .PP load[i]\*(Aq = (1 \- 1/2^i) * load[i] + (1/2^i) * load .PP Because of NOHZ it might not get called on every tick which gives need for the \fIpending_updates\fR argument\&. .PP load[i]_n = (1 \- 1/2^i) * load[i]_n\-1 + (1/2^i) * load_n\-1 = A * load[i]_n\-1 + B ; A := (1 \- 1/2^i), B := (1/2^i) * load = A * (A * load[i]_n\-2 + B) + B = A * (A * (A * load[i]_n\-3 + B) + B) + B = A^3 * load[i]_n\-3 + (A^2 + A + 1) * B = A^n * load[i]_0 + (A^(n\-1) + A^(n\-2) + \&.\&.\&. + 1) * B = A^n * load[i]_0 + ((1 \- A^n) / (1 \- A)) * B = (1 \- 1/2^i)^n * (load[i]_0 \- load) + load .PP In the above we\*(Aqve assumed load_n := load, which is true for NOHZ_FULL as any change in load would have resulted in the tick being turned back on\&. .PP For regular NOHZ, this reduces to: .PP load[i]_n = (1 \- 1/2^i)^n * load[i]_0 .PP see \fBdecay_load_misses\fR\&. For NOHZ_FULL we get to subtract and add the extra term\&. .SH "COPYRIGHT" .br