* [Devel] [PATCH hci-8.2 v2 1/3] mm/memcontrol: drop the unused update_lru_sizes()
2026-11-17 16:24 [Devel] [PATCH hci-8.2 v2 0/3] mm/memcontrol: tidy up the memory.numa_migrate code Konstantin Khorenko
@ 2026-11-17 16:24 ` Konstantin Khorenko
2026-11-17 16:27 ` no-reply
2026-11-17 16:24 ` [Devel] [PATCH hci-8.2 v2 2/3] mm/memcontrol: say where the numa_migrate code comes from Konstantin Khorenko
` (2 subsequent siblings)
3 siblings, 1 reply; 8+ messages in thread
From: Konstantin Khorenko @ 2026-11-17 16:24 UTC (permalink / raw)
To: Pavel Tikhomirov, Vasileios Almpanis; +Cc: devel
It has had no caller since commit 810e6836a6dc ("mm/memcontrol: use
lruvec_del_folio() in memcg_numa_isolate_pages()"), and being static
__always_inline it never drew a warning.
https://virtuozzo.atlassian.net/browse/VSTOR-152197
Feature: mm: interface to migrate memory between NUMA nodes upon userspace request
Fixes: 810e6836a6dc ("mm/memcontrol: use lruvec_del_folio() in memcg_numa_isolate_pages()")
Reviewed-by: Pavel Tikhomirov <ptikhomirov@virtuozzo.com>
Signed-off-by: Konstantin Khorenko <khorenko@virtuozzo.com>
---
mm/memcontrol.c | 18 ------------------
1 file changed, 18 deletions(-)
diff --git a/mm/memcontrol.c b/mm/memcontrol.c
index d8a87913ace37..a82d5e7bc8694 100644
--- a/mm/memcontrol.c
+++ b/mm/memcontrol.c
@@ -3497,24 +3497,6 @@ static struct folio *memcg_numa_migrate_new_folio(struct folio *old_folio,
ms->target_nodes);
}
-/*
- * Update LRU sizes after isolating pages. The LRU size updates must
- * be complete before mem_cgroup_update_lru_size due to a santity check.
- */
-static __always_inline void update_lru_sizes(struct lruvec *lruvec,
- enum lru_list lru, unsigned long *nr_zone_taken)
-{
- int zid;
-
- for (zid = 0; zid < MAX_NR_ZONES; zid++) {
- if (!nr_zone_taken[zid])
- continue;
-
- update_lru_size(lruvec, lru, zid, -nr_zone_taken[zid]);
- }
-
-}
-
/*
* Isolate at most @nr_to_scan pages from @lruvec for further migration and
* store them in @dst. Returns the number of pages scanned. Return value of 0
--
2.43.0
_______________________________________________
Devel mailing list
Devel@openvz.org
https://lists.openvz.org/mailman/listinfo/devel
^ permalink raw reply [flat|nested] 8+ messages in thread* [Devel] [PATCH hci-8.2 v2 2/3] mm/memcontrol: say where the numa_migrate code comes from
2026-11-17 16:24 [Devel] [PATCH hci-8.2 v2 0/3] mm/memcontrol: tidy up the memory.numa_migrate code Konstantin Khorenko
2026-11-17 16:24 ` [Devel] [PATCH hci-8.2 v2 1/3] mm/memcontrol: drop the unused update_lru_sizes() Konstantin Khorenko
@ 2026-11-17 16:24 ` Konstantin Khorenko
2026-11-17 16:28 ` no-reply
2026-11-17 16:24 ` [Devel] [PATCH hci-8.2 v2 3/3] mm/memcontrol: say what memcg_numa_isolate_pages() limits Konstantin Khorenko
2026-11-17 16:27 ` [Devel] [PATCH hci-8.2 v2 0/3] mm/memcontrol: tidy up the memory.numa_migrate code Konstantin Khorenko
3 siblings, 1 reply; 8+ messages in thread
From: Konstantin Khorenko @ 2026-11-17 16:24 UTC (permalink / raw)
To: Pavel Tikhomirov, Vasileios Almpanis; +Cc: devel
The comment in the isolation loop tells the rebase history of the code
instead of naming the upstream functions it copies, which is what a
rebase has to compare against. Replace it with those names, name the
original of the allocator too, and drop the leftovers of the copy: the
commented-out conditions and the pre-folio name of the allocator in
the comment to its private argument.
No functional change.
https://virtuozzo.atlassian.net/browse/VSTOR-152197
Feature: mm: interface to migrate memory between NUMA nodes upon userspace request
Reviewed-by: Pavel Tikhomirov <ptikhomirov@virtuozzo.com>
Signed-off-by: Konstantin Khorenko <khorenko@virtuozzo.com>
---
mm/memcontrol.c | 24 +++++++-----------------
1 file changed, 7 insertions(+), 17 deletions(-)
diff --git a/mm/memcontrol.c b/mm/memcontrol.c
index a82d5e7bc8694..4c3c06cfcf9fc 100644
--- a/mm/memcontrol.c
+++ b/mm/memcontrol.c
@@ -3462,7 +3462,7 @@ int ve_enough_memory(long pages)
#ifdef CONFIG_NUMA
/*
- * memcg_numa_migrate_new_page() private argument. @target_nodes specifies the
+ * memcg_numa_migrate_new_folio() private argument. @target_nodes specifies the
* set of nodes to allocate pages from. @current_node is the current preferable
* node, it gets rotated after each allocation.
*/
@@ -3473,7 +3473,8 @@ struct memcg_numa_migrate_struct {
/*
* Used as an argument for migrate_pages(). Allocated pages are spread evenly
- * among destination nodes.
+ * among destination nodes. The order and gfp choice follow
+ * alloc_migration_target().
*/
static struct folio *memcg_numa_migrate_new_folio(struct folio *old_folio,
unsigned long private)
@@ -3520,19 +3521,10 @@ static long memcg_numa_isolate_pages(struct lruvec *lruvec,
scanned++;
/*
- * Previously here we had a call to
- * __isolate_lru_page_prepare(page, ISOLATE_ASYNC_MIGRATE)
- * => need to get same parts from __isolate_lru_page_prepare()
- * like it's done in isolate_migratepages_block() in commit
- * 89f6c88a6ab4 ("mm: __isolate_lru_page_prepare() in
- * isolate_migratepages_block()")
- *
- * The code block below is taken from
- * isolate_migratepages_block(), mode variable is defined and
- * set to ISOLATE_ASYNC_MIGRATE in order to keep the original
- * code unchanged where possible.
- *
- * Also it is switched to folio, based on isolate_lru_folios().
+ * The checks below are a copy of the per-folio checks in
+ * isolate_migratepages_block() with mode == ISOLATE_ASYNC_MIGRATE;
+ * the isolation itself follows isolate_lru_folios(). Keep both
+ * in sync with their originals on a rebase.
*/
folio = lru_to_folio(src);
@@ -3552,7 +3544,6 @@ static long memcg_numa_isolate_pages(struct lruvec *lruvec,
is_unevictable = folio_test_unevictable(folio);
/* Compaction might skip unevictable pages but CMA takes them */
- /* if (is_unevictable) */
if (!(mode & ISOLATE_UNEVICTABLE) && is_unevictable)
goto isolate_fail;
@@ -3567,7 +3558,6 @@ static long memcg_numa_isolate_pages(struct lruvec *lruvec,
is_dirty = folio_test_dirty(folio);
- /* if (is_dirty) */
if (((mode & ISOLATE_ASYNC_MIGRATE) && is_dirty) ||
(mapping && is_unevictable)) {
bool migrate_dirty = true;
--
2.43.0
_______________________________________________
Devel mailing list
Devel@openvz.org
https://lists.openvz.org/mailman/listinfo/devel
^ permalink raw reply [flat|nested] 8+ messages in thread* Re: [Devel] [PATCH hci-8.2 v2 2/3] mm/memcontrol: say where the numa_migrate code comes from
2026-11-17 16:24 ` [Devel] [PATCH hci-8.2 v2 2/3] mm/memcontrol: say where the numa_migrate code comes from Konstantin Khorenko
@ 2026-11-17 16:28 ` no-reply
0 siblings, 0 replies; 8+ messages in thread
From: no-reply @ 2026-11-17 16:28 UTC (permalink / raw)
To: Konstantin Khorenko, Pavel Tikhomirov, Vasileios Almpanis; +Cc: devel
Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [Low] mm: memcg_numa_migrate_new_folio() comment wrongly says gfp
follows alloc_migration_target()
--
commit 2b0b5c5c2e0f48e28f410ad926fddeacad923c4a
Author: Konstantin Khorenko <khorenko@virtuozzo.com>
mm/memcontrol: say where the numa_migrate code comes from
The patch replaces the rebase-history comment in memcg_numa_isolate_pages() with the names of the upstream functions it copies. It also names alloc_migration_target() as the original of the allocator and removes leftover commented-out conditions. No functional change is intended.
> diff --git a/mm/memcontrol.c b/mm/memcontrol.c
> index a82d5e7bc869..4c3c06cfcf9f 100644
> --- a/mm/memcontrol.c
> +++ b/mm/memcontrol.c
[ ... ]
> @@ -3473,7 +3473,8 @@ struct memcg_numa_migrate_struct {
>
> /*
> * Used as an argument for migrate_pages(). Allocated pages are spread evenly
> - * among destination nodes.
> + * among destination nodes. The order and gfp choice follow
> + * alloc_migration_target().
> */
> static struct folio *memcg_numa_migrate_new_folio(struct folio *old_folio,
> unsigned long private)
[Severity: Low]
Is the claim that the gfp choice follows alloc_migration_target() accurate?
Only the order matches. alloc_migration_target() clears __GFP_RECLAIM and ORs in GFP_TRANSHUGE for large folios. It also adds __GFP_HIGHMEM based on the source zone. memcg_numa_migrate_new_folio() hardcodes GFP_HIGHUSER_MOVABLE | __GFP_NORETRY | __GFP_NOWARN. For large folios it uses GFP_TRANSHUGE_LIGHT | __GFP_THISNODE, and it has no hugetlb or zone-based highmem handling.
The commit message says the point is to give a rebase the functions to compare against, so a comment claiming gfp parity could mislead that rebase. Could the comment be limited to the large-folio order and the __folio_alloc() usage, and say that the gfp mask is deliberately different? The series tip (f81bad5580ae) still carries this comment text, so a later patch does not correct it.
--
Sashiko AI review · https://sashiko.vzint.dev/#/patchset/20261117-b4-prep-khorenko-vstor-152197-numa-migrate-cleanup-v2-0-1dce69bd115c@virtuozzo.com?part=2
_______________________________________________
Devel mailing list
Devel@openvz.org
https://lists.openvz.org/mailman/listinfo/devel
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Devel] [PATCH hci-8.2 v2 3/3] mm/memcontrol: say what memcg_numa_isolate_pages() limits
2026-11-17 16:24 [Devel] [PATCH hci-8.2 v2 0/3] mm/memcontrol: tidy up the memory.numa_migrate code Konstantin Khorenko
2026-11-17 16:24 ` [Devel] [PATCH hci-8.2 v2 1/3] mm/memcontrol: drop the unused update_lru_sizes() Konstantin Khorenko
2026-11-17 16:24 ` [Devel] [PATCH hci-8.2 v2 2/3] mm/memcontrol: say where the numa_migrate code comes from Konstantin Khorenko
@ 2026-11-17 16:24 ` Konstantin Khorenko
2026-11-17 16:27 ` no-reply
2026-11-17 16:27 ` [Devel] [PATCH hci-8.2 v2 0/3] mm/memcontrol: tidy up the memory.numa_migrate code Konstantin Khorenko
3 siblings, 1 reply; 8+ messages in thread
From: Konstantin Khorenko @ 2026-11-17 16:24 UTC (permalink / raw)
To: Pavel Tikhomirov, Vasileios Almpanis; +Cc: devel
The comment of memcg_numa_isolate_pages() says it isolates at most
@nr_to_scan pages and returns the number of pages scanned. The loop
stops at @nr_to_scan folios scanned or @nr_to_scan pages isolated,
whichever comes first, and returns the number of folios scanned.
Describe both limits and the return value.
No functional change.
https://virtuozzo.atlassian.net/browse/VSTOR-152197
Feature: mm: interface to migrate memory between NUMA nodes upon userspace request
Signed-off-by: Konstantin Khorenko <khorenko@virtuozzo.com>
---
mm/memcontrol.c | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)
diff --git a/mm/memcontrol.c b/mm/memcontrol.c
index 4c3c06cfcf9fc..a67c0bc0ee3d2 100644
--- a/mm/memcontrol.c
+++ b/mm/memcontrol.c
@@ -3499,9 +3499,10 @@ static struct folio *memcg_numa_migrate_new_folio(struct folio *old_folio,
}
/*
- * Isolate at most @nr_to_scan pages from @lruvec for further migration and
- * store them in @dst. Returns the number of pages scanned. Return value of 0
- * means that @lruvec is empty.
+ * Isolate folios from @lruvec into @dst for further migration. Stops once
+ * @nr_to_scan folios are scanned or @nr_to_scan pages are isolated, whichever
+ * comes first. Returns the number of folios scanned. Return value of 0 means
+ * that @lruvec is empty.
*/
static long memcg_numa_isolate_pages(struct lruvec *lruvec,
struct list_head *src, struct list_head *dst,
--
2.43.0
_______________________________________________
Devel mailing list
Devel@openvz.org
https://lists.openvz.org/mailman/listinfo/devel
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [Devel] [PATCH hci-8.2 v2 0/3] mm/memcontrol: tidy up the memory.numa_migrate code
2026-11-17 16:24 [Devel] [PATCH hci-8.2 v2 0/3] mm/memcontrol: tidy up the memory.numa_migrate code Konstantin Khorenko
` (2 preceding siblings ...)
2026-11-17 16:24 ` [Devel] [PATCH hci-8.2 v2 3/3] mm/memcontrol: say what memcg_numa_isolate_pages() limits Konstantin Khorenko
@ 2026-11-17 16:27 ` Konstantin Khorenko
3 siblings, 0 replies; 8+ messages in thread
From: Konstantin Khorenko @ 2026-11-17 16:27 UTC (permalink / raw)
To: Pavel Tikhomirov, Vasileios Almpanis, Konstantin Khorenko; +Cc: devel
On Tue, 17 Nov 2026 17:24:42 +0100, Konstantin Khorenko wrote:
> mm/memcontrol: tidy up the memory.numa_migrate code
>
> Leftovers found while fixing VSTOR-151607, where the allocator of
> memory.numa_migrate had fallen behind the upstream function it was
> copied from. Nothing here changes behaviour.
>
> - 1: update_lru_sizes() lost its only caller when the isolation loop
> switched to lruvec_del_folio(); static __always_inline, so no
> warning ever came.
> - 2: the comment in the isolation loop told the rebase history of the
> code. It now names the upstream functions the loop and the allocator
> copy (isolate_migratepages_block(), isolate_lru_folios(),
> alloc_migration_target()), which is what the next rebase has to
> compare against. The commented-out conditions and the pre-folio name
> of the allocator go with it.
> - 3: the comment of memcg_numa_isolate_pages() speaks of pages only,
> while the loop stops at @nr_to_scan folios scanned or @nr_to_scan
> pages isolated and returns the number of folios scanned.
>
> [...]
Applied to branch-rh10-6.12.0-211.75.1.26.x.vz10-ovz, will be released in rh10-6.12.0-211.75.1.24.3.vz10, thanks!
[1/3] mm/memcontrol: drop the unused update_lru_sizes()
https://bitbucket.org/virtuozzocore/vzkernel.vzs/commits/d7d54d7c0e0f
[2/3] mm/memcontrol: say where the numa_migrate code comes from
https://bitbucket.org/virtuozzocore/vzkernel.vzs/commits/93b7d76dbf81
[3/3] mm/memcontrol: say what memcg_numa_isolate_pages() limits
https://bitbucket.org/virtuozzocore/vzkernel.vzs/commits/5d9d7af3eef1
--
Konstantin Khorenko,
Virtuozzo Linux Kernel Team
_______________________________________________
Devel mailing list
Devel@openvz.org
https://lists.openvz.org/mailman/listinfo/devel
^ permalink raw reply [flat|nested] 8+ messages in thread