Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1682424 > unrolled thread
| Started by | Mel Gorman <mgorman@techsingularity.net> |
|---|---|
| First post | 2017-07-06 15:20 +0200 |
| Last post | 2017-07-06 22:10 +0200 |
| Articles | 9 — 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: [PATCH] mm: make allocation counters per-order Mel Gorman <mgorman@techsingularity.net> - 2017-07-06 15:20 +0200
Re: [PATCH] mm: make allocation counters per-order Debabrata Banerjee <dbavatar@gmail.com> - 2017-07-06 17:00 +0200
Re: [PATCH] mm: make allocation counters per-order Mel Gorman <mgorman@techsingularity.net> - 2017-07-06 18:00 +0200
Re: [PATCH] mm: make allocation counters per-order Debabrata Banerjee <dbavatar@gmail.com> - 2017-07-06 18:20 +0200
Re: [PATCH] mm: make allocation counters per-order Mel Gorman <mgorman@techsingularity.net> - 2017-07-06 18:50 +0200
Re: [PATCH] mm: make allocation counters per-order Mel Gorman <mgorman@techsingularity.net> - 2017-07-06 17:50 +0200
Re: [PATCH] mm: make allocation counters per-order Mel Gorman <mgorman@techsingularity.net> - 2017-07-06 19:20 +0200
Re: [PATCH] mm: make allocation counters per-order Debabrata Banerjee <dbavatar@gmail.com> - 2017-07-06 20:10 +0200
Re: [PATCH] mm: make allocation counters per-order Mel Gorman <mgorman@techsingularity.net> - 2017-07-06 22:10 +0200
| From | Mel Gorman <mgorman@techsingularity.net> |
|---|---|
| Date | 2017-07-06 15:20 +0200 |
| Subject | Re: [PATCH] mm: make allocation counters per-order |
| Message-ID | <u0eRk-4MZ-19@gated-at.bofh.it> |
On Thu, Jul 06, 2017 at 02:04:31PM +0100, Roman Gushchin wrote: > High-order allocations are obviously more costly, and it's very useful > to know how many of them happens, if there are any issues > (or suspicions) with memory fragmentation. > > This commit changes existing per-zone allocation counters to be > per-zone per-order. These counters are displayed using a new > procfs interface (similar to /proc/buddyinfo): > > $ cat /proc/allocinfo > DMA 0 0 0 0 0 \ > 0 0 0 0 0 0 > DMA32 3 0 1 0 0 \ > 0 0 0 0 0 0 > Normal 4997056 23594 10902 23686 931 \ > 23 122 786 17 1 0 > Movable 0 0 0 0 0 \ > 0 0 0 0 0 0 > Device 0 0 0 0 0 \ > 0 0 0 0 0 0 > > The existing vmstat interface remains untouched*, and still shows > the total number of single page allocations, so high-order allocations > are represented as a corresponding number of order-0 allocations. > > $ cat /proc/vmstat | grep alloc > pgalloc_dma 0 > pgalloc_dma32 7 > pgalloc_normal 5461660 > pgalloc_movable 0 > pgalloc_device 0 > > * I've added device zone for consistency with other zones, > and to avoid messy exclusion of this zone in the code. > The alloc counter updates are themselves a surprisingly heavy cost to the allocation path and this makes it worse for a debugging case that is relatively rare. I'm extremely reluctant for such a patch to be added given that the tracepoints can be used to assemble such a monitor even if it means running a userspace daemon to keep track of it. Would such a solution be suitable? Failing that if this is a severe issue, would it be possible to at least make this a compile-time or static tracepoint option? That way, only people that really need it have to take the penalty. -- Mel Gorman SUSE Labs
[toc] | [next] | [standalone]
| From | Debabrata Banerjee <dbavatar@gmail.com> |
|---|---|
| Date | 2017-07-06 17:00 +0200 |
| Message-ID | <u0gq6-6g7-11@gated-at.bofh.it> |
| In reply to | #1682424 |
On Thu, Jul 6, 2017 at 9:19 AM, Mel Gorman <mgorman@techsingularity.net> wrote: > The alloc counter updates are themselves a surprisingly heavy cost to > the allocation path and this makes it worse for a debugging case that is > relatively rare. I'm extremely reluctant for such a patch to be added > given that the tracepoints can be used to assemble such a monitor even > if it means running a userspace daemon to keep track of it. Would such a > solution be suitable? Failing that if this is a severe issue, would it be > possible to at least make this a compile-time or static tracepoint option? > That way, only people that really need it have to take the penalty. > > -- > Mel Gorman We (Akamai) have been struggling with memory fragmentation issues for years, and especially the inability to track positive or negative changes to fragmentation between allocator changes and kernels without simply looking for how many allocations are failing. We've had someone toying with trying to report the same data via scanning all pages at report time versus keeping running stats, although we don't have working code yet. If it did work it would avoid the runtime overhead. I don't believe tracepoints are a workable solution for us, since we would have to be collecting the data from boot, as well as continually processing the data in userspace at high cost. Ultimately the locations and other properties (merge-ability) of the allocations in the buddy groups are also important, which would be interesting to add on-top of Roman's patch.
[toc] | [prev] | [next] | [standalone]
| From | Mel Gorman <mgorman@techsingularity.net> |
|---|---|
| Date | 2017-07-06 18:00 +0200 |
| Message-ID | <u0hma-7mU-27@gated-at.bofh.it> |
| In reply to | #1682494 |
On Thu, Jul 06, 2017 at 10:54:24AM -0400, Debabrata Banerjee wrote: > On Thu, Jul 6, 2017 at 9:19 AM, Mel Gorman <mgorman@techsingularity.net> wrote: > > > The alloc counter updates are themselves a surprisingly heavy cost to > > the allocation path and this makes it worse for a debugging case that is > > relatively rare. I'm extremely reluctant for such a patch to be added > > given that the tracepoints can be used to assemble such a monitor even > > if it means running a userspace daemon to keep track of it. Would such a > > solution be suitable? Failing that if this is a severe issue, would it be > > possible to at least make this a compile-time or static tracepoint option? > > That way, only people that really need it have to take the penalty. > > > > -- > > Mel Gorman > > We (Akamai) have been struggling with memory fragmentation issues for > years, and especially the inability to track positive or negative > changes to fragmentation between allocator changes and kernels without > simply looking for how many allocations are failing. We've had someone > toying with trying to report the same data via scanning all pages at > report time versus keeping running stats, although we don't have > working code yet. If it did work it would avoid the runtime overhead. > I don't believe tracepoints are a workable solution for us, since we > would have to be collecting the data from boot, as well as continually > processing the data in userspace at high cost. Ultimately the > locations and other properties (merge-ability) of the allocations in > the buddy groups are also important, which would be interesting to add > on-top of Roman's patch. These counters do not actually help you solve that particular problem. Knowing how many allocations happened since the system booted doesn't tell you much about how many failed or why they failed. You don't even know what frequency they occured at unless you monitor it constantly so you're back to square one whether this information is available from proc or not. There even is a tracepoint that can be used to track information related to events that degrade fragmentation (trace_mm_page_alloc_extfrag) although the primary thing it tells you is that "the probability that an allocation will fail due to fragmentation in the future is potentially higher". -- Mel Gorman SUSE Labs
[toc] | [prev] | [next] | [standalone]
| From | Debabrata Banerjee <dbavatar@gmail.com> |
|---|---|
| Date | 2017-07-06 18:20 +0200 |
| Message-ID | <u0hFw-7Q8-15@gated-at.bofh.it> |
| In reply to | #1682539 |
On Thu, Jul 6, 2017 at 11:51 AM, Mel Gorman <mgorman@techsingularity.net> wrote: > > These counters do not actually help you solve that particular problem. > Knowing how many allocations happened since the system booted doesn't tell > you much about how many failed or why they failed. You don't even know > what frequency they occured at unless you monitor it constantly so you're > back to square one whether this information is available from proc or not. > There even is a tracepoint that can be used to track information related > to events that degrade fragmentation (trace_mm_page_alloc_extfrag) although > the primary thing it tells you is that "the probability that an allocation > will fail due to fragmentation in the future is potentially higher". I agree these counters don't have enough information, but there a start to a first order approximation of the current state of memory. buddyinfo and pagetypeinfo basically show no information now, because they only involve the small amount of free memory under the watermark and all our machines are in this state. As second order approximation, it would be nice to be able to get answers like: "There are reclaimable high order allocations of at least this order" and "None of this order allocation can become available due to unmovable and unreclaimable allocations"
[toc] | [prev] | [next] | [standalone]
| From | Mel Gorman <mgorman@techsingularity.net> |
|---|---|
| Date | 2017-07-06 18:50 +0200 |
| Message-ID | <u0i8y-84C-21@gated-at.bofh.it> |
| In reply to | #1682554 |
On Thu, Jul 06, 2017 at 12:12:47PM -0400, Debabrata Banerjee wrote: > On Thu, Jul 6, 2017 at 11:51 AM, Mel Gorman <mgorman@techsingularity.net> wrote: > > > > These counters do not actually help you solve that particular problem. > > Knowing how many allocations happened since the system booted doesn't tell > > you much about how many failed or why they failed. You don't even know > > what frequency they occured at unless you monitor it constantly so you're > > back to square one whether this information is available from proc or not. > > There even is a tracepoint that can be used to track information related > > to events that degrade fragmentation (trace_mm_page_alloc_extfrag) although > > the primary thing it tells you is that "the probability that an allocation > > will fail due to fragmentation in the future is potentially higher". > > I agree these counters don't have enough information, but there a > start to a first order approximation of the current state of memory. That incurs a universal cost on the off-chance of debugging and ultimately the debugging is only useful in combination with developing kernel patches in which case it could be behind a kconfig option. > buddyinfo and pagetypeinfo basically show no information now, because They can be used to calculate a fragmentation index at a given point in time. Admittedly, building a bigger picture requires a full scan of memory (and that's what was required when fragmentation avoidance was first being implemented). > they only involve the small amount of free memory under the watermark > and all our machines are in this state. As second order approximation, > it would be nice to be able to get answers like: "There are > reclaimable high order allocations of at least this order" and "None > of this order allocation can become available due to unmovable and > unreclaimable allocations" Which this patch doesn't provide as what you are looking for requires a full scan of memory to determine. I've done it in the past using a severe abuse of systemtap to load a module that scans all of memory with a variation of PAGE_OWNER to identify stack traces of pages that "don't belonw" within a pageblock. Even *with* that information, your options for tuning an unmodified kernel are basically limited to increasing min_free_kbytes, altering THP's level of aggression when compacting or brute forcing with either drop_caches, compact_node or both. All other options after that require kernel patches -- altering annotations, altering fallback mechanisms, altering compaction, improving support for pages that can be migrated etc. -- Mel Gorman SUSE Labs
[toc] | [prev] | [next] | [standalone]
| From | Mel Gorman <mgorman@techsingularity.net> |
|---|---|
| Date | 2017-07-06 17:50 +0200 |
| Message-ID | <u0hct-7dv-3@gated-at.bofh.it> |
| In reply to | #1682424 |
On Thu, Jul 06, 2017 at 03:46:34PM +0100, Roman Gushchin wrote: > > The alloc counter updates are themselves a surprisingly heavy cost to > > the allocation path and this makes it worse for a debugging case that is > > relatively rare. I'm extremely reluctant for such a patch to be added > > given that the tracepoints can be used to assemble such a monitor even > > if it means running a userspace daemon to keep track of it. Would such a > > solution be suitable? Failing that if this is a severe issue, would it be > > possible to at least make this a compile-time or static tracepoint option? > > That way, only people that really need it have to take the penalty. > > I've tried to measure the difference with my patch applied and without > any accounting at all (__count_alloc_event() redefined to an empty function), > and I wasn't able to find any measurable difference. > Can you, please, provide more details, how your scenario looked like, > when alloc coutners were costly? > At the time I used a page allocator microbenchmark from mmtests to call the allocator directly without zeroing pages. Triggering allocations from userspace generally mask the overhead by the zeroing costs. It's just a few cycles but given the budget for the page allocator in some circumstances is tiny, it was noticable. perf was used to examine the cost. > As new counters replace an old one, and both are per-cpu counters, I believe, > that the difference should be really small. > Minimally you add a new branch and a small number of computations. It's small but it's there. The cache footprint of the counters is also increased. That is hard to take given that it's overhead for everybody on the off-chance it can debug something. It's not a strong objection and I won't nak it on this basis but given that the same information can be easily obtained using tracepoints (optionally lower overhead with systemtap), the information is rarely going to be useful (no latency information for example) and there is an increased maintenance cost then it does not seem to be that useful. Maybe it would be slightly more convincing if there was an example of real problems in the field that can be debugged with this. For high-order allocations, I previously found that it was the latency that was of the most concern and not the absolute count that happened since the system started. Granted, the same criticism could be leveled at the existing alloc counters but at least by correlating that value with allocstall, you can determine what percentage of allocations stalled recently and optionally ftrace at that point to figure out why. The same steps would indicate then if it's only high-order allocations that stall, add stack tracing to figure out where they are coming from and go from there. Even if the per-order counters exist, all the other debugging steps are necessary so I'm struggling to see how I would use them properly. -- Mel Gorman SUSE Labs
[toc] | [prev] | [next] | [standalone]
| From | Mel Gorman <mgorman@techsingularity.net> |
|---|---|
| Date | 2017-07-06 19:20 +0200 |
| Message-ID | <u0iBA-8tF-13@gated-at.bofh.it> |
| In reply to | #1682522 |
On Thu, Jul 06, 2017 at 05:43:04PM +0100, Roman Gushchin wrote: > > At the time I used a page allocator microbenchmark from mmtests to call > > the allocator directly without zeroing pages. Triggering allocations from > > userspace generally mask the overhead by the zeroing costs. It's just a few > > cycles but given the budget for the page allocator in some circumstances > > is tiny, it was noticable. perf was used to examine the cost. > > I'll try to measure the difference with mmtests. > > I agree, that it's not a feature that worth significant performance penalty, > but if it's small even in a special benchmark, I'd say, it's acceptable. > Note that even if you keep the cycle overhead down, the CPU cache footprint for such a large increase remains. That will be permanent and unfixable which is why I would like a Kconfig option at the very least for the vast majority of people that have no intention or ability to debug such a situation. > > > As new counters replace an old one, and both are per-cpu counters, I believe, > > > that the difference should be really small. > > > > > > > Minimally you add a new branch and a small number of computations. It's > > small but it's there. The cache footprint of the counters is also increased. > > That is hard to take given that it's overhead for everybody on the off-chance > > it can debug something. > > > > It's not a strong objection and I won't nak it on this basis but given > > that the same information can be easily obtained using tracepoints > > (optionally lower overhead with systemtap), the information is rarely > > going to be useful (no latency information for example) and there is an > > increased maintenance cost then it does not seem to be that useful. > > Tracepoints are good for investigations on one machine, not so convenient > if we are talking about gathering stats from the fleet with production load. > Unfortunately, some memory fragmentation issues are hard to reproduce on > a single dev machine. > Sure, but just knowing that some high-order allocations occurred in the past doesn't help either. > > Maybe it would be slightly more convincing if there was an example of > > real problems in the field that can be debugged with this. For high-order > > allocations, I previously found that it was the latency that was of the > > most concern and not the absolute count that happened since the system > > started. > > We met an issue with compaction consuming too much CPU under some specific > conditions, and one of the suspicions was a significant number of high-order > allocations, requested by some third-party device drivers. > Even if this was the suspicion, you would have to activate monitoring on the machine under load at the time the problem is occurring to determine if the high-order allocations are currently happening or happened in the past. If you are continually logging this data then logging allocation stalls for high-order allocations would give you similar information. If you have to activate a monitor anyway (or an agent that monitors for high CPU usage), then it might as well be ftrace based as well as anything else. Even a basic systemtap script would be able to capture only stack traces for allocation requests that take longer than a threshold to limit the amount of data recorded. Even *if* you had these counters running on your grid, they will tell you nothing about how long those allocations are or whether compaction is involved and that is what is key to begin debugging the issue. A basic monitor of /proc/vmstat for the compact_* can be used an indication of excessive time spent in compaction although you're back to ftrace to quantify how much of a problem it is in terms of time. For example, rapidly increasing compact_fail combined with rapidly increasing compact_migrate_scanned and compact_free_scanned will tell you that compaction is active and failing with a comparison of the ratio of compact_fail to compact_success telling you if it's persistent or slow progress. You'd need top information to see if it's the compaction daemon that is consuming all the CPU or processes. If it's the daemon then that points you in the direction of what potentially needs fixing. If it's processes then there is a greater problem and ftrace needs to be used to establish *what* is doing the high-allocation requests and whether they can be reduced somehow or whether it's a general fragmentation problem (in which case your day takes a turn for the worse). What I'm trying to say is that in themselves, an high-order allocation count doesn't help debug this class of problem as much as you'd think. Hopefully the above information is more useful to you in helping debug what's actually wrong. > Knowing the number of allocations is especially helpful for comparing > different kernel versions in a such case, as it's hard to distinguish changes > in mm, changes in these drivers or just workload/environment changes, > leaded to an increased or decreased fragmentation. > I'm still struggling to see how counters help when an agent that monitors for high CPU usage could be activated that captures tracing to see if it's allocation and compaction stalls that are contributing to the overall load or "something else". -- Mel Gorman SUSE Labs
[toc] | [prev] | [next] | [standalone]
| From | Debabrata Banerjee <dbavatar@gmail.com> |
|---|---|
| Date | 2017-07-06 20:10 +0200 |
| Message-ID | <u0jnY-zr-23@gated-at.bofh.it> |
| In reply to | #1682605 |
On Thu, Jul 6, 2017 at 1:16 PM, Mel Gorman <mgorman@techsingularity.net> wrote: > > I'm still struggling to see how counters help when an agent that monitors > for high CPU usage could be activated > I suspect Roman has the same problem set as us, the CPU usage is either always high, high and service critical likely when something interesting is happening. We'd like to collect data on 200k machines, and study the results statistically and with respect to time based on kernel versions, build configs, hardware types, process types, load patterns, etc, etc. Even finding good candidate machines and at the right time of day to manually debug with ftrace is problematic. Granted we could be utilizing existing counters like compact_fail better. Ultimately the data either leads to dealing with certain bad actors, different vm tunings, or patches to mm.
[toc] | [prev] | [next] | [standalone]
| From | Mel Gorman <mgorman@techsingularity.net> |
|---|---|
| Date | 2017-07-06 22:10 +0200 |
| Message-ID | <u0lg5-1XJ-5@gated-at.bofh.it> |
| In reply to | #1682620 |
On Thu, Jul 06, 2017 at 02:00:00PM -0400, Debabrata Banerjee wrote: > On Thu, Jul 6, 2017 at 1:16 PM, Mel Gorman <mgorman@techsingularity.net> wrote: > > > > I'm still struggling to see how counters help when an agent that monitors > > for high CPU usage could be activated > > > > I suspect Roman has the same problem set as us, the CPU usage is > either always high, high and service critical likely when something > interesting is happening. We'd like to collect data on 200k machines, > and study the results statistically and with respect to time based on > kernel versions, build configs, hardware types, process types, load > patterns, etc, etc. Even finding good candidate machines and at the > right time of day to manually debug with ftrace is problematic. > Granted we could be utilizing existing counters like compact_fail > better. Ultimately the data either leads to dealing with certain bad > actors, different vm tunings, or patches to mm. Same issue as described in the other mail. The number of high-order allocations that happened in the past or even the recent past does not give you useful information for debugging high-order allocation stalls or fragmentation-related issues. If the high-order allocations are steady then two machines running similar workloads can both have similar allocation counts but only one of them may be experiencing high latency. Similarly, with high CPU usage, it may be due to compaction or a whole variety of other factors. Even doing a statistical analysis is not going to be enough unless all the relevant variables are accounted for and the raw allocation count in isolation is one of the weakest variables to draw conclusions from. Correlating allocstall with compaction activity from just /proc/vmstat gives a much better hint as to whether high CPU activity is due to high-order allocations. Combining it with top will indicate whether it's direct or indirect costs. If it really is high-order allocations then ftrace to identify the source of the high-order allocations becomes relevant and if it's due to fragmentation, it's a case of tracing the allocator itself to determine why the fragmentation occurred. The proc file with allocation counts is such a tiny part of debugging this class of problem that it's almost irrelevant which is why minimally I think it should be behind Kconfig at absolute minimum. If you want to activate it across production machines then by all means go ahead and if so, I'd be very interested in hearing what class of problem could be debugged and either tuned or fixed without needing ftrace to gather more information. I say "almost irrelevant" because technically, correlating high allocation counts with a kernel version change may be a relevant factor if a kernel introduced a new source of high-order allocations but I suspect that's the exception. It would be much more interesting to correlate increased latency with a kernel version because it's much more relevant. You may be able to correlate high allocation counts with particular hardware (particularly network hardware that cannot scatter/gather) *but* the same proc will will not tell you if those increased requests are actually a problem so the usefulness is diminished. I'm not saying that fragmentation and high-order allocation stalls are not a problem because they can be, but the proc file is unlikely to help and even an extremely basic systemtap script would give you the same information, work on much older kernels and with a trivial amount of additional work it can gather latency information as well as counts. -- Mel Gorman SUSE Labs
[toc] | [prev] | [standalone]
Back to top | Article view | linux.kernel
csiph-web