瀏覽代碼

powerpc/mm/hash64: Factor out hash preload psize check

Currently we have a check in hash_preload() against the psize, which is
only included when CONFIG_PPC_MM_SLICES is enabled. We want to expand
this check in a subsequent patch, so factor it out to allow that. As a
bonus it removes the #ifdef in the C code.

Unfortunately we can't put this in the existing CONFIG_PPC_MM_SLICES
block because it would require a forward declaration.

Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Michael Ellerman 9 年之前
父節點
當前提交
8bbc9b7b00
共有 1 個文件被更改,包括 17 次插入4 次删除
  1. 17 4
      arch/powerpc/mm/hash_utils_64.c

+ 17 - 4
arch/powerpc/mm/hash_utils_64.c

@@ -1322,6 +1322,22 @@ int __hash_page(unsigned long ea, unsigned long msr, unsigned long trap,
 	return hash_page_mm(mm, ea, access, trap, flags);
 	return hash_page_mm(mm, ea, access, trap, flags);
 }
 }
 
 
+#ifdef CONFIG_PPC_MM_SLICES
+static bool should_hash_preload(struct mm_struct *mm, unsigned long ea)
+{
+	/* We only prefault standard pages for now */
+	if (unlikely(get_slice_psize(mm, ea) != mm->context.user_psize))
+		return false;
+
+	return true;
+}
+#else
+static bool should_hash_preload(struct mm_struct *mm, unsigned long ea)
+{
+	return true;
+}
+#endif
+
 void hash_preload(struct mm_struct *mm, unsigned long ea,
 void hash_preload(struct mm_struct *mm, unsigned long ea,
 		  unsigned long access, unsigned long trap)
 		  unsigned long access, unsigned long trap)
 {
 {
@@ -1334,11 +1350,8 @@ void hash_preload(struct mm_struct *mm, unsigned long ea,
 
 
 	BUG_ON(REGION_ID(ea) != USER_REGION_ID);
 	BUG_ON(REGION_ID(ea) != USER_REGION_ID);
 
 
-#ifdef CONFIG_PPC_MM_SLICES
-	/* We only prefault standard pages for now */
-	if (unlikely(get_slice_psize(mm, ea) != mm->context.user_psize))
+	if (!should_hash_preload(mm, ea))
 		return;
 		return;
-#endif
 
 
 	DBG_LOW("hash_preload(mm=%p, mm->pgdir=%p, ea=%016lx, access=%lx,"
 	DBG_LOW("hash_preload(mm=%p, mm->pgdir=%p, ea=%016lx, access=%lx,"
 		" trap=%lx\n", mm, mm->pgd, ea, access, trap);
 		" trap=%lx\n", mm, mm->pgd, ea, access, trap);