Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1622710 > unrolled thread
| Started by | Minchan Kim <minchan@kernel.org> |
|---|---|
| First post | 2017-04-13 06:40 +0200 |
| Last post | 2017-04-17 06:30 +0200 |
| Articles | 3 — 2 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: [RFC 0/1] add support for reclaiming priorities per mem cgroup Minchan Kim <minchan@kernel.org> - 2017-04-13 06:40 +0200
Re: [RFC 0/1] add support for reclaiming priorities per mem cgroup Johannes Weiner <hannes@cmpxchg.org> - 2017-04-13 18:10 +0200
Re: [RFC 0/1] add support for reclaiming priorities per mem cgroup Minchan Kim <minchan@kernel.org> - 2017-04-17 06:30 +0200
| From | Minchan Kim <minchan@kernel.org> |
|---|---|
| Date | 2017-04-13 06:40 +0200 |
| Subject | Re: [RFC 0/1] add support for reclaiming priorities per mem cgroup |
| Message-ID | <tvEI1-662-5@gated-at.bofh.it> |
On Thu, Mar 30, 2017 at 12:40:32PM -0700, Tim Murray wrote: > On Thu, Mar 30, 2017 at 8:51 AM, Johannes Weiner <hannes@cmpxchg.org> wrote: > > In cgroup2, we've added a memory.low knob, where groups within their > > memory.low setting are not reclaimed. > > > > You can set that knob on foreground groups to the amount of memory > > they need to function properly, and set it to 0 on background groups. > > > > Have you tried doing that? > > I have not, but I'm trying to get that working now to evaluate it on Android. > > However, based on other experiences, I don't think it will work well. > We've experimented a lot with different limits in different places > (Java heap limits, hard_reclaim, soft_reclaim) at different times in > the process lifecycle, and the problem has always been that there's no > way for us to know what limit is reasonable. memory.low will have the > same problem. If memory.low is higher than the actual working set of a > foreground process, the system wastes memory (eg, file pages loaded > during app startup that are never used again won't be reclaimed under > pressure). If memory.low is less than the actual working set, > foreground processes will still get hit by thrashing. > > Another issue is that the working set varies tremendously from app to > app. An email client's working set may be 1/10 or 1/20 of a camera > running a computational photography pipeline with multiple captures in > flight. I can imagine a case where it makes sense for a foreground > application to take 50-75% of a device's physical memory (the camera > case or something similar), but I hope that's an extreme outlier > compared to most apps on the system. However, high-memory apps are > often the most performance-sensitive, so reclaim is more likely to > cause problems. > > As a result, I think there's still a need for relative priority > between mem cgroups, not just an absolute limit. > > Does that make sense? I agree with it. Recently, embedded platform's workload for smart things would be much diverse(from game to alarm) so it's hard to handle the absolute limit proactively and userspace has more hints about what workloads are more important(ie, greedy) compared to others although it would be harmful for something(e.g., it's not visible effect to user) As a such point of view, I support this idea as basic approach. And with thrashing detector from Johannes, we can do fine-tune of LRU balancing and vmpressure shooting time better. Johannes, Do you have any concern about this memcg prority idea? Or Do you think the patchset you are preparing solve this situation? > > > Both vmpressure and priority levels are based on reclaim efficiency, > > which is problematic on solid state storage because page reads have > > very low latency. It's rare that pages are still locked from the > > read-in by the time reclaim gets to them on the LRU, so efficiency > > tends to stay at 100%, until the system is essentially livelocked. > > > > On solid state storage, the bigger problem when you don't have enough > > memory is that you can reclaim just fine but wait a significant amount > > of time to refault the recently evicted pages, i.e. on thrashing. > > > > A more useful metric for memory pressure at this point is quantifying > > that time you spend thrashing: time the job spends in direct reclaim > > and on the flipside time the job waits for recently evicted pages to > > come back. Combined, that gives you a good measure of overhead from > > memory pressure; putting that in relation to a useful baseline of > > meaningful work done gives you a portable scale of how effictively > > your job is running. > > This sounds fantastic, and it matches the behavior I've seen around > pagecache thrashing on Android. > > On Android, I think there are three different times where userspace > would do something useful for memory: > > 1. scan priority is creeping up, scanned/reclaim ratio is getting > worse, system is exhibiting signs of approaching severe memory > pressure. userspace should probably kill something if it's got > something it can kill cheaply. > 2. direct reclaim is happening, system is thrashing, things are bad. > userspace should aggressively kill non-critical processes because > performance has already gotten worse. > 3. something's gone horribly wrong, oom_killer is imminent: userspace > should kill everything it possibly can to keep the system stable. > > My vmpressure experiments have focused on #1 because it integrates > nicely with memcg priorities. However, it doesn't seem like a good > approach for #2 or #3. Time spent thrashing sounds ideal for #2. I'm > not sure what to do for #3. The current critical vmpressure event > hasn't been that successful in avoiding oom-killer (on 3.18, at > least)--I've been able to get oom-killer to trigger without a > vmpressure event. > > Assuming that memcg priorities are reasonable, would you be open to > using scan priority info as a vmpressure signal for a low amount of > memory pressure? > > -- > 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] | [next] | [standalone]
| From | Johannes Weiner <hannes@cmpxchg.org> |
|---|---|
| Date | 2017-04-13 18:10 +0200 |
| Message-ID | <tvPtL-5kd-1@gated-at.bofh.it> |
| In reply to | #1622710 |
On Thu, Apr 13, 2017 at 01:30:47PM +0900, Minchan Kim wrote: > On Thu, Mar 30, 2017 at 12:40:32PM -0700, Tim Murray wrote: > > As a result, I think there's still a need for relative priority > > between mem cgroups, not just an absolute limit. > > > > Does that make sense? > > I agree with it. > > Recently, embedded platform's workload for smart things would be much > diverse(from game to alarm) so it's hard to handle the absolute limit > proactively and userspace has more hints about what workloads are > more important(ie, greedy) compared to others although it would be > harmful for something(e.g., it's not visible effect to user) > > As a such point of view, I support this idea as basic approach. > And with thrashing detector from Johannes, we can do fine-tune of > LRU balancing and vmpressure shooting time better. > > Johannes, > > Do you have any concern about this memcg prority idea? While I fully agree that relative priority levels would be easier to configure, this patch doesn't really do that. It allows you to set a scan window divider to a fixed amount and, as I already pointed out, the scan window is no longer representative of memory pressure. [ Really, sc->priority should probably just be called LRU lookahead factor or something, there is not much about it being representative of any kind of urgency anymore. ] With this patch, if you configure the priorities of two 8G groups to 0 and 4, reclaim will treat them exactly the same*. If you configure the priorities of two 100G groups to 0 and 7, reclaim will treat them exactly the same. The bigger the group, the more of the lower range of the priority range becomes meaningless, because once the divider produces outcomes bigger than SWAP_CLUSTER_MAX(32), it doesn't actually bias reclaim anymore. So that's not a portable relative scale of pressure discrimination. But the bigger problem with this is that, as sc->priority doesn't represent memory pressure anymore, it is merely a cut-off for which groups to scan and which groups not to scan *based on their size*. That is the same as setting memory.low! * For simplicity, I'm glossing over the fact here that LRUs are split by type and into inactive/active, so in reality the numbers are a little different, but you get the point. > Or > Do you think the patchset you are preparing solve this situation? It's certainly a requirement. In order to implement a relative scale of memory pressure discrimination, we first need to be able to really quantify memory pressure. Then we can either allow setting absolute latency/slowdown minimums for each group, with reclaim skipping groups above those thresholds, or we can map a relative priority scale against the total slowdown due to lack of memory in the system, and each group gets a relative share based on its priority compared to other groups. But there is no way around first having a working measure of memory pressure before we can meaningfully distribute it among the groups. Thanks
[toc] | [prev] | [next] | [standalone]
| From | Minchan Kim <minchan@kernel.org> |
|---|---|
| Date | 2017-04-17 06:30 +0200 |
| Message-ID | <tx6sy-4yD-5@gated-at.bofh.it> |
| In reply to | #1623145 |
Hi Johannes, On Thu, Apr 13, 2017 at 12:01:47PM -0400, Johannes Weiner wrote: > On Thu, Apr 13, 2017 at 01:30:47PM +0900, Minchan Kim wrote: > > On Thu, Mar 30, 2017 at 12:40:32PM -0700, Tim Murray wrote: > > > As a result, I think there's still a need for relative priority > > > between mem cgroups, not just an absolute limit. > > > > > > Does that make sense? > > > > I agree with it. > > > > Recently, embedded platform's workload for smart things would be much > > diverse(from game to alarm) so it's hard to handle the absolute limit > > proactively and userspace has more hints about what workloads are > > more important(ie, greedy) compared to others although it would be > > harmful for something(e.g., it's not visible effect to user) > > > > As a such point of view, I support this idea as basic approach. > > And with thrashing detector from Johannes, we can do fine-tune of > > LRU balancing and vmpressure shooting time better. > > > > Johannes, > > > > Do you have any concern about this memcg prority idea? > > While I fully agree that relative priority levels would be easier to > configure, this patch doesn't really do that. It allows you to set a > scan window divider to a fixed amount and, as I already pointed out, > the scan window is no longer representative of memory pressure. > > [ Really, sc->priority should probably just be called LRU lookahead > factor or something, there is not much about it being representative > of any kind of urgency anymore. ] I agree that sc->priority is not memory pressure indication. I should have clarified my intention. Sorry about that. I'm not saying I like this implementation as I mentioned with previous reply. http://lkml.kernel.org/r/20170322052013.GE30149@bbox Just about general idea, in global OOM case, break proportional reclaim and then prefering low-priority group's reclaim would be good for some workload like current embedded platform. And to achieve it, aging velocity control via scan window adjusting seems to be reasonable. > > With this patch, if you configure the priorities of two 8G groups to 0 > and 4, reclaim will treat them exactly the same*. If you configure the > priorities of two 100G groups to 0 and 7, reclaim will treat them > exactly the same. The bigger the group, the more of the lower range of > the priority range becomes meaningless, because once the divider > produces outcomes bigger than SWAP_CLUSTER_MAX(32), it doesn't > actually bias reclaim anymore. It seems it's the logic of memcg reclaim not global which is major concern for current problem because there is no set up limitation for each memcg. > > So that's not a portable relative scale of pressure discrimination. > > But the bigger problem with this is that, as sc->priority doesn't > represent memory pressure anymore, it is merely a cut-off for which > groups to scan and which groups not to scan *based on their size*. Yes, because there are no measurable pressure concept in current VM and you are trying to add the notion which is really good! > > That is the same as setting memory.low! > > * For simplicity, I'm glossing over the fact here that LRUs are split > by type and into inactive/active, so in reality the numbers are a > little different, but you get the point. > > > Or > > Do you think the patchset you are preparing solve this situation? > > It's certainly a requirement. In order to implement a relative scale > of memory pressure discrimination, we first need to be able to really > quantify memory pressure. Yeb. If we can get it, it would be better than unconditional discriminated aging by the static priority which would leave non-workingset pages in high priority group while workingset in low-priority group would be evicted. Rather than it, we ages every group's LRU fairly and if high-priority group makes memory pressure beyond his threshold, VM should feedback to low priority groups to be reclaimed more, which would be better. > > Then we can either allow setting absolute latency/slowdown minimums > for each group, with reclaim skipping groups above those thresholds, > or we can map a relative priority scale against the total slowdown due > to lack of memory in the system, and each group gets a relative share > based on its priority compared to other groups. Fully agreed. > > But there is no way around first having a working measure of memory > pressure before we can meaningfully distribute it among the groups. Yeb. I'm looking foward to seeing it. Thanks for the thoughtful comment, Johannes!
[toc] | [prev] | [standalone]
Back to top | Article view | linux.kernel
csiph-web