public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Guanjun He <heguanbo@gmail.com>
To: linux-kernel@vger.kernel.org
Cc: Guanjun He <heguanbo@gmail.com>
Subject: [PATCH][mm] adjust the logic of checking THP
Date: Wed,  2 Nov 2011 14:34:30 +0800	[thread overview]
Message-ID: <1320215670-10157-1-git-send-email-heguanbo@gmail.com> (raw)
In-Reply-To: <pebolle@tiscali.nl;linux-kernel@vger.kernel.org;linux-mm@kvack.org;gjhe@suse.com>


Acturally, pmd_trans_huge(orig_pmd) only checks the _PAGE_PSE bits,
it's a pmd entry bits, only mark a size, not a flag;As one can easily 
create the same pmd entry bits for some special use,then the check 
will get confused.And this patch is to adjust the logic to use the flag, 
it can perfectly avoid this potential issuse,and basically no impact 
to the current code.


Signed-off-by: Guanjun He <heguanbo@gmail.com>
---
 mm/memory.c |   28 +++++++++++++++-------------
 1 files changed, 15 insertions(+), 13 deletions(-)

diff --git a/mm/memory.c b/mm/memory.c
index a56e3ba..a76b17f 100644
--- a/mm/memory.c
+++ b/mm/memory.c
@@ -3465,20 +3465,22 @@ int handle_mm_fault(struct mm_struct *mm, struct vm_area_struct *vma,
 	pmd = pmd_alloc(mm, pud, address);
 	if (!pmd)
 		return VM_FAULT_OOM;
-	if (pmd_none(*pmd) && transparent_hugepage_enabled(vma)) {
-		if (!vma->vm_ops)
-			return do_huge_pmd_anonymous_page(mm, vma, address,
-							  pmd, flags);
-	} else {
-		pmd_t orig_pmd = *pmd;
-		barrier();
-		if (pmd_trans_huge(orig_pmd)) {
-			if (flags & FAULT_FLAG_WRITE &&
-			    !pmd_write(orig_pmd) &&
-			    !pmd_trans_splitting(orig_pmd))
-				return do_huge_pmd_wp_page(mm, vma, address,
-							   pmd, orig_pmd);
+	if (transparent_hugepage_enabled(vma)) {
+		if (pmd_none(*pmd)) {
+			if (!vma->vm_ops)
+				return do_huge_pmd_anonymous_page(mm, vma, address,
+								  pmd, flags);
+		} else {
+			pmd_t orig_pmd = *pmd;
+			barrier();
+			if (pmd_trans_huge(orig_pmd)) {
+				if (flags & FAULT_FLAG_WRITE &&
+				    !pmd_write(orig_pmd) &&
+				    !pmd_trans_splitting(orig_pmd))
+					return do_huge_pmd_wp_page(mm, vma, address,
+								   pmd, orig_pmd);
 			return 0;
+			}
 		}
 	}
 
-- 
1.7.7


       reply	other threads:[~2011-11-02  6:34 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <pebolle@tiscali.nl;linux-kernel@vger.kernel.org;linux-mm@kvack.org;gjhe@suse.com>
2011-11-02  6:34 ` Guanjun He [this message]
2011-11-02 12:17   ` [PATCH][mm] adjust the logic of checking THP Hillf Danton
2011-11-03  2:19     ` GuanJun He
2011-11-04  2:41       ` GuanJun He
2011-11-23  0:04   ` Andrea Arcangeli
2011-12-06  4:18     ` GuanJun He
     [not found] <shaohua.li@intel.com;linux-mm@kvack.org;linux-kernel@vger.kernel.org>
2011-11-01 11:41 ` [PATCH][mm:] " Guanjun He
2011-11-01 12:26   ` Paul Bolle
2011-11-01 12:29     ` Paul Bolle
2011-11-03  8:26     ` GuanJun He

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=1320215670-10157-1-git-send-email-heguanbo@gmail.com \
    --to=heguanbo@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    /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