Re: [PATCH] nommu: fix kobjsize() for SLOB and SLUB

!MAILaRCHIVE_VOTE_RePLACE
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
To: Paul Mundt <lethal@...>
Cc: David Howells <dhowells@...>, Christoph Lameter <clameter@...>, LKML <linux-kernel@...>, <cooloney@...>, <akpm@...>, <mpm@...>
Date: Sunday, June 1, 2008 - 5:13 am

Hi Paul,

On Sun, 1 Jun 2008, Paul Mundt wrote:

I was about to send a patch that fixes some of the kobjsize() abuses to 
use ksize() but then I realized that what we probably should do is 
something like this instead.

I mean, assuming the BUG_ON bits are bogus, then we should always pass the 
pointer to the allocator. I audited most of the callers and they all seem 
to be really just using kmalloc() for allocation anyway.

What do you think?

		Pekka

diff --git a/mm/nommu.c b/mm/nommu.c
index dca93fc..fc1ff52 100644
--- a/mm/nommu.c
+++ b/mm/nommu.c
@@ -103,22 +103,20 @@ EXPORT_SYMBOL(vmtruncate);
  */
 unsigned int kobjsize(const void *objp)
 {
-	struct page *page;
-
 	/*
 	 * If the object we have should not have ksize performed on it,
 	 * return size of 0
 	 */
-	if (!objp || (unsigned long)objp >= memory_end || !((page = virt_to_page(objp))))
+	if (!objp)
 		return 0;
 
-	if (PageSlab(page))
-		return ksize(objp);
+	if ((unsigned long)objp >= memory_end)
+		return 0;
 
-	BUG_ON(page->index < 0);
-	BUG_ON(page->index >= MAX_ORDER);
+	if (!virt_to_page(objp))
+		return 0;
 
-	return (PAGE_SIZE << page->index);
+	return ksize(objp);
 }
 
 /*
--
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
Re: [PATCH] nommu: fix kobjsize() for SLOB and SLUB, Pekka Enberg, (Wed May 28, 4:03 pm)
Re: [PATCH] nommu: fix kobjsize() for SLOB and SLUB, Christoph Lameter, (Wed May 28, 4:25 pm)
Re: [PATCH] nommu: fix kobjsize() for SLOB and SLUB, Pekka Enberg, (Wed May 28, 4:25 pm)
Re: [PATCH] nommu: fix kobjsize() for SLOB and SLUB, Christoph Lameter, (Wed May 28, 4:29 pm)
Re: [PATCH] nommu: fix kobjsize() for SLOB and SLUB, David Howells, (Thu May 29, 9:08 am)
Re: [PATCH] nommu: fix kobjsize() for SLOB and SLUB, Christoph Lameter, (Thu May 29, 11:00 am)
Re: [PATCH] nommu: fix kobjsize() for SLOB and SLUB, Pekka J Enberg, (Thu May 29, 9:21 am)
Re: [PATCH] nommu: fix kobjsize() for SLOB and SLUB, Paul Mundt, (Thu May 29, 5:12 pm)
Re: [PATCH] nommu: fix kobjsize() for SLOB and SLUB, Pekka Enberg, (Sun Jun 1, 3:58 am)
Re: [PATCH] nommu: fix kobjsize() for SLOB and SLUB, Paul Mundt, (Sun Jun 1, 4:22 am)
Re: [PATCH] nommu: fix kobjsize() for SLOB and SLUB, Pekka J Enberg, (Sun Jun 1, 4:22 am)
Re: [PATCH] nommu: fix kobjsize() for SLOB and SLUB, Paul Mundt, (Sun Jun 1, 4:24 am)
Re: [PATCH] nommu: fix kobjsize() for SLOB and SLUB, Pekka J Enberg, (Sun Jun 1, 5:13 am)
Re: [PATCH] nommu: fix kobjsize() for SLOB and SLUB, Paul Mundt, (Sun Jun 1, 6:24 am)
Re: [PATCH] nommu: fix kobjsize() for SLOB and SLUB, Pekka Enberg, (Sun Jun 1, 6:29 am)
Re: [PATCH] nommu: fix kobjsize() for SLOB and SLUB, Paul Mundt, (Sun Jun 1, 7:21 am)
Re: [PATCH] nommu: fix kobjsize() for SLOB and SLUB, Pekka J Enberg, (Sun Jun 1, 7:30 am)
Re: [PATCH] nommu: fix kobjsize() for SLOB and SLUB, Paul Mundt, (Mon Jun 2, 1:59 am)
Re: [PATCH] nommu: fix kobjsize() for SLOB and SLUB, Pekka Enberg, (Mon Jun 2, 2:32 am)
Re: [PATCH] nommu: fix kobjsize() for SLOB and SLUB, Paul Mundt, (Mon Jun 2, 2:50 am)
Re: [PATCH] nommu: fix kobjsize() for SLOB and SLUB, Pekka Enberg, (Mon Jun 2, 2:58 am)
Re: [PATCH] nommu: fix kobjsize() for SLOB and SLUB, Paul Mundt, (Mon Jun 2, 3:01 am)
Re: [PATCH] nommu: fix kobjsize() for SLOB and SLUB, Pekka J Enberg, (Sun Jun 1, 4:36 am)