lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [day] [month] [year] [list]
Message-Id: <1463350851-1941-1-git-send-email-chengang@emindsoft.com.cn>
Date:	Mon, 16 May 2016 06:20:51 +0800
From:	chengang@...ndsoft.com.cn
To:	akpm@...ux-foundation.org
Cc:	aarcange@...hat.com, rientjes@...gle.com,
	linux-kernel@...r.kernel.org,
	Chen Gang <chengang@...ndsoft.com.cn>,
	Chen Gang <gang.chen.5i5j@...il.com>
Subject: [PATCH] include/linux/khugepaged.h: Improve the code only

From: Chen Gang <chengang@...ndsoft.com.cn>

khugepaged_enabled() can be treated as khugepaged_always() or
khugepaged_req_madv(). The compiler will always treat it as "and 3".

khugepaged_enter() can return __khugepaged_enter() result directly,
since __khugepaged_enter() will return 0 or -ENOMEM.

Signed-off-by: Chen Gang <gang.chen.5i5j@...il.com>
---
 include/linux/khugepaged.h | 22 +++++++++-------------
 1 file changed, 9 insertions(+), 13 deletions(-)

diff --git a/include/linux/khugepaged.h b/include/linux/khugepaged.h
index eeb3079..0df1c1d 100644
--- a/include/linux/khugepaged.h
+++ b/include/linux/khugepaged.h
@@ -9,19 +9,16 @@ extern void __khugepaged_exit(struct mm_struct *mm);
 extern int khugepaged_enter_vma_merge(struct vm_area_struct *vma,
 				      unsigned long vm_flags);
 
-#define khugepaged_enabled()					       \
-	(transparent_hugepage_flags &				       \
-	 ((1<<TRANSPARENT_HUGEPAGE_FLAG) |		       \
-	  (1<<TRANSPARENT_HUGEPAGE_REQ_MADV_FLAG)))
 #define khugepaged_always()				\
 	(transparent_hugepage_flags &			\
-	 (1<<TRANSPARENT_HUGEPAGE_FLAG))
-#define khugepaged_req_madv()					\
-	(transparent_hugepage_flags &				\
-	 (1<<TRANSPARENT_HUGEPAGE_REQ_MADV_FLAG))
-#define khugepaged_defrag()					\
-	(transparent_hugepage_flags &				\
-	 (1<<TRANSPARENT_HUGEPAGE_DEFRAG_KHUGEPAGED_FLAG))
+	 (1 << TRANSPARENT_HUGEPAGE_FLAG))
+#define khugepaged_req_madv()				\
+	(transparent_hugepage_flags &			\
+	 (1 << TRANSPARENT_HUGEPAGE_REQ_MADV_FLAG))
+#define khugepaged_enabled()	(khugepaged_always() | khugepaged_req_madv())
+#define khugepaged_defrag()				\
+	(transparent_hugepage_flags &			\
+	 (1 << TRANSPARENT_HUGEPAGE_DEFRAG_KHUGEPAGED_FLAG))
 
 static inline int khugepaged_fork(struct mm_struct *mm, struct mm_struct *oldmm)
 {
@@ -43,8 +40,7 @@ static inline int khugepaged_enter(struct vm_area_struct *vma,
 		if ((khugepaged_always() ||
 		     (khugepaged_req_madv() && (vm_flags & VM_HUGEPAGE))) &&
 		    !(vm_flags & VM_NOHUGEPAGE))
-			if (__khugepaged_enter(vma->vm_mm))
-				return -ENOMEM;
+			return __khugepaged_enter(vma->vm_mm);
 	return 0;
 }
 #else /* CONFIG_TRANSPARENT_HUGEPAGE */
-- 
1.9.3

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