From: chengang@emindsoft.com.cn
To: akpm@linux-foundation.org
Cc: aarcange@redhat.com, rientjes@google.com,
linux-kernel@vger.kernel.org,
Chen Gang <chengang@emindsoft.com.cn>,
Chen Gang <gang.chen.5i5j@gmail.com>
Subject: [PATCH] include/linux/khugepaged.h: Improve the code only
Date: Mon, 16 May 2016 06:20:51 +0800 [thread overview]
Message-ID: <1463350851-1941-1-git-send-email-chengang@emindsoft.com.cn> (raw)
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
reply other threads:[~2016-05-15 22:26 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1463350851-1941-1-git-send-email-chengang@emindsoft.com.cn \
--to=chengang@emindsoft.com.cn \
--cc=aarcange@redhat.com \
--cc=akpm@linux-foundation.org \
--cc=gang.chen.5i5j@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=rientjes@google.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®