Skip to content

Commit

Permalink
add mm argument to pte/pmd/pud/pgd_free
Browse files Browse the repository at this point in the history
(with Martin Schwidefsky <schwidefsky@de.ibm.com>)

The pgd/pud/pmd/pte page table allocation functions get a mm_struct pointer as
first argument.  The free functions do not get the mm_struct argument.  This
is 1) asymmetrical and 2) to do mm related page table allocations the mm
argument is needed on the free function as well.

[kamalesh@linux.vnet.ibm.com: i386 fix]
[akpm@linux-foundation.org: coding-syle fixes]
Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Signed-off-by: Martin Schwidefsky <schwidefsky@de.ibm.com>
Cc: <linux-arch@vger.kernel.org>
Signed-off-by: Kamalesh Babulal <kamalesh@linux.vnet.ibm.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
  • Loading branch information
Benjamin Herrenschmidt authored and Linus Torvalds committed Feb 5, 2008
1 parent 9f8f217 commit 5e54197
Show file tree
Hide file tree
Showing 43 changed files with 151 additions and 151 deletions.
2 changes: 1 addition & 1 deletion arch/arm/kernel/smp.c
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ int __cpuinit __cpu_up(unsigned int cpu)
secondary_data.pgdir = 0;

*pmd_offset(pgd, PHYS_OFFSET) = __pmd(0);
pgd_free(pgd);
pgd_free(&init_mm, pgd);

if (ret) {
printk(KERN_CRIT "CPU%u: processor failed to boot\n", cpu);
Expand Down
2 changes: 1 addition & 1 deletion arch/arm/mm/ioremap.c
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ static void unmap_area_sections(unsigned long virt, unsigned long size)
* Free the page table, if there was one.
*/
if ((pmd_val(pmd) & PMD_TYPE_MASK) == PMD_TYPE_TABLE)
pte_free_kernel(pmd_page_vaddr(pmd));
pte_free_kernel(&init_mm, pmd_page_vaddr(pmd));
}

addr += PGDIR_SIZE;
Expand Down
8 changes: 4 additions & 4 deletions arch/arm/mm/pgd.c
Original file line number Diff line number Diff line change
Expand Up @@ -65,14 +65,14 @@ pgd_t *get_pgd_slow(struct mm_struct *mm)
return new_pgd;

no_pte:
pmd_free(new_pmd);
pmd_free(mm, new_pmd);
no_pmd:
free_pages((unsigned long)new_pgd, 2);
no_pgd:
return NULL;
}

void free_pgd_slow(pgd_t *pgd)
void free_pgd_slow(struct mm_struct *mm, pgd_t *pgd)
{
pmd_t *pmd;
struct page *pte;
Expand All @@ -94,8 +94,8 @@ void free_pgd_slow(pgd_t *pgd)
pmd_clear(pmd);
dec_zone_page_state(virt_to_page((unsigned long *)pgd), NR_PAGETABLE);
pte_lock_deinit(pte);
pte_free(pte);
pmd_free(pmd);
pte_free(mm, pte);
pmd_free(mm, pmd);
free:
free_pages((unsigned long) pgd, 2);
}
2 changes: 1 addition & 1 deletion arch/frv/mm/pgalloc.c
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ pgd_t *pgd_alloc(struct mm_struct *mm)
return pgd;
}

void pgd_free(pgd_t *pgd)
void pgd_free(struct mm_struct *mm, pgd_t *pgd)
{
/* in the non-PAE case, clear_page_tables() clears user pgd entries */
quicklist_free(0, pgd_dtor, pgd);
Expand Down
6 changes: 3 additions & 3 deletions arch/powerpc/mm/pgtable_32.c
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ pgd_t *pgd_alloc(struct mm_struct *mm)
return ret;
}

void pgd_free(pgd_t *pgd)
void pgd_free(struct mm_struct *mm, pgd_t *pgd)
{
free_pages((unsigned long)pgd, PGDIR_ORDER);
}
Expand Down Expand Up @@ -123,15 +123,15 @@ struct page *pte_alloc_one(struct mm_struct *mm, unsigned long address)
return ptepage;
}

void pte_free_kernel(pte_t *pte)
void pte_free_kernel(struct mm_struct *mm, pte_t *pte)
{
#ifdef CONFIG_SMP
hash_page_sync();
#endif
free_page((unsigned long)pte);
}

