hc
2023-12-11 6778948f9de86c3cfaf36725a7c87dcff9ba247f
kernel/include/linux/pid.h
....@@ -4,7 +4,7 @@
44
55 #include <linux/rculist.h>
66 #include <linux/wait.h>
7
-#include <linux/atomic.h>
7
+#include <linux/refcount.h>
88
99 enum pid_type
1010 {
....@@ -58,10 +58,12 @@
5858
5959 struct pid
6060 {
61
- atomic_t count;
61
+ refcount_t count;
6262 unsigned int level;
63
+ spinlock_t lock;
6364 /* lists of tasks that use this pid */
6465 struct hlist_head tasks[PIDTYPE_MAX];
66
+ struct hlist_head inodes;
6567 /* wait queue for pidfd notifications */
6668 wait_queue_head_t wait_pidfd;
6769 struct rcu_head rcu;
....@@ -72,15 +74,24 @@
7274
7375 extern const struct file_operations pidfd_fops;
7476
77
+struct file;
78
+
79
+extern struct pid *pidfd_pid(const struct file *file);
80
+struct pid *pidfd_get_pid(unsigned int fd, unsigned int *flags);
81
+
7582 static inline struct pid *get_pid(struct pid *pid)
7683 {
7784 if (pid)
78
- atomic_inc(&pid->count);
85
+ refcount_inc(&pid->count);
7986 return pid;
8087 }
8188
8289 extern void put_pid(struct pid *pid);
8390 extern struct task_struct *pid_task(struct pid *pid, enum pid_type);
91
+static inline bool pid_has_task(struct pid *pid, enum pid_type type)
92
+{
93
+ return !hlist_empty(&pid->tasks[type]);
94
+}
8495 extern struct task_struct *get_pid_task(struct pid *pid, enum pid_type);
8596
8697 extern struct pid *get_task_pid(struct task_struct *task, enum pid_type type);
....@@ -92,11 +103,15 @@
92103 extern void detach_pid(struct task_struct *task, enum pid_type);
93104 extern void change_pid(struct task_struct *task, enum pid_type,
94105 struct pid *pid);
106
+extern void exchange_tids(struct task_struct *task, struct task_struct *old);
95107 extern void transfer_pid(struct task_struct *old, struct task_struct *new,
96108 enum pid_type);
97109
98110 struct pid_namespace;
99111 extern struct pid_namespace init_pid_ns;
112
+
113
+extern int pid_max;
114
+extern int pid_max_min, pid_max_max;
100115
101116 /*
102117 * look up a PID in the hash table. Must be called with the tasklist_lock
....@@ -115,9 +130,9 @@
115130 */
116131 extern struct pid *find_get_pid(int nr);
117132 extern struct pid *find_ge_pid(int nr, struct pid_namespace *);
118
-int next_pidmap(struct pid_namespace *pid_ns, unsigned int last);
119133
120
-extern struct pid *alloc_pid(struct pid_namespace *ns);
134
+extern struct pid *alloc_pid(struct pid_namespace *ns, pid_t *set_tid,
135
+ size_t set_tid_size);
121136 extern void free_pid(struct pid *pid);
122137 extern void disable_pid_allocation(struct pid_namespace *ns);
123138