Re: [PATCH v2 20/29] mm: convert "movable" flag in page->mapping to a page flag

2025-07-11 Thread David Hildenbrand
On 04.07.25 12:25, David Hildenbrand wrote: Instead, let's use a page flag. As the page flag can result in false-positives, glue it to the page types for which we support/implement movable_ops page migration. We are reusing PG_uptodate, that is for example used to track file system stat

[PATCH v2 20/29] mm: convert "movable" flag in page->mapping to a page flag

2025-07-04 Thread David Hildenbrand
have to introduce __SETPAGEFLAG_NOOP(). Reviewed-by: Zi Yan Reviewed-by: Lorenzo Stoakes Signed-off-by: David Hildenbrand --- include/linux/balloon_compaction.h | 2 +- include/linux/migrate.h| 8 - include/linux/page-flags.h | 54 -

[PATCH v2 29/29] mm/balloon_compaction: provide single balloon_page_insert() and balloon_mapping_gfp_mask()

2025-07-04 Thread David Hildenbrand
Let's just special-case based on IS_ENABLED(CONFIG_BALLOON_COMPACTION) like we did for balloon_page_finalize(). Reviewed-by: Lorenzo Stoakes Signed-off-by: David Hildenbrand --- include/linux/balloon_compaction.h | 42 +++--- 1 file changed, 15 insertions(+

[PATCH v2 28/29] mm/balloon_compaction: "movable_ops" doc updates

2025-07-04 Thread David Hildenbrand
Let's bring the docs up-to-date. Setting PG_movable_ops + page->private very likely still requires to be performed under documented locks: it's complicated. We will rework this in the future, as we will try avoiding using the page lock. Reviewed-by: Lorenzo Stoakes Signed-

[PATCH v2 26/29] mm: rename PAGE_MAPPING_* to FOLIO_MAPPING_*

2025-07-04 Thread David Hildenbrand
Now that the mapping flags are only used for folios, let's rename the defines. Reviewed-by: Zi Yan Reviewed-by: Lorenzo Stoakes Reviewed-by: Harry Yoo Signed-off-by: David Hildenbrand --- fs/proc/page.c | 4 ++-- include/linux/fs.h | 2 +- include/linux/mm_ty

[PATCH v2 27/29] docs/mm: convert from "Non-LRU page migration" to "movable_ops page migration"

2025-07-04 Thread David Hildenbrand
Let's bring the docs up-to-date. Reviewed-by: Zi Yan Reviewed-by: Lorenzo Stoakes Reviewed-by: Harry Yoo Signed-off-by: David Hildenbrand --- Documentation/mm/page_migration.rst | 39 - 1 file changed, 27 insertions(+), 12 deletions(-) diff --git a/Document

[PATCH v2 25/29] mm: simplify folio_expected_ref_count()

2025-07-04 Thread David Hildenbrand
ed-by: Lorenzo Stoakes Reviewed-by: Harry Yoo Signed-off-by: David Hildenbrand --- include/linux/mm.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/include/linux/mm.h b/include/linux/mm.h index ef40f68c1183d..805108d7bbc31 100644 --- a/include/linux/mm.h +++ b/include/

[PATCH v2 24/29] mm/page-flags: remove folio_mapping_flags()

2025-07-04 Thread David Hildenbrand
It's unused and the page counterpart is gone, so let's remove it. Reviewed-by: Zi Yan Reviewed-by: Lorenzo Stoakes Reviewed-by: Harry Yoo Signed-off-by: David Hildenbrand --- include/linux/page-flags.h | 5 - 1 file changed, 5 deletions(-) diff --git a/include/linux/page

[PATCH v2 23/29] mm/page-alloc: remove PageMappingFlags()

2025-07-04 Thread David Hildenbrand
off-by: David Hildenbrand --- include/linux/page-flags.h | 5 - mm/page_alloc.c| 7 +++ 2 files changed, 3 insertions(+), 9 deletions(-) diff --git a/include/linux/page-flags.h b/include/linux/page-flags.h index 094c8605a879e..fc159fa945351 100644 --- a/include/linux/page-flag

[PATCH v2 22/29] mm/page-flags: rename PAGE_MAPPING_MOVABLE to PAGE_MAPPING_ANON_KSM

2025-07-04 Thread David Hildenbrand
KSM is the only remaining user, let's rename the flag. While at it, adjust to remaining page -> folio in the doc. Reviewed-by: Zi Yan Reviewed-by: Lorenzo Stoakes Reviewed-by: Harry Yoo Signed-off-by: David Hildenbrand --- include/linux/page-flags.h | 12 ++-- 1 file ch

[PATCH v2 21/29] mm: rename PG_isolated to PG_movable_ops_isolated

2025-07-04 Thread David Hildenbrand
Let's rename the flag to make it clearer where it applies (not folios ...). While at it, define the flag only with CONFIG_MIGRATION. Reviewed-by: Zi Yan Reviewed-by: Lorenzo Stoakes Reviewed-by: Harry Yoo Signed-off-by: David Hildenbrand --- include/linux/page-flags.h

[PATCH v2 19/29] mm: stop storing migration_ops in page->mapping

2025-07-04 Thread David Hildenbrand
ing movable (having movable_ops), which we will change next. Reviewed-by: Zi Yan Reviewed-by: Lorenzo Stoakes Reviewed-by: Harry Yoo Signed-off-by: David Hildenbrand --- include/linux/balloon_compaction.h | 2 +- include/linux/migrate.h| 14 ++ include/linux/zsmallo

[PATCH v2 18/29] mm: remove __folio_test_movable()

2025-07-04 Thread David Hildenbrand
ework page_has_movable_ops() soon either way to no longer rely on page->mapping. Wherever we cast from folio to page now is a clear sign that this code has to be decoupled. Reviewed-by: Zi Yan Reviewed-by: Lorenzo Stoakes Reviewed-by: Harry Yoo Signed-off-by: David Hildenbrand --- include/li

