Skip to content

Add support for kernel memory limit - #14006

Merged
jessfraz merged 2 commits into
moby:masterfrom
hqhq:hq_add_kmem_limit
Aug 21, 2015
Merged

jessfraz merged 2 commits into
moby:masterfrom
hqhq:hq_add_kmem_limit

Conversation

@hqhq

@hqhq hqhq commented Jun 18, 2015

Copy link
Copy Markdown
Contributor

Addresses: #6479

We have a requirement only kernel newer than 4.0 can use this feature, because
only kernel newer than 4.0 fixed reclaim problem for kmem, which makes kmem
limit real usable.

Signed-off-by: Qiang Huang [email protected]

@hqhq

hqhq commented Jun 18, 2015

Copy link
Copy Markdown
Contributor Author

It needs docker-archive/libcontainer#637 to be merged first.

@frol

frol commented Jun 19, 2015

Copy link
Copy Markdown

LGTM (if my vote counts at all :))

@cpuguy83

Copy link
Copy Markdown
Member

Would it make sense at all to set a kmem based on whatever --memory was passed in, instead of providing a different flag... or maybe the default value of the kmem flag would be that value?

I think K < U will be by far the most common scenario. I'd rather set a sensible default than require the usage of an extra flag.

@frol

frol commented Jun 19, 2015

Copy link
Copy Markdown

@cpuguy83 I agree that K < U is indeed the most common scenario, and K = U might be a good default. However, I wouldn't make such a default because kmem.limit_in_bytes has some overhead when set!

I don't understand how can you vote against a different flag while agree that K < U makes sense. How would you set K if not via the flag?

@cpuguy83

Copy link
Copy Markdown
Member

I definitely did not -1 the flag... I would just prefer that --memory does what people expect it to do in the default case.

@hqhq

hqhq commented Jun 29, 2015

Copy link
Copy Markdown
Contributor Author

@cpuguy83 We can set kmem a default value based on what --memory is, but that's not as functional as we expect.

  • First, not all users would need kmem limit (maybe most of them), and enable kmem accounting would introduce overhead, so enable kmem by default would be a bad idea
  • Second, people who need kmem limit would use them to set specific value, like limit how many process the container can create, the number may not be related to memory limit, so set a default value base on memory limit would not be enough.

So I think introduce a new option would be necessary.

@hqhq

hqhq commented Jul 7, 2015

Copy link
Copy Markdown
Contributor Author

ping

@tiborvass

Copy link
Copy Markdown
Contributor

After discussing with @mrjana, here are our thoughts:

  • Although there are many linux-specific options on docker today, I wonder if we want to continue adding os-specific flags. Are there any plans in having a more generic flag, something like an --exec-opt flag but on docker run ? something that would be passed directly to runc /cc @crosbymichael @icecrime
  • Now if we are fine with adding a new flag, should it be --kernel-memory, --kmem or --kmem-limit? I personally would prefer --kernel-memory, it's more generic.

Other than that we're fine with it.

@hqhq

hqhq commented Jul 29, 2015

Copy link
Copy Markdown
Contributor Author

@tiborvass What do you mean about exec-opt flag? What's it for?

I think different OS have different support on resource controls, it's inevitable, all we can do is to adapt these OS and make sure nothing bad would happen when we use these configs, the difference is wether they really work or not, or show some specific messages. WDYT?

@tiborvass tiborvass added the status/needs-attention Calls for a collective discussion during a review session label Jul 31, 2015
@crosbymichael

Copy link
Copy Markdown
Contributor

@tiborvass I think it would cause more confusing to make an non-typesafe flag at this point. There are not limits on the number of flags that you have an consistency with the existing data should be considered.

@tiborvass

Copy link
Copy Markdown
Contributor

Collective review

@calavera @duglin @tonistiigi @jfrazelle

We seem to agree we shouldn't hold this PR because of how we want to handle platform-specific settings in the future.

However, that concern has to be solved in some ways for that reason I opened #15374

@hqhq please rebase :)

