diff options
Diffstat (limited to 'include/linux/taskstats_kern.h')
| -rw-r--r-- | include/linux/taskstats_kern.h | 71 |
1 files changed, 55 insertions, 16 deletions
diff --git a/include/linux/taskstats_kern.h b/include/linux/taskstats_kern.h index fc9da2e26443..0ae8f67af1fd 100644 --- a/include/linux/taskstats_kern.h +++ b/include/linux/taskstats_kern.h | |||
| @@ -19,36 +19,75 @@ enum { | |||
| 19 | extern kmem_cache_t *taskstats_cache; | 19 | extern kmem_cache_t *taskstats_cache; |
| 20 | extern struct mutex taskstats_exit_mutex; | 20 | extern struct mutex taskstats_exit_mutex; |
| 21 | 21 | ||
| 22 | static inline void taskstats_exit_alloc(struct taskstats **ptidstats, | 22 | static inline void taskstats_exit_alloc(struct taskstats **ptidstats) |
| 23 | struct taskstats **ptgidstats) | ||
| 24 | { | 23 | { |
| 25 | *ptidstats = kmem_cache_zalloc(taskstats_cache, SLAB_KERNEL); | 24 | *ptidstats = kmem_cache_zalloc(taskstats_cache, SLAB_KERNEL); |
| 26 | *ptgidstats = kmem_cache_zalloc(taskstats_cache, SLAB_KERNEL); | ||
| 27 | } | 25 | } |
| 28 | 26 | ||
| 29 | static inline void taskstats_exit_free(struct taskstats *tidstats, | 27 | static inline void taskstats_exit_free(struct taskstats *tidstats) |
| 30 | struct taskstats *tgidstats) | ||
| 31 | { | 28 | { |
| 32 | if (tidstats) | 29 | if (tidstats) |
| 33 | kmem_cache_free(taskstats_cache, tidstats); | 30 | kmem_cache_free(taskstats_cache, tidstats); |
| 34 | if (tgidstats) | ||
| 35 | kmem_cache_free(taskstats_cache, tgidstats); | ||
| 36 | } | 31 | } |
| 37 | 32 | ||
| 38 | extern void taskstats_exit_send(struct task_struct *, struct taskstats *, | 33 | static inline void taskstats_tgid_init(struct signal_struct *sig) |
| 39 | struct taskstats *); | 34 | { |
| 40 | extern void taskstats_init_early(void); | 35 | spin_lock_init(&sig->stats_lock); |
| 36 | sig->stats = NULL; | ||
| 37 | } | ||
| 38 | |||
| 39 | static inline void taskstats_tgid_alloc(struct signal_struct *sig) | ||
| 40 | { | ||
| 41 | struct taskstats *stats; | ||
| 42 | unsigned long flags; | ||
| 43 | |||
| 44 | stats = kmem_cache_zalloc(taskstats_cache, SLAB_KERNEL); | ||
| 45 | if (!stats) | ||
| 46 | return; | ||
| 47 | |||
| 48 | spin_lock_irqsave(&sig->stats_lock, flags); | ||
| 49 | if (!sig->stats) { | ||
| 50 | sig->stats = stats; | ||
| 51 | stats = NULL; | ||
| 52 | } | ||
| 53 | spin_unlock_irqrestore(&sig->stats_lock, flags); | ||
| 54 | |||
| 55 | if (stats) | ||
| 56 | kmem_cache_free(taskstats_cache, stats); | ||
| 57 | } | ||
| 41 | 58 | ||
| 59 | static inline void taskstats_tgid_free(struct signal_struct *sig) | ||
| 60 | { | ||
| 61 | struct taskstats *stats = NULL; | ||
| 62 | unsigned long flags; | ||
| 63 | |||
| 64 | spin_lock_irqsave(&sig->stats_lock, flags); | ||
| 65 | if (sig->stats) { | ||
| 66 | stats = sig->stats; | ||
| 67 | sig->stats = NULL; | ||
| 68 | } | ||
| 69 | spin_unlock_irqrestore(&sig->stats_lock, flags); | ||
| 70 | if (stats) | ||
| 71 | kmem_cache_free(taskstats_cache, stats); | ||
| 72 | } | ||
| 73 | |||
| 74 | extern void taskstats_exit_send(struct task_struct *, struct taskstats *, int); | ||
| 75 | extern void taskstats_init_early(void); | ||
| 76 | extern void taskstats_tgid_alloc(struct signal_struct *); | ||
| 42 | #else | 77 | #else |
| 43 | static inline void taskstats_exit_alloc(struct taskstats **ptidstats, | 78 | static inline void taskstats_exit_alloc(struct taskstats **ptidstats) |
| 44 | struct taskstats **ptgidstats) | ||
| 45 | {} | 79 | {} |
| 46 | static inline void taskstats_exit_free(struct taskstats *ptidstats, | 80 | static inline void taskstats_exit_free(struct taskstats *ptidstats) |
| 47 | struct taskstats *ptgidstats) | ||
| 48 | {} | 81 | {} |
| 49 | static inline void taskstats_exit_send(struct task_struct *tsk, | 82 | static inline void taskstats_exit_send(struct task_struct *tsk, |
| 50 | struct taskstats *tidstats, | 83 | struct taskstats *tidstats, |
| 51 | struct taskstats *tgidstats) | 84 | int group_dead) |
| 85 | {} | ||
| 86 | static inline void taskstats_tgid_init(struct signal_struct *sig) | ||
| 87 | {} | ||
| 88 | static inline void taskstats_tgid_alloc(struct signal_struct *sig) | ||
| 89 | {} | ||
| 90 | static inline void taskstats_tgid_free(struct signal_struct *sig) | ||
| 52 | {} | 91 | {} |
| 53 | static inline void taskstats_init_early(void) | 92 | static inline void taskstats_init_early(void) |
| 54 | {} | 93 | {} |