void pte_free(struct page *ptepage)
void pte_free(struct mm_struct *mm, struct page *ptepage)
{
#ifdef CONFIG_SMP
hash_page_sync();
Expand Down
6 changes: 3 additions & 3 deletions arch/ppc/mm/pgtable.c
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ pgd_t *pgd_alloc(struct mm_struct *mm)
return ret;
}

void pgd_free(pgd_t *pgd)
void pgd_free(struct mm_struct *mm, pgd_t *pgd)
{
free_pages((unsigned long)pgd, PGDIR_ORDER);
}
Expand Down Expand Up @@ -111,15 +111,15 @@ struct page *pte_alloc_one(struct mm_struct *mm, unsigned long address)
return ptepage;
}

void pte_free_kernel(pte_t *pte)
void pte_free_kernel(struct mm_struct *mm, pte_t *pte)
{
#ifdef CONFIG_SMP
hash_page_sync();
#endif
free_page((unsigned long)pte);
}

void pte_free(struct page *ptepage)
void pte_free(struct mm_struct *mm, struct page *ptepage)
{
#ifdef CONFIG_SMP
hash_page_sync();
Expand Down
2 changes: 1 addition & 1 deletion arch/um/kernel/mem.c
Original file line number Diff line number Diff line change
Expand Up @@ -348,7 +348,7 @@ pgd_t *pgd_alloc(struct mm_struct *mm)
return pgd;
}

void pgd_free(pgd_t *pgd)
void pgd_free(struct mm_struct *mm, pgd_t *pgd)
{
free_page((unsigned long) pgd);
}
Expand Down
8 changes: 4 additions & 4 deletions arch/um/kernel/skas/mmu.c
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,9 @@ static int init_stub_pte(struct mm_struct *mm, unsigned long proc,
return 0;

out_pmd:
pud_free(pud);
pud_free(mm, pud);
out_pte:
pmd_free(pmd);
pmd_free(mm, pmd);
out:
return -ENOMEM;
}
Expand Down Expand Up @@ -144,10 +144,10 @@ void destroy_context(struct mm_struct *mm)
if (!proc_mm || !ptrace_faultinfo) {
free_page(mmu->id.stack);
pte_lock_deinit(virt_to_page(mmu->last_page_table));
pte_free_kernel((pte_t *) mmu->last_page_table);
pte_free_kernel(mm, (pte_t *) mmu->last_page_table);
dec_zone_page_state(virt_to_page(mmu->last_page_table), NR_PAGETABLE);
#ifdef CONFIG_3_LEVEL_PGTABLES
pmd_free((pmd_t *) mmu->last_pmd);
pmd_free(mm, (pmd_t *) mmu->last_pmd);
#endif
}

Expand Down
12 changes: 6 additions & 6 deletions arch/x86/mm/pgtable_32.c
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,7 @@ static void pgd_dtor(void *pgd)
* preallocate which never got a corresponding vma will need to be
* freed manually.
*/
static void pgd_mop_up_pmds(pgd_t *pgdp)
static void pgd_mop_up_pmds(struct mm_struct *mm, pgd_t *pgdp)
{
int i;

Expand All @@ -285,7 +285,7 @@ static void pgd_mop_up_pmds(pgd_t *pgdp)
pgdp[i] = native_make_pgd(0);

paravirt_release_pd(pgd_val(pgd) >> PAGE_SHIFT);
pmd_free(pmd);
pmd_free(mm, pmd);
}
}
}
Expand Down Expand Up @@ -313,7 +313,7 @@ static int pgd_prepopulate_pmd(struct mm_struct *mm, pgd_t *pgd)
pmd_t *pmd = pmd_alloc_one(mm, addr);

if (!pmd) {
pgd_mop_up_pmds(pgd);
pgd_mop_up_pmds(mm, pgd);
return 0;
}

Expand All @@ -333,7 +333,7 @@ static int pgd_prepopulate_pmd(struct mm_struct *mm, pgd_t *pgd)
return 1;
}

static void pgd_mop_up_pmds(pgd_t *pgd)
static void pgd_mop_up_pmds(struct mm_struct *mm, pgd_t *pgdp)
{
}
#endif /* CONFIG_X86_PAE */
Expand All @@ -352,9 +352,9 @@ pgd_t *pgd_alloc(struct mm_struct *mm)
return pgd;
}

void pgd_free(pgd_t *pgd)
void pgd_free(struct mm_struct *mm, pgd_t *pgd)
{
pgd_mop_up_pmds(pgd);
pgd_mop_up_pmds(mm, pgd);
quicklist_free(0, pgd_dtor, pgd);
}

