chrt: don't restrict --reset-on-fork, add more info to man page
The flag works (= kernel accepts it) for all scheduling policies and sched_getattr() returns the flag for all policies. There is no reason for userspace to be more smart than kernel or hide the flag when it prints sched_getattr()/sched_getscheduler() results. # chrt -v --reset-on-fork --batch 0 /bin/true pid 1315019's new scheduling policy: SCHED_BATCH|SCHED_RESET_ON_FORK # chrt -v --reset-on-fork --fifo 1 /bin/true pid 1315055's new scheduling policy: SCHED_FIFO|SCHED_RESET_ON_FORK # chrt -v --reset-on-fork --deadline --sched-period 10000 0 /bin/true pid 1315182's new scheduling policy: SCHED_DEADLINE|SCHED_RESET_ON_FORK # chrt -v --reset-on-fork --idle 0 /bin/true pid 1315247's new scheduling policy: SCHED_IDLE|SCHED_RESET_ON_FORK # chrt -v --reset-on-fork --rr 1 /bin/true pid 1315275's new scheduling policy: SCHED_RR|SCHED_RESET_ON_FORK # chrt -v --reset-on-fork --other 0 /bin/true pid 1315311's new scheduling policy: SCHED_OTHER|SCHED_RESET_ON_FORK Signed-off-by: Karel Zak <kzak@redhat.com>
This commit is contained in:
parent
fb4f1da4e0
commit
865f5f469c
|
@ -86,13 +86,37 @@ Specifies period parameter for SCHED_DEADLINE policy (Linux-specific).
|
|||
Specifies deadline parameter for SCHED_DEADLINE policy (Linux-specific).
|
||||
.TP
|
||||
\fB\-R\fR, \fB\-\-reset-on-fork\fR
|
||||
Add
|
||||
Use
|
||||
.B SCHED_RESET_ON_FORK
|
||||
flag to the
|
||||
or
|
||||
.B SCHED_FLAG_RESET_ON_FORK
|
||||
flag. Linux-specific, supported since 2.6.31.
|
||||
|
||||
Each thread has a reset-on-fork scheduling flag. When this flag is set, children created by
|
||||
.BR fork (2)
|
||||
do not inherit privileged scheduling policies. After the reset-on-fork flag has been enabled,
|
||||
it can be reset only if the thread has the
|
||||
.BR CAP_SYS_NICE
|
||||
capability. This flag is disabled in child processes created by
|
||||
.BR fork (2).
|
||||
|
||||
More precisely, if the reset-on-fork flag is set,
|
||||
the following rules apply for subsequently created children:
|
||||
.RS
|
||||
.IP * 3
|
||||
If the calling thread has a scheduling policy of
|
||||
.B SCHED_FIFO
|
||||
or
|
||||
.B SCHED_RR
|
||||
scheduling policy (Linux-specific, supported since 2.6.31).
|
||||
.BR SCHED_RR ,
|
||||
the policy is reset to
|
||||
.BR SCHED_OTHER
|
||||
in child processes.
|
||||
.IP *
|
||||
If the calling process has a negative nice value,
|
||||
the nice value is reset to zero in child processes.
|
||||
.RE
|
||||
|
||||
|
||||
|
||||
.SH OPTIONS
|
||||
.TP
|
||||
|
|
|
@ -152,7 +152,7 @@ static void __attribute__((__noreturn__)) usage(void)
|
|||
|
||||
fputs(USAGE_SEPARATOR, out);
|
||||
fputs(_("Scheduling options:\n"), out);
|
||||
fputs(_(" -R, --reset-on-fork set SCHED_RESET_ON_FORK for FIFO or RR\n"), out);
|
||||
fputs(_(" -R, --reset-on-fork set reset-on-fork flag\n"), out);
|
||||
fputs(_(" -T, --sched-runtime <ns> runtime parameter for DEADLINE\n"), out);
|
||||
fputs(_(" -P, --sched-period <ns> period parameter for DEADLINE\n"), out);
|
||||
fputs(_(" -D, --sched-deadline <ns> deadline parameter for DEADLINE\n"), out);
|
||||
|
@ -173,22 +173,19 @@ static void __attribute__((__noreturn__)) usage(void)
|
|||
|
||||
static const char *get_policy_name(int policy)
|
||||
{
|
||||
#ifdef SCHED_RESET_ON_FORK
|
||||
policy &= ~SCHED_RESET_ON_FORK;
|
||||
#endif
|
||||
switch (policy) {
|
||||
case SCHED_OTHER:
|
||||
return "SCHED_OTHER";
|
||||
case SCHED_FIFO:
|
||||
#ifdef SCHED_RESET_ON_FORK
|
||||
case SCHED_FIFO | SCHED_RESET_ON_FORK:
|
||||
#endif
|
||||
return "SCHED_FIFO";
|
||||
#ifdef SCHED_IDLE
|
||||
case SCHED_IDLE:
|
||||
return "SCHED_IDLE";
|
||||
#endif
|
||||
case SCHED_RR:
|
||||
#ifdef SCHED_RESET_ON_FORK
|
||||
case SCHED_RR | SCHED_RESET_ON_FORK:
|
||||
#endif
|
||||
return "SCHED_RR";
|
||||
#ifdef SCHED_BATCH
|
||||
case SCHED_BATCH:
|
||||
|
@ -257,7 +254,7 @@ fallback:
|
|||
else
|
||||
prio = sp.sched_priority;
|
||||
# ifdef SCHED_RESET_ON_FORK
|
||||
if (policy == (SCHED_FIFO|SCHED_RESET_ON_FORK) || policy == (SCHED_BATCH|SCHED_RESET_ON_FORK))
|
||||
if (policy & SCHED_RESET_ON_FORK)
|
||||
reset_on_fork = 1;
|
||||
# endif
|
||||
}
|
||||
|
@ -524,11 +521,6 @@ int main(int argc, char **argv)
|
|||
errno = 0;
|
||||
ctl->priority = strtos32_or_err(argv[optind], _("invalid priority argument"));
|
||||
|
||||
#ifdef SCHED_RESET_ON_FORK
|
||||
if (ctl->reset_on_fork && ctl->policy != SCHED_FIFO && ctl->policy != SCHED_RR)
|
||||
errx(EXIT_FAILURE, _("--reset-on-fork option is supported for "
|
||||
"SCHED_FIFO and SCHED_RR policies only"));
|
||||
#endif
|
||||
#ifdef SCHED_DEADLINE
|
||||
if ((ctl->runtime || ctl->deadline || ctl->period) && ctl->policy != SCHED_DEADLINE)
|
||||
errx(EXIT_FAILURE, _("--sched-{runtime,deadline,period} options "
|
||||
|
|
Loading…
Reference in New Issue