Why so many context switches and page faults
> uname -rsi
Linux 5.8.0-59-generic x86_64
> lsb_release -ds
Ubuntu 20.04.2 LTS
CPU: AMD Threadripper 3970X
RAM: 32G
I have a short application that just runs a loop just to load the CPU (at bottom).
> /usr/bin/time -f "elapsed %esec cpu %P ctx-sw (vol %w uvol %c) pg-flt %R io %F" ck-load
elapsed 3.89sec cpu 99% ctx-sw (vol 1 uvol 350) pg-flt 76 io 0
Why does this have 350 unvoluntary context switches?
76 page faults?
nice -n -20 does not help.
[code]
/*
* load.c - create a load on the cpu
*/
#include <math.h>
#include <stdint.h> /* int64_t */
#include <stdlib.h> /* llabs */
volatile long double pi;
volatile long double u;
volatile long double v;
volatile long double w;
volatile long double x;
volatile long double y;
volatile long double z;
volatile int64_t a;
volatile int64_t b;
volatile int64_t c;
volatile int64_t d;
volatile int64_t e;
volatile int64_t f;
volatile int64_t loop_count;
int main() {
pi = atanl(1.0);
w = -2.0 * pi;
loop_count = 0;
for (loop_count=0; loop_count < 10000000; loop_count++) {
x = sinl(w);
a = llabs(x);
y = cosl(w);
b = llabs(y);
z = tanl(w);
c = llabs(z);
u = expl(fabsl(y));
d = llabs(u);
v = sqrtl(fabsl(x*y));
e = llabs(v);
a += b;
c += d;
e += a * b;
f = c * d;
w += 0.000001;
if ( w > 2.0 * pi) {
w = -2.0 * pi;
}
}
return 0;
}
[\code]
Question information
- Language:
- English Edit question
- Status:
- Answered
- For:
- Ubuntu Edit question
- Assignee:
- No assignee Edit question
- Last query:
- Last reply:
Can you help with this problem?
Provide an answer of your own, or ask tomdean for more information if necessary.