Skip to content

Commit

Permalink
spec: add scheduler entity
Browse files Browse the repository at this point in the history
extend the process struct to represent scheduling attributes for a
process based on the sched_setattr(2) syscall.

Signed-off-by: Giuseppe Scrivano <[email protected]>
  • Loading branch information
giuseppe committed Mar 16, 2023
1 parent a7c7692 commit 80ef061
Show file tree
Hide file tree
Showing 3 changed files with 66 additions and 0 deletions.
10 changes: 10 additions & 0 deletions config.md
Original file line number Diff line number Diff line change
Expand Up @@ -291,6 +291,16 @@ For Linux-based systems, the `process` object supports the following process-spe

This is a per-process setting, where as [`disableOOMKiller`](config-linux.md#memory) is scoped for a memory cgroup.
For more information on how these two settings work together, see [the memory cgroup documentation section 10. OOM Contol][cgroup-v1-memory_2].
* **`scheduler`** (object, OPTIONAL) is an object describing the scheduler properties for the process. The `scheduler` contains the following properties:

* **`policy`** (string, OPTIONAL) represents the scheduling policy (e.g., SCHED_FIFO, SCHED_RR, SCHED_OTHER).
* **`nice`** (int32, OPTIONAL) is the nice value for the process, affecting its priority. A lower nice value corresponds to a higher priority.
* **`priority`** (int32, OPTIONAL) represents the static priority of the process, used by real-time policies like SCHED_FIFO and SCHED_RR.
* **`flags`** (array of strings, OPTIONAL) is an array of strings representing scheduling flags (e.g., SCHED_FLAG_RESET_ON_FORK, SCHED_FLAG_RECLAIM).
* **`runtime`** (uint64, OPTIONAL) represents the amount of time in nanoseconds during which the process is allowed to run in a given period, used by the deadline scheduler.
* **`deadline`** (uint64, OPTIONAL) represents the absolute deadline for the process to complete its execution, used by the deadline scheduler.
* **`period`** (uint64, OPTIONAL) represents the length of the period in nanoseconds used for determining the process runtime, used by the deadline scheduler.

* **`selinuxLabel`** (string, OPTIONAL) specifies the SELinux label for the process.
For more information about SELinux, see [SELinux documentation][selinux].

Expand Down
26 changes: 26 additions & 0 deletions schema/config-schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,32 @@
"noNewPrivileges": {
"type": "boolean"
},
"scheduler": {
"type": "object",
"properties": {
"policy": {
"type": "string"
},
"nice": {
"$ref": "defs.json#/definitions/int32"
},
"priority": {
"$ref": "defs.json#/definitions/int32"
},
"flags": {
"$ref": "defs.json#/definitions/ArrayOfStrings"
},
"runtime": {
"$ref": "defs.json#/definitions/uint64"
},
"deadline": {
"$ref": "defs.json#/definitions/uint64"
},
"period": {
"$ref": "defs.json#/definitions/uint64"
}
}
},
"rlimits": {
"type": "array",
"items": {
Expand Down
30 changes: 30 additions & 0 deletions specs-go/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,34 @@ type Spec struct {
ZOS *ZOS `json:"zos,omitempty" platform:"zos"`
}

// Scheduler represents the scheduling attributes for a process. It is based on
// the Linux sched_setattr(2) syscall.
type Scheduler struct {
// Policy represents the scheduling policy (e.g., SCHED_FIFO, SCHED_RR, SCHED_OTHER).
Policy string `json:"policy"`

// Nice is the nice value for the process, which affects its priority.
Nice int32 `json:"nice"`

// Priority represents the static priority of the process.
Priority int32 `json:"priority"`

// Flags is an array of strings representing scheduling flags.
Flags []string `json:"flags"`

// The following ones are used by the DEADLINE scheduler.

// Runtime is the amount of time in nanoseconds during which the process
// is allowed to run in a given period.
Runtime uint64 `json:"runtime"`

// Deadline is the absolute deadline for the process to complete its execution.
Deadline uint64 `json:"deadline"`

// Period is the length of the period in nanoseconds used for determining the process runtime.
Period uint64 `json:"period"`
}

// Process contains information to start a specific application inside the container.
type Process struct {
// Terminal creates an interactive terminal for the container.
Expand Down Expand Up @@ -60,6 +88,8 @@ type Process struct {
ApparmorProfile string `json:"apparmorProfile,omitempty" platform:"linux"`
// Specify an oom_score_adj for the container.
OOMScoreAdj *int `json:"oomScoreAdj,omitempty" platform:"linux"`
// Scheduler specifies the scheduling attributes for a process
Scheduler *Scheduler `json:"scheduler,omitempty" platform:"linux"`
// SelinuxLabel specifies the selinux context that the container process is run as.
SelinuxLabel string `json:"selinuxLabel,omitempty" platform:"linux"`
}
Expand Down

0 comments on commit 80ef061

Please sign in to comment.