aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux
diff options
context:
space:
mode:
Diffstat (limited to 'include/linux')
-rw-r--r--include/linux/taskstats.h84
-rw-r--r--include/linux/taskstats_kern.h57
2 files changed, 141 insertions, 0 deletions
diff --git a/include/linux/taskstats.h b/include/linux/taskstats.h
new file mode 100644
index 000000000000..51f62759bea9
--- /dev/null
+++ b/include/linux/taskstats.h
@@ -0,0 +1,84 @@
1/* taskstats.h - exporting per-task statistics
2 *
3 * Copyright (C) Shailabh Nagar, IBM Corp. 2006
4 * (C) Balbir Singh, IBM Corp. 2006
5 *
6 * This program is free software; you can redistribute it and/or modify it
7 * under the terms of version 2.1 of the GNU Lesser General Public License
8 * as published by the Free Software Foundation.
9 *
10 * This program is distributed in the hope that it would be useful, but
11 * WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
13 */
14
15#ifndef _LINUX_TASKSTATS_H
16#define _LINUX_TASKSTATS_H
17
18/* Format for per-task data returned to userland when
19 * - a task exits
20 * - listener requests stats for a task
21 *
22 * The struct is versioned. Newer versions should only add fields to
23 * the bottom of the struct to maintain backward compatibility.
24 *
25 *
26 * To add new fields
27 * a) bump up TASKSTATS_VERSION
28 * b) add comment indicating new version number at end of struct
29 * c) add new fields after version comment; maintain 64-bit alignment
30 */
31
32#define TASKSTATS_VERSION 1
33
34struct taskstats {
35
36 /* Version 1 */
37 __u64 version;
38};
39
40
41#define TASKSTATS_LISTEN_GROUP 0x1
42
43/*
44 * Commands sent from userspace
45 * Not versioned. New commands should only be inserted at the enum's end
46 * prior to __TASKSTATS_CMD_MAX
47 */
48
49enum {
50 TASKSTATS_CMD_UNSPEC = 0, /* Reserved */
51 TASKSTATS_CMD_GET, /* user->kernel request/get-response */
52 TASKSTATS_CMD_NEW, /* kernel->user event */
53 __TASKSTATS_CMD_MAX,
54};
55
56#define TASKSTATS_CMD_MAX (__TASKSTATS_CMD_MAX - 1)
57
58enum {
59 TASKSTATS_TYPE_UNSPEC = 0, /* Reserved */
60 TASKSTATS_TYPE_PID, /* Process id */
61 TASKSTATS_TYPE_TGID, /* Thread group id */
62 TASKSTATS_TYPE_STATS, /* taskstats structure */
63 TASKSTATS_TYPE_AGGR_PID, /* contains pid + stats */
64 TASKSTATS_TYPE_AGGR_TGID, /* contains tgid + stats */
65 __TASKSTATS_TYPE_MAX,
66};
67
68#define TASKSTATS_TYPE_MAX (__TASKSTATS_TYPE_MAX - 1)
69
70enum {
71 TASKSTATS_CMD_ATTR_UNSPEC = 0,
72 TASKSTATS_CMD_ATTR_PID,
73 TASKSTATS_CMD_ATTR_TGID,
74 __TASKSTATS_CMD_ATTR_MAX,
75};
76
77#define TASKSTATS_CMD_ATTR_MAX (__TASKSTATS_CMD_ATTR_MAX - 1)
78
79/* NETLINK_GENERIC related info */
80
81#define TASKSTATS_GENL_NAME "TASKSTATS"
82#define TASKSTATS_GENL_VERSION 0x1
83
84#endif /* _LINUX_TASKSTATS_H */
diff --git a/include/linux/taskstats_kern.h b/include/linux/taskstats_kern.h
new file mode 100644
index 000000000000..bd0ecb969c26
--- /dev/null
+++ b/include/linux/taskstats_kern.h
@@ -0,0 +1,57 @@
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
13enum {
14 TASKSTATS_MSG_UNICAST, /* send data only to requester */
15 TASKSTATS_MSG_MULTICAST, /* send data to a group */
16};
17
18#ifdef CONFIG_TASKSTATS
19extern kmem_cache_t *taskstats_cache;
20
21static 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
28static 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
37extern void taskstats_exit_send(struct task_struct *, struct taskstats *,
38 struct taskstats *);
39extern void taskstats_init_early(void);
40
41#else
42static inline void taskstats_exit_alloc(struct taskstats **ptidstats,
43 struct taskstats **ptgidstats)
44{}
45static inline void taskstats_exit_free(struct taskstats *ptidstats,
46 struct taskstats *ptgidstats)
47{}
48static inline void taskstats_exit_send(struct task_struct *tsk,
49 struct taskstats *tidstats,
50 struct taskstats *tgidstats)
51{}
52static inline void taskstats_init_early(void)
53{}
54#endif /* CONFIG_TASKSTATS */
55
56#endif
57