On Tue, Jan 11, 2011 at 12:45:51PM -0800, Andrew Morton wrote: > On Tue, 11 Jan 2011 11:45:21 +0000 > Mel Gorman <mel@xxxxxxxxx> wrote: > > > --- a/mm/page_alloc.c > > +++ b/mm/page_alloc.c > > @@ -1809,12 +1809,15 @@ __alloc_pages_direct_compact(gfp_t gfp_mask, unsigned int order, > > bool sync_migration) > > { > > struct page *page; > > + struct task_struct *p = current; > > > > if (!order || compaction_deferred(preferred_zone)) > > return NULL; > > > > + p->flags |= PF_MEMALLOC; > > *did_some_progress = try_to_compact_pages(zonelist, order, gfp_mask, > > nodemask, sync_migration); > > + p->flags &= ~PF_MEMALLOC; > > Thus accidentally wiping out PF_MEMALLOC if it was already set. > Subtle but we can't have reached here if PF_MEMALLOC was previous set. It gets caught by /* Avoid recursion of direct reclaim */ if (p->flags & PF_MEMALLOC) goto nopage; > It's risky, and general bad practice. The default operation here > should be to push the old value and to later restore it. > Arguably we would do this in case that check was ever removed but I can't imagine why we would allow direct reclaim or compaction to recurse into direct reclaim or compaction. > If it is safe to micro-optimise that operation then we need to make > sure that it's really really safe and that there is no risk of > accidentally breaking things later on as code evolves. > If the code evolves in that direction, it's pretty dangerous. > One way of doing that would be to add a WARN_ON(p->flags & PF_MEMALLOC) > on entry. > That would be reasonable. > Oh, and since when did we use `p' to identify task_structs? > It's pretty stupid all right but it was the name chosen for other parts of page_alloc.c. A patch that either removed all local caching or renamed p to tsk throughout page_alloc.c would be reasonable. -- Mel Gorman Part-time Phd Student Linux Technology Center University of Limerick IBM Dublin Software Lab -- 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/ . Fight unfair telecom policy in Canada: sign http://dissolvethecrtc.ca/ Don't email: <a href=mailto:"dont@xxxxxxxxx"> email@xxxxxxxxx </a>