Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 115871
b: refs/heads/master
c: 4b2e38a
h: refs/heads/master
i:
  115869: f586b47
  115867: 5b56cc9
  115863: 54c5a8d
  115855: caddaf0
  115839: 6c0a546
v: v3
  • Loading branch information
KOSAKI Motohiro authored and Linus Torvalds committed Oct 20, 2008
1 parent 71cc3b6 commit 31cfd7b
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 4 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: e575f111dc0f27044e170580e7de50985ab3e011
refs/heads/master: 4b2e38ad703541f7845c2d766426148b8d1aa329
22 changes: 19 additions & 3 deletions trunk/mm/hugetlb.c
Original file line number Diff line number Diff line change
Expand Up @@ -2071,6 +2071,14 @@ follow_huge_pud(struct mm_struct *mm, unsigned long address,
return NULL;
}

static int huge_zeropage_ok(pte_t *ptep, int write, int shared)
{
if (!ptep || write || shared)
return 0;
else
return huge_pte_none(huge_ptep_get(ptep));
}

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,
Expand All @@ -2080,6 +2088,8 @@ int follow_hugetlb_page(struct mm_struct *mm, struct vm_area_struct *vma,
unsigned long vaddr = *position;
int remainder = *length;
struct hstate *h = hstate_vma(vma);
int zeropage_ok = 0;
int shared = vma->vm_flags & VM_SHARED;

spin_lock(&mm->page_table_lock);
while (vaddr < vma->vm_end && remainder) {
Expand All @@ -2092,8 +2102,11 @@ int follow_hugetlb_page(struct mm_struct *mm, struct vm_area_struct *vma,
* first, for the page indexing below to work.
*/
pte = huge_pte_offset(mm, vaddr & huge_page_mask(h));
if (huge_zeropage_ok(pte, write, shared))
zeropage_ok = 1;

if (!pte || huge_pte_none(huge_ptep_get(pte)) ||
if (!pte ||
(huge_pte_none(huge_ptep_get(pte)) && !zeropage_ok) ||
(write && !pte_write(huge_ptep_get(pte)))) {
int ret;

Expand All @@ -2113,8 +2126,11 @@ int follow_hugetlb_page(struct mm_struct *mm, struct vm_area_struct *vma,
page = pte_page(huge_ptep_get(pte));
same_page:
if (pages) {
get_page(page);
pages[i] = page + pfn_offset;
if (zeropage_ok)
pages[i] = ZERO_PAGE(0);
else
pages[i] = page + pfn_offset;
get_page(pages[i]);
}

if (vmas)
Expand Down

0 comments on commit 31cfd7b

Please sign in to comment.