diff options
author | Oleg Nesterov <oleg@tv-sign.ru> | 2006-12-06 20:36:50 -0800 |
---|---|---|
committer | Linus Torvalds <torvalds@woody.osdl.org> | 2006-12-07 08:39:34 -0800 |
commit | 128fb95650b3273a8dc9ba5514b6fe7db8ea30bf (patch) | |
tree | 82e8070451edbd7421b6176083658f5f2b997b58 /kernel/taskstats.c | |
parent | 38da288b8ba2b07b4e07165027e650b61d7c8ffc (diff) | |
download | linux-128fb95650b3273a8dc9ba5514b6fe7db8ea30bf.tar.gz linux-128fb95650b3273a8dc9ba5514b6fe7db8ea30bf.tar.bz2 linux-128fb95650b3273a8dc9ba5514b6fe7db8ea30bf.zip |
[PATCH] taskstats_exit_alloc: optimize/simplify
If there are no listeners, every task does unneeded kmem_cache alloc/free on
exit. We don't need listeners->sem for 'if (!list_empty())' check. Yes, we may
have a false positive, but this doesn't differ from the case when the listener
is unregistered after we drop the semaphore. So we don't need to do allocation
beforehand.
Signed-off-by: Oleg Nesterov <oleg@tv-sign.ru>
Cc: Balbir Singh <balbir@in.ibm.com>
Acked-by: Shailabh Nagar <nagar@watson.ibm.com>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'kernel/taskstats.c')
-rw-r--r-- | kernel/taskstats.c | 17 |
1 files changed, 4 insertions, 13 deletions
diff --git a/kernel/taskstats.c b/kernel/taskstats.c index f5f92014ae98..d9d7c3576238 100644 --- a/kernel/taskstats.c +++ b/kernel/taskstats.c @@ -416,7 +416,6 @@ err: void taskstats_exit_alloc(struct taskstats **ptidstats, unsigned int *mycpu) { struct listener_list *listeners; - struct taskstats *tmp; /* * This is the cpu on which the task is exiting currently and will * be the one for which the exit event is sent, even if the cpu @@ -424,19 +423,11 @@ void taskstats_exit_alloc(struct taskstats **ptidstats, unsigned int *mycpu) */ *mycpu = raw_smp_processor_id(); - *ptidstats = NULL; - tmp = kmem_cache_zalloc(taskstats_cache, GFP_KERNEL); - if (!tmp) - return; - listeners = &per_cpu(listener_array, *mycpu); - down_read(&listeners->sem); - if (!list_empty(&listeners->list)) { - *ptidstats = tmp; - tmp = NULL; - } - up_read(&listeners->sem); - kfree(tmp); + + *ptidstats = NULL; + if (!list_empty(&listeners->list)) + *ptidstats = kmem_cache_zalloc(taskstats_cache, GFP_KERNEL); } /* Send pid data out on exit */ |