Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support the deadline CPUSchedulingPolicy #10034

Open
bristot opened this issue Sep 7, 2018 · 3 comments
Open

Support the deadline CPUSchedulingPolicy #10034

bristot opened this issue Sep 7, 2018 · 3 comments
Labels
pid1 RFE 🎁 Request for Enhancement, i.e. a feature request

Comments

@bristot
Copy link

bristot commented Sep 7, 2018

systemd supports setting the scheduling policy and priority of a service via the directives:

CPUSchedulingPolicy=fifo
CPUSchedulingPriority=10

This works fine! But as SCHED_DEADLINE is also supported on Linux, it would be nice to have the ability to set the deadline policy and its parameters.

The deadline policy is set using the sched_setattr() (Linux specific) system call:

int sched_setattr(pid_t pid, struct sched_attr *attr, unsigned int flags);

The first argument is the pid of the thread and the last is for future usage (always 0 now). The scheduling information is set in the second argument, the struct sched_attr.

The sched_attr struct is defined as:

       struct sched_attr {
           u32 size;              /* Size of this structure */
           u32 sched_policy;      /* Policy (SCHED_*) */
           u64 sched_flags;       /* Flags */
           s32 sched_nice;        /* Nice value (SCHED_OTHER,
                                     SCHED_BATCH) */
           u32 sched_priority;    /* Static priority (SCHED_FIFO,
                                     SCHED_RR) */
           /* Remaining fields are for SCHED_DEADLINE */
           u64 sched_runtime;
           u64 sched_deadline;
           u64 sched_period;
       };

The fields of this structure are as follows:

  • The size field should be set to the size of the structure in bytes, as in sizeof(struct sched_attr).

  • The sched_policy specifies the scheduling policy, sched deadline is SCHED_DEADLINE

  • The sched_flags contains flags controlling scheduling behavior, for example, RESET_ON_FORK and SCHED_FLAG_RECLAIM. The last is specific for the deadline scheduler.

  • sched_nice sched_priority should be zero for sched deadline.

The main fields for the sched deadline are (from man page):

  • sched_runtime: Specifies the "Runtime" in nanoseconds

  • sched_deadline: Specifies the "Deadline" in nanoseconds.

  • sched_period: Specifies the "Period" parameter in nanoseconds.

The runtime/deadline/and period should be at least 1024 (nanosconds) and must be: runtime <= deadline <=period.

These articles might be useful:

Deadline scheduling part 1 — overview and theory: https://lwn.net/Articles/743740/
Deadline scheduler part 2 — details and usage: https://lwn.net/Articles/743946/

Feel free to ping me to make questions about the parameters and to test a possible implementation (unfortunately, I don't have time to implement this now).

@poettering poettering added RFE 🎁 Request for Enhancement, i.e. a feature request pid1 labels Sep 11, 2018
@kakra
Copy link
Contributor

kakra commented Sep 14, 2018

Then please also support SCHED_ISO.

@SudoNova
Copy link

Is there any progress/milestone on this issue?

@oakwhiz
Copy link

oakwhiz commented Nov 1, 2022

This would be a helpful feature. It seems logical to have the option to set up SCHED_DEADLINE inside systemd rather than inside the applications that use SCHED_DEADLINE.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
pid1 RFE 🎁 Request for Enhancement, i.e. a feature request
Development

No branches or pull requests

5 participants