diff options
author | Frederic Weisbecker <fweisbec@gmail.com> | 2012-10-05 22:07:19 -0400 |
---|---|---|
committer | Frederic Weisbecker <fweisbec@gmail.com> | 2012-10-29 16:31:32 -0400 |
commit | fa5058f3b63153e0147ef65bcdb3a4ee63581346 (patch) | |
tree | d9d88284e22953fc8a175b334f1ead0c455e4cd1 /include/linux/vtime.h | |
parent | b080935c8638e08134629d0a9ebdf35669bec14d (diff) |
cputime: Specialize irq vtime hooks
With CONFIG_VIRT_CPU_ACCOUNTING, when vtime_account()
is called in irq entry/exit, we perform a check on the
context: if we are interrupting the idle task we
account the pending cputime to idle, otherwise account
to system time or its sub-areas: tsk->stime, hardirq time,
softirq time, ...
However this check for idle only concerns the hardirq entry
and softirq entry:
* Hardirq may directly interrupt the idle task, in which case
we need to flush the pending CPU time to idle.
* The idle task may be directly interrupted by a softirq if
it calls local_bh_enable(). There is probably no such call
in any idle task but we need to cover every case. Ksoftirqd
is not concerned because the idle time is flushed on context
switch and softirq in the end of hardirq have the idle time
already flushed from the hardirq entry.
In the other cases we always account to system/irq time:
* On hardirq exit we account the time to hardirq time.
* On softirq exit we account the time to softirq time.
To optimize this and avoid the indirect call to vtime_account()
and the checks it performs, specialize the vtime irq APIs and
only perform the check on irq entry. Irq exit can directly call
vtime_account_system().
CONFIG_IRQ_TIME_ACCOUNTING behaviour doesn't change and directly
maps to its own vtime_account() implementation. One may want
to take benefits from the new APIs to optimize irq time accounting
as well in the future.
Signed-off-by: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Ingo Molnar <mingo@kernel.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Steven Rostedt <rostedt@goodmis.org>
Cc: Paul Gortmaker <paul.gortmaker@windriver.com>
Diffstat (limited to 'include/linux/vtime.h')
-rw-r--r-- | include/linux/vtime.h | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/include/linux/vtime.h b/include/linux/vtime.h index b9fc4f9ab470..c35c02223da8 100644 --- a/include/linux/vtime.h +++ b/include/linux/vtime.h | |||
@@ -21,4 +21,29 @@ static inline void vtime_account(struct task_struct *tsk) | |||
21 | extern void vtime_account(struct task_struct *tsk); | 21 | extern void vtime_account(struct task_struct *tsk); |
22 | #endif | 22 | #endif |
23 | 23 | ||
24 | static inline void vtime_account_irq_enter(struct task_struct *tsk) | ||
25 | { | ||
26 | /* | ||
27 | * Hardirq can interrupt idle task anytime. So we need vtime_account() | ||
28 | * that performs the idle check in CONFIG_VIRT_CPU_ACCOUNTING. | ||
29 | * Softirq can also interrupt idle task directly if it calls | ||
30 | * local_bh_enable(). Such case probably don't exist but we never know. | ||
31 | * Ksoftirqd is not concerned because idle time is flushed on context | ||
32 | * switch. Softirqs in the end of hardirqs are also not a problem because | ||
33 | * the idle time is flushed on hardirq time already. | ||
34 | */ | ||
35 | vtime_account(tsk); | ||
36 | } | ||
37 | |||
38 | static inline void vtime_account_irq_exit(struct task_struct *tsk) | ||
39 | { | ||
40 | #ifdef CONFIG_VIRT_CPU_ACCOUNTING | ||
41 | /* On hard|softirq exit we always account to hard|softirq cputime */ | ||
42 | __vtime_account_system(tsk); | ||
43 | #endif | ||
44 | #ifdef CONFIG_IRQ_TIME_ACCOUNTING | ||
45 | vtime_account(tsk); | ||
46 | #endif | ||
47 | } | ||
48 | |||
24 | #endif /* _LINUX_KERNEL_VTIME_H */ | 49 | #endif /* _LINUX_KERNEL_VTIME_H */ |