public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] nommu: fix kobjsize() for SLOB and SLUB
@ 2008-05-22 16:09 Pekka J Enberg
  2008-05-22 16:48 ` Christoph Lameter
                   ` (2 more replies)
  0 siblings, 3 replies; 43+ messages in thread
From: Pekka J Enberg @ 2008-05-22 16:09 UTC (permalink / raw)
  To: dhowells; +Cc: clameter, mpm, lethal, linux-kernel

From: Christoph Lameter <clameter@sgi.com>

As reported by Paul Mundt, kobjsize() does not work properly with SLOB and SLUB
that re-use parts of struct page for their own purposes. Fix it up by using
compound_order() for compound pages that don't have PageSlab set.

Reported-by: Paul Mundt <lethal@linux-sh.org>
Cc: Christoph Lameter <clameter@sgi.com>
Signed-off-by: Pekka Enberg <penberg@cs.helsinki.fi>
---
I kept the original object size calculation for non-compound pages in this 
version. It looks like the nommu code uses kobjsize() for all sorts of 
interesting things.

 mm/nommu.c |   14 +++++++++-----
 1 files changed, 9 insertions(+), 5 deletions(-)

Index: slab-2.6/mm/nommu.c
===================================================================
--- slab-2.6.orig/mm/nommu.c	2008-05-22 18:59:01.000000000 +0300
+++ slab-2.6/mm/nommu.c	2008-05-22 19:00:36.000000000 +0300
@@ -109,12 +109,22 @@
 	 * 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 ((unsigned long) objp >= memory_end)
+		return 0;
+
+	page = virt_to_head_page(objp);
+	if (!page)
 		return 0;
 
 	if (PageSlab(page))
 		return ksize(objp);
 
+	if (PageCompound(page))
+		return PAGE_SIZE << compound_order(page);
+
 	BUG_ON(page->index < 0);
 	BUG_ON(page->index >= MAX_ORDER);
 

^ permalink raw reply	[flat|nested] 43+ messages in thread
[parent not found: <Pine.LNX.4.64.0805281646470.27125@sbz-30.cs.Helsinki.FI>]

end of thread, other threads:[~2008-06-02  7:03 UTC | newest]

Thread overview: 43+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-05-22 16:09 [PATCH] nommu: fix kobjsize() for SLOB and SLUB Pekka J Enberg
2008-05-22 16:48 ` Christoph Lameter
2008-05-22 23:40 ` Paul Mundt
2008-05-22 23:45   ` Christoph Lameter
2008-05-22 23:50     ` Paul Mundt
2008-05-23  0:04       ` Christoph Lameter
2008-05-28 13:12 ` David Howells
2008-05-28 13:17   ` Pekka J Enberg
2008-05-28 13:40     ` David Howells
2008-05-28 14:09   ` David Howells
2008-05-28 17:26     ` Christoph Lameter
2008-05-28 17:38       ` David Howells
2008-05-28 20:35         ` Mike Frysinger
2008-05-29 13:03           ` David Howells
2008-05-29 20:25             ` Mike Frysinger
2008-05-29 20:30               ` Christoph Lameter
2008-05-29 20:51                 ` Mike Frysinger
2008-05-29 21:29                   ` Christoph Lameter
2008-05-30  4:18                     ` Mike Frysinger
2008-05-28 14:27   ` David Howells
     [not found] <Pine.LNX.4.64.0805281646470.27125@sbz-30.cs.Helsinki.FI>
     [not found] ` <20080528153648.GA27783@linux-sh.org>
2008-05-28 20:03   ` Pekka Enberg
2008-05-28 20:25     ` Christoph Lameter
2008-05-28 20:25       ` Pekka Enberg
2008-05-28 20:29         ` Christoph Lameter
2008-05-29 13:08           ` David Howells
2008-05-29 13:21             ` Pekka J Enberg
2008-05-29 21:12               ` Paul Mundt
2008-06-01  7:58                 ` Pekka Enberg
2008-06-01  8:22                   ` Pekka J Enberg
2008-06-01  8:24                     ` Paul Mundt
2008-06-01  8:36                       ` Pekka J Enberg
2008-06-01  9:13                       ` Pekka J Enberg
2008-06-01 10:24                         ` Paul Mundt
2008-06-01 10:29                           ` Pekka Enberg
2008-06-01 11:21                             ` Paul Mundt
2008-06-01 11:30                               ` Pekka J Enberg
2008-06-02  5:59                                 ` Paul Mundt
2008-06-02  6:32                                   ` Pekka Enberg
2008-06-02  6:50                                     ` Paul Mundt
2008-06-02  6:58                                       ` Pekka Enberg
2008-06-02  7:01                                         ` Paul Mundt
2008-06-01  8:22                   ` Paul Mundt
2008-05-29 15:00             ` Christoph Lameter

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox