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 @@ #include <linux/taskstats.h> #include <linux/sched.h> +#include <net/genetlink.h> enum { TASKSTATS_MSG_UNICAST, /* send data only to requester */ @@ -19,9 +20,19 @@ enum { extern kmem_cache_t *taskstats_cache; extern struct mutex taskstats_exit_mutex; +static inline int taskstats_has_listeners(void) +{ + if (!genl_sock) + return 0; + return netlink_has_listeners(genl_sock, TASKSTATS_LISTEN_GROUP); +} + + static inline void taskstats_exit_alloc(struct taskstats **ptidstats) { - *ptidstats = kmem_cache_zalloc(taskstats_cache, SLAB_KERNEL); + *ptidstats = NULL; + if (taskstats_has_listeners()) + *ptidstats = kmem_cache_zalloc(taskstats_cache, SLAB_KERNEL); } static inline void taskstats_exit_free(struct taskstats *tidstats) |