xref: /linux/include/uapi/linux/sched.h (revision ead5d1f4d877e92c051e1a1ade623d0d30e71619)
16f52b16cSGreg Kroah-Hartman /* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
2607ca46eSDavid Howells #ifndef _UAPI_LINUX_SCHED_H
3607ca46eSDavid Howells #define _UAPI_LINUX_SCHED_H
4607ca46eSDavid Howells 
57f192e3cSChristian Brauner #include <linux/types.h>
67f192e3cSChristian Brauner 
7607ca46eSDavid Howells /*
8607ca46eSDavid Howells  * cloning flags:
9607ca46eSDavid Howells  */
10607ca46eSDavid Howells #define CSIGNAL		0x000000ff	/* signal mask to be sent at exit */
11607ca46eSDavid Howells #define CLONE_VM	0x00000100	/* set if VM shared between processes */
12607ca46eSDavid Howells #define CLONE_FS	0x00000200	/* set if fs info shared between processes */
13607ca46eSDavid Howells #define CLONE_FILES	0x00000400	/* set if open files shared between processes */
14607ca46eSDavid Howells #define CLONE_SIGHAND	0x00000800	/* set if signal handlers and blocked signals shared */
15b3e58382SChristian Brauner #define CLONE_PIDFD	0x00001000	/* set if a pidfd should be placed in parent */
16607ca46eSDavid Howells #define CLONE_PTRACE	0x00002000	/* set if we want to let tracing continue on the child too */
17607ca46eSDavid Howells #define CLONE_VFORK	0x00004000	/* set if the parent wants the child to wake it up on mm_release */
18607ca46eSDavid Howells #define CLONE_PARENT	0x00008000	/* set if we want to have the same parent as the cloner */
19607ca46eSDavid Howells #define CLONE_THREAD	0x00010000	/* Same thread group? */
20fcd964ddSChen Hanxiao #define CLONE_NEWNS	0x00020000	/* New mount namespace group */
21607ca46eSDavid Howells #define CLONE_SYSVSEM	0x00040000	/* share system V SEM_UNDO semantics */
22607ca46eSDavid Howells #define CLONE_SETTLS	0x00080000	/* create a new TLS for the child */
23607ca46eSDavid Howells #define CLONE_PARENT_SETTID	0x00100000	/* set the TID in the parent */
24607ca46eSDavid Howells #define CLONE_CHILD_CLEARTID	0x00200000	/* clear the TID in the child */
25607ca46eSDavid Howells #define CLONE_DETACHED		0x00400000	/* Unused, ignored */
26607ca46eSDavid Howells #define CLONE_UNTRACED		0x00800000	/* set if the tracing process can't force CLONE_PTRACE on this clone */
27607ca46eSDavid Howells #define CLONE_CHILD_SETTID	0x01000000	/* set the TID in the child */
285e2bec7cSAditya Kali #define CLONE_NEWCGROUP		0x02000000	/* New cgroup namespace */
29f622b429SChen Hanxiao #define CLONE_NEWUTS		0x04000000	/* New utsname namespace */
30f622b429SChen Hanxiao #define CLONE_NEWIPC		0x08000000	/* New ipc namespace */
31607ca46eSDavid Howells #define CLONE_NEWUSER		0x10000000	/* New user namespace */
32607ca46eSDavid Howells #define CLONE_NEWPID		0x20000000	/* New pid namespace */
33607ca46eSDavid Howells #define CLONE_NEWNET		0x40000000	/* New network namespace */
34607ca46eSDavid Howells #define CLONE_IO		0x80000000	/* Clone io context */
35607ca46eSDavid Howells 
36b612e5dfSChristian Brauner /* Flags for the clone3() syscall. */
37b612e5dfSChristian Brauner #define CLONE_CLEAR_SIGHAND 0x100000000ULL /* Clear any signal handler and reset to SIG_DFL. */
38*ef2c41cfSChristian Brauner #define CLONE_INTO_CGROUP 0x200000000ULL /* Clone into a specific cgroup given the right permissions. */
39b612e5dfSChristian Brauner 
40769071acSAndrei Vagin /*
41769071acSAndrei Vagin  * cloning flags intersect with CSIGNAL so can be used with unshare and clone3
42769071acSAndrei Vagin  * syscalls only:
43769071acSAndrei Vagin  */
44769071acSAndrei Vagin #define CLONE_NEWTIME	0x00000080	/* New time namespace */
45769071acSAndrei Vagin 
4661129dd2SSeth Forshee #ifndef __ASSEMBLY__
4778f6faceSChristian Brauner /**
4878f6faceSChristian Brauner  * struct clone_args - arguments for the clone3 syscall
4978f6faceSChristian Brauner  * @flags:        Flags for the new process as listed above.
5078f6faceSChristian Brauner  *                All flags are valid except for CSIGNAL and
5178f6faceSChristian Brauner  *                CLONE_DETACHED.
5278f6faceSChristian Brauner  * @pidfd:        If CLONE_PIDFD is set, a pidfd will be
5378f6faceSChristian Brauner  *                returned in this argument.
5478f6faceSChristian Brauner  * @child_tid:    If CLONE_CHILD_SETTID is set, the TID of the
5578f6faceSChristian Brauner  *                child process will be returned in the child's
5678f6faceSChristian Brauner  *                memory.
5778f6faceSChristian Brauner  * @parent_tid:   If CLONE_PARENT_SETTID is set, the TID of
5878f6faceSChristian Brauner  *                the child process will be returned in the
5978f6faceSChristian Brauner  *                parent's memory.
6078f6faceSChristian Brauner  * @exit_signal:  The exit_signal the parent process will be
6178f6faceSChristian Brauner  *                sent when the child exits.
6278f6faceSChristian Brauner  * @stack:        Specify the location of the stack for the
6378f6faceSChristian Brauner  *                child process.
64fa729c4dSChristian Brauner  *                Note, @stack is expected to point to the
65fa729c4dSChristian Brauner  *                lowest address. The stack direction will be
66fa729c4dSChristian Brauner  *                determined by the kernel and set up
67fa729c4dSChristian Brauner  *                appropriately based on @stack_size.
6878f6faceSChristian Brauner  * @stack_size:   The size of the stack for the child process.
6978f6faceSChristian Brauner  * @tls:          If CLONE_SETTLS is set, the tls descriptor
7078f6faceSChristian Brauner  *                is set to tls.
7149cb2fc4SAdrian Reber  * @set_tid:      Pointer to an array of type *pid_t. The size
7249cb2fc4SAdrian Reber  *                of the array is defined using @set_tid_size.
7349cb2fc4SAdrian Reber  *                This array is used to select PIDs/TIDs for
7449cb2fc4SAdrian Reber  *                newly created processes. The first element in
7549cb2fc4SAdrian Reber  *                this defines the PID in the most nested PID
7649cb2fc4SAdrian Reber  *                namespace. Each additional element in the array
7749cb2fc4SAdrian Reber  *                defines the PID in the parent PID namespace of
7849cb2fc4SAdrian Reber  *                the original PID namespace. If the array has
7949cb2fc4SAdrian Reber  *                less entries than the number of currently
8049cb2fc4SAdrian Reber  *                nested PID namespaces only the PIDs in the
8149cb2fc4SAdrian Reber  *                corresponding namespaces are set.
8249cb2fc4SAdrian Reber  * @set_tid_size: This defines the size of the array referenced
8349cb2fc4SAdrian Reber  *                in @set_tid. This cannot be larger than the
8449cb2fc4SAdrian Reber  *                kernel's limit of nested PID namespaces.
85*ef2c41cfSChristian Brauner  * @cgroup:       If CLONE_INTO_CGROUP is specified set this to
86*ef2c41cfSChristian Brauner  *                a file descriptor for the cgroup.
8778f6faceSChristian Brauner  *
8878f6faceSChristian Brauner  * The structure is versioned by size and thus extensible.
8978f6faceSChristian Brauner  * New struct members must go at the end of the struct and
9078f6faceSChristian Brauner  * must be properly 64bit aligned.
917f192e3cSChristian Brauner  */
927f192e3cSChristian Brauner struct clone_args {
937f192e3cSChristian Brauner 	__aligned_u64 flags;
947f192e3cSChristian Brauner 	__aligned_u64 pidfd;
957f192e3cSChristian Brauner 	__aligned_u64 child_tid;
967f192e3cSChristian Brauner 	__aligned_u64 parent_tid;
977f192e3cSChristian Brauner 	__aligned_u64 exit_signal;
987f192e3cSChristian Brauner 	__aligned_u64 stack;
997f192e3cSChristian Brauner 	__aligned_u64 stack_size;
1007f192e3cSChristian Brauner 	__aligned_u64 tls;
10149cb2fc4SAdrian Reber 	__aligned_u64 set_tid;
10249cb2fc4SAdrian Reber 	__aligned_u64 set_tid_size;
103*ef2c41cfSChristian Brauner 	__aligned_u64 cgroup;
1047f192e3cSChristian Brauner };
10561129dd2SSeth Forshee #endif
1067f192e3cSChristian Brauner 
107f14c234bSAleksa Sarai #define CLONE_ARGS_SIZE_VER0 64 /* sizeof first published struct */
10849cb2fc4SAdrian Reber #define CLONE_ARGS_SIZE_VER1 80 /* sizeof second published struct */
109*ef2c41cfSChristian Brauner #define CLONE_ARGS_SIZE_VER2 88 /* sizeof third published struct */
110f14c234bSAleksa Sarai 
1117f192e3cSChristian Brauner /*
112607ca46eSDavid Howells  * Scheduling policies
113607ca46eSDavid Howells  */
114607ca46eSDavid Howells #define SCHED_NORMAL		0
115607ca46eSDavid Howells #define SCHED_FIFO		1
116607ca46eSDavid Howells #define SCHED_RR		2
117607ca46eSDavid Howells #define SCHED_BATCH		3
118607ca46eSDavid Howells /* SCHED_ISO: reserved but not implemented yet */
119607ca46eSDavid Howells #define SCHED_IDLE		5
120aab03e05SDario Faggioli #define SCHED_DEADLINE		6
1217479f3c9SPeter Zijlstra 
122607ca46eSDavid Howells /* Can be ORed in to make sure the process is reverted back to SCHED_NORMAL on fork */
123607ca46eSDavid Howells #define SCHED_RESET_ON_FORK     0x40000000
124607ca46eSDavid Howells 
1257479f3c9SPeter Zijlstra /*
1267479f3c9SPeter Zijlstra  * For the sched_{set,get}attr() calls
1277479f3c9SPeter Zijlstra  */
1287479f3c9SPeter Zijlstra #define SCHED_FLAG_RESET_ON_FORK	0x01
1292d4283e9SLuca Abeni #define SCHED_FLAG_RECLAIM		0x02
13034be3930SJuri Lelli #define SCHED_FLAG_DL_OVERRUN		0x04
1311d6362faSPatrick Bellasi #define SCHED_FLAG_KEEP_POLICY		0x08
132a509a7cdSPatrick Bellasi #define SCHED_FLAG_KEEP_PARAMS		0x10
133a509a7cdSPatrick Bellasi #define SCHED_FLAG_UTIL_CLAMP_MIN	0x20
134a509a7cdSPatrick Bellasi #define SCHED_FLAG_UTIL_CLAMP_MAX	0x40
135a509a7cdSPatrick Bellasi 
136a509a7cdSPatrick Bellasi #define SCHED_FLAG_KEEP_ALL	(SCHED_FLAG_KEEP_POLICY | \
137a509a7cdSPatrick Bellasi 				 SCHED_FLAG_KEEP_PARAMS)
138a509a7cdSPatrick Bellasi 
139a509a7cdSPatrick Bellasi #define SCHED_FLAG_UTIL_CLAMP	(SCHED_FLAG_UTIL_CLAMP_MIN | \
140a509a7cdSPatrick Bellasi 				 SCHED_FLAG_UTIL_CLAMP_MAX)
14134be3930SJuri Lelli 
14234be3930SJuri Lelli #define SCHED_FLAG_ALL	(SCHED_FLAG_RESET_ON_FORK	| \
14334be3930SJuri Lelli 			 SCHED_FLAG_RECLAIM		| \
1441d6362faSPatrick Bellasi 			 SCHED_FLAG_DL_OVERRUN		| \
145a509a7cdSPatrick Bellasi 			 SCHED_FLAG_KEEP_ALL		| \
146a509a7cdSPatrick Bellasi 			 SCHED_FLAG_UTIL_CLAMP)
147607ca46eSDavid Howells 
148607ca46eSDavid Howells #endif /* _UAPI_LINUX_SCHED_H */
149