Skip to content

Commit 61bc346

Browse files
esyr-rhChristian Brauner
authored and
Christian Brauner
committed
uapi/linux/prctl: provide macro definitions for the PR_SCHED_CORE type argument
Commit 7ac592a ("sched: prctl() core-scheduling interface") made use of enum pid_type in prctl's arg4; this type and the associated enumeration definitions are not exposed to userspace. Christian has suggested to provide additional macro definitions that convey the meaning of the type argument more in alignment with its actual usage, and this patch does exactly that. Link: https://lore.kernel.org/r/[email protected] Suggested-by: Christian Brauner <[email protected]> Acked-by: Christian Brauner <[email protected]> Signed-off-by: Eugene Syromiatnikov <[email protected]> Complements: 7ac592a ("sched: prctl() core-scheduling interface") Signed-off-by: Christian Brauner <[email protected]>
1 parent 5816b3e commit 61bc346

File tree

3 files changed

+10
-2
lines changed

3 files changed

+10
-2
lines changed

Documentation/admin-guide/hw-vuln/core-scheduling.rst

+3-2
Original file line numberDiff line numberDiff line change
@@ -61,8 +61,9 @@ arg3:
6161
``pid`` of the task for which the operation applies.
6262

6363
arg4:
64-
``pid_type`` for which the operation applies. It is of type ``enum pid_type``.
65-
For example, if arg4 is ``PIDTYPE_TGID``, then the operation of this command
64+
``pid_type`` for which the operation applies. It is one of
65+
``PR_SCHED_CORE_SCOPE_``-prefixed macro constants. For example, if arg4
66+
is ``PR_SCHED_CORE_SCOPE_THREAD_GROUP``, then the operation of this command
6667
will be performed for all tasks in the task group of ``pid``.
6768

6869
arg5:

include/uapi/linux/prctl.h

+3
Original file line numberDiff line numberDiff line change
@@ -268,5 +268,8 @@ struct prctl_mm_map {
268268
# define PR_SCHED_CORE_SHARE_TO 2 /* push core_sched cookie to pid */
269269
# define PR_SCHED_CORE_SHARE_FROM 3 /* pull core_sched cookie to pid */
270270
# define PR_SCHED_CORE_MAX 4
271+
# define PR_SCHED_CORE_SCOPE_THREAD 0
272+
# define PR_SCHED_CORE_SCOPE_THREAD_GROUP 1
273+
# define PR_SCHED_CORE_SCOPE_PROCESS_GROUP 2
271274

272275
#endif /* _LINUX_PRCTL_H */

kernel/sched/core_sched.c

+4
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,10 @@ int sched_core_share_pid(unsigned int cmd, pid_t pid, enum pid_type type,
134134
if (!static_branch_likely(&sched_smt_present))
135135
return -ENODEV;
136136

137+
BUILD_BUG_ON(PR_SCHED_CORE_SCOPE_THREAD != PIDTYPE_PID);
138+
BUILD_BUG_ON(PR_SCHED_CORE_SCOPE_THREAD_GROUP != PIDTYPE_TGID);
139+
BUILD_BUG_ON(PR_SCHED_CORE_SCOPE_PROCESS_GROUP != PIDTYPE_PGID);
140+
137141
if (type > PIDTYPE_PGID || cmd >= PR_SCHED_CORE_MAX || pid < 0 ||
138142
(cmd != PR_SCHED_CORE_GET && uaddr))
139143
return -EINVAL;

0 commit comments

Comments
 (0)