Message ID | 20200428194449.22615-3-willy@infradead.org (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | Record the mm_struct in the page table pages | expand |
Hi Matthew, On Tue, Apr 28, 2020 at 9:44 PM Matthew Wilcox <willy@infradead.org> wrote: > From: "Matthew Wilcox (Oracle)" <willy@infradead.org> > Instead of a per-arch word within struct page, use a formerly reserved > word. This word is shared with page->mapping, so it must be cleared > before being freed as it is checked in free_pages(). > > Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org> Thanks for your patch! > --- a/include/linux/mm_types.h > +++ b/include/linux/mm_types.h > @@ -149,11 +149,8 @@ struct page { > pgtable_t pmd_huge_pte; > }; > }; > - unsigned long _pt_pad_2; /* mapping */ > - union { > - struct mm_struct *pt_mm; /* x86 pgds only */ > - atomic_t pt_frag_refcount; /* powerpc */ > - }; > + struct mm_struct *pt_mm; > + atomic_t pt_frag_refcount; /* powerpc */ So here is now an implicit hole on 64-bit platforms, right? Do we have any where alignof(long) != 8? > #if ALLOC_SPLIT_PTLOCKS > spinlock_t *ptl; > #else Gr{oetje,eeting}s, Geert
On Wed, Apr 29, 2020 at 09:34:02AM +0200, Geert Uytterhoeven wrote: > > +++ b/include/linux/mm_types.h > > @@ -149,11 +149,8 @@ struct page { > > pgtable_t pmd_huge_pte; > > }; > > }; > > - unsigned long _pt_pad_2; /* mapping */ > > - union { > > - struct mm_struct *pt_mm; /* x86 pgds only */ > > - atomic_t pt_frag_refcount; /* powerpc */ > > - }; > > + struct mm_struct *pt_mm; > > + atomic_t pt_frag_refcount; /* powerpc */ > > So here is now an implicit hole on 64-bit platforms, right? > Do we have any where alignof(long) != 8? There's an implicit hole if someone's turned on spinlock debugging and has split pagetable locks. Without the need to allocate the spinlock separately, the ptl will actually move from the same word as 'private' to the same word as 'index', freeing up 'private' entirely. I don't intend to depend on that, but it's not quite as critical to line up the various members of struct page as it used to be.
diff --git a/arch/x86/mm/pgtable.c b/arch/x86/mm/pgtable.c index 7bd2c3a52297..f5f46737aea0 100644 --- a/arch/x86/mm/pgtable.c +++ b/arch/x86/mm/pgtable.c @@ -95,6 +95,7 @@ static inline void pgd_list_del(pgd_t *pgd) struct page *page = virt_to_page(pgd); list_del(&page->lru); + page->pt_mm = NULL; } #define UNSHARED_PTRS_PER_PGD \ diff --git a/include/linux/mm_types.h b/include/linux/mm_types.h index 9bb34e2cd5a5..7efa12f4626f 100644 --- a/include/linux/mm_types.h +++ b/include/linux/mm_types.h @@ -149,11 +149,8 @@ struct page { pgtable_t pmd_huge_pte; }; }; - unsigned long _pt_pad_2; /* mapping */ - union { - struct mm_struct *pt_mm; /* x86 pgds only */ - atomic_t pt_frag_refcount; /* powerpc */ - }; + struct mm_struct *pt_mm; + atomic_t pt_frag_refcount; /* powerpc */ #if ALLOC_SPLIT_PTLOCKS spinlock_t *ptl; #else