瀏覽代碼

mm/hugetlb: don't crash when HPAGE_SHIFT is 0

Some platform decide whether they support huge pages at boot time.  On
these, such as powerpc, HPAGE_SHIFT is a variable, not a constant, and is
set to 0 when there is no such support.

The patches to introduce multiple huge pages support broke that causing
the kernel to crash at boot time on machines such as POWER3 which lack
support for multiple page sizes.

Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Benjamin Herrenschmidt 17 年之前
父節點
當前提交
0ef89d25d3
共有 1 個文件被更改,包括 6 次插入1 次删除
  1. 6 1
      mm/hugetlb.c

+ 6 - 1
mm/hugetlb.c

@@ -1283,7 +1283,12 @@ module_exit(hugetlb_exit);
 
 
 static int __init hugetlb_init(void)
 static int __init hugetlb_init(void)
 {
 {
-	BUILD_BUG_ON(HPAGE_SHIFT == 0);
+	/* Some platform decide whether they support huge pages at boot
+	 * time. On these, such as powerpc, HPAGE_SHIFT is set to 0 when
+	 * there is no such support
+	 */
+	if (HPAGE_SHIFT == 0)
+		return 0;
 
 
 	if (!size_to_hstate(default_hstate_size)) {
 	if (!size_to_hstate(default_hstate_size)) {
 		default_hstate_size = HPAGE_SIZE;
 		default_hstate_size = HPAGE_SIZE;