Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756847AbXFYGr2 (ORCPT ); Mon, 25 Jun 2007 02:47:28 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1752901AbXFYGrV (ORCPT ); Mon, 25 Jun 2007 02:47:21 -0400 Received: from mail1.asahi-net.or.jp ([202.224.39.197]:62305 "EHLO mail.asahi-net.or.jp" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1752380AbXFYGrU (ORCPT ); Mon, 25 Jun 2007 02:47:20 -0400 Date: Mon, 25 Jun 2007 15:45:43 +0900 Message-ID: From: Yoshinori Sato To: Matt Mackall Cc: Nick Piggin , lkml Subject: Re: [PATCH] SLOB allocator imcompatible SLAB In-Reply-To: <20070622145635.GX11115@waste.org> References: <20070622145635.GX11115@waste.org> User-Agent: Wanderlust/2.15.5 (Almost Unreal) SEMI/1.14.6 (Maruoka) FLIM/1.14.8 (=?ISO-8859-4?Q?Shij=F2?=) APEL/10.6 Emacs/22.0.93 (i486-pc-linux-gnu) MULE/5.0 (SAKAKI) Organization: SIOS Technology, Inc. MIME-Version: 1.0 (generated by SEMI 1.14.6 - "Maruoka") Content-Type: text/plain; charset=US-ASCII Sender: linux-kernel-owner@vger.kernel.org X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 3160 Lines: 105 At Fri, 22 Jun 2007 09:56:35 -0500, Matt Mackall wrote: > > On Fri, Jun 22, 2007 at 05:08:07PM +0900, Yoshinori Sato wrote: > > Because the page which SLOB allocator got does not have PG_slab, > > This is for a NOMMU system? Yes. > You're using an old kernel with an old version of SLOB. SLOB in newer > kernels actually sets per-page flags. Nick, can you see any reason not > to s/PG_active/PG_slab/ in the current code? in mm/nommu.c 109 unsigned int kobjsize(const void *objp) 110 { : 116 if (PageSlab(page)) 117 return ksize(objp); : 122 return (PAGE_SIZE << page->index); 123 } PG_slab is verified here. > > Signed-off-by: Yoshinori Sato > > > > diff --git a/mm/slob.c b/mm/slob.c > > index 71976c5..d10bcda 100644 > > --- a/mm/slob.c > > +++ b/mm/slob.c > > @@ -73,6 +73,21 @@ static DEFINE_SPINLOCK(block_lock); > > static void slob_free(void *b, int size); > > static void slob_timer_cbk(void); > > > > +static inline void set_slabflags(const void *ptr, int order) > > +{ > > + int i; > > + struct page *page = virt_to_page(ptr); > > + for (i = 0; i < (1 << order); i++) > > + __SetPageSlab(page++); > > +} > > + > > +static inline void clear_slabflags(const void *ptr, int order) > > +{ > > + int i; > > + struct page *page = virt_to_page(ptr); > > + for (i = 0; i < (1 << order); i++) > > + __ClearPageSlab(page++); > > +} > > > > static void *slob_alloc(size_t size, gfp_t gfp, int align) > > { > > @@ -180,6 +195,7 @@ void *__kmalloc(size_t size, gfp_t gfp) > > bb->pages = (void *)__get_free_pages(gfp, bb->order); > > > > if (bb->pages) { > > + set_slabflags(bb->pages, bb->order); > > spin_lock_irqsave(&block_lock, flags); > > bb->next = bigblocks; > > bigblocks = bb; > > @@ -240,6 +256,7 @@ void kfree(const void *block) > > if (bb->pages == block) { > > *last = bb->next; > > spin_unlock_irqrestore(&block_lock, flags); > > + clear_slabflags(block, bb->order); > > free_pages((unsigned long)block, bb->order); > > slob_free(bb, sizeof(bigblock_t)); > > return; > > @@ -323,9 +340,11 @@ void *kmem_cache_alloc(struct kmem_cache *c, gfp_t flags) > > > > if (c->size < PAGE_SIZE) > > b = slob_alloc(c->size, flags, c->align); > > - else > > + else { > > b = (void *)__get_free_pages(flags, get_order(c->size)); > > - > > + if (b) > > + set_slabflags(b, get_order(c->size)); > > + } > > if (c->ctor) > > c->ctor(b, c, 0); > > > > @@ -347,8 +366,10 @@ static void __kmem_cache_free(void *b, int size) > > { > > if (size < PAGE_SIZE) > > slob_free(b, size); > > - else > > + else { > > + clear_slabflags(b, get_order(size)); > > free_pages((unsigned long)b, get_order(size)); > > + } > > } > > > > static void kmem_rcu_free(struct rcu_head *head) > > -- > Mathematics is the supreme nostalgia of our time. - To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/