Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 118431
b: refs/heads/master
c: 69d177c
h: refs/heads/master
i:
  118429: 78c7f03
  118427: be8e7cd
  118423: 1e61878
  118415: bb4b6dd
  118399: ca602c6
v: v3
  • Loading branch information
Andy Whitcroft authored and Linus Torvalds committed Nov 6, 2008
1 parent b116a7e commit 5bd77fc
Show file tree
Hide file tree
Showing 3 changed files with 65 additions and 2 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: 22bece00dc1f28dd3374c55e464c9f02eb642876
refs/heads/master: 69d177c2fc702d402b17fdca2190d5a7e3ca55c5
37 changes: 36 additions & 1 deletion trunk/mm/hugetlb.c
Original file line number Diff line number Diff line change
Expand Up @@ -354,24 +354,59 @@ static int vma_has_reserves(struct vm_area_struct *vma)
return 0;
}

static void clear_gigantic_page(struct page *page,
unsigned long addr, unsigned long sz)
{
int i;
struct page *p = page;

might_sleep();
for (i = 0; i < sz/PAGE_SIZE; i++, p = mem_map_next(p, page, i)) {
cond_resched();
clear_user_highpage(p, addr + i * PAGE_SIZE);
}
}
static void clear_huge_page(struct page *page,
unsigned long addr, unsigned long sz)
{
int i;

if (unlikely(sz > MAX_ORDER_NR_PAGES))
return clear_gigantic_page(page, addr, sz);

might_sleep();
for (i = 0; i < sz/PAGE_SIZE; i++) {
cond_resched();
clear_user_highpage(page + i, addr + i * PAGE_SIZE);
}
}

static void copy_gigantic_page(struct page *dst, struct page *src,
unsigned long addr, struct vm_area_struct *vma)
{
int i;
struct hstate *h = hstate_vma(vma);
struct page *dst_base = dst;
struct page *src_base = src;
might_sleep();
for (i = 0; i < pages_per_huge_page(h); ) {
cond_resched();
copy_user_highpage(dst, src, addr + i*PAGE_SIZE, vma);

i++;
dst = mem_map_next(dst, dst_base, i);
src = mem_map_next(src, src_base, i);
}
}
static void copy_huge_page(struct page *dst, struct page *src,
unsigned long addr, struct vm_area_struct *vma)
{
int i;
struct hstate *h = hstate_vma(vma);

if (unlikely(pages_per_huge_page(h) > MAX_ORDER_NR_PAGES))
return copy_gigantic_page(dst, src, addr, vma);

might_sleep();
for (i = 0; i < pages_per_huge_page(h); i++) {
cond_resched();
Expand Down Expand Up @@ -2130,7 +2165,7 @@ int follow_hugetlb_page(struct mm_struct *mm, struct vm_area_struct *vma,
if (zeropage_ok)
pages[i] = ZERO_PAGE(0);
else
pages[i] = page + pfn_offset;
pages[i] = mem_map_offset(page, pfn_offset);
get_page(pages[i]);
}

Expand Down
28 changes: 28 additions & 0 deletions trunk/mm/internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,34 @@ static inline void free_page_mlock(struct page *page) { }

#endif /* CONFIG_UNEVICTABLE_LRU */

/*
* Return the mem_map entry representing the 'offset' subpage within
* the maximally aligned gigantic page 'base'. Handle any discontiguity
* in the mem_map at MAX_ORDER_NR_PAGES boundaries.
*/
static inline struct page *mem_map_offset(struct page *base, int offset)
{
if (unlikely(offset >= MAX_ORDER_NR_PAGES))
return pfn_to_page(page_to_pfn(base) + offset);
return base + offset;
}

/*
* Iterator over all subpages withing the maximally aligned gigantic
* page 'base'. Handle any discontiguity in the mem_map.
*/
static inline struct page *mem_map_next(struct page *iter,
struct page *base, int offset)
{
if (unlikely((offset & (MAX_ORDER_NR_PAGES - 1)) == 0)) {
unsigned long pfn = page_to_pfn(base) + offset;
if (!pfn_valid(pfn))
return NULL;
return pfn_to_page(pfn);
}
return iter + 1;
}

/*
* FLATMEM and DISCONTIGMEM configurations use alloc_bootmem_node,
* so all functions starting at paging_init should be marked __init
Expand Down

0 comments on commit 5bd77fc

Please sign in to comment.