hc
2023-12-09 b22da3d8526a935aa31e086e63f60ff3246cb61c
kernel/include/linux/pid.h
....@@ -3,7 +3,9 @@
33 #define _LINUX_PID_H
44
55 #include <linux/rculist.h>
6
+#include <linux/atomic.h>
67 #include <linux/wait.h>
8
+#include <linux/refcount.h>
79
810 enum pid_type
911 {
....@@ -57,10 +59,12 @@
5759
5860 struct pid
5961 {
60
- atomic_t count;
62
+ refcount_t count;
6163 unsigned int level;
64
+ spinlock_t lock;
6265 /* lists of tasks that use this pid */
6366 struct hlist_head tasks[PIDTYPE_MAX];
67
+ struct hlist_head inodes;
6468 /* wait queue for pidfd notifications */
6569 wait_queue_head_t wait_pidfd;
6670 struct rcu_head rcu;
....@@ -71,15 +75,24 @@
7175
7276 extern const struct file_operations pidfd_fops;
7377
78
+struct file;
79
+
80
+extern struct pid *pidfd_pid(const struct file *file);
81
+struct pid *pidfd_get_pid(unsigned int fd, unsigned int *flags);
82
+
7483 static inline struct pid *get_pid(struct pid *pid)
7584 {
7685 if (pid)
77
- atomic_inc(&pid->count);
86
+ refcount_inc(&pid->count);
7887 return pid;
7988 }
8089
8190 extern void put_pid(struct pid *pid);
8291 extern struct task_struct *pid_task(struct pid *pid, enum pid_type);
92
+static inline bool pid_has_task(struct pid *pid, enum pid_type type)
93
+{
94
+ return !hlist_empty(&pid->tasks[type]);
95
+}
8396 extern struct task_struct *get_pid_task(struct pid *pid, enum pid_type);
8497
8598 extern struct pid *get_task_pid(struct task_struct *task, enum pid_type type);
....@@ -91,11 +104,15 @@
91104 extern void detach_pid(struct task_struct *task, enum pid_type);
92105 extern void change_pid(struct task_struct *task, enum pid_type,
93106 struct pid *pid);
107
+extern void exchange_tids(struct task_struct *task, struct task_struct *old);
94108 extern void transfer_pid(struct task_struct *old, struct task_struct *new,
95109 enum pid_type);
96110
97111 struct pid_namespace;
98112 extern struct pid_namespace init_pid_ns;
113
+
114
+extern int pid_max;
115
+extern int pid_max_min, pid_max_max;
99116
100117 /*
101118 * look up a PID in the hash table. Must be called with the tasklist_lock
....@@ -114,9 +131,9 @@
114131 */
115132 extern struct pid *find_get_pid(int nr);
116133 extern struct pid *find_ge_pid(int nr, struct pid_namespace *);
117
-int next_pidmap(struct pid_namespace *pid_ns, unsigned int last);
118134
119
-extern struct pid *alloc_pid(struct pid_namespace *ns);
135
+extern struct pid *alloc_pid(struct pid_namespace *ns, pid_t *set_tid,
136
+ size_t set_tid_size);
120137 extern void free_pid(struct pid *pid);
121138 extern void disable_pid_allocation(struct pid_namespace *ns);
122139