diff options
Diffstat (limited to 'include/linux/taskstats_kern.h')
-rw-r--r-- | include/linux/taskstats_kern.h | 13 |
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 | ||
13 | enum { | 14 | enum { |
14 | TASKSTATS_MSG_UNICAST, /* send data only to requester */ | 15 | TASKSTATS_MSG_UNICAST, /* send data only to requester */ |
@@ -19,9 +20,19 @@ enum { | |||
19 | extern kmem_cache_t *taskstats_cache; | 20 | extern kmem_cache_t *taskstats_cache; |
20 | extern struct mutex taskstats_exit_mutex; | 21 | extern struct mutex taskstats_exit_mutex; |
21 | 22 | ||
23 | static 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 | |||
22 | static inline void taskstats_exit_alloc(struct taskstats **ptidstats) | 31 | static 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 | ||
27 | static inline void taskstats_exit_free(struct taskstats *tidstats) | 38 | static inline void taskstats_exit_free(struct taskstats *tidstats) |