From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail144.messagelabs.com (mail144.messagelabs.com [216.82.254.51]) by kanga.kvack.org (Postfix) with SMTP id 65C676003C2 for ; Fri, 21 May 2010 17:18:59 -0400 (EDT) Message-Id: <20100521211539.878341791@quilx.com> Date: Fri, 21 May 2010 16:14:57 -0500 From: Christoph Lameter Subject: [RFC V2 SLEB 05/14] SLUB: is_kmalloc_cache References: <20100521211452.659982351@quilx.com> Content-Disposition: inline; filename=slub_is_kmalloc_cache Sender: owner-linux-mm@kvack.org To: Pekka Enberg Cc: linux-mm@kvack.org List-ID: The determination if a slab is a kmalloc slab is occurring multiple times. Signed-off-by: Christoph Lameter --- mm/slub.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) Index: linux-2.6/mm/slub.c =================================================================== --- linux-2.6.orig/mm/slub.c 2010-05-12 14:46:58.000000000 -0500 +++ linux-2.6/mm/slub.c 2010-05-12 14:49:37.000000000 -0500 @@ -312,6 +312,11 @@ static inline int oo_objects(struct kmem return x.x & OO_MASK; } +static int is_kmalloc_cache(struct kmem_cache *s) +{ + return (s < kmalloc_caches + KMALLOC_CACHES && s >= kmalloc_caches); +} + #ifdef CONFIG_SLUB_DEBUG /* * Debug settings: @@ -2076,7 +2081,7 @@ static DEFINE_PER_CPU(struct kmem_cache_ static inline int alloc_kmem_cache_cpus(struct kmem_cache *s, gfp_t flags) { - if (s < kmalloc_caches + KMALLOC_CACHES && s >= kmalloc_caches) + if (is_kmalloc_cache(s)) /* * Boot time creation of the kmalloc array. Use static per cpu data * since the per cpu allocator is not available yet. @@ -2158,8 +2163,7 @@ static int init_kmem_cache_nodes(struct int node; int local_node; - if (slab_state >= UP && (s < kmalloc_caches || - s >= kmalloc_caches + KMALLOC_CACHES)) + if (slab_state >= UP && !is_kmalloc_cache(s)) local_node = page_to_nid(virt_to_page(s)); else local_node = 0; -- 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