From: Pavel Tikhomirov <ptikhomirov@virtuozzo.com>
To: Konstantin Khorenko <khorenko@virtuozzo.com>
Cc: devel@openvz.org
Subject: Re: [Devel] [PATCH hci-8.1 3/3] mm/memcontrol: memory.numa_migrate MAX_SCAN counts folios
Date: Tue, 17 Nov 2026 09:40:53 +0100 [thread overview]
Message-ID: <179490485332.1839806.8808380962168459299.b4-review@b4> (raw)
In-Reply-To: <20261028-b4-prep-khorenko-vstor-152197-numa-migrate-cleanup-v1-3-aa959eecd3fd@virtuozzo.com>
> 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.
Sadly it does not:
while (... && scanned < nr_to_scan && taken < nr_to_scan) {
...
scanned++;
...
taken += folio_nr_pages(folio);
}
So we limit both the scanned amount in folios and the isolated amount
in pages. That is fine: the scan limit bounds the work, and checking a
big folio costs the same as a small one, so it should count as one
iteration, not as many as it has pages. But the isolated amount, the
part we actually care about, is in pages, so saying "folios" in the
comments is wrong.
Either describe both limits, or stick with pages as a main thing.
>
> 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>
>
> 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.
The above part is excess.
> 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.
Looks excess.
> */
> 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.
Looks excess.
--
Pavel Tikhomirov <ptikhomirov@virtuozzo.com>
_______________________________________________
Devel mailing list
Devel@openvz.org
https://lists.openvz.org/mailman/listinfo/devel
next prev parent reply other threads:[~2026-11-17 8:42 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
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-11-17 8:40 ` Pavel Tikhomirov
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-11-17 8:40 ` Pavel Tikhomirov
2026-10-28 13:49 ` [Devel] [PATCH hci-8.1 3/3] mm/memcontrol: memory.numa_migrate MAX_SCAN counts folios Konstantin Khorenko
2026-11-17 8:40 ` Pavel Tikhomirov [this message]
2026-11-12 18:04 ` [Devel] [PATCH hci-8.1 0/3] mm/memcontrol: tidy up the memory.numa_migrate code Konstantin Khorenko
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=179490485332.1839806.8808380962168459299.b4-review@b4 \
--to=ptikhomirov@virtuozzo.com \
--cc=devel@openvz.org \
--cc=khorenko@virtuozzo.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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.