public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [RFC/PATCH 1/3] SLAB: Add PageSlab checking to ksize()
@ 2008-05-21 18:25 Pekka J Enberg
  2008-05-21 23:45 ` Paul Mundt
  0 siblings, 1 reply; 13+ messages in thread
From: Pekka J Enberg @ 2008-05-21 18:25 UTC (permalink / raw)
  To: linux-kernel; +Cc: clameter, mpm, lethal, dhowells

From: Pekka Enberg <penberg@cs.helsinki.fi>

The ksize() function is meant for objects allocated from the slab caches, not
for arbitrary objects. Add a BUG_ON() to enforce that.

Cc: Christoph Lameter <clameter@sgi.com>
Cc: Matt Mackall <mpm@selenic.com>
Cc: Paul Mundt <lethal@linux-sh.org>
Cc: David Howells <dhowells@redhat.com>
Signed-off-by: Pekka Enberg <penberg@cs.helsinki.fi>
---
 mm/slab.c |    6 +++++-
 1 files changed, 5 insertions(+), 1 deletions(-)

diff --git a/mm/slab.c b/mm/slab.c
index 06236e4..b98bb7c 100644
--- a/mm/slab.c
+++ b/mm/slab.c
@@ -4472,10 +4472,14 @@ const struct seq_operations slabstats_op = {
  */
 size_t ksize(const void *objp)
 {
+	struct page *page;
+
 	BUG_ON(!objp);
 	if (unlikely(objp == ZERO_SIZE_PTR))
 		return 0;
 
-	return obj_size(virt_to_cache(objp));
+	page = virt_to_page(objp);
+	BUG_ON(!PageSlab(page));
+	return obj_size(page_get_cache(page));
 }
 EXPORT_SYMBOL(ksize);
-- 
1.5.2.5


^ permalink raw reply related	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2008-05-23 14:27 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-05-21 18:25 [RFC/PATCH 1/3] SLAB: Add PageSlab checking to ksize() Pekka J Enberg
2008-05-21 23:45 ` Paul Mundt
2008-05-22  4:13   ` Pekka Enberg
2008-05-22  4:17     ` Christoph Lameter
2008-05-22  4:21       ` Pekka Enberg
2008-05-22  4:34         ` Paul Mundt
2008-05-22  4:43           ` Pekka Enberg
2008-05-22  4:55             ` Paul Mundt
2008-05-22 15:01             ` Matt Mackall
2008-05-22 16:13               ` Pekka Enberg
2008-05-22 16:51                 ` Christoph Lameter
2008-05-22 18:31                 ` Matt Mackall
2008-05-23 14:23                 ` Adrian Bunk

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