xref: /linux-6.15/include/linux/taskstats_kern.h (revision c757249a)
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>
12 
13 enum {
14 	TASKSTATS_MSG_UNICAST,		/* send data only to requester */
15 	TASKSTATS_MSG_MULTICAST,	/* send data to a group */
16 };
17 
18 #ifdef CONFIG_TASKSTATS
19 extern kmem_cache_t *taskstats_cache;
20 
21 static inline void taskstats_exit_alloc(struct taskstats **ptidstats,
22 					struct taskstats **ptgidstats)
23 {
24 	*ptidstats = kmem_cache_zalloc(taskstats_cache, SLAB_KERNEL);
25 	*ptgidstats = kmem_cache_zalloc(taskstats_cache, SLAB_KERNEL);
26 }
27 
28 static inline void taskstats_exit_free(struct taskstats *tidstats,
29 					struct taskstats *tgidstats)
30 {
31 	if (tidstats)
32 		kmem_cache_free(taskstats_cache, tidstats);
33 	if (tgidstats)
34 		kmem_cache_free(taskstats_cache, tgidstats);
35 }
36 
37 extern void taskstats_exit_send(struct task_struct *, struct taskstats *,
38 				struct taskstats *);
39 extern void taskstats_init_early(void);
40 
41 #else
42 static inline void taskstats_exit_alloc(struct taskstats **ptidstats,
43 					struct taskstats **ptgidstats)
44 {}
45 static inline void taskstats_exit_free(struct taskstats *ptidstats,
46 					struct taskstats *ptgidstats)
47 {}
48 static inline void taskstats_exit_send(struct task_struct *tsk,
49 					struct taskstats *tidstats,
50 					struct taskstats *tgidstats)
51 {}
52 static inline void taskstats_init_early(void)
53 {}
54 #endif /* CONFIG_TASKSTATS */
55 
56 #endif
57 
58