diff options
author | Shailabh Nagar <nagar@watson.ibm.com> | 2006-07-14 03:24:36 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@g5.osdl.org> | 2006-07-15 00:53:56 -0400 |
commit | ca74e92b4698276b6696f15a801759f50944f387 (patch) | |
tree | 26f0de66d8207608e07ee22389bfc173e773c0c2 /include/linux | |
parent | e8f4d97e1b58b50ad6449bb2d35e6632c0236abd (diff) |
[PATCH] per-task-delay-accounting: setup
Initialization code related to collection of per-task "delay" statistics which
measure how long it had to wait for cpu, sync block io, swapping etc. The
collection of statistics and the interface are in other patches. This patch
sets up the data structures and allows the statistics collection to be
disabled through a kernel boot parameter.
Signed-off-by: Shailabh Nagar <nagar@watson.ibm.com>
Signed-off-by: Balbir Singh <balbir@in.ibm.com>
Cc: Jes Sorensen <jes@sgi.com>
Cc: Peter Chubb <peterc@gelato.unsw.edu.au>
Cc: Erich Focht <efocht@ess.nec.de>
Cc: Levent Serinol <lserinol@gmail.com>
Cc: Jay Lan <jlan@engr.sgi.com>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'include/linux')
-rw-r--r-- | include/linux/delayacct.h | 69 | ||||
-rw-r--r-- | include/linux/sched.h | 20 | ||||
-rw-r--r-- | include/linux/time.h | 12 |
3 files changed, 101 insertions, 0 deletions
diff --git a/include/linux/delayacct.h b/include/linux/delayacct.h new file mode 100644 index 000000000000..9572cfa1f129 --- /dev/null +++ b/include/linux/delayacct.h | |||
@@ -0,0 +1,69 @@ | |||
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 | ||
diff --git a/include/linux/sched.h b/include/linux/sched.h index 1c876e27ff93..7a54e62763c5 100644 --- a/include/linux/sched.h +++ b/include/linux/sched.h | |||
@@ -552,6 +552,23 @@ struct sched_info { | |||
552 | extern struct file_operations proc_schedstat_operations; | 552 | extern struct file_operations proc_schedstat_operations; |
553 | #endif | 553 | #endif |
554 | 554 | ||
555 | #ifdef CONFIG_TASK_DELAY_ACCT | ||
556 | struct task_delay_info { | ||
557 | spinlock_t lock; | ||
558 | unsigned int flags; /* Private per-task flags */ | ||
559 | |||
560 | /* For each stat XXX, add following, aligned appropriately | ||
561 | * | ||
562 | * struct timespec XXX_start, XXX_end; | ||
563 | * u64 XXX_delay; | ||
564 | * u32 XXX_count; | ||
565 | * | ||
566 | * Atomicity of updates to XXX_delay, XXX_count protected by | ||
567 | * single lock above (split into XXX_lock if contention is an issue). | ||
568 | */ | ||
569 | }; | ||
570 | #endif | ||
571 | |||
555 | enum idle_type | 572 | enum idle_type |
556 | { | 573 | { |
557 | SCHED_IDLE, | 574 | SCHED_IDLE, |
@@ -945,6 +962,9 @@ struct task_struct { | |||
945 | * cache last used pipe for splice | 962 | * cache last used pipe for splice |
946 | */ | 963 | */ |
947 | struct pipe_inode_info *splice_pipe; | 964 | struct pipe_inode_info *splice_pipe; |
965 | #ifdef CONFIG_TASK_DELAY_ACCT | ||
966 | struct task_delay_info *delays; | ||
967 | #endif | ||
948 | }; | 968 | }; |
949 | 969 | ||
950 | static inline pid_t process_group(struct task_struct *tsk) | 970 | static inline pid_t process_group(struct task_struct *tsk) |
diff --git a/include/linux/time.h b/include/linux/time.h index c05f8bb9a323..a5b739967b74 100644 --- a/include/linux/time.h +++ b/include/linux/time.h | |||
@@ -71,6 +71,18 @@ extern unsigned long mktime(const unsigned int year, const unsigned int mon, | |||
71 | extern void set_normalized_timespec(struct timespec *ts, time_t sec, long nsec); | 71 | extern void set_normalized_timespec(struct timespec *ts, time_t sec, long nsec); |
72 | 72 | ||
73 | /* | 73 | /* |
74 | * sub = lhs - rhs, in normalized form | ||
75 | */ | ||
76 | static inline struct timespec timespec_sub(struct timespec lhs, | ||
77 | struct timespec rhs) | ||
78 | { | ||
79 | struct timespec ts_delta; | ||
80 | set_normalized_timespec(&ts_delta, lhs.tv_sec - rhs.tv_sec, | ||
81 | lhs.tv_nsec - rhs.tv_nsec); | ||
82 | return ts_delta; | ||
83 | } | ||
84 | |||
85 | /* | ||
74 | * Returns true if the timespec is norm, false if denorm: | 86 | * Returns true if the timespec is norm, false if denorm: |
75 | */ | 87 | */ |
76 | #define timespec_valid(ts) \ | 88 | #define timespec_valid(ts) \ |