diff options
author | Shailabh Nagar <nagar@watson.ibm.com> | 2006-09-01 00:27:38 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@g5.osdl.org> | 2006-09-01 14:39:08 -0400 |
commit | 35df17c57cecb08f0120fb18926325f1093dc429 (patch) | |
tree | dc79780b3133e55dc591e35238fdb313e8e0219e /include/linux | |
parent | 30f3174d1c506db2c6d2c1dddc9c064e741d6b76 (diff) |
[PATCH] task delay accounting fixes
Cleanup allocation and freeing of tsk->delays used by delay accounting.
This solves two problems reported for delay accounting:
1. oops in __delayacct_blkio_ticks
http://www.uwsg.indiana.edu/hypermail/linux/kernel/0608.2/1844.html
Currently tsk->delays is getting freed too early in task exit which can
cause a NULL tsk->delays to get accessed via reading of /proc/<tgid>/stats.
The patch fixes this problem by freeing tsk->delays closer to when
task_struct itself is freed up. As a result, it also eliminates the use of
tsk->delays_lock which was only being used (inadequately) to safeguard
access to tsk->delays while a task was exiting.
2. Possible memory leak in kernel/delayacct.c
http://www.uwsg.indiana.edu/hypermail/linux/kernel/0608.2/1389.html
The patch cleans up tsk->delays allocations after a bad fork which was
missing earlier.
The patch has been tested to fix the problems listed above and stress
tested with rapid calls to delay accounting's taskstats command interface
(which is the other path that can access the same data, besides the /proc
interface causing the oops above).
Signed-off-by: Shailabh Nagar <nagar@watson.ibm.com>
Cc: Balbir Singh <balbir@in.ibm.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 | 10 | ||||
-rw-r--r-- | include/linux/sched.h | 1 |
2 files changed, 7 insertions, 4 deletions
diff --git a/include/linux/delayacct.h b/include/linux/delayacct.h index 11487b6e7127..561e2a77805c 100644 --- a/include/linux/delayacct.h +++ b/include/linux/delayacct.h | |||
@@ -59,10 +59,14 @@ static inline void delayacct_tsk_init(struct task_struct *tsk) | |||
59 | __delayacct_tsk_init(tsk); | 59 | __delayacct_tsk_init(tsk); |
60 | } | 60 | } |
61 | 61 | ||
62 | static inline void delayacct_tsk_exit(struct task_struct *tsk) | 62 | /* Free tsk->delays. Called from bad fork and __put_task_struct |
63 | * where there's no risk of tsk->delays being accessed elsewhere | ||
64 | */ | ||
65 | static inline void delayacct_tsk_free(struct task_struct *tsk) | ||
63 | { | 66 | { |
64 | if (tsk->delays) | 67 | if (tsk->delays) |
65 | __delayacct_tsk_exit(tsk); | 68 | kmem_cache_free(delayacct_cache, tsk->delays); |
69 | tsk->delays = NULL; | ||
66 | } | 70 | } |
67 | 71 | ||
68 | static inline void delayacct_blkio_start(void) | 72 | static inline void delayacct_blkio_start(void) |
@@ -101,7 +105,7 @@ static inline void delayacct_init(void) | |||
101 | {} | 105 | {} |
102 | static inline void delayacct_tsk_init(struct task_struct *tsk) | 106 | static inline void delayacct_tsk_init(struct task_struct *tsk) |
103 | {} | 107 | {} |
104 | static inline void delayacct_tsk_exit(struct task_struct *tsk) | 108 | static inline void delayacct_tsk_free(struct task_struct *tsk) |
105 | {} | 109 | {} |
106 | static inline void delayacct_blkio_start(void) | 110 | static inline void delayacct_blkio_start(void) |
107 | {} | 111 | {} |
diff --git a/include/linux/sched.h b/include/linux/sched.h index 6674fc1e51bf..34ed0d99b1bd 100644 --- a/include/linux/sched.h +++ b/include/linux/sched.h | |||
@@ -994,7 +994,6 @@ struct task_struct { | |||
994 | */ | 994 | */ |
995 | struct pipe_inode_info *splice_pipe; | 995 | struct pipe_inode_info *splice_pipe; |
996 | #ifdef CONFIG_TASK_DELAY_ACCT | 996 | #ifdef CONFIG_TASK_DELAY_ACCT |
997 | spinlock_t delays_lock; | ||
998 | struct task_delay_info *delays; | 997 | struct task_delay_info *delays; |
999 | #endif | 998 | #endif |
1000 | }; | 999 | }; |