[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>
This commit is contained in:
committed by
Linus Torvalds
parent
30f3174d1c
commit
35df17c57c
@ -59,10 +59,14 @@ static inline void delayacct_tsk_init(struct task_struct *tsk)
|
||||
__delayacct_tsk_init(tsk);
|
||||
}
|
||||
|
||||
static inline void delayacct_tsk_exit(struct task_struct *tsk)
|
||||
/* Free tsk->delays. Called from bad fork and __put_task_struct
|
||||
* where there's no risk of tsk->delays being accessed elsewhere
|
||||
*/
|
||||
static inline void delayacct_tsk_free(struct task_struct *tsk)
|
||||
{
|
||||
if (tsk->delays)
|
||||
__delayacct_tsk_exit(tsk);
|
||||
kmem_cache_free(delayacct_cache, tsk->delays);
|
||||
tsk->delays = NULL;
|
||||
}
|
||||
|
||||
static inline void delayacct_blkio_start(void)
|
||||
@ -101,7 +105,7 @@ static inline void delayacct_init(void)
|
||||
{}
|
||||
static inline void delayacct_tsk_init(struct task_struct *tsk)
|
||||
{}
|
||||
static inline void delayacct_tsk_exit(struct task_struct *tsk)
|
||||
static inline void delayacct_tsk_free(struct task_struct *tsk)
|
||||
{}
|
||||
static inline void delayacct_blkio_start(void)
|
||||
{}
|
||||
|
Reference in New Issue
Block a user