[PATCH v2 15/29] mm/migration: remove PageMovable()

2025-07-04 Thread David Hildenbrand
PageMovable() checks by __PageMovable(). In fact, __PageMovable() cannot change until a page is freed, so we can turn some PageMovable() into sanity checks for __PageMovable(). Reviewed-by: Zi Yan Reviewed-by: Lorenzo Stoakes Reviewed-by: Harry Yoo Signed-off-by: David Hildenbrand --- include/linux

[PATCH v2 17/29] mm/page_isolation: drop __folio_test_movable() check for large folios

2025-07-04 Thread David Hildenbrand
Currently, we only support migration of individual movable_ops pages, so we can not run into that. Reviewed-by: Zi Yan Reviewed-by: Lorenzo Stoakes Reviewed-by: Harry Yoo Signed-off-by: David Hildenbrand --- mm/page_isolation.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff

[PATCH v2 16/29] mm: rename __PageMovable() to page_has_movable_ops()

2025-07-04 Thread David Hildenbrand
Let's make it clearer that we are talking about movable_ops pages. While at it, convert a VM_BUG_ON to a VM_WARN_ON_ONCE_PAGE. Reviewed-by: Zi Yan Reviewed-by: Lorenzo Stoakes Reviewed-by: Harry Yoo Signed-off-by: David Hildenbrand --- include/linux/migrate.h| 2 +- include/linux

[PATCH v2 14/29] mm/migrate: remove __ClearPageMovable()

2025-07-04 Thread David Hildenbrand
renzo Stoakes Signed-off-by: David Hildenbrand --- include/linux/migrate.h | 8 ++-- mm/compaction.c | 11 --- 2 files changed, 2 insertions(+), 17 deletions(-) diff --git a/include/linux/migrate.h b/include/linux/migrate.h index c99a00d4ca27d..6eeda8eb1e0d8 100644 --- a/include/

[PATCH v2 13/29] mm/balloon_compaction: stop using __ClearPageMovable()

2025-07-04 Thread David Hildenbrand
ack. Add a WARN_ON_ONCE for now. Reviewed-by: Lorenzo Stoakes Signed-off-by: David Hildenbrand --- include/linux/balloon_compaction.h | 4 +--- mm/balloon_compaction.c| 11 +++ 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/include/linux/balloon_compact

[PATCH v2 12/29] mm/zsmalloc: stop using __ClearPageMovable()

2025-07-04 Thread David Hildenbrand
TODO for that. Reviewed-by: Harry Yoo Reviewed-by: Lorenzo Stoakes Signed-off-by: David Hildenbrand --- mm/zsmalloc.c | 18 ++ 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/mm/zsmalloc.c b/mm/zsmalloc.c index 626f09fb27138..b12250e219bb7 100644 --- a/mm/zsmall

[PATCH v2 11/29] mm/migrate: move movable_ops page handling out of move_to_new_folio()

2025-07-04 Thread David Hildenbrand
pages) Reviewed-by: Zi Yan Reviewed-by: Harry Yoo Reviewed-by: Lorenzo Stoakes Signed-off-by: David Hildenbrand --- mm/migrate.c | 63 +--- 1 file changed, 30 insertions(+), 33 deletions(-) diff --git a/mm/migrate.c b/mm/migrate.c index d66d0776

[PATCH v2 10/29] mm/migrate: remove folio_test_movable() and folio_movable_ops()

2025-07-04 Thread David Hildenbrand
igned-off-by: David Hildenbrand --- include/linux/migrate.h | 14 -- 1 file changed, 14 deletions(-) diff --git a/include/linux/migrate.h b/include/linux/migrate.h index c0ec7422837bd..c99a00d4ca27d 100644 --- a/include/linux/migrate.h +++ b/include/linux/migrate.h @@ -118,20 +

[PATCH v2 09/29] mm/migrate: factor out movable_ops page handling into migrate_movable_ops_page()

2025-07-04 Thread David Hildenbrand
st_anon() to make it clearer, because movable_ops pages will never take that path. Reviewed-by: Zi Yan Reviewed-by: Lorenzo Stoakes Signed-off-by: David Hildenbrand --- mm/migrate.c | 82 1 file changed, 45 insertions(+), 37 deletions(-) diff --git

[PATCH v2 08/29] mm/migrate: rename putback_movable_folio() to putback_movable_ops_page()

2025-07-04 Thread David Hildenbrand
... and factor the complete handling of movable_ops pages out. Convert it similar to isolate_movable_ops_page(). While at it, convert the VM_BUG_ON_FOLIO() into a VM_WARN_ON_PAGE(). Reviewed-by: Lorenzo Stoakes Reviewed-by: Harry Yoo Reviewed-by: Zi Yan Signed-off-by: David Hildenbrand

[PATCH v2 07/29] mm/migrate: rename isolate_movable_page() to isolate_movable_ops_page()

2025-07-04 Thread David Hildenbrand
Yoo Reviewed-by: Lorenzo Stoakes Signed-off-by: David Hildenbrand --- include/linux/migrate.h | 4 ++-- mm/compaction.c | 2 +- mm/migrate.c| 39 +-- 3 files changed, 32 insertions(+), 13 deletions(-) diff --git a/include/linux/migrate.h b/incl

[PATCH v2 06/29] mm/zsmalloc: make PageZsmalloc() sticky until the page is freed

2025-07-04 Thread David Hildenbrand
: David Hildenbrand --- mm/zpdesc.h | 5 - mm/zsmalloc.c | 4 ++-- 2 files changed, 2 insertions(+), 7 deletions(-) diff --git a/mm/zpdesc.h b/mm/zpdesc.h index 5cb7e3de43952..5763f36039736 100644 --- a/mm/zpdesc.h +++ b/mm/zpdesc.h @@ -163,11 +163,6 @@ static inline void __zpdesc_set_zsmalloc

