[PATCH] per-task-delay-accounting: setup
[GitHub/mt8127/android_kernel_alcatel_ttab.git] / include / linux / delayacct.h
CommitLineData
ca74e92b
SN
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
24extern int delayacct_on; /* Delay accounting turned on/off */
25extern kmem_cache_t *delayacct_cache;
26extern void delayacct_init(void);
27extern void __delayacct_tsk_init(struct task_struct *);
28extern void __delayacct_tsk_exit(struct task_struct *);
29
30static inline void delayacct_set_flag(int flag)
31{
32 if (current->delays)
33 current->delays->flags |= flag;
34}
35
36static inline void delayacct_clear_flag(int flag)
37{
38 if (current->delays)
39 current->delays->flags &= ~flag;
40}
41
42static 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
50static inline void delayacct_tsk_exit(struct task_struct *tsk)
51{
52 if (tsk->delays)
53 __delayacct_tsk_exit(tsk);
54}
55
56#else
57static inline void delayacct_set_flag(int flag)
58{}
59static inline void delayacct_clear_flag(int flag)
60{}
61static inline void delayacct_init(void)
62{}
63static inline void delayacct_tsk_init(struct task_struct *tsk)
64{}
65static inline void delayacct_tsk_exit(struct task_struct *tsk)
66{}
67#endif /* CONFIG_TASK_DELAY_ACCT */
68
69#endif