aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux/taskstats_kern.h
diff options
context:
space:
mode:
authorShailabh Nagar <nagar@watson.ibm.com>2006-07-14 03:24:46 -0400
committerLinus Torvalds <torvalds@g5.osdl.org>2006-07-15 00:53:57 -0400
commitc8924363da07aec213e5d359f23eeae1fff91951 (patch)
treebef390d55719cf3f4b0d02c7efe03dd9ebc7321a /include/linux/taskstats_kern.h
parent9e06d3f9f6b14f6e3120923ed215032726246c98 (diff)
[PATCH] per-task delay accounting: avoid send without listeners
Don't send taskstats (per-pid or per-tgid) on thread exit when no one is listening for such data. Currently the taskstats interface allocates a structure, fills it in and calls netlink to send out per-pid and per-tgid stats regardless of whether a userspace listener for the data exists (netlink layer would check for that and avoid the multicast). As a result of this patch, the check for the no-listener case is performed early, avoiding the redundant allocation and filling up of the taskstats structures. Signed-off-by: Balbir Singh <balbir@in.ibm.com> Signed-off-by: Shailabh Nagar <nagar@watson.ibm.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/taskstats_kern.h')
-rw-r--r--include/linux/taskstats_kern.h13
1 files changed, 12 insertions, 1 deletions
diff --git a/include/linux/taskstats_kern.h b/include/linux/taskstats_kern.h
index 0ae8f67af1fd..2b6adec3a2e4 100644
--- a/include/linux/taskstats_kern.h
+++ b/include/linux/taskstats_kern.h
@@ -9,6 +9,7 @@
9 9
10#include <linux/taskstats.h> 10#include <linux/taskstats.h>
11#include <linux/sched.h> 11#include <linux/sched.h>
12#include <net/genetlink.h>
12 13
13enum { 14enum {
14 TASKSTATS_MSG_UNICAST, /* send data only to requester */ 15 TASKSTATS_MSG_UNICAST, /* send data only to requester */
@@ -19,9 +20,19 @@ enum {
19extern kmem_cache_t *taskstats_cache; 20extern kmem_cache_t *taskstats_cache;
20extern struct mutex taskstats_exit_mutex; 21extern struct mutex taskstats_exit_mutex;
21 22
23static inline int taskstats_has_listeners(void)
24{
25 if (!genl_sock)
26 return 0;
27 return netlink_has_listeners(genl_sock, TASKSTATS_LISTEN_GROUP);
28}
29
30
22static inline void taskstats_exit_alloc(struct taskstats **ptidstats) 31static inline void taskstats_exit_alloc(struct taskstats **ptidstats)
23{ 32{
24 *ptidstats = kmem_cache_zalloc(taskstats_cache, SLAB_KERNEL); 33 *ptidstats = NULL;
34 if (taskstats_has_listeners())
35 *ptidstats = kmem_cache_zalloc(taskstats_cache, SLAB_KERNEL);
25} 36}
26 37
27static inline void taskstats_exit_free(struct taskstats *tidstats) 38static inline void taskstats_exit_free(struct taskstats *tidstats)