-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
Fix problem when update memory and swap memory #592
Conversation
What do you think about setting memsw first before setting memory ? |
@dqminh It won't work for the initial set, where memory is unlimited for a new cgroup, you can't set memsw lower than memory. |
Hmm you are right. I think the problem with this approach is that it reset the limit momentarily, so theres a chance bad things can happen i.e. process can request more memory than it can. WDYT about reading the existing value out so we can set the order approriately. If new memsw < old mem, then set new mem first etc ? |
Yeah, I thought about reading existing values and compare them, that logic would be a bit complicated , if in such case that lots of memory are allocated in such short period, after the new limits are set, memory will be reclaimed or cause oom, and this reclaim or oom will happen in such case either we reset the limit momentarily or set the right limit directly, so it's not that bad, but is, there will be a slight difference for user's application. I'll update it to set the right limit directly. |
I agree with @dqminh, we shouldn't reset the limits in order to set new ones. Unfortunately, this will have race conditions no matter how we do it (if we do it in memory, two racing |
@cyphar Yeah I agree too, too busy today, I'll update next week. |
c8a459f
to
2de001f
Compare
2de001f
to
638ead2
Compare
@hqhq What about the memory soft limit? AFAICS it'll have similar ordering issues. |
@cyphar I don't think there is problem. Soft limit can be set larger than memory limit, we just recommend to set the soft limit always below the hard limit, otherwise the hard limit will take precedence. But there is no force which will cause |
@hqhq Yeah, you're right. I thought they'd have mirrored what they did with |
638ead2
to
e456096
Compare
Rebased, ping @cyphar @dqminh @mrunalp @crosbymichael @LK4D4 |
build failed
|
Currently, if we start a container with: `docker run -ti --name foo --memory 300M --memory-swap 500M busybox sh` Then we want to update it with: `docker update --memory 600M --memory-swap 800M foo` It'll get error because we can't set memory to 600M with the 500M limit of swap memory. Signed-off-by: Qiang Huang <h.huangqiang@huawei.com>
e456096
to
d8b8f76
Compare
@mrunalp Updated. |
LGTM |
1 similar comment
LGTM |
This adds test coverage for code added by commit d8b8f76 ("Fix problem when update memory and swap memory", 2016-04-05). Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
Add test coverage for code initially added by commit d8b8f76 ("Fix problem when update memory and swap memory", 2016-04-05). Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
Add test coverage for code initially added by commit d8b8f76 ("Fix problem when update memory and swap memory", 2016-04-05). Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
Add integration test coverage for code initially added by commit d8b8f76 ("Fix problem when update memory and swap memory", 2016-04-05). This is in addition to existing unit test, TestMemorySetSwapSmallerThanMemory. Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
Add integration test coverage for code initially added by commit d8b8f76 ("Fix problem when update memory and swap memory", 2016-04-05). This is in addition to existing unit test, TestMemorySetSwapSmallerThanMemory. Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
Add integration test coverage for code initially added by commit d8b8f76 ("Fix problem when update memory and swap memory", 2016-04-05). This is in addition to existing unit test, TestMemorySetSwapSmallerThanMemory. Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
Add integration test coverage for code initially added by commit d8b8f76 ("Fix problem when update memory and swap memory", 2016-04-05). This is in addition to existing unit test, TestMemorySetSwapSmallerThanMemory. Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
Currently, if we start a container with:
docker run -ti --name foo --memory 300M --memory-swap 500M busybox sh
Then we want to update it with:
docker update --memory 600M --memory-swap 800M foo
It'll get error because we can't set memory to 600M with
the 500M limit of swap memory.
Signed-off-by: Qiang Huang h.huangqiang@huawei.com