Re: [RFC PATCH 5/6] mm, pgtable: Add the reference counter for COW PTE

Chih-En Lin
2022-05-21T05:10:26Z

On Sat, May 21, 2022 at 05:08:09AM +0100, Matthew Wilcox wrote:
> On Fri, May 20, 2022 at 02:31:26AM +0800, Chih-En Lin wrote:
> > +++ b/include/linux/mm_types.h
> > @@ -221,6 +221,7 @@ struct page {
> > #ifdef LAST_CPUPID_NOT_IN_PAGE_FLAGS
> > int _last_cpupid;
> > #endif
> > + atomic_t cow_pgtable_refcount; /* COW page table */
> > pmd_t *cow_pte_owner; /* cow pte: pmd */
> > } _struct_page_alignment;
>
> Oh. You need another 4 bytes. Hmm.
>
> Can you share _refcount?
>
> Using _pt_pad_2 should be possible, but some care will be needed to make
> sure it's (a) in a union with an unsigned long to keep the alignment
> as expected, and (b) is definitely zero before the page is freed (or
> the page allocator will squawk at you).

_refcount may be better. I will try this at first, and if any other
thing let _refcount cannot be used, I will consider _pt_pad_2.

Thanks!