[PATCH] taskstats_exit_alloc: optimize/simplify
[deliverable/linux.git] / include / linux / taskstats_kern.h
CommitLineData
c757249a
SN
1/* taskstats_kern.h - kernel header for per-task statistics interface
2 *
3 * Copyright (C) Shailabh Nagar, IBM Corp. 2006
4 * (C) Balbir Singh, IBM Corp. 2006
5 */
6
7#ifndef _LINUX_TASKSTATS_KERN_H
8#define _LINUX_TASKSTATS_KERN_H
9
10#include <linux/taskstats.h>
11#include <linux/sched.h>
c8924363 12#include <net/genetlink.h>
c757249a 13
c757249a 14#ifdef CONFIG_TASKSTATS
e18b890b 15extern struct kmem_cache *taskstats_cache;
6f44993f 16extern struct mutex taskstats_exit_mutex;
c757249a 17
ad4ecbcb 18static inline void taskstats_exit_free(struct taskstats *tidstats)
c757249a
SN
19{
20 if (tidstats)
21 kmem_cache_free(taskstats_cache, tidstats);
c757249a
SN
22}
23
ad4ecbcb
SN
24static inline void taskstats_tgid_init(struct signal_struct *sig)
25{
ad4ecbcb
SN
26 sig->stats = NULL;
27}
28
b8534d7b 29static inline void taskstats_tgid_alloc(struct task_struct *tsk)
ad4ecbcb 30{
b8534d7b 31 struct signal_struct *sig = tsk->signal;
ad4ecbcb 32 struct taskstats *stats;
ad4ecbcb 33
17b02695
ON
34 if (sig->stats != NULL)
35 return;
36
b8534d7b 37 /* No problem if kmem_cache_zalloc() fails */
e94b1766 38 stats = kmem_cache_zalloc(taskstats_cache, GFP_KERNEL);
ad4ecbcb 39
b8534d7b 40 spin_lock_irq(&tsk->sighand->siglock);
ad4ecbcb
SN
41 if (!sig->stats) {
42 sig->stats = stats;
43 stats = NULL;
44 }
b8534d7b 45 spin_unlock_irq(&tsk->sighand->siglock);
ad4ecbcb
SN
46
47 if (stats)
48 kmem_cache_free(taskstats_cache, stats);
49}
c757249a 50
ad4ecbcb
SN
51static inline void taskstats_tgid_free(struct signal_struct *sig)
52{
093a8e8a
ON
53 if (sig->stats)
54 kmem_cache_free(taskstats_cache, sig->stats);
ad4ecbcb
SN
55}
56
f9fd8914
SN
57extern void taskstats_exit_alloc(struct taskstats **, unsigned int *);
58extern void taskstats_exit_send(struct task_struct *, struct taskstats *, int, unsigned int);
ad4ecbcb 59extern void taskstats_init_early(void);
c757249a 60#else
f9fd8914 61static inline void taskstats_exit_alloc(struct taskstats **ptidstats, unsigned int *mycpu)
c757249a 62{}
ad4ecbcb 63static inline void taskstats_exit_free(struct taskstats *ptidstats)
c757249a
SN
64{}
65static inline void taskstats_exit_send(struct task_struct *tsk,
ad4ecbcb 66 struct taskstats *tidstats,
f9fd8914 67 int group_dead, unsigned int cpu)
ad4ecbcb
SN
68{}
69static inline void taskstats_tgid_init(struct signal_struct *sig)
70{}
b8534d7b 71static inline void taskstats_tgid_alloc(struct task_struct *tsk)
ad4ecbcb
SN
72{}
73static inline void taskstats_tgid_free(struct signal_struct *sig)
c757249a
SN
74{}
75static inline void taskstats_init_early(void)
76{}
77#endif /* CONFIG_TASKSTATS */
78
79#endif
80
This page took 0.099426 seconds and 5 git commands to generate.