[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <alpine.DEB.2.00.1009011512190.16322@router.home>
Date: Wed, 1 Sep 2010 15:16:59 -0500 (CDT)
From: Christoph Lameter <cl@...ux.com>
To: KOSAKI Motohiro <kosaki.motohiro@...fujitsu.com>
cc: Mel Gorman <mel@....ul.ie>,
Andrew Morton <akpm@...ux-foundation.org>,
Linux Kernel List <linux-kernel@...r.kernel.org>,
linux-mm@...ck.org, Rik van Riel <riel@...hat.com>,
Johannes Weiner <hannes@...xchg.org>,
Minchan Kim <minchan.kim@...il.com>,
KAMEZAWA Hiroyuki <kamezawa.hiroyu@...fujitsu.com>
Subject: Re: [PATCH 2/3] mm: page allocator: Calculate a better estimate of
NR_FREE_PAGES when memory is low and kswapd is awake
On Wed, 1 Sep 2010, KOSAKI Motohiro wrote:
> > How about the following? It records a delta and checks if delta is negative
> > and would cause underflow.
> >
> > unsigned long zone_nr_free_pages(struct zone *zone)
> > {
> > unsigned long nr_free_pages = zone_page_state(zone, NR_FREE_PAGES);
> > long delta = 0;
> >
> > /*
> > * While kswapd is awake, it is considered the zone is under some
> > * memory pressure. Under pressure, there is a risk that
> > * per-cpu-counter-drift will allow the min watermark to be breached
> > * potentially causing a live-lock. While kswapd is awake and
> > * free pages are low, get a better estimate for free pages
> > */
> > if (nr_free_pages < zone->percpu_drift_mark &&
> > !waitqueue_active(&zone->zone_pgdat->kswapd_wait)) {
> > int cpu;
> >
> > for_each_online_cpu(cpu) {
> > struct per_cpu_pageset *pset;
> >
> > pset = per_cpu_ptr(zone->pageset, cpu);
> > delta += pset->vm_stat_diff[NR_FREE_PAGES];
> > }
> > }
> >
> > /* Watch for underflow */
> > if (delta < 0 && abs(delta) > nr_free_pages)
> > delta = -nr_free_pages;
Not sure what the point here is. If the delta is going below zero then
there was a concurrent operation updating the counters negatively while
we summed up the counters. It is then safe to assume a value of zero. We
cannot really be more accurate than that.
so
if (delta < 0)
delta = 0;
would be correct. See also handling of counter underflow in
vmstat.h:zone_page_state(). As I have said before: I would rather have the
counter handling in one place to avoid creating differences in counter
handling.
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists