From: Adam Litke <agl@us.ibm.com>
To: akpm@osdl.org
Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org,
David Gibson <david@gibson.dropbear.id.au>,
wli@holomorphy.com, hugh@veritas.com, rohit.seth@intel.com,
kenneth.w.chen@intel.com, "ADAM G. LITKE [imap]" <agl@us.ibm.com>
Subject: [PATCH 3/4] Hugetlb: Reorganize hugetlb_fault to prepare for COW
Date: Wed, 09 Nov 2005 17:38:47 -0600 [thread overview]
Message-ID: <1131579527.28383.22.camel@localhost.localdomain> (raw)
In-Reply-To: <1131578925.28383.9.camel@localhost.localdomain>
Hugetlb: Reorganize hugetlb_fault to prepare for COW
This patch splits the "no_page()" type activity into its own function,
hugetlb_no_page(). hugetlb_fault() becomes the entry point for hugetlb faults
and delegates to the appropriate handler depending on the type of fault. Right
now we still have only hugetlb_no_page() but a later patch introduces a COW
fault.
Original post by David Gibson <david@gibson.dropbear.id.au>
Version 2: Wed 9 Nov 2005
Broken out into a separate patch
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
Signed-off-by: Adam Litke <agl@us.ibm.com>
---
hugetlb.c | 34 +++++++++++++++++++++++++---------
1 files changed, 25 insertions(+), 9 deletions(-)
diff -upN reference/mm/hugetlb.c current/mm/hugetlb.c
--- reference/mm/hugetlb.c
+++ current/mm/hugetlb.c
@@ -370,20 +370,15 @@ out:
return page;
}
-int hugetlb_fault(struct mm_struct *mm, struct vm_area_struct *vma,
- unsigned long address, int write_access)
+int hugetlb_no_page(struct mm_struct *mm, struct vm_area_struct *vma,
+ unsigned long address, pte_t *ptep)
{
int ret = VM_FAULT_SIGBUS;
unsigned long idx;
unsigned long size;
- pte_t *pte;
struct page *page;
struct address_space *mapping;
- pte = huge_pte_alloc(mm, address);
- if (!pte)
- goto out;
-
mapping = vma->vm_file->f_mapping;
idx = ((address - vma->vm_start) >> HPAGE_SHIFT)
+ (vma->vm_pgoff >> (HPAGE_SHIFT - PAGE_SHIFT));
@@ -402,11 +397,11 @@ int hugetlb_fault(struct mm_struct *mm,
goto backout;
ret = VM_FAULT_MINOR;
- if (!pte_none(*pte))
+ if (!pte_none(*ptep))
goto backout;
add_mm_counter(mm, file_rss, HPAGE_SIZE / PAGE_SIZE);
- set_huge_pte_at(mm, address, pte, make_huge_pte(vma, page));
+ set_huge_pte_at(mm, address, ptep, make_huge_pte(vma, page));
spin_unlock(&mm->page_table_lock);
unlock_page(page);
out:
@@ -420,6 +415,27 @@ backout:
goto out;
}
+int hugetlb_fault(struct mm_struct *mm, struct vm_area_struct *vma,
+ unsigned long address, int write_access)
+{
+ pte_t *ptep;
+ pte_t entry;
+
+ ptep = huge_pte_alloc(mm, address);
+ if (!ptep)
+ return VM_FAULT_OOM;
+
+ entry = *ptep;
+ if (pte_none(entry))
+ return hugetlb_no_page(mm, vma, address, ptep);
+
+ /*
+ * We could get here if another thread instantiated the pte
+ * before the test above.
+ */
+ return VM_FAULT_MINOR;
+}
+
int follow_hugetlb_page(struct mm_struct *mm, struct vm_area_struct *vma,
struct page **pages, struct vm_area_struct **vmas,
unsigned long *position, int *length, int i)
--
Adam Litke - (agl at us.ibm.com)
IBM Linux Technology Center
WARNING: multiple messages have this Message-ID (diff)
From: Adam Litke <agl@us.ibm.com>
To: akpm@osdl.org
Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org,
David Gibson <david@gibson.dropbear.id.au>,
wli@holomorphy.com, hugh@veritas.com, rohit.seth@intel.com,
kenneth.w.chen@intel.com, "ADAM G. LITKE [imap]" <agl@us.ibm.com>
Subject: [PATCH 3/4] Hugetlb: Reorganize hugetlb_fault to prepare for COW
Date: Wed, 09 Nov 2005 17:38:47 -0600 [thread overview]
Message-ID: <1131579527.28383.22.camel@localhost.localdomain> (raw)
In-Reply-To: <1131578925.28383.9.camel@localhost.localdomain>
This patch splits the "no_page()" type activity into its own function,
hugetlb_no_page(). hugetlb_fault() becomes the entry point for hugetlb faults
and delegates to the appropriate handler depending on the type of fault. Right
now we still have only hugetlb_no_page() but a later patch introduces a COW
fault.
Original post by David Gibson <david@gibson.dropbear.id.au>
Version 2: Wed 9 Nov 2005
Broken out into a separate patch
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
Signed-off-by: Adam Litke <agl@us.ibm.com>
---
hugetlb.c | 34 +++++++++++++++++++++++++---------
1 files changed, 25 insertions(+), 9 deletions(-)
diff -upN reference/mm/hugetlb.c current/mm/hugetlb.c
--- reference/mm/hugetlb.c
+++ current/mm/hugetlb.c
@@ -370,20 +370,15 @@ out:
return page;
}
-int hugetlb_fault(struct mm_struct *mm, struct vm_area_struct *vma,
- unsigned long address, int write_access)
+int hugetlb_no_page(struct mm_struct *mm, struct vm_area_struct *vma,
+ unsigned long address, pte_t *ptep)
{
int ret = VM_FAULT_SIGBUS;
unsigned long idx;
unsigned long size;
- pte_t *pte;
struct page *page;
struct address_space *mapping;
- pte = huge_pte_alloc(mm, address);
- if (!pte)
- goto out;
-
mapping = vma->vm_file->f_mapping;
idx = ((address - vma->vm_start) >> HPAGE_SHIFT)
+ (vma->vm_pgoff >> (HPAGE_SHIFT - PAGE_SHIFT));
@@ -402,11 +397,11 @@ int hugetlb_fault(struct mm_struct *mm,
goto backout;
ret = VM_FAULT_MINOR;
- if (!pte_none(*pte))
+ if (!pte_none(*ptep))
goto backout;
add_mm_counter(mm, file_rss, HPAGE_SIZE / PAGE_SIZE);
- set_huge_pte_at(mm, address, pte, make_huge_pte(vma, page));
+ set_huge_pte_at(mm, address, ptep, make_huge_pte(vma, page));
spin_unlock(&mm->page_table_lock);
unlock_page(page);
out:
@@ -420,6 +415,27 @@ backout:
goto out;
}
+int hugetlb_fault(struct mm_struct *mm, struct vm_area_struct *vma,
+ unsigned long address, int write_access)
+{
+ pte_t *ptep;
+ pte_t entry;
+
+ ptep = huge_pte_alloc(mm, address);
+ if (!ptep)
+ return VM_FAULT_OOM;
+
+ entry = *ptep;
+ if (pte_none(entry))
+ return hugetlb_no_page(mm, vma, address, ptep);
+
+ /*
+ * We could get here if another thread instantiated the pte
+ * before the test above.
+ */
+ return VM_FAULT_MINOR;
+}
+
int follow_hugetlb_page(struct mm_struct *mm, struct vm_area_struct *vma,
struct page **pages, struct vm_area_struct **vmas,
unsigned long *position, int *length, int i)
--
Adam Litke - (agl at us.ibm.com)
IBM Linux Technology Center
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
next prev parent reply other threads:[~2005-11-09 23:39 UTC|newest]
Thread overview: 28+ messages / expand[flat|nested] mbox.gz Atom feed top
2005-11-09 23:28 [PATCH 0/4] hugetlb: copy on write Adam Litke
2005-11-09 23:28 ` Adam Litke
2005-11-09 23:36 ` [PATCH 1/4] Hugetlb: Remove duplicate i_size check Adam Litke
2005-11-09 23:36 ` Adam Litke
2005-11-10 0:10 ` William Lee Irwin III
2005-11-10 0:10 ` William Lee Irwin III
2005-11-09 23:37 ` [PATCH 2/4] Hugetlb: Rename find_lock_page to find_or_alloc_huge_page Adam Litke
2005-11-09 23:37 ` Adam Litke
2005-11-10 0:11 ` William Lee Irwin III
2005-11-10 0:11 ` William Lee Irwin III
2005-11-09 23:38 ` Adam Litke [this message]
2005-11-09 23:38 ` [PATCH 3/4] Hugetlb: Reorganize hugetlb_fault to prepare for COW Adam Litke
2005-11-10 0:13 ` William Lee Irwin III
2005-11-10 0:13 ` William Lee Irwin III
2005-11-09 23:39 ` [PATCH 4/4] Hugetlb: Copy on Write support Adam Litke
2005-11-09 23:39 ` Adam Litke
2005-11-10 0:15 ` William Lee Irwin III
2005-11-10 0:15 ` William Lee Irwin III
2005-11-10 0:49 ` David Gibson
2005-11-10 0:49 ` David Gibson
2005-11-10 0:56 ` William Lee Irwin III
2005-11-10 0:56 ` William Lee Irwin III
2005-11-10 1:52 ` Rohit Seth
2005-11-10 1:52 ` Rohit Seth
2005-11-10 3:54 ` David Gibson
2005-11-10 3:54 ` David Gibson
2005-11-10 4:20 ` William Lee Irwin III
2005-11-10 4:20 ` William Lee Irwin III
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=1131579527.28383.22.camel@localhost.localdomain \
--to=agl@us.ibm.com \
--cc=akpm@osdl.org \
--cc=david@gibson.dropbear.id.au \
--cc=hugh@veritas.com \
--cc=kenneth.w.chen@intel.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=rohit.seth@intel.com \
--cc=wli@holomorphy.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.