lkml.org 
[lkml]   [2010]   [Oct]   [28]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    /
    Date
    From
    SubjectRe: [PATCH 1/2] mm: page allocator: Adjust the per-cpu counter threshold when memory is low
    On Thu, 28 Oct 2010 10:49:03 +0100
    Mel Gorman <mel@csn.ul.ie> wrote:

    > On Thu, Oct 28, 2010 at 10:09:20AM +0900, KAMEZAWA Hiroyuki wrote:
    > > On Wed, 27 Oct 2010 09:47:35 +0100
    > > Mel Gorman <mel@csn.ul.ie> wrote:
    > >
    > > > Commit [aa45484: calculate a better estimate of NR_FREE_PAGES when
    > > > memory is low] noted that watermarks were based on the vmstat
    > > > NR_FREE_PAGES. To avoid synchronization overhead, these counters are
    > > > maintained on a per-cpu basis and drained both periodically and when a
    > > > threshold is above a threshold. On large CPU systems, the difference
    > > > between the estimate and real value of NR_FREE_PAGES can be very high.
    > > > The system can get into a case where pages are allocated far below the
    > > > min watermark potentially causing livelock issues. The commit solved the
    > > > problem by taking a better reading of NR_FREE_PAGES when memory was low.
    > > >
    > > > <SNIP>
    > > >
    > > > diff --git a/mm/vmstat.c b/mm/vmstat.c
    > > > index 355a9e6..cafcc2d 100644
    > > > --- a/mm/vmstat.c
    > > > +++ b/mm/vmstat.c
    > > > @@ -81,6 +81,12 @@ EXPORT_SYMBOL(vm_stat);
    > > >
    > > > #ifdef CONFIG_SMP
    > > >
    > > > +static int calculate_pressure_threshold(struct zone *zone)
    > > > +{
    > > > + return max(1, (int)((high_wmark_pages(zone) - low_wmark_pages(zone) /
    > > > + num_online_cpus())));
    > > > +}
    > > > +
    > >
    > > Could you add background theory of this calculation as a comment to
    > > show the difference with calculate_threshold() ?
    > >
    >
    > Sure. When writing it, I realised that the calculations here differ from
    > what percpu_drift_mark does. This is what I currently have
    >
    > int calculate_pressure_threshold(struct zone *zone)
    > {
    > int threshold;
    > int watermark_distance;
    >
    > /*
    > * As vmstats are not up to date, there is drift between the estimated
    > * and real values. For high thresholds and a high number of CPUs, it
    > * is possible for the min watermark to be breached while the estimated
    > * value looks fine. The pressure threshold is a reduced value such
    > * that even the maximum amount of drift will not accidentally breach
    > * the min watermark
    > */
    > watermark_distance = low_wmark_pages(zone) - min_wmark_pages(zone);
    > threshold = max(1, watermark_distance / num_online_cpus());
    >
    > /*
    > * Maximum threshold is 125
    > */
    > threshold = min(125, threshold);
    >
    > return threshold;
    > }
    >
    > Is this better?
    >

    sounds nice.

    Regards,
    -Kame




    \
     
     \ /
      Last update: 2010-10-28 12:07    [W:4.171 / U:1.000 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site