]> bbs.cooldavid.org Git - net-next-2.6.git/blob - include/linux/delayacct.h
[PATCH] per-task-delay-accounting: setup
[net-next-2.6.git] / include / linux / delayacct.h
1 /* delayacct.h - per-task delay accounting
2  *
3  * Copyright (C) Shailabh Nagar, IBM Corp. 2006
4  *
5  * This program is free software;  you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License as published by
7  * the Free Software Foundation; either version 2 of the License, or
8  * (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY;  without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See
13  * the GNU General Public License for more details.
14  *
15  */
16
17 #ifndef _LINUX_DELAYACCT_H
18 #define _LINUX_DELAYACCT_H
19
20 #include <linux/sched.h>
21
22 #ifdef CONFIG_TASK_DELAY_ACCT
23
24 extern int delayacct_on;        /* Delay accounting turned on/off */
25 extern kmem_cache_t *delayacct_cache;
26 extern void delayacct_init(void);
27 extern void __delayacct_tsk_init(struct task_struct *);
28 extern void __delayacct_tsk_exit(struct task_struct *);
29
30 static inline void delayacct_set_flag(int flag)
31 {
32         if (current->delays)
33                 current->delays->flags |= flag;
34 }
35
36 static inline void delayacct_clear_flag(int flag)
37 {
38         if (current->delays)
39                 current->delays->flags &= ~flag;
40 }
41
42 static inline void delayacct_tsk_init(struct task_struct *tsk)
43 {
44         /* reinitialize in case parent's non-null pointer was dup'ed*/
45         tsk->delays = NULL;
46         if (unlikely(delayacct_on))
47                 __delayacct_tsk_init(tsk);
48 }
49
50 static inline void delayacct_tsk_exit(struct task_struct *tsk)
51 {
52         if (tsk->delays)
53                 __delayacct_tsk_exit(tsk);
54 }
55
56 #else
57 static inline void delayacct_set_flag(int flag)
58 {}
59 static inline void delayacct_clear_flag(int flag)
60 {}
61 static inline void delayacct_init(void)
62 {}
63 static inline void delayacct_tsk_init(struct task_struct *tsk)
64 {}
65 static inline void delayacct_tsk_exit(struct task_struct *tsk)
66 {}
67 #endif /* CONFIG_TASK_DELAY_ACCT */
68
69 #endif