@hqhq
hqhq force-pushed the hq_add_kmem_limit branch 2 times, most recently from d67ec32 to a36598b Compare August 11, 2015 12:25
@hqhq

hqhq commented Aug 11, 2015

Copy link
Copy Markdown
Contributor Author

@tiborvass Rebased, thanks.

Comment thread daemon/daemon_unix.go Outdated

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Should we just warn here? Is the fix for this not ever going to be backported?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

You mean fix in kernel? Actually it's not a bug, but a feature, support kernel memory reclaim so kernel memory limit is actually usable. I don't think it'll be backported to older kernel.

In kernel doc, kernel memory limit is an experimental feature before 4.0, maybe we can just warn here, to both daemon and client.

@hqhq
hqhq force-pushed the hq_add_kmem_limit branch from a36598b to 24fc467 Compare August 12, 2015 01:19
@hqhq

hqhq commented Aug 12, 2015

Copy link
Copy Markdown
Contributor Author

@cpuguy83 Updated, thanks.

Comment thread daemon/daemon_unix.go

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

discard means to throw away. Do you mean ignored? It looks like the user specified a limit for a kernel that does not support memory limits.

"You specified a memory limit which will is ignored because your kernel does not have memory limit capabilities."

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

hi @moxiegirl This description was trying to be constant with other warnings in this function, if they were not good enough, maybe we can pull an separate request and change them all in once?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I understand. Your choice of course...

@hqhq

hqhq commented Aug 18, 2015

Copy link
Copy Markdown
Contributor Author

@thaJeztah @moxiegirl thanks for your review, will address your comments soon, in ContainerCon now.

@hqhq

hqhq commented Aug 19, 2015

Copy link
Copy Markdown
Contributor Author

@thaJeztah @moxiegirl Thanks for your review, updated.

@thaJeztah

Copy link
Copy Markdown
Member

@hqhq Oh, so sorry! I just merged #15482, so this needs a rebase now 😢

@hqhq
hqhq force-pushed the hq_add_kmem_limit branch from 916883a to b6f1b4a Compare August 19, 2015 15:57
@hqhq

hqhq commented Aug 19, 2015

Copy link
Copy Markdown
Contributor Author

@thaJeztah Never mind, rebased, just wait for Jenkins :)

@thaJeztah

Copy link
Copy Markdown
Member

Thanks @hqhq, LGTM!

@hqhq

hqhq commented Aug 20, 2015

Copy link
Copy Markdown
Contributor Author

ping @moxiegirl hope this can be merged before I rebase the other one.

@moxiegirl

Copy link
Copy Markdown
Contributor

@hqhq I see material that needs changing --- our documentation should not use the royal "We" but actually since this is in general approval and you have a dependency. Let's do this...merge it and I'll carry the change to the royal we. @thaJeztah for the merge.

@hqhq

hqhq commented Aug 21, 2015

Copy link
Copy Markdown
Contributor Author

Thanks @moxiegirl , ping @thaJeztah

jessfraz pushed a commit that referenced this pull request Aug 21, 2015
Add support for kernel memory limit
@jessfraz
jessfraz merged commit 9bd8a9b into moby:master Aug 21, 2015
@thaJeztah

Copy link
Copy Markdown
Member

It's merged! Thanks @hqhq !!

@hqhq
hqhq deleted the hq_add_kmem_limit branch August 21, 2015 22:11
@cpuguy83 cpuguy83 mentioned this pull request Aug 22, 2015
@frol

frol commented Aug 22, 2015

Copy link
Copy Markdown

Thank you @hqhq!

@thaJeztah thaJeztah added this to the 1.9.0 milestone Nov 28, 2015
@pmoust

pmoust commented Feb 21, 2018

Copy link
Copy Markdown

We have a requirement only kernel newer than 4.0 can use this feature, because
only kernel newer than 4.0 fixed reclaim problem for kmem, which makes kmem
limit real usable.

@hqhq could you point to the commit sha in kernel upstream that fixes the issue you mention?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.