hc
2023-12-09 b22da3d8526a935aa31e086e63f60ff3246cb61c
kernel/include/linux/pid.h
....@@ -3,8 +3,9 @@
33 #define _LINUX_PID_H
44
55 #include <linux/rculist.h>
6
-#include <linux/wait.h>
76 #include <linux/atomic.h>
7
+#include <linux/wait.h>
8
+#include <linux/refcount.h>
89
910 enum pid_type
1011 {
....@@ -58,10 +59,12 @@
5859
5960 struct pid
6061 {
61
- atomic_t count;
62
+ refcount_t count;
6263 unsigned int level;
64
+ spinlock_t lock;
6365 /* lists of tasks that use this pid */
6466 struct hlist_head tasks[PIDTYPE_MAX];
67
+ struct hlist_head inodes;
6568 /* wait queue for pidfd notifications */
6669 wait_queue_head_t wait_pidfd;
6770 struct rcu_head rcu;
....@@ -72,15 +75,24 @@
7275
7376 extern const struct file_operations pidfd_fops;
7477
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
+
7583 static inline struct pid *get_pid(struct pid *pid)
7684 {
7785 if (pid)
78
- atomic_inc(&pid->count);
86
+ refcount_inc(&pid->count);
7987 return pid;
8088 }
8189
8290 extern void put_pid(struct pid *pid);
8391 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
+}
8496 extern struct task_struct *get_pid_task(struct pid *pid, enum pid_type);
8597
8698 extern struct pid *get_task_pid(struct task_struct *task, enum pid_type type);
....@@ -92,11 +104,15 @@
92104 extern void detach_pid(struct task_struct *task, enum pid_type);
93105 extern void change_pid(struct task_struct *task, enum pid_type,
94106 struct pid *pid);
107
+extern void exchange_tids(struct task_struct *task, struct task_struct *old);
95108 extern void transfer_pid(struct task_struct *old, struct task_struct *new,
96109 enum pid_type);
97110
98111 struct pid_namespace;
99112 extern struct pid_namespace init_pid_ns;
113
+
114
+extern int pid_max;
115
+extern int pid_max_min, pid_max_max;
100116
101117 /*
102118 * look up a PID in the hash table. Must be called with the tasklist_lock
....@@ -115,9 +131,9 @@
115131 */
116132 extern struct pid *find_get_pid(int nr);
117133 extern struct pid *find_ge_pid(int nr, struct pid_namespace *);
118
-int next_pidmap(struct pid_namespace *pid_ns, unsigned int last);
119134
120
-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);
121137 extern void free_pid(struct pid *pid);
122138 extern void disable_pid_allocation(struct pid_namespace *ns);
123139