On Sat, 4 Sep 2010 11:23:11 +0800 Wu Fengguang <fengguang.wu@xxxxxxxxx> wrote: > > Still, given the improvements in performance from this patchset, > > I'd say inclusion is a no-braniner.... > > In your case it's not really high memory pressure, but maybe too many > concurrent direct reclaimers, so that when one reclaimed some free > pages, others kick in and "steal" the free pages. So we need to kill > the second cond_resched() call (which effectively gives other tasks a > good chance to steal this task's vmscan fruits), and only do > drain_all_pages() when nothing was reclaimed (instead of allocated). Well... cond_resched() will only resched when this task has been marked for preemption. If that's happening at such a high frequency then Something Is Up with the scheduler, and the reported context switch rate will be high. > Dave, will you give a try of this patch? It's based on Mel's. > > > --- linux-next.orig/mm/page_alloc.c 2010-09-04 11:08:03.000000000 +0800 > +++ linux-next/mm/page_alloc.c 2010-09-04 11:16:33.000000000 +0800 > @@ -1850,6 +1850,7 @@ __alloc_pages_direct_reclaim(gfp_t gfp_m > > cond_resched(); > > +retry: > /* We now go into synchronous reclaim */ > cpuset_memory_pressure_bump(); > p->flags |= PF_MEMALLOC; > @@ -1863,26 +1864,23 @@ __alloc_pages_direct_reclaim(gfp_t gfp_m > lockdep_clear_current_reclaim_state(); > p->flags &= ~PF_MEMALLOC; > > - cond_resched(); > - > - if (unlikely(!(*did_some_progress))) > + if (unlikely(!(*did_some_progress))) { > + if (!drained) { > + drain_all_pages(); > + drained = true; > + goto retry; > + } > return NULL; > + } > > -retry: > page = get_page_from_freelist(gfp_mask, nodemask, order, > zonelist, high_zoneidx, > alloc_flags, preferred_zone, > migratetype); > > - /* > - * If an allocation failed after direct reclaim, it could be because > - * pages are pinned on the per-cpu lists. Drain them and try again > - */ > - if (!page && !drained) { > - drain_all_pages(); > - drained = true; > + /* someone steal our vmscan fruits? */ > + if (!page && *did_some_progress) > goto retry; > - } Perhaps the fruit-stealing event is worth adding to the userspace-exposed vm stats somewhere. But not in /proc - somewhere more temporary, in debugfs. -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to majordomo@xxxxxxxxxx For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: <a href=mailto:"dont@xxxxxxxxx"> email@xxxxxxxxx </a>