Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 3bf5ee95 authored by Hugh Dickins's avatar Hugh Dickins Committed by Linus Torvalds
Browse files

[PATCH] freepgt: hugetlb_free_pgd_range



ia64 and ppc64 had hugetlb_free_pgtables functions which were no longer being
called, and it wasn't obvious what to do about them.

The ppc64 case turns out to be easy: the associated tables are noted elsewhere
and freed later, safe to either skip its hugetlb areas or go through the
motions of freeing nothing.  Since ia64 does need a special case, restore to
ppc64 the special case of skipping them.

The ia64 hugetlb case has been broken since pgd_addr_end went in, though it
probably appeared to work okay if you just had one such area; in fact it's
been broken much longer if you consider a long munmap spanning from another
region into the hugetlb region.

In the ia64 hugetlb region, more virtual address bits are available than in
the other regions, yet the page tables are structured the same way: the page
at the bottom is larger.  Here we need to scale down each addr before passing
it to the standard free_pgd_range.  Was about to write a hugely_scaled_down
macro, but found htlbpage_to_page already exists for just this purpose.  Fixed
off-by-one in ia64 is_hugepage_only_range.

Uninline free_pgd_range to make it available to ia64.  Make sure the
vma-gathering loop in free_pgtables cannot join a hugepage_only_range to any
other (safe to join huges?  probably but don't bother).

Signed-off-by: default avatarHugh Dickins <hugh@veritas.com>
Signed-off-by: default avatarAndrew Morton <akpm@osdl.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@osdl.org>
parent ee39b37b
Loading
Loading
Loading
Loading
+23 −6
Original line number Diff line number Diff line
@@ -186,13 +186,30 @@ follow_huge_pmd(struct mm_struct *mm, unsigned long address, pmd_t *pmd, int wri
	return NULL;
}

void hugetlb_free_pgd_range(struct mmu_gather **tlb,
			unsigned long addr, unsigned long end,
			unsigned long floor, unsigned long ceiling)
{
	/*
 * Do nothing, until we've worked out what to do!  To allow build, we
 * must remove reference to clear_page_range since it no longer exists.
	 * This is called only when is_hugepage_only_range(addr,),
	 * and it follows that is_hugepage_only_range(end,) also.
	 *
	 * The offset of these addresses from the base of the hugetlb
	 * region must be scaled down by HPAGE_SIZE/PAGE_SIZE so that
	 * the standard free_pgd_range will free the right page tables.
	 *
	 * If floor and ceiling are also in the hugetlb region, they
	 * must likewise be scaled down; but if outside, left unchanged.
	 */
void hugetlb_free_pgtables(struct mmu_gather *tlb, struct vm_area_struct *prev,
	unsigned long start, unsigned long end)
{

	addr = htlbpage_to_page(addr);
	end  = htlbpage_to_page(end);
	if (is_hugepage_only_range(tlb->mm, floor, HPAGE_SIZE))
		floor = htlbpage_to_page(floor);
	if (is_hugepage_only_range(tlb->mm, ceiling, HPAGE_SIZE))
		ceiling = htlbpage_to_page(ceiling);

	free_pgd_range(tlb, addr, end, floor, ceiling);
}

void unmap_hugepage_range(struct vm_area_struct *vma, unsigned long start, unsigned long end)
+0 −10
Original line number Diff line number Diff line
@@ -430,16 +430,6 @@ void unmap_hugepage_range(struct vm_area_struct *vma,
	flush_tlb_pending();
}

void hugetlb_free_pgtables(struct mmu_gather *tlb, struct vm_area_struct *prev,
			   unsigned long start, unsigned long end)
{
	/* Because the huge pgtables are only 2 level, they can take
	 * at most around 4M, much less than one hugepage which the
	 * process is presumably entitled to use.  So we don't bother
	 * freeing up the pagetables on unmap, and wait until
	 * destroy_context() to clean up the lot. */
}

int hugetlb_prefault(struct address_space *mapping, struct vm_area_struct *vma)
{
	struct mm_struct *mm = current->mm;
+1 −1
Original line number Diff line number Diff line
@@ -139,7 +139,7 @@ typedef union ia64_va {
# define HUGETLB_PAGE_ORDER	(HPAGE_SHIFT - PAGE_SHIFT)
# define is_hugepage_only_range(mm, addr, len)		\
	 (REGION_NUMBER(addr) == REGION_HPAGE &&	\
	  REGION_NUMBER((addr)+(len)) == REGION_HPAGE)
	  REGION_NUMBER((addr)+(len)-1) == REGION_HPAGE)
extern unsigned int hpage_shift;
#endif

+2 −2
Original line number Diff line number Diff line
@@ -472,8 +472,8 @@ extern struct page *zero_page_memmap_ptr;
#define HUGETLB_PGDIR_SIZE	(__IA64_UL(1) << HUGETLB_PGDIR_SHIFT)
#define HUGETLB_PGDIR_MASK	(~(HUGETLB_PGDIR_SIZE-1))
struct mmu_gather;
extern void hugetlb_free_pgtables(struct mmu_gather *tlb,
	struct vm_area_struct * prev, unsigned long start, unsigned long end);
void hugetlb_free_pgd_range(struct mmu_gather **tlb, unsigned long addr,
		unsigned long end, unsigned long floor, unsigned long ceiling);
#endif

/*
+9 −3
Original line number Diff line number Diff line
@@ -500,9 +500,15 @@ extern pgd_t ioremap_dir[1024];

extern void paging_init(void);

struct mmu_gather;
void hugetlb_free_pgtables(struct mmu_gather *tlb, struct vm_area_struct *prev,
			   unsigned long start, unsigned long end);
/*
 * Because the huge pgtables are only 2 level, they can take
 * at most around 4M, much less than one hugepage which the
 * process is presumably entitled to use.  So we don't bother
 * freeing up the pagetables on unmap, and wait until
 * destroy_context() to clean up the lot.
 */
#define hugetlb_free_pgd_range(tlb, addr, end, floor, ceiling) \
						do { } while (0)

/*
 * This gets called at the end of handling a page fault, when
Loading