Skip to content

Commit 2d28ed5

Browse files
CmdrMoozyakpm00
authored andcommitted
Revert "ptdesc: remove references to folios from __pagetable_ctor() and pagetable_dtor()"
This change swapped out mod_node_page_state for lruvec_stat_add_folio. But, these two APIs are not interchangeable: the lruvec version also increments memcg stats, in addition to "global" pgdat stats. So after this change, the "pagetables" memcg stat in memory.stat always yields "0", which is a userspace visible regression. I tried to look for a refactor where we add a variant of lruvec_stat_mod_folio which takes a pgdat and a memcg instead of a folio, to try to adhere to the spirit of the original patch. But at the end of the day this just means we have to call folio_memcg(ptdesc_folio(ptdesc)) anyway, which doesn't really accomplish much. This regression is visible in master as well as 6.18 stable, so CC stable too. Link: https://lkml.kernel.org/r/20260225002434.2953895-1-axelrasmussen@google.com Fixes: f0c9272 ("ptdesc: remove references to folios from __pagetable_ctor() and pagetable_dtor()") Signed-off-by: Axel Rasmussen <axelrasmussen@google.com> Acked-by: Shakeel Butt <shakeel.butt@linux.dev> Acked-by: Johannes Weiner <hannes@cmpxchg.org> Reviewed-by: Vishal Moola (Oracle) <vishal.moola@gmail.com> Cc: David Hildenbrand <david@kernel.org> Cc: Liam Howlett <liam.howlett@oracle.com> Cc: Lorenzo Stoakes <lorenzo.stoakes@oracle.com> Cc: Matthew Wilcox (Oracle) <willy@infradead.org> Cc: Michal Hocko <mhocko@suse.com> Cc: Mike Rapoport <rppt@kernel.org> Cc: Suren Baghdasaryan <surenb@google.com> Cc: Vlastimil Babka <vbabka@suse.cz> Cc: Roman Gushchin <roman.gushchin@linux.dev> Cc: Muchun Song <muchun.song@linux.dev> Cc: <stable@vger.kernel.org> Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
1 parent f4355d6 commit 2d28ed5

1 file changed

Lines changed: 6 additions & 11 deletions

File tree

include/linux/mm.h

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3514,26 +3514,21 @@ static inline bool ptlock_init(struct ptdesc *ptdesc) { return true; }
35143514
static inline void ptlock_free(struct ptdesc *ptdesc) {}
35153515
#endif /* defined(CONFIG_SPLIT_PTE_PTLOCKS) */
35163516

3517-
static inline unsigned long ptdesc_nr_pages(const struct ptdesc *ptdesc)
3518-
{
3519-
return compound_nr(ptdesc_page(ptdesc));
3520-
}
3521-
35223517
static inline void __pagetable_ctor(struct ptdesc *ptdesc)
35233518
{
3524-
pg_data_t *pgdat = NODE_DATA(memdesc_nid(ptdesc->pt_flags));
3519+
struct folio *folio = ptdesc_folio(ptdesc);
35253520

3526-
__SetPageTable(ptdesc_page(ptdesc));
3527-
mod_node_page_state(pgdat, NR_PAGETABLE, ptdesc_nr_pages(ptdesc));
3521+
__folio_set_pgtable(folio);
3522+
lruvec_stat_add_folio(folio, NR_PAGETABLE);
35283523
}
35293524

35303525
static inline void pagetable_dtor(struct ptdesc *ptdesc)
35313526
{
3532-
pg_data_t *pgdat = NODE_DATA(memdesc_nid(ptdesc->pt_flags));
3527+
struct folio *folio = ptdesc_folio(ptdesc);
35333528

35343529
ptlock_free(ptdesc);
3535-
__ClearPageTable(ptdesc_page(ptdesc));
3536-
mod_node_page_state(pgdat, NR_PAGETABLE, -ptdesc_nr_pages(ptdesc));
3530+
__folio_clear_pgtable(folio);
3531+
lruvec_stat_sub_folio(folio, NR_PAGETABLE);
35373532
}
35383533

35393534
static inline void pagetable_dtor_free(struct ptdesc *ptdesc)

0 commit comments

Comments
 (0)