Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1320130 > unrolled thread

Re: [PATCH] mm/vmstat: retrieve more accurate vmstat value

Started byDavid Rientjes <rientjes@google.com>
First post2016-01-28 00:20 +0100
Last post2016-01-28 06:10 +0100
Articles 2 — 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.


Contents

  Re: [PATCH] mm/vmstat: retrieve more accurate vmstat value David Rientjes <rientjes@google.com> - 2016-01-28 00:20 +0100
    Re: [PATCH] mm/vmstat: retrieve more accurate vmstat value Joonsoo Kim <iamjoonsoo.kim@lge.com> - 2016-01-28 06:10 +0100

#1320130 — Re: [PATCH] mm/vmstat: retrieve more accurate vmstat value

FromDavid Rientjes <rientjes@google.com>
Date2016-01-28 00:20 +0100
SubjectRe: [PATCH] mm/vmstat: retrieve more accurate vmstat value
Message-ID<qVHxw-2GU-19@gated-at.bofh.it>
On Thu, 26 Nov 2015, Joonsoo Kim wrote:

> I understand design decision, but, it is better to get value as much
> as accurate if there is no performance problem. My patch would not
> cause much performance degradation because it is just adding one
> this_cpu_read().
> 
> Consider about following example. Current implementation returns
> interesting output if someone do following things.
> 
> v1 = zone_page_state(XXX);
> mod_zone_page_state(XXX, 1);
> v2 = zone_page_state(XXX);
> 
> v2 would be same with v1 in most of cases even if we already update
> it.
> 
> This situation could occurs in page allocation path and others. If
> some task try to allocate many pages, then watermark check returns
> same values until updating vmstat even if some freepage are allocated.
> There are some adjustments for this imprecision but why not do it become
> accurate? I think that this change is reasonable trade-off.
> 

I'm not sure that NR_ISOLATED_* should be vmstats in the first place.  The 
most important callers that depend on its accuracy is 
zone_reclaimable_pages() and the too_many_isolated() loop in both 
shrink_inactive_list() and memory compaction.  If zlc's are updated every 
1s, the HZ/10 in those loops don't really matter, they may as well be 
HZ/2.

I think memory compaction updates the counters in the most appropriate 
way, by incrementing a counter and then finally doing 
mod_zone_page_state() for the counter.  The other updaters are thp 
collapse and page migration.

I discount user-visible vmstats here because the trade-off has already 
been made that they may be stale for up to 1s and userspace isn't 
affected.

So what happens if we simply convert NR_ISOLATED_* into per-zone 
atomic64_t?

[toc] | [next] | [standalone]


#1320304

FromJoonsoo Kim <iamjoonsoo.kim@lge.com>
Date2016-01-28 06:10 +0100
Message-ID<qVN0e-6Kp-9@gated-at.bofh.it>
In reply to#1320130
On Wed, Jan 27, 2016 at 03:13:12PM -0800, David Rientjes wrote:
> On Thu, 26 Nov 2015, Joonsoo Kim wrote:
> 
> > I understand design decision, but, it is better to get value as much
> > as accurate if there is no performance problem. My patch would not
> > cause much performance degradation because it is just adding one
> > this_cpu_read().
> > 
> > Consider about following example. Current implementation returns
> > interesting output if someone do following things.
> > 
> > v1 = zone_page_state(XXX);
> > mod_zone_page_state(XXX, 1);
> > v2 = zone_page_state(XXX);
> > 
> > v2 would be same with v1 in most of cases even if we already update
> > it.
> > 
> > This situation could occurs in page allocation path and others. If
> > some task try to allocate many pages, then watermark check returns
> > same values until updating vmstat even if some freepage are allocated.
> > There are some adjustments for this imprecision but why not do it become
> > accurate? I think that this change is reasonable trade-off.
> > 
> 
> I'm not sure that NR_ISOLATED_* should be vmstats in the first place.  The 
> most important callers that depend on its accuracy is 
> zone_reclaimable_pages() and the too_many_isolated() loop in both 
> shrink_inactive_list() and memory compaction.  If zlc's are updated every 
> 1s, the HZ/10 in those loops don't really matter, they may as well be 
> HZ/2.
> 
> I think memory compaction updates the counters in the most appropriate 
> way, by incrementing a counter and then finally doing 
> mod_zone_page_state() for the counter.  The other updaters are thp 
> collapse and page migration.
> 
> I discount user-visible vmstats here because the trade-off has already 
> been made that they may be stale for up to 1s and userspace isn't 
> affected.
> 
> So what happens if we simply convert NR_ISOLATED_* into per-zone 
> atomic64_t?

Just a small uncomfortable thing is that calculation is done
with different kinds of metric. For example, comparing vmstat values
(NR_INACTIVE_*, NR_ACTIVE_*) with per-zone atomic NR_ISOLATED_*
looks ugly and error-prone because their accuracy is different.

Thanks.

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web