Skip to contentSkip to conversation

sched: accurate user accounting

PATCH Al Boldi 3 participants 3 messages Mar 26, 2007

lore
Share & tools
lore

Al Boldi

author
#0 lore raw
Quoted 2 lines · Con Kolivas

Ok this one is heavily tested. Please try it when you find the time.

It's better, but still skewed. Try two chew.c's; they account 80% each.

Quoted 7 lines

---
Currently we only do cpu accounting to userspace based on what is actually happening precisely on each tick. The accuracy of that accounting gets progressively worse the lower HZ is. As we already keep accounting of nanosecond resolution we can accurately track user cpu, nice cpu and idle cpu if we move the accounting to update_cpu_clock with a nanosecond cpu_usage_stat entry.

That's great and much needed, but this is still probed; so what's wrong with doing it in-lined?

Quoted 2 lines

This increases overhead slightly but
avoids the problem of tick aliasing errors making accounting unreliable.

Higher scheduling accuracy may actually offset any overhead incurred, so it's well worth it; and if it's in-lined it should mean even less overhead.

Quoted 3 lines

+ /* Sanity check. It should never go backwards or ruin accounting
*/ + if (unlikely(now < p->last_ran))
+ goto out_set;

If sched_clock() goes backwards, why not fix it, instead of hacking around it?

Thanks!

--
Al

#1 lore raw
Quoted 6 lines · Al Boldi
Quoted 3 lines

+ /* Sanity check. It should never go backwards or ruin accounting
*/ + if (unlikely(now < p->last_ran))
+ goto out_set;

If sched_clock() goes backwards, why not fix it, instead of hacking around it?

When tasks change cpu, timestamp correction is attempted, but isn't perfect (perfection: submit patch to read remote clock - people likely toast poor submitter's buns very thoroughly). Timewarps happen, and even on Intel processors there seems to be very small difference in TSCs in the same package. (that's what instrumentation here said must be true, possible booboos aside)

-Mike

#2 lore raw
In reply to Al Boldi
Quoted 26 lines · Al Boldi
Quoted 1 line · Con Kolivas

Ok this one is heavily tested. Please try it when you find the time.

It's better, but still skewed. Try two chew.c's; they account 80% each.

Quoted 7 lines

---
Currently we only do cpu accounting to userspace based on what is actually happening precisely on each tick. The accuracy of that accounting gets progressively worse the lower HZ is. As we already keep accounting of nanosecond resolution we can accurately track user cpu, nice cpu and idle cpu if we move the accounting to update_cpu_clock with a nanosecond cpu_usage_stat entry.

That's great and much needed, but this is still probed; so what's wrong with doing it in-lined?

Quoted 2 lines

This increases overhead slightly but
avoids the problem of tick aliasing errors making accounting unreliable.

Higher scheduling accuracy may actually offset any overhead incurred, so it's well worth it; and if it's in-lined it should mean even less overhead.

Quoted 3 lines

+ /* Sanity check. It should never go backwards or ruin accounting
*/ + if (unlikely(now < p->last_ran))
+ goto out_set;

Quoted 5 lines

If sched_clock() goes backwards, why not fix it, instead of hacking around it?

Thanks!

Actually I'm going to give up this idea as not worth my effort given the sched_clock fsckage that seems to cause so much grief. If someone else wants to take up the challenge feel free to.

Andrew please drop this patch. It's still broken and I have too much on my plate to try and debug it sorry.

Signature · 1 line
-ck