[PATCH v2 05/29] mm/balloon_compaction: make PageOffline sticky until the page is freed

2025-07-04 Thread David Hildenbrand
Let the page freeing code handle clearing the page type. Being able to identify balloon pages until actually freed is a requirement for upcoming movable_ops migration changes. Acked-by: Zi Yan Acked-by: Harry Yoo Reviewed-by: Lorenzo Stoakes Signed-off-by: David Hildenbrand --- include/linux

[PATCH v2 04/29] mm/page_alloc: let page freeing clear any set page type

2025-07-04 Thread David Hildenbrand
ransition phase). In the future we might want to warn on some page types. Instead of having an "allow list", let's rather wait until we know about once that should go on such a "disallow list". Reviewed-by: Zi Yan Acked-by: Harry Yoo Reviewed-by: Lorenzo Stoakes S

[PATCH v2 03/29] mm/zsmalloc: drop PageIsolated() related VM_BUG_ONs

2025-07-04 Thread David Hildenbrand
Let's drop these checks; these are conditions the core migration code must make sure will hold either way, no need to double check. Acked-by: Zi Yan Reviewed-by: Sergey Senozhatsky Acked-by: Harry Yoo Reviewed-by: Lorenzo Stoakes Signed-off-by: David Hildenbrand --- mm/zpdesc.h

[PATCH v2 02/29] mm/balloon_compaction: convert balloon_page_delete() to balloon_page_finalize()

2025-07-04 Thread David Hildenbrand
ust before dropping the balloon reference. Document that the page lock is currently required when modifying the movability aspects of a page; hopefully we can soon decouple this from the page lock. Reviewed-by: Lorenzo Stoakes Signed-off-by: David Hildenbrand --- arch/powerpc/platforms/pseries/

[PATCH v2 01/29] mm/balloon_compaction: we cannot have isolated pages in the balloon list

2025-07-04 Thread David Hildenbrand
Signed-off-by: David Hildenbrand --- mm/balloon_compaction.c | 6 -- 1 file changed, 6 deletions(-) diff --git a/mm/balloon_compaction.c b/mm/balloon_compaction.c index d3e00731e2628..fcb60233aa35d 100644 --- a/mm/balloon_compaction.c +++ b/mm/balloon_compaction.c @@ -94,12 +94,6 @

[PATCH v2 00/29] mm/migration: rework movable_ops page migration (part 1)

2025-07-04 Thread David Hildenbrand
e: move movable_ops page handling out of move_to_new_folio()" -> Fix goto out; vs goto out_unlock_both; * "mm: remove __folio_test_movable()" -> Fix page_has_movable_ops() checking wrong page Cc: Andrew Morton Cc: Jonathan Corbet Cc: Madhavan Srinivasan Cc: Michael Ellerman

Re: [PATCH v1 12/29] mm/zsmalloc: stop using __ClearPageMovable()

