lkml.org 
[lkml]   [2016]   [May]   [15]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH] include/linux/khugepaged.h: Improve the code only
Date
From: Chen Gang <chengang@emindsoft.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@gmail.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
\
 
 \ /
  Last update: 2016-05-16 00:41    [W:0.055 / U:0.036 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site