XenevaOS
Loading...
Searching...
No Matches
pid.h
Go to the documentation of this file.
1/*
2 * DCL pid.h -- the pid surface drm_file.c names.
3 *
4 * mainline splits this across <linux/pid_types.h> (enum pid_type) and
5 * <linux/pid.h> (struct pid and the accessors), and it reaches drm_file.c
6 * because mainline's <linux/fs.h> includes <linux/pid.h> (fs.h:20). DCL's
7 * fs.h is pinned and includes nothing, so the whole surface lands in
8 * <linux/file.h> with the rest of the vocabulary fs.h owes the drm set --
9 * see the note at the top of that header for why file.h is that carrier.
10 *
11 * Both halves are in this one file because nothing else in the tree needs
12 * either, and a header holding a five-value enum and four functions is not
13 * worth splitting the way mainline splits it: the split exists there so
14 * <linux/types.h> can carry the enum, and no source here reaches the enum
15 * that way.
16 *
17 * There is no pid table, and that is the fact everything below follows from.
18 * DCL identifies a task by the scheduler context dcl_current() hands back
19 * (<linux/sched.h>), not by a number, so there is no pid for a task to
20 * report and no table to look one up in.
21 */
22#ifndef _LINUX_PID_H
23#define _LINUX_PID_H
24
25struct pid;
26struct task_struct;
27
28/*
29 * enum pid_type -- mainline's five values in mainline's order, copied from
30 * <linux/pid_types.h>. Only PIDTYPE_TGID is named in this tree, at
31 * drm_file.c:1030; the other four are here so that naming the next one is a
32 * copy and not a guess about what number it should carry.
33 */
41
42/*
43 * get_pid() / put_pid() -- the refcount pair. DCL's are the identity and a
44 * no-op, which is only sound because there is nothing to refcount: they both
45 * take whatever task_tgid() handed out (below, NULL) and pass it on. Every
46 * call site in this tree has been checked against that --
47 * drm_file.c:145 stores the result, :193 and :273 put it on file teardown,
48 * :476-481 do get_pid/replace/put_pid around drm_file_update_pid's swap --
49 * and all four deal in NULL.
50 */
51static inline struct pid* get_pid(struct pid* pid)
52{
53 return pid;
54}
55
56static inline void put_pid(struct pid* pid)
57{
58 (void)pid;
59}
60
61/*
62 * task_tgid() -- the thread-group pid of a task. NULL, because there is no
63 * pid to report (see the top of this file). It is not a stub that ought to
64 * become real when pids arrive: a NULL here is already the correct answer
65 * for the one caller's model, which is a single client that never changes --
66 * drm_file.c:145 stores it, and drm_file.c:465-471 compares the next call's
67 * result against the stored one and returns early when they are equal, which
68 * NULL == NULL is. The swap at :476-481 is therefore never reached, and
69 * drm_file.c:1029-1034 reads it back as `task ? ... : "Unset"`.
70 */
71static inline struct pid* task_tgid(struct task_struct* task)
72{
73 (void)task;
74 return NULL;
75}
76
77/*
78 * task_pid_nr() -- the numeric process id, for a debug line. 0 is the answer
79 * mainline gives for a task outside the calling namespace, and drm_file.c:243
80 * and :333 print it as `%d` beside current->comm in drm_dbg_core(), which is
81 * a line DCL's logging drops at compile time anyway.
82 */
83static inline int task_pid_nr(struct task_struct* task)
84{
85 (void)task;
86 return 0;
87}
88
89/*
90 * pid_task() -- the task owning a pid, in a given pid type. NULL: there is
91 * no table to look in. The single caller (drm_file.c:1030) prints the result
92 * behind a NULL check, so an empty log is the whole cost -- "comm: Unset
93 * pid: 0" on a path that only runs when drm_file_err() is already logging an
94 * error.
95 *
96 * A static inline and not the exported function mainline has in
97 * kernel/pid.c, so no link symbol is added for a body that returns NULL.
98 */
99static inline struct task_struct* pid_task(struct pid* pid, enum pid_type type)
100{
101 (void)pid;
102 (void)type;
103 return NULL;
104}
105
106#endif /* _LINUX_PID_H */
#define NULL
Definition actypes.h:561
pid_type
Definition pid.h:34
@ PIDTYPE_TGID
Definition pid.h:36
@ PIDTYPE_SID
Definition pid.h:38
@ PIDTYPE_MAX
Definition pid.h:39
@ PIDTYPE_PID
Definition pid.h:35
@ PIDTYPE_PGID
Definition pid.h:37
Definition sched.h:121
int pid
Definition sched.h:123