[PATCH] delay accounting taskstats interface send tgid once
[firefly-linux-kernel-4.4.55.git] / include / linux / taskstats_kern.h
index fc9da2e26443911d266883924da1499d73713e4a..0ae8f67af1fd29d72f396bac891a81e72ed05711 100644 (file)
@@ -19,36 +19,75 @@ enum {
 extern kmem_cache_t *taskstats_cache;
 extern struct mutex taskstats_exit_mutex;
 
-static inline void taskstats_exit_alloc(struct taskstats **ptidstats,
-                                       struct taskstats **ptgidstats)
+static inline void taskstats_exit_alloc(struct taskstats **ptidstats)
 {
        *ptidstats = kmem_cache_zalloc(taskstats_cache, SLAB_KERNEL);
-       *ptgidstats = kmem_cache_zalloc(taskstats_cache, SLAB_KERNEL);
 }
 
-static inline void taskstats_exit_free(struct taskstats *tidstats,
-                                       struct taskstats *tgidstats)
+static inline void taskstats_exit_free(struct taskstats *tidstats)
 {
        if (tidstats)
                kmem_cache_free(taskstats_cache, tidstats);
-       if (tgidstats)
-               kmem_cache_free(taskstats_cache, tgidstats);
 }
 
-extern void taskstats_exit_send(struct task_struct *, struct taskstats *,
-                               struct taskstats *);
-extern void taskstats_init_early(void);
+static inline void taskstats_tgid_init(struct signal_struct *sig)
+{
+       spin_lock_init(&sig->stats_lock);
+       sig->stats = NULL;
+}
+
+static inline void taskstats_tgid_alloc(struct signal_struct *sig)
+{
+       struct taskstats *stats;
+       unsigned long flags;
+
+       stats = kmem_cache_zalloc(taskstats_cache, SLAB_KERNEL);
+       if (!stats)
+               return;
+
+       spin_lock_irqsave(&sig->stats_lock, flags);
+       if (!sig->stats) {
+               sig->stats = stats;
+               stats = NULL;
+       }
+       spin_unlock_irqrestore(&sig->stats_lock, flags);
+
+       if (stats)
+               kmem_cache_free(taskstats_cache, stats);
+}
 
+static inline void taskstats_tgid_free(struct signal_struct *sig)
+{
+       struct taskstats *stats = NULL;
+       unsigned long flags;
+
+       spin_lock_irqsave(&sig->stats_lock, flags);
+       if (sig->stats) {
+               stats = sig->stats;
+               sig->stats = NULL;
+       }
+       spin_unlock_irqrestore(&sig->stats_lock, flags);
+       if (stats)
+               kmem_cache_free(taskstats_cache, stats);
+}
+
+extern void taskstats_exit_send(struct task_struct *, struct taskstats *, int);
+extern void taskstats_init_early(void);
+extern void taskstats_tgid_alloc(struct signal_struct *);
 #else
-static inline void taskstats_exit_alloc(struct taskstats **ptidstats,
-                                       struct taskstats **ptgidstats)
+static inline void taskstats_exit_alloc(struct taskstats **ptidstats)
 {}
-static inline void taskstats_exit_free(struct taskstats *ptidstats,
-                                       struct taskstats *ptgidstats)
+static inline void taskstats_exit_free(struct taskstats *ptidstats)
 {}
 static inline void taskstats_exit_send(struct task_struct *tsk,
-                                       struct taskstats *tidstats,
-                                       struct taskstats *tgidstats)
+                                      struct taskstats *tidstats,
+                                      int group_dead)
+{}
+static inline void taskstats_tgid_init(struct signal_struct *sig)
+{}
+static inline void taskstats_tgid_alloc(struct signal_struct *sig)
+{}
+static inline void taskstats_tgid_free(struct signal_struct *sig)
 {}
 static inline void taskstats_init_early(void)
 {}