2025-07-03 Thread David Hildenbrand
On 03.07.25 05:22, Sergey Senozhatsky wrote: On (25/07/03 11:28), Sergey Senozhatsky wrote: static int zs_page_migrate(struct page *newpage, struct page *page, @@ -1736,6 +1736,13 @@ static int zs_page_migrate(struct page *newpage, struct page *page, unsigned long old_obj, new_obj;

Re: [PATCH v1 20/29] mm: convert "movable" flag in page->mapping to a page flag

2025-07-02 Thread David Hildenbrand
On 02.07.25 15:01, Harry Yoo wrote: On Wed, Jul 02, 2025 at 02:01:33PM +0200, David Hildenbrand wrote: On 02.07.25 13:54, Harry Yoo wrote: On Mon, Jun 30, 2025 at 03:00:01PM +0200, David Hildenbrand wrote: Instead, let's use a page flag. As the page flag can result in false-positives, gl

Re: [PATCH v1 27/29] docs/mm: convert from "Non-LRU page migration" to "movable_ops page migration"

2025-07-02 Thread David Hildenbrand
On 02.07.25 16:23, Harry Yoo wrote: On Mon, Jun 30, 2025 at 03:00:08PM +0200, David Hildenbrand wrote: Let's bring the docs up-to-date. Reviewed-by: Zi Yan Signed-off-by: David Hildenbrand --- +movable_ops page migration +== + +Selected typed, non-folio pages

Re: [PATCH v1 20/29] mm: convert "movable" flag in page->mapping to a page flag

2025-07-02 Thread David Hildenbrand
On 02.07.25 13:54, Harry Yoo wrote: On Mon, Jun 30, 2025 at 03:00:01PM +0200, David Hildenbrand wrote: Instead, let's use a page flag. As the page flag can result in false-positives, glue it to the page types for which we support/implement movable_ops page migration. The flag reus

Re: [PATCH v1 19/29] mm: stop storing migration_ops in page->mapping

2025-07-02 Thread David Hildenbrand
On 02.07.25 13:43, Harry Yoo wrote: On Wed, Jul 02, 2025 at 01:04:05PM +0200, David Hildenbrand wrote: On 02.07.25 12:34, Harry Yoo wrote: On Mon, Jun 30, 2025 at 03:00:00PM +0200, David Hildenbrand wrote: ... instead, look them up statically based on the page type. Maybe in the future we

Re: [PATCH v1 19/29] mm: stop storing migration_ops in page->mapping

2025-07-02 Thread David Hildenbrand
On 02.07.25 12:34, Harry Yoo wrote: On Mon, Jun 30, 2025 at 03:00:00PM +0200, David Hildenbrand wrote: ... instead, look them up statically based on the page type. Maybe in the future we want a registration interface? At least for now, it can be easily handled using the two page types that

Re: [PATCH v1 12/29] mm/zsmalloc: stop using __ClearPageMovable()

2025-07-02 Thread David Hildenbrand
On 02.07.25 12:10, Sergey Senozhatsky wrote: On (25/07/02 10:25), David Hildenbrand wrote: On 02.07.25 10:11, Sergey Senozhatsky wrote: On (25/06/30 14:59), David Hildenbrand wrote: [..] static int zs_page_migrate(struct page *newpage, struct page *page, @@ -1736,6 +1736,13 @@ static int

Re: [PATCH v1 23/29] mm/page-alloc: remove PageMappingFlags()

2025-07-02 Thread David Hildenbrand
On 02.07.25 11:09, Lorenzo Stoakes wrote: On Wed, Jul 02, 2025 at 11:02:21AM +0200, David Hildenbrand wrote: On 02.07.25 10:49, Lorenzo Stoakes wrote: On Tue, Jul 01, 2025 at 09:34:41PM +0200, David Hildenbrand wrote: On 01.07.25 15:02, Lorenzo Stoakes wrote: On Mon, Jun 30, 2025 at 03:00

Re: [PATCH v1 23/29] mm/page-alloc: remove PageMappingFlags()

2025-07-02 Thread David Hildenbrand
On 02.07.25 10:49, Lorenzo Stoakes wrote: On Tue, Jul 01, 2025 at 09:34:41PM +0200, David Hildenbrand wrote: On 01.07.25 15:02, Lorenzo Stoakes wrote: On Mon, Jun 30, 2025 at 03:00:04PM +0200, David Hildenbrand wrote: We can now simply check for PageAnon() and remove PageMappingFlags

Re: [PATCH v1 12/29] mm/zsmalloc: stop using __ClearPageMovable()

2025-07-02 Thread David Hildenbrand
On 02.07.25 10:11, Sergey Senozhatsky wrote: On (25/06/30 14:59), David Hildenbrand wrote: [..] static int zs_page_migrate(struct page *newpage, struct page *page, @@ -1736,6 +1736,13 @@ static int zs_page_migrate(struct page *newpage, struct page *page, unsigned long old_obj

Re: [PATCH v1 00/29] mm/migration: rework movable_ops page migration (part 1)

2025-07-01 Thread David Hildenbrand
On 30.06.25 14:59, David Hildenbrand wrote: Based on mm/mm-new. In the future, as we decouple "struct page" from "struct folio", pages that support "non-lru page migration" -- movable_ops page migration such as memory balloons and zsmalloc -- will no longer

Re: [PATCH v1 23/29] mm/page-alloc: remove PageMappingFlags()

2025-07-01 Thread David Hildenbrand
On 01.07.25 15:02, Lorenzo Stoakes wrote: On Mon, Jun 30, 2025 at 03:00:04PM +0200, David Hildenbrand wrote: We can now simply check for PageAnon() and remove PageMappingFlags(). ... and while at it, use the folio instead and operate on folio->mapping. Probably worth mentioning to be su

Re: [PATCH v1 22/29] mm/page-flags: rename PAGE_MAPPING_MOVABLE to PAGE_MAPPING_ANON_KSM

2025-07-01 Thread David Hildenbrand
On 01.07.25 14:54, Lorenzo Stoakes wrote: On Mon, Jun 30, 2025 at 03:00:03PM +0200, David Hildenbrand wrote: KSM is the only remaining user, let's rename the flag. While at it, adjust to remaining page -> folio in the doc. Hm I wonder if we could just ideally have this be a separ

Re: [PATCH v1 21/29] mm: rename PG_isolated to PG_movable_ops_isolated

2025-07-01 Thread David Hildenbrand
PAGEFLAG(MovableOps, movable_ops, PF_NO_TAIL); +/* + * A movable_ops page has this flag set while it is isolated for migration. + * This flag primarily protects against concurrent migration attempts. + * + * Once migration ended (success or failure), the flag is cleared. The + * flag is manag

Re: [PATCH v1 17/29] mm/page_isolation: drop __folio_test_movable() check for large folios

2025-07-01 Thread David Hildenbrand
On 01.07.25 13:03, Lorenzo Stoakes wrote: On Mon, Jun 30, 2025 at 02:59:58PM +0200, David Hildenbrand wrote: Currently, we only support migration of individual movable_ops pages, so we can not run into that. Reviewed-by: Zi Yan Signed-off-by: David Hildenbrand Seems sensible, so: Reviewed

Re: [PATCH v1 20/29] mm: convert "movable" flag in page->mapping to a page flag

2025-07-01 Thread David Hildenbrand
On 01.07.25 14:44, Lorenzo Stoakes wrote: On Mon, Jun 30, 2025 at 03:00:01PM +0200, David Hildenbrand wrote: Instead, let's use a page flag. As the page flag can result in false-positives, glue it to the page types for which we support/implement movable_ops page migration. The flag reus

Re: [PATCH v1 19/29] mm: stop storing migration_ops in page->mapping

2025-07-01 Thread David Hildenbrand
On 01.07.25 14:12, Lorenzo Stoakes wrote: On Mon, Jun 30, 2025 at 03:00:00PM +0200, David Hildenbrand wrote: ... instead, look them up statically based on the page type. Maybe in the future we want a registration interface? At least for now, it can be easily handled using the two page types

Re: [PATCH v1 18/29] mm: remove __folio_test_movable()

2025-07-01 Thread David Hildenbrand
--- include/linux/page-flags.h | 6 -- mm/migrate.c | 43 -- mm/vmscan.c| 6 -- 3 files changed, 17 insertions(+), 38 deletions(-) diff --git a/include/linux/page-flags.h b/include/linux/page-flags.h index c67163b73c

Re: [PATCH v1 13/29] mm/balloon_compaction: stop using __ClearPageMovable()

2025-07-01 Thread David Hildenbrand
OK I guess this is fine... :) An aside, unrelated tot his series: it'd be nice to use 'deflate' consistently in this code. We do __count_vm_event(BALLOON_DEFLATE) in balloon_page_list_dequeue() but say 'deflate' nowhere else... well before this patch :) Right, dequeue is actually deflate, becau

Re: [PATCH v1 16/29] mm: rename __PageMovable() to page_has_movable_ops()

2025-07-01 Thread David Hildenbrand
On 01.07.25 12:59, Lorenzo Stoakes wrote: On Mon, Jun 30, 2025 at 02:59:57PM +0200, David Hildenbrand wrote: Let's make it clearer that we are talking about movable_ops pages. While at it, convert a VM_BUG_ON to a VM_WARN_ON_ONCE_PAGE. <3 Reviewed-by: Zi Yan Signed-off-b

Re: [PATCH v1 15/29] mm/migration: remove PageMovable()

2025-07-01 Thread David Hildenbrand
On 01.07.25 12:50, Lorenzo Stoakes wrote: On Mon, Jun 30, 2025 at 02:59:56PM +0200, David Hildenbrand wrote: As __ClearPageMovable() is gone that would have only made PageMovable()==false but still __PageMovable()==true, now PageMovable() == __PageMovable(). I think this could be rephrased to

Re: [PATCH v1 14/29] mm/migrate: remove __ClearPageMovable()

2025-07-01 Thread David Hildenbrand
On 01.07.25 12:43, Lorenzo Stoakes wrote: On Mon, Jun 30, 2025 at 02:59:55PM +0200, David Hildenbrand wrote: Unused, let's remove it. The Chinese docs in Documentation/translations/zh_CN/mm/page_migration.rst still mention it, but that whole docs is destined to get outdated and updat

Re: [PATCH v1 04/29] mm/page_alloc: let page freeing clear any set page type

2025-07-01 Thread David Hildenbrand
On 01.07.25 10:27, Lorenzo Stoakes wrote: On Tue, Jul 01, 2025 at 10:17:13AM +0200, David Hildenbrand wrote: On 30.06.25 17:27, Lorenzo Stoakes wrote: On Mon, Jun 30, 2025 at 02:59:45PM +0200, David Hildenbrand wrote: Currently, any user of page types must clear that type before freeing a

Re: [PATCH v1 13/29] mm/balloon_compaction: stop using __ClearPageMovable()

2025-07-01 Thread David Hildenbrand
On 01.07.25 12:03, Lorenzo Stoakes wrote: On Mon, Jun 30, 2025 at 02:59:54PM +0200, David Hildenbrand wrote: We can just look at the balloon device (stored in page->private), to see if the page is still part of the balloon. As isolated balloon pages cannot get released (they are taken off

Re: [PATCH v1 10/29] mm/migrate: remove folio_test_movable() and folio_movable_ops()

2025-07-01 Thread David Hildenbrand
On 30.06.25 19:07, Lorenzo Stoakes wrote: On Mon, Jun 30, 2025 at 02:59:51PM +0200, David Hildenbrand wrote: Folios will have nothing to do with movable_ops page migration. These functions are now unused, so let's remove them. Maybe worth mentioning that __folio_test_movable() is st

Re: [PATCH v1 09/29] mm/migrate: factor out movable_ops page handling into migrate_movable_ops_page()

2025-07-01 Thread David Hildenbrand
On 01.07.25 11:24, David Hildenbrand wrote: On 30.06.25 19:05, Lorenzo Stoakes wrote: On Mon, Jun 30, 2025 at 02:59:50PM +0200, David Hildenbrand wrote: Let's factor it out, simplifying the calling code. The assumption is that flush_dcache_page() is not required for movable_ops page

Re: [PATCH v1 04/29] mm/page_alloc: let page freeing clear any set page type

2025-07-01 Thread David Hildenbrand
On 01.07.25 10:37, Lorenzo Stoakes wrote: On Tue, Jul 01, 2025 at 10:34:33AM +0200, David Hildenbrand wrote: Reviewed-by: Zi Yan Acked-by: Harry Yoo Signed-off-by: David Hildenbrand Based on discussion below, I'm good with this now with the comment change, so feel free to add: Review

Re: [PATCH v1 02/29] mm/balloon_compaction: convert balloon_page_delete() to balloon_page_finalize()

2025-07-01 Thread David Hildenbrand
[...] -{ - __ClearPageOffline(page); - __ClearPageMovable(page); - set_page_private(page, 0); - /* -* No touch page.lru field once @page has been isolated -* because VM is using the field. -*/ - if (!PageIsolated(page)) - list_d

Re: [PATCH v1 09/29] mm/migrate: factor out movable_ops page handling into migrate_movable_ops_page()

2025-07-01 Thread David Hildenbrand
On 30.06.25 19:05, Lorenzo Stoakes wrote: On Mon, Jun 30, 2025 at 02:59:50PM +0200, David Hildenbrand wrote: Let's factor it out, simplifying the calling code. The assumption is that flush_dcache_page() is not required for movable_ops pages: as documented for flush_dcache_folio(), it r

Re: [PATCH v1 07/29] mm/migrate: rename isolate_movable_page() to isolate_movable_ops_page()

2025-07-01 Thread David Hildenbrand
On 30.06.25 18:24, Lorenzo Stoakes wrote: On Mon, Jun 30, 2025 at 02:59:48PM +0200, David Hildenbrand wrote: ... and start moving back to per-page things that will absolutely not be folio things in the future. Add documentation and a comment that the remaining folio stuff (lock, refcount) will

Re: [PATCH v1 06/29] mm/zsmalloc: make PageZsmalloc() sticky until the page is freed

2025-07-01 Thread David Hildenbrand
On 30.06.25 18:03, Lorenzo Stoakes wrote: On Mon, Jun 30, 2025 at 02:59:47PM +0200, David Hildenbrand wrote: Let the page freeing code handle clearing the page type. Acked-by: Zi Yan Reviewed-by: Sergey Senozhatsky Acked-by: Harry Yoo Signed-off-by: David Hildenbrand On basis of sanity

Re: [PATCH v1 05/29] mm/balloon_compaction: make PageOffline sticky until the page is freed

2025-07-01 Thread David Hildenbrand
On 30.06.25 18:01, Lorenzo Stoakes wrote: On Mon, Jun 30, 2025 at 02:59:46PM +0200, David Hildenbrand wrote: Let the page freeing code handle clearing the page type. Why is this advantageous? We want to keep the page marked offline for longer? Less code? ;) I will add: "Being ab

Re: [PATCH v1 04/29] mm/page_alloc: let page freeing clear any set page type

2025-07-01 Thread David Hildenbrand
On 30.06.25 17:27, Lorenzo Stoakes wrote: On Mon, Jun 30, 2025 at 02:59:45PM +0200, David Hildenbrand wrote: Currently, any user of page types must clear that type before freeing a page back to the buddy, otherwise we'll run into mapcount related sanity checks (because the page type curr

Re: [PATCH v1 05/29] mm/balloon_compaction: make PageOffline sticky until the page is freed

2025-07-01 Thread David Hildenbrand
On 30.06.25 18:14, Zi Yan wrote: On 30 Jun 2025, at 12:01, Lorenzo Stoakes wrote: On Mon, Jun 30, 2025 at 02:59:46PM +0200, David Hildenbrand wrote: Let the page freeing code handle clearing the page type. Why is this advantageous? We want to keep the page marked offline for longer

Re: [PATCH v1 05/29] mm/balloon_compaction: make PageOffline sticky until the page is freed

2025-07-01 Thread David Hildenbrand
On 01.07.25 08:13, Harry Yoo wrote: On Mon, Jun 30, 2025 at 12:14:01PM -0400, Zi Yan wrote: On 30 Jun 2025, at 12:01, Lorenzo Stoakes wrote: On Mon, Jun 30, 2025 at 02:59:46PM +0200, David Hildenbrand wrote: Let the page freeing code handle clearing the page type. Why is this advantageous

Re: [PATCH v1 03/29] mm/zsmalloc: drop PageIsolated() related VM_BUG_ONs

2025-07-01 Thread David Hildenbrand
On 30.06.25 17:17, Lorenzo Stoakes wrote: On Mon, Jun 30, 2025 at 02:59:44PM +0200, David Hildenbrand wrote: Let's drop these checks; these are conditions the core migration code must make sure will hold either way, no need to double check. Acked-by: Zi Yan Reviewed-by: Sergey Senozh

Re: [PATCH v1 02/29] mm/balloon_compaction: convert balloon_page_delete() to balloon_page_finalize()

2025-07-01 Thread David Hildenbrand
On 30.06.25 17:15, Lorenzo Stoakes wrote: On Mon, Jun 30, 2025 at 02:59:43PM +0200, David Hildenbrand wrote: Let's move the removal of the page from the balloon list into the single caller, to remove the dependency on the PG_isolated flag and clarify locking requirements. We'll s

[PATCH v1 13/29] mm/balloon_compaction: stop using __ClearPageMovable()

2025-06-30 Thread David Hildenbrand
ack. Add a WARN_ON_ONCE for now. Signed-off-by: David Hildenbrand --- include/linux/balloon_compaction.h | 4 +--- mm/balloon_compaction.c| 11 +++ 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/include/linux/balloon_compaction.h b/include/linux/balloon_comp

[PATCH v1 27/29] docs/mm: convert from "Non-LRU page migration" to "movable_ops page migration"

2025-06-30 Thread David Hildenbrand
Let's bring the docs up-to-date. Reviewed-by: Zi Yan Signed-off-by: David Hildenbrand --- Documentation/mm/page_migration.rst | 39 - 1 file changed, 27 insertions(+), 12 deletions(-) diff --git a/Documentation/mm/page_migration.rst b/Documentati

[PATCH v1 28/29] mm/balloon_compaction: "movable_ops" doc updates

2025-06-30 Thread David Hildenbrand
Let's bring the docs up-to-date. Setting PG_movable_ops + page->private very likely still requires to be performed under documented locks: it's complicated. We will rework this in the future, as we will try avoiding using the page lock. Signed-off-by: David Hildenbrand ---

[PATCH v1 26/29] mm: rename PAGE_MAPPING_* to FOLIO_MAPPING_*

2025-06-30 Thread David Hildenbrand
Now that the mapping flags are only used for folios, let's rename the defines. Reviewed-by: Zi Yan Signed-off-by: David Hildenbrand --- fs/proc/page.c | 4 ++-- include/linux/fs.h | 2 +- include/linux/mm_types.h | 1 - include/linux/page-flags.h

[PATCH v1 29/29] mm/balloon_compaction: provide single balloon_page_insert() and balloon_mapping_gfp_mask()

2025-06-30 Thread David Hildenbrand
Let's just special-case based on IS_ENABLED(CONFIG_BALLOON_COMPACTION like we did for balloon_page_finalize(). Signed-off-by: David Hildenbrand --- include/linux/balloon_compaction.h | 42 +++--- 1 file changed, 15 insertions(+), 27 deletions(-) diff --git a/in

[PATCH v1 23/29] mm/page-alloc: remove PageMappingFlags()

2025-06-30 Thread David Hildenbrand
We can now simply check for PageAnon() and remove PageMappingFlags(). ... and while at it, use the folio instead and operate on folio->mapping. Reviewed-by: Zi Yan Signed-off-by: David Hildenbrand --- include/linux/page-flags.h | 5 - mm/page_alloc.c| 7 +++ 2 fi

[PATCH v1 25/29] mm: simplify folio_expected_ref_count()

2025-06-30 Thread David Hildenbrand
d-off-by: David Hildenbrand --- include/linux/mm.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/include/linux/mm.h b/include/linux/mm.h index 6a5447bd43fd8..f6ef4c4eb536b 100644 --- a/include/linux/mm.h +++ b/include/linux/mm.h @@ -2176,13 +2176,13 @@ static inlin

[PATCH v1 24/29] mm/page-flags: remove folio_mapping_flags()

2025-06-30 Thread David Hildenbrand
It's unused and the page counterpart is gone, so let's remove it. Reviewed-by: Zi Yan Signed-off-by: David Hildenbrand --- include/linux/page-flags.h | 5 - 1 file changed, 5 deletions(-) diff --git a/include/linux/page-flags.h b/include/linux/page-flags.h index f53

[PATCH v1 22/29] mm/page-flags: rename PAGE_MAPPING_MOVABLE to PAGE_MAPPING_ANON_KSM

2025-06-30 Thread David Hildenbrand
KSM is the only remaining user, let's rename the flag. While at it, adjust to remaining page -> folio in the doc. Reviewed-by: Zi Yan Signed-off-by: David Hildenbrand --- include/linux/page-flags.h | 12 ++-- 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/inclu

[PATCH v1 21/29] mm: rename PG_isolated to PG_movable_ops_isolated

2025-06-30 Thread David Hildenbrand
Let's rename the flag to make it clearer where it applies (not folios ...). While at it, define the flag only with CONFIG_MIGRATION. Reviewed-by: Zi Yan Signed-off-by: David Hildenbrand --- include/linux/page-flags.h | 16 +++- mm/compaction.c| 2 +- mm/migr

[PATCH v1 20/29] mm: convert "movable" flag in page->mapping to a page flag

2025-06-30 Thread David Hildenbrand
might result in false-positive warnings. Reviewed-by: Zi Yan Signed-off-by: David Hildenbrand --- include/linux/balloon_compaction.h | 2 +- include/linux/migrate.h| 8 - include/linux/page-flags.h | 52 -- mm/compaction.c

[PATCH v1 19/29] mm: stop storing migration_ops in page->mapping

2025-06-30 Thread David Hildenbrand
ing movable (having movable_ops), which we will change next. Reviewed-by: Zi Yan Signed-off-by: David Hildenbrand --- include/linux/balloon_compaction.h | 2 +- include/linux/migrate.h| 14 ++ include/linux/zsmalloc.h | 2 ++ mm/balloon_compactio

[PATCH v1 18/29] mm: remove __folio_test_movable()

2025-06-30 Thread David Hildenbrand
ework page_has_movable_ops() soon either way to no longer rely on page->mapping. Wherever we cast from folio to page now is a clear sign that this code has to be decoupled. Reviewed-by: Zi Yan Signed-off-by: David Hildenbrand --- include/linux/page-flags.h | 6 -- mm/migrate.c

[PATCH v1 17/29] mm/page_isolation: drop __folio_test_movable() check for large folios

2025-06-30 Thread David Hildenbrand
Currently, we only support migration of individual movable_ops pages, so we can not run into that. Reviewed-by: Zi Yan Signed-off-by: David Hildenbrand --- mm/page_isolation.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mm/page_isolation.c b/mm/page_isolation.c index

[PATCH v1 16/29] mm: rename __PageMovable() to page_has_movable_ops()

2025-06-30 Thread David Hildenbrand
Let's make it clearer that we are talking about movable_ops pages. While at it, convert a VM_BUG_ON to a VM_WARN_ON_ONCE_PAGE. Reviewed-by: Zi Yan Signed-off-by: David Hildenbrand --- include/linux/migrate.h| 2 +- include/linux/page-flags.h | 2 +- mm/compaction.c

[PATCH v1 15/29] mm/migration: remove PageMovable()

2025-06-30 Thread David Hildenbrand
PageMovable() into sanity checks for __PageMovable(). Reviewed-by: Zi Yan Signed-off-by: David Hildenbrand --- include/linux/migrate.h | 2 -- mm/compaction.c | 15 --- mm/migrate.c| 18 ++ 3 files changed, 10 insertions(+), 25 deletions(-) diff --git

[PATCH v1 12/29] mm/zsmalloc: stop using __ClearPageMovable()

2025-06-30 Thread David Hildenbrand
TODO for that. Signed-off-by: David Hildenbrand --- mm/zsmalloc.c | 15 +++ 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/mm/zsmalloc.c b/mm/zsmalloc.c index f98747aed4330..72c2b7562c511 100644 --- a/mm/zsmalloc.c +++ b/mm/zsmalloc.c @@ -876,7 +876,6 @@ static void reset_

[PATCH v1 14/29] mm/migrate: remove __ClearPageMovable()

2025-06-30 Thread David Hildenbrand
Unused, let's remove it. The Chinese docs in Documentation/translations/zh_CN/mm/page_migration.rst still mention it, but that whole docs is destined to get outdated and updated by somebody that actually speaks that language. Reviewed-by: Zi Yan Signed-off-by: David Hildenbrand --- in

[PATCH v1 11/29] mm/migrate: move movable_ops page handling out of move_to_new_folio()

2025-06-30 Thread David Hildenbrand
pages) Reviewed-by: Zi Yan Signed-off-by: David Hildenbrand --- mm/migrate.c | 63 +--- 1 file changed, 30 insertions(+), 33 deletions(-) diff --git a/mm/migrate.c b/mm/migrate.c index 0898ddd2f661f..22c115710d0e2 100644 --- a/mm/migrate.c +++

[PATCH v1 10/29] mm/migrate: remove folio_test_movable() and folio_movable_ops()

2025-06-30 Thread David Hildenbrand
Folios will have nothing to do with movable_ops page migration. These functions are now unused, so let's remove them. Reviewed-by: Zi Yan Signed-off-by: David Hildenbrand --- include/linux/migrate.h | 14 -- 1 file changed, 14 deletions(-) diff --git a/include/linux/migrat

[PATCH v1 09/29] mm/migrate: factor out movable_ops page handling into migrate_movable_ops_page()

2025-06-30 Thread David Hildenbrand
dling flushing caches if ever required. Note that we can now change folio_mapping_flags() to folio_test_anon() to make it clearer, because movable_ops pages will never take that path. Reviewed-by: Zi Yan Signed-off-by: David Hildenbrand --- mm/migrate.c

[PATCH v1 08/29] mm/migrate: rename putback_movable_folio() to putback_movable_ops_page()

2025-06-30 Thread David Hildenbrand
... and factor the complete handling of movable_ops pages out. Convert it similar to isolate_movable_ops_page(). While at it, convert the VM_BUG_ON_FOLIO() into a VM_WARN_ON_PAGE(). Signed-off-by: David Hildenbrand --- mm/migrate.c | 37 - 1 file changed, 24

[PATCH v1 07/29] mm/migrate: rename isolate_movable_page() to isolate_movable_ops_page()

2025-06-30 Thread David Hildenbrand
Yoo Signed-off-by: David Hildenbrand --- include/linux/migrate.h | 4 ++-- mm/compaction.c | 2 +- mm/migrate.c| 39 +-- 3 files changed, 32 insertions(+), 13 deletions(-) diff --git a/include/linux/migrate.h b/include/linux/migrate.h in

[PATCH v1 06/29] mm/zsmalloc: make PageZsmalloc() sticky until the page is freed

2025-06-30 Thread David Hildenbrand
Let the page freeing code handle clearing the page type. Acked-by: Zi Yan Reviewed-by: Sergey Senozhatsky Acked-by: Harry Yoo Signed-off-by: David Hildenbrand --- mm/zpdesc.h | 5 - mm/zsmalloc.c | 3 +-- 2 files changed, 1 insertion(+), 7 deletions(-) diff --git a/mm/zpdesc.h b/mm

[PATCH v1 05/29] mm/balloon_compaction: make PageOffline sticky until the page is freed

2025-06-30 Thread David Hildenbrand
Let the page freeing code handle clearing the page type. Acked-by: Zi Yan Acked-by: Harry Yoo Signed-off-by: David Hildenbrand --- include/linux/balloon_compaction.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/linux/balloon_compaction.h b/include/linux

[PATCH v1 02/29] mm/balloon_compaction: convert balloon_page_delete() to balloon_page_finalize()

2025-06-30 Thread David Hildenbrand
n decouple this from the page lock. Signed-off-by: David Hildenbrand --- arch/powerpc/platforms/pseries/cmm.c | 2 +- drivers/misc/vmw_balloon.c | 3 +- drivers/virtio/virtio_balloon.c | 4 +-- include/linux/balloon_compaction.h | 43 +++- mm/balloon_co

[PATCH v1 03/29] mm/zsmalloc: drop PageIsolated() related VM_BUG_ONs

2025-06-30 Thread David Hildenbrand
Let's drop these checks; these are conditions the core migration code must make sure will hold either way, no need to double check. Acked-by: Zi Yan Reviewed-by: Sergey Senozhatsky Acked-by: Harry Yoo Signed-off-by: David Hildenbrand --- mm/zpdesc.h | 5 - mm/zsmalloc.c | 5 ---

[PATCH v1 04/29] mm/page_alloc: let page freeing clear any set page type

2025-06-30 Thread David Hildenbrand
ransition phase). In the future we might want to warn on some page types. Instead of having an "allow list", let's rather wait until we know about once that should go on such a "disallow list". Reviewed-by: Zi Yan Acked-by: Harry Yoo Signed-off-by: David Hildenbrand ---

[PATCH v1 00/29] mm/migration: rework movable_ops page migration (part 1)

2025-06-30 Thread David Hildenbrand
ble_ops() checking wrong page Cc: Andrew Morton Cc: Jonathan Corbet Cc: Madhavan Srinivasan Cc: Michael Ellerman Cc: Nicholas Piggin Cc: Christophe Leroy Cc: Jerrin Shaji George Cc: Arnd Bergmann Cc: Greg Kroah-Hartman Cc: "Michael S. Tsirkin" Cc: David Hildenbrand Cc: Jason Wang

[PATCH v1 01/29] mm/balloon_compaction: we cannot have isolated pages in the balloon list

2025-06-30 Thread David Hildenbrand
The core will set PG_isolated only after mops->isolate_page() was called. In case of the balloon, that is where we will remove it from the balloon list. So we cannot have isolated pages in the balloon list. Let's drop this unnecessary check. Acked-by: Zi Yan Signed-off-by: David Hil

Re: [PATCH RFC 11/29] mm/migrate: move movable_ops page handling out of move_to_new_folio()

2025-06-30 Thread David Hildenbrand
On 18.06.25 19:39, David Hildenbrand wrote: Let's move that handling directly into migrate_folio_move(), so we can simplify move_to_new_folio(). While at it, fixup the documentation a bit. Note that unmap_and_move_huge_page() does not care, because it only deals with actual folios. (we

Re: [PATCH RFC 18/29] mm: remove __folio_test_movable()

2025-06-30 Thread David Hildenbrand
@@ -1164,7 +1148,6 @@ static int migrate_folio_unmap(new_folio_t get_new_folio, int rc = -EAGAIN; int old_page_state = 0; struct anon_vma *anon_vma = NULL; - bool is_lru = data_race(!__folio_test_movable(src)); bool locked = false; bool dst_locked = fa

  1   2   3   4   5   6   7   8   9   10   >