Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1550266 > unrolled thread
| Started by | David Rientjes <rientjes@google.com> |
|---|---|
| First post | 2017-01-03 23:50 +0100 |
| Last post | 2017-01-04 23:10 +0100 |
| Articles | 4 — 3 participants |
Back to article view | Back to linux.kernel
This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by
below is the oldest one visible, not the original post.
Re: [patch] mm, thp: always direct reclaim for MADV_HUGEPAGE even when deferred David Rientjes <rientjes@google.com> - 2017-01-03 23:50 +0100
Re: [patch] mm, thp: always direct reclaim for MADV_HUGEPAGE even when deferred Vlastimil Babka <vbabka@suse.cz> - 2017-01-04 09:40 +0100
Re: [patch] mm, thp: always direct reclaim for MADV_HUGEPAGE even when deferred Michal Hocko <mhocko@kernel.org> - 2017-01-04 10:50 +0100
Re: [patch] mm, thp: always direct reclaim for MADV_HUGEPAGE even when deferred David Rientjes <rientjes@google.com> - 2017-01-04 23:10 +0100
| From | David Rientjes <rientjes@google.com> |
|---|---|
| Date | 2017-01-03 23:50 +0100 |
| Subject | Re: [patch] mm, thp: always direct reclaim for MADV_HUGEPAGE even when deferred |
| Message-ID | <sVG41-4nb-9@gated-at.bofh.it> |
On Mon, 2 Jan 2017, Vlastimil Babka wrote: > I'm late to the thread (I did read it fully though), so instead of > multiple responses, I'll just list my observations here: > > - "defer", e.g. background kswapd+compaction is not a silver bullet, it > will also affect the system. Mel already mentioned extra reclaim. > Compaction also has CPU costs, just hides the accounting to a kernel > thread so it's not visible as latency. It also increases zone/node > lru_lock and lock pressure. > > For the same reasons, admin might want to limit direct compaction for > THP, even for madvise() apps. It's also likely that "defer" might have > lower system overhead than "madvise", as with "defer", > reclaim/compaction is done by one per-node thread at a time, but there > might be multiple madvise() threads. So there might be sense in not > allowing madvise() apps to do direct reclaim/compaction on "defer". > Hmm, is there a significant benefit to setting "defer" rather than "never" if you can rely on khugepaged to trigger compaction when it tries to allocate. I suppose if there is nothing to collapse that this won't do compaction, but is this not intended for users who always want to defer when not immediately available? "Defer" in it's current setting is useless, in my opinion, other than providing it as a simple workaround to users when their applications are doing MADV_HUGEPAGE without allowing them to configure it. We would love to use "defer" if it didn't completely break MADV_HUGEPAGE, though. > - for overriding specific apps such as QEMU (including their madvise() > usage, AFAICS), we have PR_SET_THP_DISABLE prctl(), so no need to > LD_PRELOAD stuff IMO. > Very good point, and I think it's also worthwhile to allow users to suppress the MADV_HUGEPAGE when allocating a translation buffer in qemu if they choose to do so; it's a very trivial patch to qemu to allow this to be configurable. I haven't proposed it because I don't personally have a need for it, and haven't been pointed to anyone who has a need for it. > - I have wondered about exactly the issue here when Mel proposed the > defer option [1]. Mel responded that it doesn't seem needed at that > point. Now it seems it is. Too bad you didn't raise it then, but to be > fair you were not CC'd. > My understanding is that the defer option is available to users who cannot modify their binary to suppress an madvise(MADV_HUGEPAGE) and are unaware that PR_SET_THP_DISABLE exists. The prctl was added specifically when you cannot control your binary. > So would something like this be possible? > > > echo "defer madvise" > /sys/kernel/mm/transparent_hugepage/defrag > > cat /sys/kernel/mm/transparent_hugepage/defrag > always [defer] [madvise] never > > I'm not sure about the analogous kernel boot option though, I guess > those can't use spaces, so maybe comma-separated? > > If that's not acceptable, then I would probably rather be for changing > "madvise" to include "defer", than the other way around. When we augment > kcompactd to be more proactive, it might easily be that it will > effectively act as "defer", even when defrag=none is set, anyway. > The concern I have with changing the behavior of "madvise" is that it changes long standing behavior that people have correctly implemented userspace applications with. I suggest doing this only with "defer" since it's an option that is new, nobody appears to be deploying with, and makes it much more powerful. I think we could make the kernel default as "defer" later as well and not break userspace that has been setting "madvise" ever since the 2.6 kernel. My position is this: userspace that does MADV_HUGEPAGES knows what it's doing. Let it stall if it wants to stall. If users don't want it to be done, allow them to configure it. If a binary has forced you into using it, use the prctl. Otherwise, I think "defer" doing background compaction for everybody and direct compaction for users who really want hugepages is appropriate and is precisely what I need.
[toc] | [next] | [standalone]
| From | Vlastimil Babka <vbabka@suse.cz> |
|---|---|
| Date | 2017-01-04 09:40 +0100 |
| Message-ID | <sVPh0-2aY-9@gated-at.bofh.it> |
| In reply to | #1550266 |
On 01/03/2017 11:44 PM, David Rientjes wrote: > On Mon, 2 Jan 2017, Vlastimil Babka wrote: > >> I'm late to the thread (I did read it fully though), so instead of >> multiple responses, I'll just list my observations here: >> >> - "defer", e.g. background kswapd+compaction is not a silver bullet, it >> will also affect the system. Mel already mentioned extra reclaim. >> Compaction also has CPU costs, just hides the accounting to a kernel >> thread so it's not visible as latency. It also increases zone/node >> lru_lock and lock pressure. >> >> For the same reasons, admin might want to limit direct compaction for >> THP, even for madvise() apps. It's also likely that "defer" might have >> lower system overhead than "madvise", as with "defer", >> reclaim/compaction is done by one per-node thread at a time, but there >> might be multiple madvise() threads. So there might be sense in not >> allowing madvise() apps to do direct reclaim/compaction on "defer". >> > > Hmm, is there a significant benefit to setting "defer" rather than "never" > if you can rely on khugepaged to trigger compaction when it tries to > allocate. I suppose if there is nothing to collapse that this won't do > compaction, but is this not intended for users who always want to defer > when not immediately available? I guess two things - khugepaged is quite sleepy and will not respond to demand quickly, so it won't compact that much than kcompactd triggered by "defer" - thus with "defer" it's more likely that although some THP faults will fail, others in near future will succeed and benefit from THP immediately. Again, khugepaged is much slower. But it may recover long-running processes that were unlucky in the initial faults, so it's not useless. > "Defer" in it's current setting is useless, in my opinion, other than > providing it as a simple workaround to users when their applications are > doing MADV_HUGEPAGE without allowing them to configure it. I don't think the primary motivation for "defer" was to restrict MADV_HUGEPAGE apps, but rather to prevent latency to the majority of apps oblivious to THP when the default was "always". On the other hand, setting "madvise" would make performance needlessly worse in some scenarios, so "defer" is a compromise that tries to provide THP's but without the latency, and still much more timely than khugepaged. But that's just my POV, Mel probably has/had also the MADV_HUGEPAGE restriction in mind. I'd expect that the "you have to disable THP" cargo-cult originated around apps (databases?) that did not use MADV_HUGEPAGE, though. > We would love > to use "defer" if it didn't completely break MADV_HUGEPAGE, though. Right. >> - for overriding specific apps such as QEMU (including their madvise() >> usage, AFAICS), we have PR_SET_THP_DISABLE prctl(), so no need to >> LD_PRELOAD stuff IMO. >> > > Very good point, and I think it's also worthwhile to allow users to > suppress the MADV_HUGEPAGE when allocating a translation buffer in qemu if > they choose to do so; it's a very trivial patch to qemu to allow this to > be configurable. I haven't proposed it because I don't personally have a > need for it, and haven't been pointed to anyone who has a need for it. > >> - I have wondered about exactly the issue here when Mel proposed the >> defer option [1]. Mel responded that it doesn't seem needed at that >> point. Now it seems it is. Too bad you didn't raise it then, but to be >> fair you were not CC'd. >> > > My understanding is that the defer option is available to users who cannot > modify their binary to suppress an madvise(MADV_HUGEPAGE) and are unaware > that PR_SET_THP_DISABLE exists. The prctl was added specifically when you > cannot control your binary. Yeah, it's easier than LD_PRELOAD, but still not system-wide transparent. >> So would something like this be possible? >> >>> echo "defer madvise" > /sys/kernel/mm/transparent_hugepage/defrag >>> cat /sys/kernel/mm/transparent_hugepage/defrag >> always [defer] [madvise] never >> >> I'm not sure about the analogous kernel boot option though, I guess >> those can't use spaces, so maybe comma-separated? No opinion on the above? I think it could be somewhat more elegant than a fifth-option that Mel said he would prefer, and deliver the same flexibility. >> If that's not acceptable, then I would probably rather be for changing >> "madvise" to include "defer", than the other way around. When we augment >> kcompactd to be more proactive, it might easily be that it will >> effectively act as "defer", even when defrag=none is set, anyway. >> > > The concern I have with changing the behavior of "madvise" is that it > changes long standing behavior that people have correctly implemented > userspace applications with. I suggest doing this only with "defer" since > it's an option that is new, nobody appears to be deploying with, and makes > it much more powerful. I think we could make the kernel default as > "defer" later as well and not break userspace that has been setting > "madvise" ever since the 2.6 kernel. > > My position is this: userspace that does MADV_HUGEPAGES knows what it's > doing. Let it stall if it wants to stall. If users don't want it to be > done, allow them to configure it. If a binary has forced you into using > it, use the prctl. Otherwise, I think "defer" doing background compaction > for everybody and direct compaction for users who really want hugepages is > appropriate and is precisely what I need. I'm not completely against this. But we haven't really ruled out the most flexible option yet... > -- > To unsubscribe, send a message with 'unsubscribe linux-mm' in > the body to majordomo@kvack.org. For more info on Linux MM, > see: http://www.linux-mm.org/ . > Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a> >
[toc] | [prev] | [next] | [standalone]
| From | Michal Hocko <mhocko@kernel.org> |
|---|---|
| Date | 2017-01-04 10:50 +0100 |
| Message-ID | <sVQmJ-2QA-19@gated-at.bofh.it> |
| In reply to | #1550518 |
On Wed 04-01-17 09:32:55, Vlastimil Babka wrote: > On 01/03/2017 11:44 PM, David Rientjes wrote: > > On Mon, 2 Jan 2017, Vlastimil Babka wrote: [...] > >>> echo "defer madvise" > /sys/kernel/mm/transparent_hugepage/defrag > >>> cat /sys/kernel/mm/transparent_hugepage/defrag > >> always [defer] [madvise] never > >> > >> I'm not sure about the analogous kernel boot option though, I guess > >> those can't use spaces, so maybe comma-separated? > > No opinion on the above? I think it could be somewhat more elegant than > a fifth-option that Mel said he would prefer, and deliver the same > flexibility. I am not sure we have considered the kcompactd watermark option throughly as well. In case the relation is not clear because I admit that the propsal was scattered in more emails. So let me summarize it here. Let's add a system configuration whih would control the pro-active background compaction which would - wake up kcompactd pro-actively even when there is no immediate memory pressure - based on the timeout - keep compacting as long as the requested order is under the configured watermark and the compaction makes further progress. Admin can set up this tunable to reflect demand for the THP in the particular workload. Now how it would play with the THP specific defrag options? - never - THP allocations will be tried without any feedback to kcopactd - no stalls in the page fault path - defer - THP allocations will be tried and kcompactd woken up outside of its wmark setting to catch with the workload - no stalls in the page fault path - madvise - do the direct compaction for madvised VMAs and rely on kcompactd watermarks setting to do the background compaction - always - do the direct compaction for all VMAs We won't have to add or modify any new THP specific option and we will have a generic user independent tunable to tell that the system should try to generate high order pages which is something that is demand for. Such a solution would be more flexible as well because the configuration could reflect the demand much better. Is there any reason, except for not being implemented yet, that would make it inappropriate for the described usecase? -- Michal Hocko SUSE Labs
[toc] | [prev] | [next] | [standalone]
| From | David Rientjes <rientjes@google.com> |
|---|---|
| Date | 2017-01-04 23:10 +0100 |
| Message-ID | <sW1UT-2ik-57@gated-at.bofh.it> |
| In reply to | #1550518 |
On Wed, 4 Jan 2017, Vlastimil Babka wrote: > > Hmm, is there a significant benefit to setting "defer" rather than "never" > > if you can rely on khugepaged to trigger compaction when it tries to > > allocate. I suppose if there is nothing to collapse that this won't do > > compaction, but is this not intended for users who always want to defer > > when not immediately available? > > I guess two things > - khugepaged is quite sleepy and will not respond to demand quickly, so > it won't compact that much than kcompactd triggered by "defer" That's configurable, so if a user sets defrag to never, they also have the ability to make khugepaged more aggressive in the background to complement that decision. > I don't think the primary motivation for "defer" was to restrict > MADV_HUGEPAGE apps, but rather to prevent latency to the majority of > apps oblivious to THP when the default was "always". On the other hand, > setting "madvise" would make performance needlessly worse in some > scenarios, so "defer" is a compromise that tries to provide THP's but > without the latency, and still much more timely than khugepaged. > It's disappointing we need to have an option that exists solely to suppress a userspace MADV_HUGEPAGE and not actually fix the userspace to not do the MADV_HUGEPAGE in the first place by making it configurable. That is backwards compatible and doesn't require a new kernel version. This never gets answered in the thread, however, and I offered to make the very trivial patch to qemu to do that for the translation buffer but nobody who uses qemu is even asking for this. It's baffling. > >> So would something like this be possible? > >> > >>> echo "defer madvise" > /sys/kernel/mm/transparent_hugepage/defrag > >>> cat /sys/kernel/mm/transparent_hugepage/defrag > >> always [defer] [madvise] never > >> > >> I'm not sure about the analogous kernel boot option though, I guess > >> those can't use spaces, so maybe comma-separated? > > No opinion on the above? I think it could be somewhat more elegant than > a fifth-option that Mel said he would prefer, and deliver the same > flexibility. > I think this would work, but I'm concerned about two things: (1) the kernel command line format as you pointed out earlier, (2) allowing two options to be combined but not other options (always + never), so it takes even more explaining to do to say what you can actually formulate and what the results of that combining is. The tristate, quadstate, and now quint-state options for thp were never extendable, but now this appears to be the most desired option. We can await the bug reports of users who say their MADV_HUGEPAGE is a no-op, though, and tell them their admin needs to switch away from "defer" if anybody actually ever uses that setting. I think you, me, and Kirill are mostly on the same page with respect to this, but I can't argue against hypothetical usecases and how we need to wait years for "defer" to be available to see if any bug reports are generated to make a decision in this area, so my final proposal in this matter will be the reluctant fifth option and if it doesn't work I'll just carry this for ourselves (we have no use for "defer" without this patch).
[toc] | [prev] | [standalone]
Back to top | Article view | linux.kernel
csiph-web