@@ -108,7 +108,7 @@ pte_alloc_one(struct mm_struct *mm)
return 0;
memzero((void *)pte_pg, PTRS_PER_PTE * sizeof(pte_t));
page = virt_to_page(pte_pg);
- if (!pgtable_pte_page_ctor(page)) {
+ if (!pgtable_pte_page_ctor(page, mm)) {
__free_page(page);
return 0;
}
@@ -707,7 +707,7 @@ static void *__init late_alloc(unsigned long sz, struct mm_struct *mm)
{
void *ptr = (void *)__get_free_pages(GFP_PGTABLE_KERNEL, get_order(sz));
- if (!ptr || !pgtable_pte_page_ctor(virt_to_page(ptr)))
+ if (!ptr || !pgtable_pte_page_ctor(virt_to_page(ptr), mm))
BUG();
return ptr;
}
@@ -381,7 +381,7 @@ static phys_addr_t pgd_pgtable_alloc(int shift, struct mm_struct *mm)
* folded, and if so pgtable_pmd_page_ctor() becomes nop.
*/
if (shift == PAGE_SHIFT)
- BUG_ON(!pgtable_pte_page_ctor(phys_to_page(pa)));
+ BUG_ON(!pgtable_pte_page_ctor(phys_to_page(pa), mm));
else if (shift == PMD_SHIFT)
BUG_ON(!pgtable_pmd_page_ctor(phys_to_page(pa)));
@@ -50,7 +50,7 @@ static inline pgtable_t pte_alloc_one(struct mm_struct *mm)
if (!page)
return NULL;
- if (!pgtable_pte_page_ctor(page)) {
+ if (!pgtable_pte_page_ctor(page, mm)) {
__free_page(page);
return NULL;
}
@@ -137,7 +137,7 @@ void *get_pointer_table(int type, struct mm_struct *mm)
* m68k doesn't have SPLIT_PTE_PTLOCKS for not having
* SMP.
*/
- pgtable_pte_page_ctor(virt_to_page(page));
+ pgtable_pte_page_ctor(virt_to_page(page, mm));
}
mmu_page_ctor(page);
@@ -75,7 +75,7 @@ static inline struct page *pte_alloc_one(struct mm_struct *mm)
if (!pte)
return NULL;
clear_page(page_address(pte));
- if (!pgtable_pte_page_ctor(pte)) {
+ if (!pgtable_pte_page_ctor(pte, mm)) {
__free_page(pte);
return NULL;
}
@@ -61,7 +61,7 @@ static pte_t *__alloc_for_ptecache(struct mm_struct *mm, int kernel)
page = alloc_page(PGALLOC_GFP | __GFP_ACCOUNT);
if (!page)
return NULL;
- if (!pgtable_pte_page_ctor(page)) {
+ if (!pgtable_pte_page_ctor(page, mm)) {
__free_page(page);
return NULL;
}
@@ -208,7 +208,7 @@ unsigned long *page_table_alloc(struct mm_struct *mm)
page = alloc_page(GFP_KERNEL);
if (!page)
return NULL;
- if (!pgtable_pte_page_ctor(page)) {
+ if (!pgtable_pte_page_ctor(page, mm)) {
__free_page(page);
return NULL;
}
@@ -2928,7 +2928,7 @@ pgtable_t pte_alloc_one(struct mm_struct *mm)
struct page *page = alloc_page(GFP_KERNEL | __GFP_ZERO);
if (!page)
return NULL;
- if (!pgtable_pte_page_ctor(page)) {
+ if (!pgtable_pte_page_ctor(page, mm)) {
free_unref_page(page);
return NULL;
}
@@ -382,7 +382,7 @@ pgtable_t pte_alloc_one(struct mm_struct *mm)
if ((pte = (unsigned long)pte_alloc_one_kernel(mm)) == 0)
return NULL;
page = pfn_to_page(__nocache_pa(pte) >> PAGE_SHIFT);
- if (!pgtable_pte_page_ctor(page)) {
+ if (!pgtable_pte_page_ctor(page, mm)) {
__free_page(page);
return NULL;
}
@@ -55,7 +55,7 @@ static inline pgtable_t pte_alloc_one(struct mm_struct *mm)
if (!pte)
return NULL;
page = virt_to_page(pte);
- if (!pgtable_pte_page_ctor(page)) {
+ if (!pgtable_pte_page_ctor(page, mm)) {
__free_page(page);
return NULL;
}
@@ -63,7 +63,7 @@ static inline pgtable_t __pte_alloc_one(struct mm_struct *mm, gfp_t gfp)
pte = alloc_page(gfp);
if (!pte)
return NULL;
- if (!pgtable_pte_page_ctor(pte)) {
+ if (!pgtable_pte_page_ctor(pte, mm)) {
__free_page(pte);
return NULL;
}
@@ -2157,11 +2157,13 @@ static inline void pgtable_init(void)
pgtable_cache_init();
}
-static inline bool pgtable_pte_page_ctor(struct page *page)
+static inline
+bool pgtable_pte_page_ctor(struct page *page, struct mm_struct *mm)
{
if (!ptlock_init(page))
return false;
__SetPageTable(page);
+ page->pt_mm = mm;
inc_zone_page_state(page, NR_PAGETABLE);
return true;
}
@@ -2170,6 +2172,7 @@ static inline void pgtable_pte_page_dtor(struct page *page)
{
ptlock_free(page);
__ClearPageTable(page);
+ page->pt_mm = NULL;
dec_zone_page_state(page, NR_PAGETABLE);
}