From: Oleg Nesterov <oleg@tv-sign.ru>
To: Andrew Morton <akpm@osdl.org>
Cc: Shailabh Nagar <nagar@watson.ibm.com>,
Balbir Singh <balbir@in.ibm.com>, Jay Lan <jlan@sgi.com>,
linux-kernel@vger.kernel.org
Subject: [PATCH] taskstats_exit_alloc: optimize/simplify
Date: Mon, 30 Oct 2006 23:48:43 +0300 [thread overview]
Message-ID: <20061030204843.GA1135@oleg> (raw)
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>
--- STATS/kernel/taskstats.c~1_alloc 2006-10-29 18:35:40.000000000 +0300
+++ STATS/kernel/taskstats.c 2006-10-30 23:45:20.000000000 +0300
@@ -421,7 +421,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
@@ -429,19 +428,11 @@ void taskstats_exit_alloc(struct tasksta
*/
*mycpu = raw_smp_processor_id();
- *ptidstats = NULL;
- tmp = kmem_cache_zalloc(taskstats_cache, SLAB_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, SLAB_KERNEL);
}
/* Send pid data out on exit */
next reply other threads:[~2006-10-30 20:48 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-10-30 20:48 Oleg Nesterov [this message]
2006-10-31 3:04 ` [PATCH] taskstats_exit_alloc: optimize/simplify Shailabh Nagar
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20061030204843.GA1135@oleg \
--to=oleg@tv-sign.ru \
--cc=akpm@osdl.org \
--cc=balbir@in.ibm.com \
--cc=jlan@sgi.com \
--cc=linux-kernel@vger.kernel.org \
--cc=nagar@watson.ibm.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.