-
Notifications
You must be signed in to change notification settings - Fork 582
Add support for Linux memory policy #1282
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -791,6 +791,45 @@ and may use a maximum memory bandwidth of 20% on socket 0 and 70% on socket 1. | |
} | ||
``` | ||
|
||
## <a name="configLinuxMemoryPolicy" />Memory policy | ||
|
||
**`memoryPolicy`** (object, OPTIONAL) sets the NUMA memory policy for the container. | ||
For more information see the [set_mempolicy(2)][set_mempolicy.2] man page. | ||
|
||
* **`mode`** *(string, REQUIRED)* - | ||
|
||
A valid list of constants is shown below. | ||
|
||
* `MPOL_DEFAULT` | ||
* `MPOL_BIND` | ||
* `MPOL_INTERLEAVE` | ||
* `MPOL_WEIGHTED_INTERLEAVE` | ||
* `MPOL_PREFERRED` | ||
* `MPOL_PREFERRED_MANY` | ||
* `MPOL_LOCAL` | ||
|
||
* **`nodes`** *(string, REQUIRED)* - list of memory nodes from which nodemask is constructed to set_mempolicy(2). This is a comma-separated list, with dashes to represent ranges. For example, `0-3,7` represents memory nodes 0,1,2,3, and 7. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think this might not be 100% correct. nodes is not required for MPOL_DEFAULT or MPOL_LOCAL, in fact set_mempolicy(2) explicitly mention to set nodes to NULL, 0 (even if some variants can work as well as long as nodes is empty). There is also a question about parsing nodes strings. libnuma supports more modes than the ones described here. Including "all" (all nodes), "+" for relative and "!" for negation. Wouldn´t it be better to align the implementations to configure mempolicy to a common format/method and provide a better user interface? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks for pointing out the issue in documentation, @fabbione! Fixed in PR #1294. Regarding the convenience syntax for nodes, I was arguing against it in opencontainers/runc#4726 (comment). Let's continue the discussion there, if you disagree. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. no problem at all, thanks for being so fast in fixing the docs etc. |
||
|
||
* **`flags`** *(array of strings, OPTIONAL)* - list of flags to use with set_mempolicy(2). | ||
|
||
A valid list of constants is shown below. | ||
|
||
* `MPOL_F_NUMA_BALANCING` | ||
* `MPOL_F_RELATIVE_NODES` | ||
* `MPOL_F_STATIC_NODES` | ||
|
||
### Example | ||
|
||
```json | ||
"linux": { | ||
"memoryPolicy": { | ||
"mode": "MPOL_INTERLEAVE", | ||
"nodes": "2-3" | ||
"flags": ["MPOL_F_STATIC_NODES"], | ||
} | ||
} | ||
``` | ||
|
||
## <a name="configLinuxSysctl" />Sysctl | ||
|
||
**`sysctl`** (object, OPTIONAL) allows kernel parameters to be modified at runtime for the container. | ||
|
@@ -1073,6 +1112,7 @@ subset of the available options. | |
[tmpfs]: https://www.kernel.org/doc/Documentation/filesystems/tmpfs.txt | ||
|
||
[full.4]: https://man7.org/linux/man-pages/man4/full.4.html | ||
[set_mempolicy.2]: https://man7.org/linux/man-pages/man2/set_mempolicy.2.html | ||
[mknod.1]: https://man7.org/linux/man-pages/man1/mknod.1.html | ||
[mknod.2]: https://man7.org/linux/man-pages/man2/mknod.2.html | ||
[namespaces.7_2]: https://man7.org/linux/man-pages/man7/namespaces.7.html | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -251,6 +251,8 @@ type Linux struct { | |
// IntelRdt contains Intel Resource Director Technology (RDT) information for | ||
// handling resource constraints and monitoring metrics (e.g., L3 cache, memory bandwidth) for the container | ||
IntelRdt *LinuxIntelRdt `json:"intelRdt,omitempty"` | ||
// MemoryPolicy contains NUMA memory policy for the container. | ||
MemoryPolicy *LinuxMemoryPolicy `json:"memoryPolicy,omitempty"` | ||
// Personality contains configuration for the Linux personality syscall | ||
Personality *LinuxPersonality `json:"personality,omitempty"` | ||
// TimeOffsets specifies the offset for supporting time namespaces. | ||
|
@@ -855,6 +857,19 @@ type LinuxIntelRdt struct { | |
EnableMBM bool `json:"enableMBM,omitempty"` | ||
} | ||
|
||
// LinuxMemoryPolicy represents input for the set_mempolicy syscall. | ||
type LinuxMemoryPolicy struct { | ||
// Mode for the set_mempolicy syscall. | ||
Mode MemoryPolicyModeType `json:"mode"` | ||
|
||
// Nodes representing the nodemask for the set_mempolicy syscall in comma separated ranges format. | ||
// Format: "<node0>-<node1>,<node2>,<node3>-<node4>,..." | ||
Nodes string `json:"nodes"` | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should this have been |
||
|
||
// Flags for the set_mempolicy syscall. | ||
Flags []MemoryPolicyFlagType `json:"flags,omitempty"` | ||
} | ||
|
||
// ZOS contains platform-specific configuration for z/OS based containers. | ||
type ZOS struct { | ||
// Namespaces contains the namespaces that are created and/or joined by the container | ||
|
@@ -884,6 +899,26 @@ const ( | |
ZOSUTSNamespace ZOSNamespaceType = "uts" | ||
) | ||
|
||
type MemoryPolicyModeType string | ||
|
||
const ( | ||
MpolDefault MemoryPolicyModeType = "MPOL_DEFAULT" | ||
MpolBind MemoryPolicyModeType = "MPOL_BIND" | ||
MpolInterleave MemoryPolicyModeType = "MPOL_INTERLEAVE" | ||
MpolWeightedInterleave MemoryPolicyModeType = "MPOL_WEIGHTED_INTERLEAVE" | ||
MpolPreferred MemoryPolicyModeType = "MPOL_PREFERRED" | ||
MpolPreferredMany MemoryPolicyModeType = "MPOL_PREFERRED_MANY" | ||
MpolLocal MemoryPolicyModeType = "MPOL_LOCAL" | ||
) | ||
|
||
type MemoryPolicyFlagType string | ||
|
||
const ( | ||
MpolFNumaBalancing MemoryPolicyFlagType = "MPOL_F_NUMA_BALANCING" | ||
MpolFRelativeNodes MemoryPolicyFlagType = "MPOL_F_RELATIVE_NODES" | ||
MpolFStaticNodes MemoryPolicyFlagType = "MPOL_F_STATIC_NODES" | ||
) | ||
|
||
// LinuxSchedulerPolicy represents different scheduling policies used with the Linux Scheduler | ||
type LinuxSchedulerPolicy string | ||
|
||
|
Uh oh!
There was an error while loading. Please reload this page.