All Virtuozzo development lists (kernel + QEMU)
 help / color / mirror / Atom feed
From: no-reply@sashiko.virtuozzo.com
To: Konstantin Khorenko <khorenko@virtuozzo.com>,
	Pavel Tikhomirov <ptikhomirov@virtuozzo.com>
Cc: devel@openvz.org
Subject: Re: [Devel] [PATCH hci-8.1 v2 1/2] mm/memcontrol: allocate numa_migrate targets of the source folio order
Date: Wed, 28 Oct 2026 14:22:54 +0000	[thread overview]
Message-ID: <010701a182e47c1c-07e58fbb-43c1-45ec-8a62-7bbdd6363582-000000@eu-central-1.amazonses.com> (raw)
In-Reply-To: <20261028-b4-prep-khorenko-vstor-151607-numa-migrate-order-v2-1-b973a82a5b0c@virtuozzo.com>

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Medium] mm: memcg numa_migrate uses no-reclaim THISNODE gfp for all large folio orders
--

commit dc423622ee7bf287039eede1edeca15b40cb3108
Author: Konstantin Khorenko <khorenko@virtuozzo.com>

mm/memcontrol: allocate numa_migrate targets of the source folio order

This patch makes memcg_numa_migrate_new_folio() allocate the destination
folio with the same order as the source large folio, instead of always
using HPAGE_PMD_ORDER. It also drops the thp_migration_supported() check.

> diff --git a/mm/memcontrol.c b/mm/memcontrol.c
> index 0734c0fa21d05..d8a87913ace37 100644
> --- a/mm/memcontrol.c
> +++ b/mm/memcontrol.c

[ ... ]

> @@ -3487,13 +3488,13 @@ static struct folio *memcg_numa_migrate_new_folio(struct folio *old_folio,
>  		VM_BUG_ON(ms->current_node >= MAX_NUMNODES);
>  	}
>  
> -	if (thp_migration_supported() && folio_test_large(old_folio)) {
> -		return __folio_alloc(GFP_TRANSHUGE_LIGHT | __GFP_THISNODE,
> -				HPAGE_PMD_ORDER, ms->current_node,
> -				ms->target_nodes);
> +	if (folio_test_large(old_folio)) {
> +		gfp_mask = GFP_TRANSHUGE_LIGHT | __GFP_THISNODE;
> +		order = folio_order(old_folio);
>  	}

[Severity: Medium]
The order fix looks right, but the no-reclaim, single-node policy is now
applied to every large folio, not only PMD-sized THPs.

GFP_TRANSHUGE_LIGHT has no __GFP_DIRECT_RECLAIM, and __GFP_THISNODE pins
the allocation to ms->current_node. For a small-order file folio or an
mTHP, can the allocation now fail on a fragmented node, with no fallback
to the other nodes in target_nodes? Before this patch, such folios got an
order-0 destination allocated with GFP_HIGHUSER_MOVABLE | __GFP_NORETRY,
which does allow direct reclaim.

If the allocation fails, migrate_folio_unmap() returns -ENOMEM. In
migrate_pages_batch() the -ENOMEM case then does this:

    case -ENOMEM:
        ...
        if (is_large && !nosplit) {
            int ret = try_split_folio(folio, split_folios, mode);
            ...
        }
        ...
        rc_saved = rc;
        if (list_empty(&unmap_folios))
            goto out;

When the split also fails (for example -EAGAIN from an elevated refcount,
or a mapping whose minimum folio order is above 0), migrate_pages()
returns a negative value. Then in __memcg_numa_migrate_pages():

    ret = migrate_pages(&pages, memcg_numa_migrate_new_folio, ...);
    putback_movable_pages(&pages);
    if (ret < 0)
        return ret;

Does this abort the whole memory.numa_migrate write with -ENOMEM and
leave the remaining folios of the memcg unmigrated?

The old PMD-THP path had the same failure semantics. This patch widens
it to all large folio orders, and the commit message doesn't mention the
change in allocation policy.

Would it be reasonable to fall back to order 0 or to a reclaim-capable
gfp mask when the large allocation fails?

>  
> -	return __folio_alloc(gfp_mask, 0, ms->current_node, ms->target_nodes);
> +	return __folio_alloc(gfp_mask, order, ms->current_node,
> +			     ms->target_nodes);
>  }

-- 
Sashiko AI review · https://sashiko.vzint.dev/#/patchset/20261028-b4-prep-khorenko-vstor-151607-numa-migrate-order-v2-0-b973a82a5b0c@virtuozzo.com?part=1

_______________________________________________
Devel mailing list
Devel@openvz.org
https://lists.openvz.org/mailman/listinfo/devel

  reply	other threads:[~2026-10-28 14:24 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-28 14:17 [Devel] [PATCH hci-8.1 v2 0/2] mm/memcontrol: numa_migrate destinations " Konstantin Khorenko
2026-10-28 14:17 ` [Devel] [PATCH hci-8.1 v2 1/2] mm/memcontrol: allocate numa_migrate targets " Konstantin Khorenko
2026-10-28 14:22   ` no-reply [this message]
2026-10-28 15:30     ` Konstantin Khorenko
2026-10-28 15:40       ` Konstantin Khorenko
2026-10-28 14:17 ` [Devel] [PATCH hci-8.1 v2 2/2] selftests/ve: check memory.numa_migrate keeps the " Konstantin Khorenko
2026-10-28 14:23   ` no-reply
2026-10-28 15:13 ` [Devel] [PATCH hci-8.1 v2 0/2] mm/memcontrol: numa_migrate destinations of the source " Pavel Tikhomirov

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=010701a182e47c1c-07e58fbb-43c1-45ec-8a62-7bbdd6363582-000000@eu-central-1.amazonses.com \
    --to=no-reply@sashiko.virtuozzo.com \
    --cc=devel@openvz.org \
    --cc=khorenko@virtuozzo.com \
    --cc=ptikhomirov@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.