Re: [PATCH 01/12] mm/ksm: catch tail page abnormal in page_stable_node
From: Matthew Wilcox
Date: Mon Mar 18 2024 - 09:15:08 EST
On Mon, Mar 18, 2024 at 08:14:30PM +0800, alexs@xxxxxxxxxx wrote:
> From: Alex Shi <alexs@xxxxxxxxxx>
>
> commit 19138349ed59 ("mm/migrate: Add folio_migrate_flags()") change the
> meaning of func page_stable_node() to check the compound head for tail
> 'page' instead of tail page self.
> But seems both semantics are same at results, the func always return NULL
> for tail page. So adding a bug monitor here in case of abnormal.
No. I didn't object to you doing this to convince yourself, but there's
no way we should have this upstream.
If we did have large KSM folios (and I don't think we should!), you'd
crash the kernel instead of silently doing the right thing.
> static inline struct ksm_stable_node *page_stable_node(struct page *page)
> {
> - return folio_stable_node(page_folio(page));
> + struct ksm_stable_node *node;
> +
> + node = folio_stable_node(page_folio(page));
> + VM_BUG_ON_PAGE(PageTail(page) && node, page);
> +
> + return node;
> }