Expand Down
8 changes: 4 additions & 4 deletions include/asm-alpha/pgalloc.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ pgd_populate(struct mm_struct *mm, pgd_t *pgd, pmd_t *pmd)
extern pgd_t *pgd_alloc(struct mm_struct *mm);

static inline void
pgd_free(pgd_t *pgd)
pgd_free(struct mm_struct *mm, pgd_t *pgd)
{
free_page((unsigned long)pgd);
}
Expand All @@ -44,15 +44,15 @@ pmd_alloc_one(struct mm_struct *mm, unsigned long address)
}

static inline void
pmd_free(pmd_t *pmd)
pmd_free(struct mm_struct *mm, pmd_t *pmd)
{
free_page((unsigned long)pmd);
}

extern pte_t *pte_alloc_one_kernel(struct mm_struct *mm, unsigned long addr);

static inline void
pte_free_kernel(pte_t *pte)
pte_free_kernel(struct mm_struct *mm, pte_t *pte)
{
free_page((unsigned long)pte);
}
Expand All @@ -67,7 +67,7 @@ pte_alloc_one(struct mm_struct *mm, unsigned long addr)
}

static inline void
pte_free(struct page *page)
pte_free(struct mm_struct *mm, struct page *page)
{
__free_page(page);
}
Expand Down
4 changes: 2 additions & 2 deletions include/asm-alpha/tlb.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

#include <asm-generic/tlb.h>

#define __pte_free_tlb(tlb,pte) pte_free(pte)
#define __pmd_free_tlb(tlb,pmd) pmd_free(pmd)
#define __pte_free_tlb(tlb, pte) pte_free((tlb)->mm, pte)
#define __pmd_free_tlb(tlb, pmd) pmd_free((tlb)->mm, pmd)

#endif
10 changes: 5 additions & 5 deletions include/asm-arm/pgalloc.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,14 @@
* Since we have only two-level page tables, these are trivial
*/
#define pmd_alloc_one(mm,addr) ({ BUG(); ((pmd_t *)2); })
#define pmd_free(pmd) do { } while (0)
#define pmd_free(mm, pmd) do { } while (0)
#define pgd_populate(mm,pmd,pte) BUG()

extern pgd_t *get_pgd_slow(struct mm_struct *mm);
extern void free_pgd_slow(pgd_t *pgd);
extern void free_pgd_slow(struct mm_struct *mm, pgd_t *pgd);

#define pgd_alloc(mm) get_pgd_slow(mm)
#define pgd_free(pgd) free_pgd_slow(pgd)
#define pgd_free(mm, pgd) free_pgd_slow(mm, pgd)

/*
* Allocate one PTE table.
Expand Down Expand Up @@ -83,15 +83,15 @@ pte_alloc_one(struct mm_struct *mm, unsigned long addr)
/*
* Free one PTE table.
*/
static inline void pte_free_kernel(pte_t *pte)
static inline void pte_free_kernel(struct mm_struct *mm, pte_t *pte)
{
if (pte) {
pte -= PTRS_PER_PTE;
free_page((unsigned long)pte);
}
}

static inline void pte_free(struct page *pte)
static inline void pte_free(struct mm_struct *mm, struct page *pte)
{
__free_page(pte);
}
Expand Down
4 changes: 2 additions & 2 deletions include/asm-arm/tlb.h
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,8 @@ tlb_end_vma(struct mmu_gather *tlb, struct vm_area_struct *vma)
}

#define tlb_remove_page(tlb,page) free_page_and_swap_cache(page)
#define pte_free_tlb(tlb,ptep) pte_free(ptep)
#define pmd_free_tlb(tlb,pmdp) pmd_free(pmdp)
#define pte_free_tlb(tlb, ptep) pte_free((tlb)->mm, ptep)
#define pmd_free_tlb(tlb, pmdp) pmd_free((tlb)->mm, pmdp)

#define tlb_migrate_finish(mm) do { } while (0)

Expand Down
6 changes: 3 additions & 3 deletions include/asm-avr32/pgalloc.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ static __inline__ pgd_t *pgd_alloc(struct mm_struct *mm)
return kcalloc(USER_PTRS_PER_PGD, sizeof(pgd_t), GFP_KERNEL);
}

static inline void pgd_free(pgd_t *pgd)
static inline void pgd_free(struct mm_struct *mm, pgd_t *pgd)
{
kfree(pgd);
}
Expand All @@ -55,12 +55,12 @@ static inline struct page *pte_alloc_one(struct mm_struct *mm,
return pte;
}

