Skip to content

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

askervin
Copy link
Contributor

Enable setting a NUMA memory policy for the container. New linux.mempolicy object contains inputs to the set_mempolicy(2) syscall.

@kad
Copy link
Contributor

kad commented Mar 27, 2025

Small nit, I'd suggest to use MemoryPolicy and memoryPolicy instead of mempolicy. It would be more readable IMHO.

@giuseppe
Copy link
Member

LGTM after the changes suggested above

@askervin askervin force-pushed the 5aD-oci-mempolicy branch from be4b9f4 to ee377f1 Compare March 28, 2025 14:56
@askervin
Copy link
Contributor Author

Small nit, I'd suggest to use MemoryPolicy and memoryPolicy instead of mempolicy. It would be more readable IMHO.

Thanks @kad, fixed. Definitely better.

@askervin askervin force-pushed the 5aD-oci-mempolicy branch from ee377f1 to 68936b6 Compare March 28, 2025 15:00
Copy link
Member

@utam0k utam0k left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems set_mempolicy(2) is only effective agains for called threads. I'm not sure how to do it for processes created with exec. Any ideas?

set_mempolicy() sets the NUMA memory policy of the calling thread,
which consists of a policy mode and zero or more nodes, to the
values specified by the mode, nodemask, and maxnode arguments.

The behavior of several other system calls is the same, so it might be a good idea to define their behavior as well.

@utam0k
Copy link
Member

utam0k commented Apr 1, 2025

It seems set_mempolicy(2) is only effective agains for called threads.

I'm not sure but we may need to implement it in nsexec.c of runc because of the thread limitation. I recommend to implement PoC in runc.

@giuseppe
Copy link
Member

giuseppe commented Apr 1, 2025

It seems set_mempolicy(2) is only effective agains for called threads. I'm not sure how to do it for processes created with exec. Any ideas?

the man page says:

The process memory policy is preserved across an [execve](https://linux.die.net/man/2/execve)(2), and is inherited by child processes created using [fork](https://linux.die.net/man/2/fork)(2) or [clone](https://linux.die.net/man/2/clone)(2).

so I don't think it is a problem for the spec

@utam0k
Copy link
Member

utam0k commented Apr 1, 2025

@giuseppe Oh, I missed it. Looks good.

@AkihiroSuda AkihiroSuda added this to the v1.3.0 milestone Apr 8, 2025
askervin added a commit to askervin/runc that referenced this pull request Apr 16, 2025
Implement support for Linux memory policy in OCI spec PR:
opencontainers/runtime-spec#1282

TODO:
- remove the replace from go.mod when OCI spec is merged

Signed-off-by: Antti Kervinen <antti.kervinen@intel.com>
askervin added a commit to askervin/runc that referenced this pull request Apr 16, 2025
Implement support for Linux memory policy in OCI spec PR:
opencontainers/runtime-spec#1282

TODO:
- remove the replace from go.mod when OCI spec is merged

Signed-off-by: Antti Kervinen <antti.kervinen@intel.com>
askervin added a commit to askervin/runc that referenced this pull request Apr 16, 2025
Implement support for Linux memory policy in OCI spec PR:
opencontainers/runtime-spec#1282

TODO:
- remove the replace from go.mod when OCI spec is merged

Signed-off-by: Antti Kervinen <antti.kervinen@intel.com>
askervin added a commit to askervin/runc that referenced this pull request Apr 16, 2025
Implement support for Linux memory policy in OCI spec PR:
opencontainers/runtime-spec#1282

TODO:
- remove the replace from go.mod when OCI spec is merged

Signed-off-by: Antti Kervinen <antti.kervinen@intel.com>
askervin added a commit to askervin/runc that referenced this pull request Apr 16, 2025
Implement support for Linux memory policy in OCI spec PR:
opencontainers/runtime-spec#1282

TODO:
- remove the replace from go.mod when OCI spec is merged

Signed-off-by: Antti Kervinen <antti.kervinen@intel.com>
askervin added a commit to askervin/runc that referenced this pull request Apr 16, 2025
Implement support for Linux memory policy in OCI spec PR:
opencontainers/runtime-spec#1282

TODO:
- remove the replace from go.mod when OCI spec is merged

Signed-off-by: Antti Kervinen <antti.kervinen@intel.com>
askervin added a commit to askervin/runc that referenced this pull request Apr 17, 2025
Implement support for Linux memory policy in OCI spec PR:
opencontainers/runtime-spec#1282

TODO:
- remove the replace from go.mod when OCI spec is merged

Signed-off-by: Antti Kervinen <antti.kervinen@intel.com>
@askervin askervin force-pushed the 5aD-oci-mempolicy branch from 68936b6 to a722a43 Compare April 17, 2025 13:02
askervin added a commit to askervin/runc that referenced this pull request Apr 17, 2025
Implement support for Linux memory policy in OCI spec PR:
opencontainers/runtime-spec#1282

TODO:
- remove the replace from go.mod when OCI spec is merged

Signed-off-by: Antti Kervinen <antti.kervinen@intel.com>
askervin added a commit to askervin/runc that referenced this pull request Apr 22, 2025
Implement support for Linux memory policy in OCI spec PR:
opencontainers/runtime-spec#1282

TODO:
- remove the replace from go.mod

Signed-off-by: Antti Kervinen <antti.kervinen@intel.com>
askervin added a commit to askervin/runc that referenced this pull request Apr 22, 2025
Implement support for Linux memory policy in OCI spec PR:
opencontainers/runtime-spec#1282

TODO:
- remove the replace from go.mod

Signed-off-by: Antti Kervinen <antti.kervinen@intel.com>
askervin added a commit to askervin/runc that referenced this pull request Apr 22, 2025
Implement support for Linux memory policy in OCI spec PR:
opencontainers/runtime-spec#1282

TODO:
- remove the replace from go.mod

Signed-off-by: Antti Kervinen <antti.kervinen@intel.com>
askervin added a commit to askervin/runc that referenced this pull request Apr 22, 2025
Implement support for Linux memory policy in OCI spec PR:
opencontainers/runtime-spec#1282

TODO:
- remove the replace from go.mod

Signed-off-by: Antti Kervinen <antti.kervinen@intel.com>
askervin added a commit to askervin/runc that referenced this pull request Apr 22, 2025
Implement support for Linux memory policy in OCI spec PR:
opencontainers/runtime-spec#1282

TODO:
- remove the replace from go.mod

Signed-off-by: Antti Kervinen <antti.kervinen@intel.com>
@askervin askervin force-pushed the 5aD-oci-mempolicy branch from a722a43 to fb37d43 Compare April 23, 2025 07:26
askervin added a commit to askervin/runc that referenced this pull request Apr 23, 2025
Implement support for Linux memory policy in OCI spec PR:
opencontainers/runtime-spec#1282

TODO:
- remove the replace from go.mod

Signed-off-by: Antti Kervinen <antti.kervinen@intel.com>
askervin added a commit to askervin/runc that referenced this pull request Apr 23, 2025
Implement support for Linux memory policy in OCI spec PR:
opencontainers/runtime-spec#1282

TODO:
- remove the replace from go.mod

Signed-off-by: Antti Kervinen <antti.kervinen@intel.com>
Enable setting a NUMA memory policy for the container. New
linux.memoryPolicy object contains inputs to the set_mempolicy(2)
syscall.

Signed-off-by: Antti Kervinen <antti.kervinen@intel.com>
@askervin askervin force-pushed the 5aD-oci-mempolicy branch from fb37d43 to 57c9495 Compare April 23, 2025 07:33
askervin added a commit to askervin/runc that referenced this pull request Apr 23, 2025
Implement support for Linux memory policy in OCI spec PR:
opencontainers/runtime-spec#1282

TODO:
- remove the replace from go.mod

Signed-off-by: Antti Kervinen <antti.kervinen@intel.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants