History

[PATCH] idle cputime accounting

The cpu time spent by the idle process actually doing something is currently accounted as idle time. This is plain wrong, the architectures that support VIRT_CPU_ACCOUNTING=y can do better: distinguish between the time spent doing nothing and the time spent by idle doing work. The first is accounted with account_idle_time and the second with account_system_time. The architectures that use the account_xxx_time interface directly and not the account_xxx_ticks interface now need to do the check for the idle process in their arch code. In particular to improve the system vs true idle time accounting the arch code needs to measure the true idle time instead of just testing for the idle process. To improve the tick based accounting as well we would need an architecture primitive that can tell us if the pt_regs of the interrupted context points to the magic instruction that halts the cpu. In addition idle time is no more added to the stime of the idle process. This field now contains the system time of the idle process as it should be. On systems without VIRT_CPU_ACCOUNTING this will always be zero as every tick that occurs while idle is running will be accounted as idle time. This patch contains the necessary common code changes to be able to distinguish idle system time and true idle time. The architectures with support for VIRT_CPU_ACCOUNTING need some changes to exploit this.

Martin Schwidefsky committed 17 years ago

Commit 79741dd1 parent 457533a10 files · +114 −54Browse files

Showing the changes to kernel/timer.c (1 of 10 files). Show all

Unified · Split

kernel/timer.c+0−13
@@ -1018,19 +1018,6 @@ unsigned long get_next_timer_interrupt(unsigned long now) · 1017 unmodified lines
10181018 }
10191019 #endif
10201020
1021−#ifndef CONFIG_VIRT_CPU_ACCOUNTING
1022−void account_process_tick(struct task_struct *p, int user_tick)
1023−{
1024− cputime_t one_jiffy = jiffies_to_cputime(1);
1025−
1026− if (user_tick)
1027− account_user_time(p, one_jiffy, cputime_to_scaled(one_jiffy));
1028− else
1029− account_system_time(p, HARDIRQ_OFFSET, one_jiffy,
1030− cputime_to_scaled(one_jiffy));
1031−}
1032−#endif
1033−
10341021 /*
10351022 * Called from the timer interrupt handler to charge one tick to the current
10361023 * process. user_tick is 1 if the tick is user time, 0 for system.

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t