* [Devel] [PATCH hci-8.1 0/3] mm/memcontrol: tidy up the memory.numa_migrate code
@ 2026-10-28 13:49 Konstantin Khorenko
2026-10-28 13:49 ` [Devel] [PATCH hci-8.1 1/3] mm/memcontrol: drop the unused update_lru_sizes() Konstantin Khorenko
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Konstantin Khorenko @ 2026-10-28 13:49 UTC (permalink / raw)
To: Pavel Tikhomirov, Vasileios Almpanis; +Cc: devel
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. Applies on top of
"mm/memcontrol: numa_migrate destinations of the source folio order".
- 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 MAX_SCAN argument of memory.numa_migrate is documented in
pages while the scan counts folios.
https://virtuozzo.atlassian.net/browse/VSTOR-152197
Assisted-by: LLM
Signed-off-by: Konstantin Khorenko <khorenko@virtuozzo.com>
---
Konstantin Khorenko (3):
mm/memcontrol: drop the unused update_lru_sizes()
mm/memcontrol: say where the numa_migrate code comes from
mm/memcontrol: memory.numa_migrate MAX_SCAN counts folios
mm/memcontrol.c | 54 +++++++++++++-----------------------------------------
1 file changed, 13 insertions(+), 41 deletions(-)
---
base-commit: 8f4b2db111bee113348656f1b1f98c841d7c19e7
change-id: 20261028-b4-prep-khorenko-vstor-152197-numa-migrate-cleanup-dcc488d8d106
Best regards,
--
Konstantin Khorenko,
Virtuozzo Linux Kernel Team
_______________________________________________
Devel mailing list
Devel@openvz.org
https://lists.openvz.org/mailman/listinfo/devel
^ permalink raw reply [flat|nested] 4+ messages in thread
* [Devel] [PATCH hci-8.1 1/3] mm/memcontrol: drop the unused update_lru_sizes()
2026-10-28 13:49 [Devel] [PATCH hci-8.1 0/3] mm/memcontrol: tidy up the memory.numa_migrate code Konstantin Khorenko
@ 2026-10-28 13:49 ` Konstantin Khorenko
2026-10-28 13:49 ` [Devel] [PATCH hci-8.1 2/3] mm/memcontrol: say where the numa_migrate code comes from Konstantin Khorenko
2026-10-28 13:49 ` [Devel] [PATCH hci-8.1 3/3] mm/memcontrol: memory.numa_migrate MAX_SCAN counts folios Konstantin Khorenko
2 siblings, 0 replies; 4+ messages in thread
From: Konstantin Khorenko @ 2026-10-28 13:49 UTC (permalink / raw)
To: Pavel Tikhomirov, Vasileios Almpanis; +Cc: devel
It has had no caller since commit 3c6e0c1ac1d6 ("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
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] 4+ messages in thread
* [Devel] [PATCH hci-8.1 2/3] mm/memcontrol: say where the numa_migrate code comes from
2026-10-28 13:49 [Devel] [PATCH hci-8.1 0/3] mm/memcontrol: tidy up the memory.numa_migrate code Konstantin Khorenko
2026-10-28 13:49 ` [Devel] [PATCH hci-8.1 1/3] mm/memcontrol: drop the unused update_lru_sizes() Konstantin Khorenko
@ 2026-10-28 13:49 ` Konstantin Khorenko
2026-10-28 13:49 ` [Devel] [PATCH hci-8.1 3/3] mm/memcontrol: memory.numa_migrate MAX_SCAN counts folios Konstantin Khorenko
2 siblings, 0 replies; 4+ messages in thread
From: Konstantin Khorenko @ 2026-10-28 13:49 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
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] 4+ messages in thread
* [Devel] [PATCH hci-8.1 3/3] mm/memcontrol: memory.numa_migrate MAX_SCAN counts folios
2026-10-28 13:49 [Devel] [PATCH hci-8.1 0/3] mm/memcontrol: tidy up the memory.numa_migrate code Konstantin Khorenko
2026-10-28 13:49 ` [Devel] [PATCH hci-8.1 1/3] mm/memcontrol: drop the unused update_lru_sizes() Konstantin Khorenko
2026-10-28 13:49 ` [Devel] [PATCH hci-8.1 2/3] mm/memcontrol: say where the numa_migrate code comes from Konstantin Khorenko
@ 2026-10-28 13:49 ` Konstantin Khorenko
2 siblings, 0 replies; 4+ messages in thread
From: Konstantin Khorenko @ 2026-10-28 13:49 UTC (permalink / raw)
To: Pavel Tikhomirov, Vasileios Almpanis; +Cc: devel
memcg_numa_isolate_pages() counts a scanned folio as one whatever its
size, so the MAX_SCAN limit of memory.numa_migrate and the @nr_to_scan
arguments are in folios, not in pages as the comments say.
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 | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)
diff --git a/mm/memcontrol.c b/mm/memcontrol.c
index 4c3c06cfcf9fc..f93b0400c786d 100644
--- a/mm/memcontrol.c
+++ b/mm/memcontrol.c
@@ -3499,8 +3499,8 @@ 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
+ * Isolate at most @nr_to_scan folios from @lruvec for further migration and
+ * store them in @dst. Returns the number of folios scanned. Return value of 0
* means that @lruvec is empty.
*/
static long memcg_numa_isolate_pages(struct lruvec *lruvec,
@@ -3661,9 +3661,9 @@ static long __memcg_numa_migrate_pages(struct lruvec *lruvec, struct list_head *
}
/*
- * Migrate at most @nr_to_scan pages accounted to @memcg to @target_nodes.
- * Pages are spreaded evenly among destination nodes. If @nr_to_scan is <= 0,
- * then the function will attempt to migrate all pages accounted to @memcg.
+ * Scan at most @nr_to_scan folios accounted to @memcg and migrate them to
+ * @target_nodes, spread evenly among the nodes. If @nr_to_scan is <= 0, the
+ * function attempts to migrate all pages accounted to @memcg.
*/
static int memcg_numa_migrate_pages(struct mem_cgroup *memcg,
nodemask_t *target_nodes, long nr_to_scan)
@@ -3750,7 +3750,7 @@ static int memcg_numa_migrate_pages(struct mem_cgroup *memcg,
*
* where NODELIST is a comma-separated list of ranges N1-N2 specifying the set
* of nodes to migrate pages of this cgroup to, and the optional MAX_SCAN
- * imposes a limit on the number of pages that can be migrated in one go.
+ * imposes a limit on the number of folios scanned in one go.
*
* The call may be interrupted by a signal, in which case -EINTR is returned.
*/
--
2.43.0
_______________________________________________
Devel mailing list
Devel@openvz.org
https://lists.openvz.org/mailman/listinfo/devel
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2026-10-28 13:50 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-10-28 13:49 [Devel] [PATCH hci-8.1 0/3] mm/memcontrol: tidy up the memory.numa_migrate code Konstantin Khorenko
2026-10-28 13:49 ` [Devel] [PATCH hci-8.1 1/3] mm/memcontrol: drop the unused update_lru_sizes() Konstantin Khorenko
2026-10-28 13:49 ` [Devel] [PATCH hci-8.1 2/3] mm/memcontrol: say where the numa_migrate code comes from Konstantin Khorenko
2026-10-28 13:49 ` [Devel] [PATCH hci-8.1 3/3] mm/memcontrol: memory.numa_migrate MAX_SCAN counts folios Konstantin Khorenko
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.