static inline void pte_free_kernel(pte_t *pte)
static inline void pte_free_kernel(struct mm_struct *mm, pte_t *pte)
{
free_page((unsigned long)pte);
}

static inline void pte_free(struct page *pte)
static inline void pte_free(struct mm_struct *mm, struct page *pte)
{
__free_page(pte);
}
Expand Down
6 changes: 3 additions & 3 deletions include/asm-cris/pgalloc.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ static inline pgd_t *pgd_alloc (struct mm_struct *mm)
return (pgd_t *)get_zeroed_page(GFP_KERNEL);
}

static inline void pgd_free (pgd_t *pgd)
static inline void pgd_free(struct mm_struct *mm, pgd_t *pgd)
{
free_page((unsigned long)pgd);
}
Expand All @@ -34,12 +34,12 @@ static inline struct page *pte_alloc_one(struct mm_struct *mm, unsigned long add
return pte;
}

static inline void pte_free_kernel(pte_t *pte)
static inline void pte_free_kernel(struct mm_struct *mm, pte_t *pte)
{
free_page((unsigned long)pte);
}

static inline void pte_free(struct page *pte)
static inline void pte_free(struct mm_struct *mm, struct page *pte)
{
__free_page(pte);
}
Expand Down
8 changes: 4 additions & 4 deletions include/asm-frv/pgalloc.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,18 +31,18 @@ do { \
*/

extern pgd_t *pgd_alloc(struct mm_struct *);
extern void pgd_free(pgd_t *);
extern void pgd_free(struct mm_struct *mm, pgd_t *);

extern pte_t *pte_alloc_one_kernel(struct mm_struct *, unsigned long);

extern struct page *pte_alloc_one(struct mm_struct *, unsigned long);

static inline void pte_free_kernel(pte_t *pte)
static inline void pte_free_kernel(struct mm_struct *mm, pte_t *pte)
{
free_page((unsigned long)pte);
}

static inline void pte_free(struct page *pte)
static inline void pte_free(struct mm_struct *mm, struct page *pte)
{
__free_page(pte);
}
Expand All @@ -55,7 +55,7 @@ static inline void pte_free(struct page *pte)
* (In the PAE case we free the pmds as part of the pgd.)
*/
#define pmd_alloc_one(mm, addr) ({ BUG(); ((pmd_t *) 2); })
#define pmd_free(x) do { } while (0)
#define pmd_free(mm, x) do { } while (0)
#define __pmd_free_tlb(tlb,x) do { } while (0)

#endif /* CONFIG_MMU */
Expand Down
2 changes: 1 addition & 1 deletion include/asm-frv/pgtable.h
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ static inline pud_t *pud_offset(pgd_t *pgd, unsigned long address)
* inside the pgd, so has no extra memory associated with it.
*/
#define pud_alloc_one(mm, address) NULL
#define pud_free(x) do { } while (0)
#define pud_free(mm, x) do { } while (0)
#define __pud_free_tlb(tlb, x) do { } while (0)

/*
Expand Down
2 changes: 1 addition & 1 deletion include/asm-generic/4level-fixup.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@

#undef pud_free_tlb
#define pud_free_tlb(tlb, x) do { } while (0)
#define pud_free(x) do { } while (0)
#define pud_free(mm, x) do { } while (0)
#define __pud_free_tlb(tlb, x) do { } while (0)

#undef pud_addr_end
Expand Down
2 changes: 1 addition & 1 deletion include/asm-generic/pgtable-nopmd.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ static inline pmd_t * pmd_offset(pud_t * pud, unsigned long address)
* inside the pud, so has no extra memory associated with it.
*/
#define pmd_alloc_one(mm, address) NULL
#define pmd_free(x) do { } while (0)
#define pmd_free(mm, x) do { } while (0)
#define __pmd_free_tlb(tlb, x) do { } while (0)

#undef pmd_addr_end
Expand Down
2 changes: 1 addition & 1 deletion include/asm-generic/pgtable-nopud.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ static inline pud_t * pud_offset(pgd_t * pgd, unsigned long address)
* inside the pgd, so has no extra memory associated with it.
*/
#define pud_alloc_one(mm, address) NULL
#define pud_free(x) do { } while (0)
#define pud_free(mm, x) do { } while (0)
#define __pud_free_tlb(tlb, x) do { } while (0)

#undef pud_addr_end
Expand Down
Loading

0 comments on commit 5e54197

Please sign in to comment.