From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail138.messagelabs.com (mail138.messagelabs.com [216.82.249.35]) by kanga.kvack.org (Postfix) with SMTP id F13686B02A8 for ; Fri, 9 Jul 2010 15:12:20 -0400 (EDT) Message-Id: <20100709190857.912752982@quilx.com> Date: Fri, 09 Jul 2010 14:07:20 -0500 From: Christoph Lameter Subject: [S+Q2 14/19] slub: Move gfpflag masking out of the hotpath References: <20100709190706.938177313@quilx.com> Content-Disposition: inline; filename=slub_move_gfpflags Sender: owner-linux-mm@kvack.org To: Pekka Enberg Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, Nick Piggin , David Rientjes List-ID: Move the gfpflags masking into the hooks for checkers and into the slowpaths. gfpflag masking requires access to a global variable and thus adds an additional cacheline reference to the hotpaths. If no hooks are active then the gfpflag masking will result in code that the compiler can toss out. Signed-off-by: Christoph Lameter --- mm/slub.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) Index: linux-2.6/mm/slub.c =================================================================== --- linux-2.6.orig/mm/slub.c 2010-07-07 10:38:17.000000000 -0500 +++ linux-2.6/mm/slub.c 2010-07-07 10:38:22.000000000 -0500 @@ -798,6 +798,7 @@ static void trace(struct kmem_cache *s, */ static inline int slab_pre_alloc_hook(struct kmem_cache *s, gfp_t flags) { + flags &= gfp_allowed_mask; lockdep_trace_alloc(flags); might_sleep_if(flags & __GFP_WAIT); @@ -806,6 +807,7 @@ static inline int slab_pre_alloc_hook(st static inline void slab_post_alloc_hook(struct kmem_cache *s, gfp_t flags, void *object) { + flags &= gfp_allowed_mask; kmemcheck_slab_alloc(s, flags, object, s->objsize); kmemleak_alloc_recursive(object, s->objsize, 1, s->flags, flags); } @@ -1648,6 +1650,7 @@ static void *__slab_alloc(struct kmem_ca /* We handle __GFP_ZERO in the caller */ gfpflags &= ~__GFP_ZERO; + gfpflags &= gfp_allowed_mask; if (!c->page) goto new_slab; @@ -1733,8 +1736,6 @@ static __always_inline void *slab_alloc( struct kmem_cache_cpu *c; unsigned long flags; - gfpflags &= gfp_allowed_mask; - if (!slab_pre_alloc_hook(s, gfpflags)) return NULL; -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to majordomo@kvack.org. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: email@kvack.org