xref: /OK3568_Linux_fs/kernel/tools/include/uapi/linux/sched.h (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1*4882a593Smuzhiyun /* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
2*4882a593Smuzhiyun #ifndef _UAPI_LINUX_SCHED_H
3*4882a593Smuzhiyun #define _UAPI_LINUX_SCHED_H
4*4882a593Smuzhiyun 
5*4882a593Smuzhiyun #include <linux/types.h>
6*4882a593Smuzhiyun 
7*4882a593Smuzhiyun /*
8*4882a593Smuzhiyun  * cloning flags:
9*4882a593Smuzhiyun  */
10*4882a593Smuzhiyun #define CSIGNAL		0x000000ff	/* signal mask to be sent at exit */
11*4882a593Smuzhiyun #define CLONE_VM	0x00000100	/* set if VM shared between processes */
12*4882a593Smuzhiyun #define CLONE_FS	0x00000200	/* set if fs info shared between processes */
13*4882a593Smuzhiyun #define CLONE_FILES	0x00000400	/* set if open files shared between processes */
14*4882a593Smuzhiyun #define CLONE_SIGHAND	0x00000800	/* set if signal handlers and blocked signals shared */
15*4882a593Smuzhiyun #define CLONE_PIDFD	0x00001000	/* set if a pidfd should be placed in parent */
16*4882a593Smuzhiyun #define CLONE_PTRACE	0x00002000	/* set if we want to let tracing continue on the child too */
17*4882a593Smuzhiyun #define CLONE_VFORK	0x00004000	/* set if the parent wants the child to wake it up on mm_release */
18*4882a593Smuzhiyun #define CLONE_PARENT	0x00008000	/* set if we want to have the same parent as the cloner */
19*4882a593Smuzhiyun #define CLONE_THREAD	0x00010000	/* Same thread group? */
20*4882a593Smuzhiyun #define CLONE_NEWNS	0x00020000	/* New mount namespace group */
21*4882a593Smuzhiyun #define CLONE_SYSVSEM	0x00040000	/* share system V SEM_UNDO semantics */
22*4882a593Smuzhiyun #define CLONE_SETTLS	0x00080000	/* create a new TLS for the child */
23*4882a593Smuzhiyun #define CLONE_PARENT_SETTID	0x00100000	/* set the TID in the parent */
24*4882a593Smuzhiyun #define CLONE_CHILD_CLEARTID	0x00200000	/* clear the TID in the child */
25*4882a593Smuzhiyun #define CLONE_DETACHED		0x00400000	/* Unused, ignored */
26*4882a593Smuzhiyun #define CLONE_UNTRACED		0x00800000	/* set if the tracing process can't force CLONE_PTRACE on this clone */
27*4882a593Smuzhiyun #define CLONE_CHILD_SETTID	0x01000000	/* set the TID in the child */
28*4882a593Smuzhiyun #define CLONE_NEWCGROUP		0x02000000	/* New cgroup namespace */
29*4882a593Smuzhiyun #define CLONE_NEWUTS		0x04000000	/* New utsname namespace */
30*4882a593Smuzhiyun #define CLONE_NEWIPC		0x08000000	/* New ipc namespace */
31*4882a593Smuzhiyun #define CLONE_NEWUSER		0x10000000	/* New user namespace */
32*4882a593Smuzhiyun #define CLONE_NEWPID		0x20000000	/* New pid namespace */
33*4882a593Smuzhiyun #define CLONE_NEWNET		0x40000000	/* New network namespace */
34*4882a593Smuzhiyun #define CLONE_IO		0x80000000	/* Clone io context */
35*4882a593Smuzhiyun 
36*4882a593Smuzhiyun /* Flags for the clone3() syscall. */
37*4882a593Smuzhiyun #define CLONE_CLEAR_SIGHAND 0x100000000ULL /* Clear any signal handler and reset to SIG_DFL. */
38*4882a593Smuzhiyun #define CLONE_INTO_CGROUP 0x200000000ULL /* Clone into a specific cgroup given the right permissions. */
39*4882a593Smuzhiyun 
40*4882a593Smuzhiyun /*
41*4882a593Smuzhiyun  * cloning flags intersect with CSIGNAL so can be used with unshare and clone3
42*4882a593Smuzhiyun  * syscalls only:
43*4882a593Smuzhiyun  */
44*4882a593Smuzhiyun #define CLONE_NEWTIME	0x00000080	/* New time namespace */
45*4882a593Smuzhiyun 
46*4882a593Smuzhiyun #ifndef __ASSEMBLY__
47*4882a593Smuzhiyun /**
48*4882a593Smuzhiyun  * struct clone_args - arguments for the clone3 syscall
49*4882a593Smuzhiyun  * @flags:        Flags for the new process as listed above.
50*4882a593Smuzhiyun  *                All flags are valid except for CSIGNAL and
51*4882a593Smuzhiyun  *                CLONE_DETACHED.
52*4882a593Smuzhiyun  * @pidfd:        If CLONE_PIDFD is set, a pidfd will be
53*4882a593Smuzhiyun  *                returned in this argument.
54*4882a593Smuzhiyun  * @child_tid:    If CLONE_CHILD_SETTID is set, the TID of the
55*4882a593Smuzhiyun  *                child process will be returned in the child's
56*4882a593Smuzhiyun  *                memory.
57*4882a593Smuzhiyun  * @parent_tid:   If CLONE_PARENT_SETTID is set, the TID of
58*4882a593Smuzhiyun  *                the child process will be returned in the
59*4882a593Smuzhiyun  *                parent's memory.
60*4882a593Smuzhiyun  * @exit_signal:  The exit_signal the parent process will be
61*4882a593Smuzhiyun  *                sent when the child exits.
62*4882a593Smuzhiyun  * @stack:        Specify the location of the stack for the
63*4882a593Smuzhiyun  *                child process.
64*4882a593Smuzhiyun  *                Note, @stack is expected to point to the
65*4882a593Smuzhiyun  *                lowest address. The stack direction will be
66*4882a593Smuzhiyun  *                determined by the kernel and set up
67*4882a593Smuzhiyun  *                appropriately based on @stack_size.
68*4882a593Smuzhiyun  * @stack_size:   The size of the stack for the child process.
69*4882a593Smuzhiyun  * @tls:          If CLONE_SETTLS is set, the tls descriptor
70*4882a593Smuzhiyun  *                is set to tls.
71*4882a593Smuzhiyun  * @set_tid:      Pointer to an array of type *pid_t. The size
72*4882a593Smuzhiyun  *                of the array is defined using @set_tid_size.
73*4882a593Smuzhiyun  *                This array is used to select PIDs/TIDs for
74*4882a593Smuzhiyun  *                newly created processes. The first element in
75*4882a593Smuzhiyun  *                this defines the PID in the most nested PID
76*4882a593Smuzhiyun  *                namespace. Each additional element in the array
77*4882a593Smuzhiyun  *                defines the PID in the parent PID namespace of
78*4882a593Smuzhiyun  *                the original PID namespace. If the array has
79*4882a593Smuzhiyun  *                less entries than the number of currently
80*4882a593Smuzhiyun  *                nested PID namespaces only the PIDs in the
81*4882a593Smuzhiyun  *                corresponding namespaces are set.
82*4882a593Smuzhiyun  * @set_tid_size: This defines the size of the array referenced
83*4882a593Smuzhiyun  *                in @set_tid. This cannot be larger than the
84*4882a593Smuzhiyun  *                kernel's limit of nested PID namespaces.
85*4882a593Smuzhiyun  * @cgroup:       If CLONE_INTO_CGROUP is specified set this to
86*4882a593Smuzhiyun  *                a file descriptor for the cgroup.
87*4882a593Smuzhiyun  *
88*4882a593Smuzhiyun  * The structure is versioned by size and thus extensible.
89*4882a593Smuzhiyun  * New struct members must go at the end of the struct and
90*4882a593Smuzhiyun  * must be properly 64bit aligned.
91*4882a593Smuzhiyun  */
92*4882a593Smuzhiyun struct clone_args {
93*4882a593Smuzhiyun 	__aligned_u64 flags;
94*4882a593Smuzhiyun 	__aligned_u64 pidfd;
95*4882a593Smuzhiyun 	__aligned_u64 child_tid;
96*4882a593Smuzhiyun 	__aligned_u64 parent_tid;
97*4882a593Smuzhiyun 	__aligned_u64 exit_signal;
98*4882a593Smuzhiyun 	__aligned_u64 stack;
99*4882a593Smuzhiyun 	__aligned_u64 stack_size;
100*4882a593Smuzhiyun 	__aligned_u64 tls;
101*4882a593Smuzhiyun 	__aligned_u64 set_tid;
102*4882a593Smuzhiyun 	__aligned_u64 set_tid_size;
103*4882a593Smuzhiyun 	__aligned_u64 cgroup;
104*4882a593Smuzhiyun };
105*4882a593Smuzhiyun #endif
106*4882a593Smuzhiyun 
107*4882a593Smuzhiyun #define CLONE_ARGS_SIZE_VER0 64 /* sizeof first published struct */
108*4882a593Smuzhiyun #define CLONE_ARGS_SIZE_VER1 80 /* sizeof second published struct */
109*4882a593Smuzhiyun #define CLONE_ARGS_SIZE_VER2 88 /* sizeof third published struct */
110*4882a593Smuzhiyun 
111*4882a593Smuzhiyun /*
112*4882a593Smuzhiyun  * Scheduling policies
113*4882a593Smuzhiyun  */
114*4882a593Smuzhiyun #define SCHED_NORMAL		0
115*4882a593Smuzhiyun #define SCHED_FIFO		1
116*4882a593Smuzhiyun #define SCHED_RR		2
117*4882a593Smuzhiyun #define SCHED_BATCH		3
118*4882a593Smuzhiyun /* SCHED_ISO: reserved but not implemented yet */
119*4882a593Smuzhiyun #define SCHED_IDLE		5
120*4882a593Smuzhiyun #define SCHED_DEADLINE		6
121*4882a593Smuzhiyun 
122*4882a593Smuzhiyun /* Can be ORed in to make sure the process is reverted back to SCHED_NORMAL on fork */
123*4882a593Smuzhiyun #define SCHED_RESET_ON_FORK     0x40000000
124*4882a593Smuzhiyun 
125*4882a593Smuzhiyun /*
126*4882a593Smuzhiyun  * For the sched_{set,get}attr() calls
127*4882a593Smuzhiyun  */
128*4882a593Smuzhiyun #define SCHED_FLAG_RESET_ON_FORK	0x01
129*4882a593Smuzhiyun #define SCHED_FLAG_RECLAIM		0x02
130*4882a593Smuzhiyun #define SCHED_FLAG_DL_OVERRUN		0x04
131*4882a593Smuzhiyun #define SCHED_FLAG_KEEP_POLICY		0x08
132*4882a593Smuzhiyun #define SCHED_FLAG_KEEP_PARAMS		0x10
133*4882a593Smuzhiyun #define SCHED_FLAG_UTIL_CLAMP_MIN	0x20
134*4882a593Smuzhiyun #define SCHED_FLAG_UTIL_CLAMP_MAX	0x40
135*4882a593Smuzhiyun 
136*4882a593Smuzhiyun #define SCHED_FLAG_KEEP_ALL	(SCHED_FLAG_KEEP_POLICY | \
137*4882a593Smuzhiyun 				 SCHED_FLAG_KEEP_PARAMS)
138*4882a593Smuzhiyun 
139*4882a593Smuzhiyun #define SCHED_FLAG_UTIL_CLAMP	(SCHED_FLAG_UTIL_CLAMP_MIN | \
140*4882a593Smuzhiyun 				 SCHED_FLAG_UTIL_CLAMP_MAX)
141*4882a593Smuzhiyun 
142*4882a593Smuzhiyun #define SCHED_FLAG_ALL	(SCHED_FLAG_RESET_ON_FORK	| \
143*4882a593Smuzhiyun 			 SCHED_FLAG_RECLAIM		| \
144*4882a593Smuzhiyun 			 SCHED_FLAG_DL_OVERRUN		| \
145*4882a593Smuzhiyun 			 SCHED_FLAG_KEEP_ALL		| \
146*4882a593Smuzhiyun 			 SCHED_FLAG_UTIL_CLAMP)
147*4882a593Smuzhiyun 
148*4882a593Smuzhiyun #endif /* _UAPI_LINUX_SCHED_H */
149