Messages in this thread | | | Date | Mon, 23 Feb 2009 14:59:36 -0800 | From | Andrew Morton <> | Subject | Re: [PATCH] mm: gfp_to_alloc_flags() |
| |
On Mon, 23 Feb 2009 12:55:03 +0100 Peter Zijlstra <peterz@infradead.org> wrote:
> +static int gfp_to_alloc_flags(gfp_t gfp_mask) > +{ > + struct task_struct *p = current; > + int alloc_flags = ALLOC_WMARK_MIN | ALLOC_CPUSET; > + const gfp_t wait = gfp_mask & __GFP_WAIT; > + > + /* > + * The caller may dip into page reserves a bit more if the caller > + * cannot run direct reclaim, or if the caller has realtime scheduling > + * policy or is asking for __GFP_HIGH memory. GFP_ATOMIC requests will > + * set both ALLOC_HARDER (!wait) and ALLOC_HIGH (__GFP_HIGH). > + */ > + if (gfp_mask & __GFP_HIGH) > + alloc_flags |= ALLOC_HIGH;
This could be sped up by making ALLOC_HIGH==__GFP_HIGH (hack)
> + if (!wait) { > + alloc_flags |= ALLOC_HARDER; > + /* > + * Ignore cpuset if GFP_ATOMIC (!wait) rather than fail alloc. > + * See also cpuset_zone_allowed() comment in kernel/cpuset.c. > + */ > + alloc_flags &= ~ALLOC_CPUSET; > + } else if (unlikely(rt_task(p)) && !in_interrupt()) > + alloc_flags |= ALLOC_HARDER; > + > + if (likely(!(gfp_mask & __GFP_NOMEMALLOC))) { > + if (!in_interrupt() && > + ((p->flags & PF_MEMALLOC) || > + unlikely(test_thread_flag(TIF_MEMDIE)))) > + alloc_flags |= ALLOC_NO_WATERMARKS; > + } > + return alloc_flags; > +}
But really, the whole function can be elided on the fastpath. Try the allocation with the current flags (and __GFP_NOWARN) and only if it failed will we try altering the flags to try harder?
| |