Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 105311
b: refs/heads/master
c: 39c11e6
h: refs/heads/master
i:
  105309: 06e3d34
  105307: fd01ac1
  105303: 28e843e
  105295: ee2ad89
  105279: 812b1ae
v: v3
  • Loading branch information
Andi Kleen authored and Linus Torvalds committed Jul 24, 2008
1 parent 5da13fc commit 97e2260
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 12 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: ceb868796181dc95ea01a110e123afd391639873
refs/heads/master: 39c11e6c05b7fedbf7ed4df3908b25f622d56204
33 changes: 22 additions & 11 deletions trunk/arch/x86/mm/hugetlbpage.c
Original file line number Diff line number Diff line change
Expand Up @@ -134,9 +134,14 @@ pte_t *huge_pte_alloc(struct mm_struct *mm,
pgd = pgd_offset(mm, addr);
pud = pud_alloc(mm, pgd, addr);
if (pud) {
if (pud_none(*pud))
huge_pmd_share(mm, addr, pud);
pte = (pte_t *) pmd_alloc(mm, pud, addr);
if (sz == PUD_SIZE) {
pte = (pte_t *)pud;
} else {
BUG_ON(sz != PMD_SIZE);
if (pud_none(*pud))
huge_pmd_share(mm, addr, pud);
pte = (pte_t *) pmd_alloc(mm, pud, addr);
}
}
BUG_ON(pte && !pte_none(*pte) && !pte_huge(*pte));

Expand All @@ -152,8 +157,11 @@ pte_t *huge_pte_offset(struct mm_struct *mm, unsigned long addr)
pgd = pgd_offset(mm, addr);
if (pgd_present(*pgd)) {
pud = pud_offset(pgd, addr);
if (pud_present(*pud))
if (pud_present(*pud)) {
if (pud_large(*pud))
return (pte_t *)pud;
pmd = pmd_offset(pud, addr);
}
}
return (pte_t *) pmd;
}
Expand Down Expand Up @@ -216,7 +224,7 @@ int pmd_huge(pmd_t pmd)

int pud_huge(pud_t pud)
{
return 0;
return !!(pud_val(pud) & _PAGE_PSE);
}

struct page *
Expand Down Expand Up @@ -252,6 +260,7 @@ static unsigned long hugetlb_get_unmapped_area_bottomup(struct file *file,
unsigned long addr, unsigned long len,
unsigned long pgoff, unsigned long flags)
{
struct hstate *h = hstate_file(file);
struct mm_struct *mm = current->mm;
struct vm_area_struct *vma;
unsigned long start_addr;
Expand All @@ -264,7 +273,7 @@ static unsigned long hugetlb_get_unmapped_area_bottomup(struct file *file,
}

full_search:
addr = ALIGN(start_addr, HPAGE_SIZE);
addr = ALIGN(start_addr, huge_page_size(h));

for (vma = find_vma(mm, addr); ; vma = vma->vm_next) {
/* At this point: (!vma || addr < vma->vm_end). */
Expand All @@ -286,14 +295,15 @@ static unsigned long hugetlb_get_unmapped_area_bottomup(struct file *file,
}
if (addr + mm->cached_hole_size < vma->vm_start)
mm->cached_hole_size = vma->vm_start - addr;
addr = ALIGN(vma->vm_end, HPAGE_SIZE);
addr = ALIGN(vma->vm_end, huge_page_size(h));
}
}

static unsigned long hugetlb_get_unmapped_area_topdown(struct file *file,
unsigned long addr0, unsigned long len,
unsigned long pgoff, unsigned long flags)
{
struct hstate *h = hstate_file(file);
struct mm_struct *mm = current->mm;
struct vm_area_struct *vma, *prev_vma;
unsigned long base = mm->mmap_base, addr = addr0;
Expand All @@ -314,7 +324,7 @@ static unsigned long hugetlb_get_unmapped_area_topdown(struct file *file,
goto fail;

/* either no address requested or cant fit in requested address hole */
addr = (mm->free_area_cache - len) & HPAGE_MASK;
addr = (mm->free_area_cache - len) & huge_page_mask(h);
do {
/*
* Lookup failure means no vma is above this address,
Expand Down Expand Up @@ -345,7 +355,7 @@ static unsigned long hugetlb_get_unmapped_area_topdown(struct file *file,
largest_hole = vma->vm_start - addr;

/* try just below the current vma->vm_start */
addr = (vma->vm_start - len) & HPAGE_MASK;
addr = (vma->vm_start - len) & huge_page_mask(h);
} while (len <= vma->vm_start);

fail:
Expand Down Expand Up @@ -383,10 +393,11 @@ unsigned long
hugetlb_get_unmapped_area(struct file *file, unsigned long addr,
unsigned long len, unsigned long pgoff, unsigned long flags)
{
struct hstate *h = hstate_file(file);
struct mm_struct *mm = current->mm;
struct vm_area_struct *vma;

if (len & ~HPAGE_MASK)
if (len & ~huge_page_mask(h))
return -EINVAL;
if (len > TASK_SIZE)
return -ENOMEM;
Expand All @@ -398,7 +409,7 @@ hugetlb_get_unmapped_area(struct file *file, unsigned long addr,
}

if (addr) {
addr = ALIGN(addr, HPAGE_SIZE);
addr = ALIGN(addr, huge_page_size(h));
vma = find_vma(mm, addr);
if (TASK_SIZE - len >= addr &&
(!vma || addr + len <= vma->vm_start))
Expand Down

0 comments on commit 97e2260

Please sign in to comment.