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

From: Matthew Wilcox
Date: Sat May 21 2022 - 00:08:58 EST


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).