From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail.openvz.org (mail.openvz.org [69.168.225.77]) by lore.virtuozzo.com (Postfix) with ESMTPS id E49AC8045D for ; Wed, 28 Oct 2026 13:11:27 +0000 (UTC) Received: from mail.openvz.org (localhost [127.0.0.1]) by mail.openvz.org (8.14.4/8.14.4) with ESMTP id 69SDA9hl020237; Wed, 28 Oct 2026 16:10:10 +0300 DKIM-Filter: OpenDKIM Filter v2.11.0 mail.openvz.org 69SDA9hl020237 Authentication-Results: mail.openvz.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=virtuozzo.com header.i=@virtuozzo.com header.b="H+mutPJh" Received: from mail-wr1-f71.google.com (mail-wr1-f71.google.com [209.85.221.71]) by mail.openvz.org (8.14.4/8.14.4) with ESMTP id 69SDA001020220 (version=TLSv1/SSLv3 cipher=AES128-GCM-SHA256 bits=128 verify=FAIL) for ; Wed, 28 Oct 2026 16:10:00 +0300 DKIM-Filter: OpenDKIM Filter v2.11.0 mail.openvz.org 69SDA001020220 Received: by mail-wr1-f71.google.com with SMTP id ffacd0b85a97d-48e29c25101so552633f8f.3 for ; Wed, 28 Oct 2026 06:10:00 -0700 (PDT) X-Forwarded-Encrypted: i=2; AKwUvBwpo0ERsr4dhInCacuQffrcrGZtZ5wri/hxWQbQpMVhHhAr81FpoGLyj0pEkIWTBZrs4bezoA==@openvz.org X-Gm-Message-State: AFq9FYJdId4jbqlmskuc/DYfihYolENv3PhcmKksfacXfdcV4Kkirv+E 4+OBijdgGpJj7Fvzf8pIZKhlijUKYBrZ9QhKBaNen1cWegWdjShjZ1neE0beje1csvahe3niBJ5 9zboorDoieRivi8i4tXngQ7MElsV2D8+44+vz+iOwQJYBTRxyaTaAGg== X-Gm-Gg: AYBFou1qe11M1oXLyBmMzHRs+vs4/UTJdHuLoDhZsaNqSSXP4yq4KP9mayUuCtFj5/j sK/GOc/OQCh9oYfJNFAipD7T+g7bij+Hx1g30jaMN37oGzMFLNQ6MvyaUZtmsf7weSSgYavGyjt 27kEgFgXOii6nZdw0fU9vVXv165508n4z7cGCEjq80xbHOnuLa/SYKhjFEVMcKo/MosvqTWUIxc 6mUiRZXOj4ei13xYR6Tc8KfNBrsJH/jFxFAGNqlx1M/vc2BtVSpS003OmHEM2dO1YBUGQnDe27r eDtGylAuLjO1mzeYMN1OCGBikyNJ/7nUd/ivptNQ/vU4A1A3f6sF1m9XXxCXSJDFKToVsbPaMn0 y59iAAbV95ZW+V3M6SAFrNaY/wYRFoCU= X-Received: by 2002:a05:6000:2089:b0:48c:4444:f0a2 with SMTP id ffacd0b85a97d-48e5d58cb94mr5648382f8f.7.1793193000131; Wed, 28 Oct 2026 06:10:00 -0700 (PDT) X-Received: by 2002:a05:6000:2089:b0:48c:4444:f0a2 with SMTP id ffacd0b85a97d-48e5d58cb94mr5648315f8f.7.1793192999533; Wed, 28 Oct 2026 06:09:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1793192999; cv=none; d=google.com; s=arc-20260327; b=fhO0forAHFN3ysZ5O8lbYtTrQ7rWutVFr5H7hcQ/HxoWGMqgsPOTUVwB5MeQa8ZFne RREm1JKkcgWBCGkJi1JLEnj3FeFe2GK+N0iBcCTn13ndlZ1k2yQpFCf6IIccyF8wTGg1 DwyxoygEvbaxplPKY0jbfBe2NPAhbgrpMTeUaG9n90O/ieyz09RRKo77n1c9YlQEYZpG nyy1yb/FxljF95rcNtaqIFEM5aN3anAEv3ZtzV0UKGLaAYeyqul4dzFiSMPPGDpKty/S Mgq9loYI5mYhT3vConK8kOTCjO3kt0W49BO1efxTcLI3YOfMtRUORq5NH85CUUbrcAGe xHmQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20260327; h=message-id:date:references:in-reply-to:cc:to:from:subject :content-transfer-encoding:mime-version:dkim-signature; bh=d6M26kV0LoaHPrbOwDMYr5It53yfDUR1xAgWd9j+7E4=; fh=iW+EeVBgw6gMfBKTMQNjVEaljb3qEpbHxtkEro0NxH8=; b=VmGN6CYqyM243ehlyKIgnah7Bv/MqrSafdzWOX8sWkKnmOXnAQ7zp2Z7WFVmb3/eLV EX41WIkYR2JAVLQm5UJTBa7dVLdDpfp6PPIqR/81SKLwDCVqRQf6J3Wwhl0/Z4EPIw2m krQbUH+AkxVtaprVgcgMpgkgHXyFD3rW93tpR+kC43ETqmgDTL+yGMgX3LJkYP3sY779 nTfo5CCP1D5Jds7gWbsG5+YrC/6KtIrztW4aotvXFngzpC3TP9cLnhjaIbBAodyrG1Bf EalBbc0q1fENPP6IWrAXCW/jCg0+zVt5FVO1L0VMhb0sPLxBuObef0WaixOgvDhOpqVi bLlQ==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@virtuozzo.com header.s=relay header.b=H+mutPJh; spf=pass (google.com: domain of vasileios.almpanis@virtuozzo.com designates 130.117.225.111 as permitted sender) smtp.mailfrom=vasileios.almpanis@virtuozzo.com; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=virtuozzo.com Received: from relay.virtuozzo.com (relay.virtuozzo.com. [130.117.225.111]) by mx.google.com with ESMTPS id ffacd0b85a97d-48e3ece86d7si26665095f8f.159.2026.10.28.06.09.59 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 28 Oct 2026 06:09:59 -0700 (PDT) Received-SPF: pass (google.com: domain of vasileios.almpanis@virtuozzo.com designates 130.117.225.111 as permitted sender) client-ip=130.117.225.111; Authentication-Results: mx.google.com; dkim=pass header.i=@virtuozzo.com header.s=relay header.b=H+mutPJh; spf=pass (google.com: domain of vasileios.almpanis@virtuozzo.com designates 130.117.225.111 as permitted sender) smtp.mailfrom=vasileios.almpanis@virtuozzo.com; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=virtuozzo.com DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=virtuozzo.com; s=relay; h=Message-Id:Date:From:Subject:Content-Type: MIME-Version; bh=d6M26kV0LoaHPrbOwDMYr5It53yfDUR1xAgWd9j+7E4=; b=H+mutPJhCH7W xDDVELVoG8IDXoXp1LX5mMFnQxxSMSB4QcoDSKAdlaF6DDR6WwqHB7rWSXfGjpGi4w5jK5Ys6dwjf ZCRcL5gJcRV3yA9fmqs/NppCqFklM89S8oPJps7KDYw4ASLv7E8wLtvaE+1Y7cl3QLS0laTx2zcPZ z6vZFkA+TfFD77Kkf/BhzDKfuHOCEUZFhgyZt1EOjYAQoCFhcl2HjCZcoHpM5iDD6Hq1Hm2BMv1wO qhAHhDr9nb+6RcXBMwLky6k15c6CxuVGZ0L+oZQ28ipmo1RSAnZriFrG6vb8CYZPjusErExDFj3TK e4x46jEkKpWAZRNURG1KUQ==; Received: from [130.117.225.5] (helo=dev010.ch-qa.vzint.dev) by relay.virtuozzo.com with esmtp (Exim 4.96) (envelope-from ) id 1xM3Lw-008HWi-37; Wed, 28 Oct 2026 14:09:58 +0100 MIME-Version: 1.0 From: Vasileios Almpanis To: Konstantin Khorenko In-Reply-To: <20261028-b4-prep-khorenko-vstor-151607-numa-migrate-order-v1-1-268336526677@virtuozzo.com> References: <20261028-b4-prep-khorenko-vstor-151607-numa-migrate-order-v1-0-268336526677@virtuozzo.com> <20261028-b4-prep-khorenko-vstor-151607-numa-migrate-order-v1-1-268336526677@virtuozzo.com> Date: Wed, 28 Oct 2026 13:09:57 +0000 Message-Id: <179319299768.343268.1788849324039542699.b4-review@b4> X-Mailer: b4 0.16.0 X-Developer-Signature: v=1; a=ed25519-sha256; t=1793192999; l=3656; i=vasileios.almpanis@virtuozzo.com; s=20260812; h=from:subject:message-id; bh=Na6wa0INFGw9lbkvJti8BWcKhuB016GF80x9nnYWb0Y=; b=FFY7NXBeVX8+dnPWkTdTLLKZ820ngCiYOAlP5LvgxtVJGuemuzn5HcCbkYeYKa+yPnzfusSEZ 7gGOlLmD/E2C8GPXs6auF6RTaeTSBZljbEAeR6119oGKqhuf4XzWBWR X-Developer-Key: i=vasileios.almpanis@virtuozzo.com; a=ed25519; pk=HhuHDXAcPva9A8zccWEMRsb36reu+y4IVbBjXKxNUjw= X-OZ-Fwd: true Cc: devel@openvz.org Subject: Re: [Devel] [PATCH hci-8.1 1/2] mm/memcontrol: allocate numa_migrate targets of the source folio order X-BeenThere: devel@openvz.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: OpenVZ development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: devel-bounces@openvz.org Errors-To: devel-bounces@openvz.org > memcg_numa_migrate_new_folio() treats every large folio as a PMD-sized > THP and allocates an HPAGE_PMD_ORDER destination for it. The branch is > the 4.18 pattern of new_page() in mm/mempolicy.c: a compound page on > the LRU could only be a THP then, so PageTransHuge() implied > HPAGE_PMD_ORDER. > > Today the page cache holds large folios of any order (NFS sizes a folio > to the write, XFS and shmem have them too) and anonymous memory has > mTHP, while folio_test_large() is still just folio_test_head() and is > true for any order from 1 up. migrate_pages() never checks that the > destination order matches the source. > > For an order-1 or order-4 file folio the destination is an order-9 > folio that inherits the source index and page cache reference count, > so every later page cache operation that sizes the folio by its order > goes wrong: nrpages underflows, neighbouring xarray slots get wiped, > the folio can never be freed. > > On a two-node host a VM migration to another NUMA node along with a > backup to NFS ends up with a negative nrpages, and closing the backup > file dies in nfs4_evict_inode(): > > kernel BUG at fs/inode.c:737! > RIP: 0010:clear_inode+0x75/0x80 > Call Trace: > nfs4_evict_inode+0x21/0x80 [nfsv4] > evict+0x115/0x2a0 > nfs4_delegreturn_release+0x55/0xa0 [nfsv4] > rpc_free_task+0x39/0x60 [sunrpc] > __rpc_execute+0x3d1/0x3e0 [sunrpc] > > A debug build dies earlier, on the first migration of a large folio of > any file system, in mem_cgroup_migrate(): > > VM_BUG_ON_FOLIO(folio_nr_pages(old) != folio_nr_pages(new)) > > Make memcg_numa_migrate_new_folio() handle large folios properly. > > Fixes: 9f8a754ad6c2 ("mm: memcontrol: add memory.numa_migrate file") > https://virtuozzo.atlassian.net/browse/VSTOR-151607 > > Feature: mm: interface to migrate memory between NUMA nodes upon userspace request > Signed-off-by: Konstantin Khorenko > > diff --git a/mm/memcontrol.c b/mm/memcontrol.c > index 0734c0fa21d0..d8a87913ace3 100644 > --- a/mm/memcontrol.c > +++ b/mm/memcontrol.c > @@ -3480,6 +3480,7 @@ static struct folio *memcg_numa_migrate_new_folio(struct folio *old_folio, > { > struct memcg_numa_migrate_struct *ms = (void *)private; > gfp_t gfp_mask = GFP_HIGHUSER_MOVABLE | __GFP_NORETRY | __GFP_NOWARN; > + unsigned int order = 0; > > ms->current_node = next_node(ms->current_node, *ms->target_nodes); > if (ms->current_node >= MAX_NUMNODES) { > @@ -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); > } > > - return __folio_alloc(gfp_mask, 0, ms->current_node, ms->target_nodes); > + return __folio_alloc(gfp_mask, order, ms->current_node, > + ms->target_nodes); The patch looks good to me. There is another issue that is about parsing and has nothing to do with this patch but I though of bringing it up. If we write an empty nodelist to memory.numa_migrate it will get past nodes_subset. memcg_numa_migrate_new_folio will pass MAX_NUMNODES to __folio_alloc and will cause OOB. We need another patch that adds nodes_empty next to nodes_subset. -- Vasileios Almpanis _______________________________________________ Devel mailing list Devel@openvz.org https://lists.openvz.org/mailman/listinfo/devel