summaryrefslogtreecommitdiffstats
path: root/include/linux/slub_def.h
diff options
context:
space:
mode:
authorChristoph Lameter <cl@linux.com>2011-05-20 09:42:48 -0500
committerPekka Enberg <penberg@kernel.org>2011-05-21 12:53:53 +0300
commit3e0c2ab67e48f77c2da0a5c826aac397792a214e (patch)
tree937d195659cb72bbd038907e36b23e5c0e7c262d /include/linux/slub_def.h
parent442b06bcea23a01934d3da7ec5898fa154a6cafb (diff)
downloadop-kernel-dev-3e0c2ab67e48f77c2da0a5c826aac397792a214e.zip
op-kernel-dev-3e0c2ab67e48f77c2da0a5c826aac397792a214e.tar.gz
slub: Deal with hyperthetical case of PAGE_SIZE > 2M
kmalloc_index() currently returns -1 if the PAGE_SIZE is larger than 2M which seems to cause some concern since the callers do not check for -1. Insert a BUG() and add a comment to the -1 explaining that the code cannot be reached. Signed-off-by: Christoph Lameter <cl@linux.com> Signed-off-by: Pekka Enberg <penberg@kernel.org>
Diffstat (limited to 'include/linux/slub_def.h')
-rw-r--r--include/linux/slub_def.h6
1 files changed, 4 insertions, 2 deletions
diff --git a/include/linux/slub_def.h b/include/linux/slub_def.h
index ca0c076..c8668d1 100644
--- a/include/linux/slub_def.h
+++ b/include/linux/slub_def.h
@@ -177,7 +177,8 @@ static __always_inline int kmalloc_index(size_t size)
if (size <= 4 * 1024) return 12;
/*
* The following is only needed to support architectures with a larger page
- * size than 4k.
+ * size than 4k. We need to support 2 * PAGE_SIZE here. So for a 64k page
+ * size we would have to go up to 128k.
*/
if (size <= 8 * 1024) return 13;
if (size <= 16 * 1024) return 14;
@@ -188,7 +189,8 @@ static __always_inline int kmalloc_index(size_t size)
if (size <= 512 * 1024) return 19;
if (size <= 1024 * 1024) return 20;
if (size <= 2 * 1024 * 1024) return 21;
- return -1;
+ BUG();
+ return -1; /* Will never be reached */
/*
* What we really wanted to do and cannot do because of compiler issues is:
OpenPOWER on IntegriCloud