[RFC PATCH 01/18] mm/pgtable: use ptdesc in pte_free_now/pte_free_defer

From: alexs
Date: Tue Jul 30 2024 - 02:43:16 EST


From: Alex Shi <alexs@xxxxxxxxxx>

page table descriptor is splited from struct page, use it to replace struct
page in right place.

Signed-off-by: Alex Shi <alexs@xxxxxxxxxx>
Cc: linux-kernel@xxxxxxxxxxxxxxx
Cc: linux-mm@xxxxxxxxx
Cc: Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx>
Cc: Matthew Wilcox <willy@xxxxxxxxxxxxx>
Cc: David Hildenbrand <david@xxxxxxxxxx>
---
mm/pgtable-generic.c | 13 ++++++-------
1 file changed, 6 insertions(+), 7 deletions(-)

diff --git a/mm/pgtable-generic.c b/mm/pgtable-generic.c
index 13a7705df3f8..2ce714f1dd15 100644
--- a/mm/pgtable-generic.c
+++ b/mm/pgtable-generic.c
@@ -238,18 +238,17 @@ pmd_t pmdp_collapse_flush(struct vm_area_struct *vma, unsigned long address,
#ifndef pte_free_defer
static void pte_free_now(struct rcu_head *head)
{
- struct page *page;
+ struct ptdesc *ptdesc;

- page = container_of(head, struct page, rcu_head);
- pte_free(NULL /* mm not passed and not used */, (pgtable_t)page);
+ ptdesc = container_of(head, struct ptdesc, pt_rcu_head);
+ pte_free(NULL /* mm not passed and not used */, (pgtable_t)ptdesc);
}

void pte_free_defer(struct mm_struct *mm, pgtable_t pgtable)
{
- struct page *page;
+ struct ptdesc *ptdesc = page_ptdesc(pgtable);

- page = pgtable;
- call_rcu(&page->rcu_head, pte_free_now);
+ call_rcu(&ptdesc->pt_rcu_head, pte_free_now);
}
#endif /* pte_free_defer */
#endif /* CONFIG_TRANSPARENT_HUGEPAGE */
@@ -330,7 +329,7 @@ pte_t *pte_offset_map_nolock(struct mm_struct *mm, pmd_t *pmd,
* kmapped if necessary (when CONFIG_HIGHPTE), and locked against concurrent
* modification by software, with a pointer to that spinlock in ptlp (in some
* configs mm->page_table_lock, in SPLIT_PTLOCK configs a spinlock in table's
- * struct page). pte_unmap_unlock(pte, ptl) to unlock and unmap afterwards.
+ * struct ptdesc). pte_unmap_unlock(pte, ptl) to unlock and unmap afterwards.
*
* But it is unsuccessful, returning NULL with *ptlp unchanged, if there is no
* page table at *pmd: if, for example, the page table has just been removed,
--
2.43.0