From patchwork Mon Jul 8 21:55:37 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Xu X-Patchwork-Id: 13727073 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id BFA14C3271E for ; Mon, 8 Jul 2024 21:55:45 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 14D646B0098; Mon, 8 Jul 2024 17:55:45 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 0FDAB6B0099; Mon, 8 Jul 2024 17:55:45 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id F07286B009A; Mon, 8 Jul 2024 17:55:44 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id D24326B0098 for ; Mon, 8 Jul 2024 17:55:44 -0400 (EDT) Received: from smtpin16.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id 5B899A457F for ; Mon, 8 Jul 2024 21:55:44 +0000 (UTC) X-FDA: 82317943008.16.156279B Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf09.hostedemail.com (Postfix) with ESMTP id 66F3314001F for ; Mon, 8 Jul 2024 21:55:42 +0000 (UTC) Authentication-Results: imf09.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=I3zjtAFU; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf09.hostedemail.com: domain of peterx@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=peterx@redhat.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1720475720; a=rsa-sha256; cv=none; b=MQgUF8evgSs9GLeIy060zLGSOdxv4ozzdVb9U6y9enfj03X+t6nrRtDHbk6nU4gPu9/vAy 1dE3anWahBTCT2S9XFot36iyFCz49VRtMiHIhSeugIVqkyKrwWPtQpW0sTkGA1758d5C5t fj2lZ/JwBWw6EXtOjxcyNP2/wPcBagY= ARC-Authentication-Results: i=1; imf09.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=I3zjtAFU; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf09.hostedemail.com: domain of peterx@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=peterx@redhat.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1720475720; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding:in-reply-to: references:dkim-signature; bh=bdZl7zE1LbnN4RcXWZNvf+JG0YErrvEqH4FuELpRXl4=; b=TCqolMaavtDwc/+awaGnZ1OdibgbNcj7KgJtrVOGsylpdIk1ABr+D59ZhWG+N/szlkQ8Xm EWNLRV+l9X8cr78E3jtUksuAZ0Xy6rzkOKFcQ4ElHpgS2wgUbopIuAQ/IJpsWbYNkGGIYD JCgj7Nq0mEkj/7VlT/oT2RYJN7gnVYM= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1720475741; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=bdZl7zE1LbnN4RcXWZNvf+JG0YErrvEqH4FuELpRXl4=; b=I3zjtAFUVhGfpGmwR6hbGIH6KRP+FoK9HLvtHzGLXmIBagwSJIRNWJGfnQLuA5IF24PiD4 noJ4fsGALorQ++yt3KoWIoAby97+Z3t27Ra9mJIJGXjE9D/uSzc+LZjth1Kt/KqHZF0KhE FaVMyMF9avUWHA49ZZTqfsGxLv6gAEM= Received: from mail-qv1-f69.google.com (mail-qv1-f69.google.com [209.85.219.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-402-N_U9YYj2MNOuWUvpnIZFEg-1; Mon, 08 Jul 2024 17:55:40 -0400 X-MC-Unique: N_U9YYj2MNOuWUvpnIZFEg-1 Received: by mail-qv1-f69.google.com with SMTP id 6a1803df08f44-6b5e4f6e95bso14010186d6.3 for ; Mon, 08 Jul 2024 14:55:40 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1720475739; x=1721080539; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=bdZl7zE1LbnN4RcXWZNvf+JG0YErrvEqH4FuELpRXl4=; b=tSH0aJZvVgRfwBfwjXuSfdhXwj7u2hDlVMmoMQlGIiy95wiUezrIqrBDDfQ/k88NeN Nm92HlPLgnk3AR0xtRjTJ7XrqVDsGBOKhDOrYx+SNrve0rSx4MKCDkWzWQ7+EFRQfMNH PDcpJWv+YHYjQaICqQsjbb4kN6IfEKw3cbuU+9h0CW970KAEnHC8ZmU8/M6OVBVkJDV7 lr9v3XcBcJ/PESfF/QOpnoaQKUH2+pjKgT/3plqOAUdhfkfWsHuYI8gC9Ku8fi/XOH/U G6DIQ/fXk8mvBr5phPTkS9SKf7zB6ZD7tqxsqsXyUvvsp+RVPh+Ybzf4K1NqHACRUgHB s2eQ== X-Gm-Message-State: AOJu0YykCkEGy6N9CJBVbJX60/XpF7mwJ+T6O70MrjxMXqJ+5JVMPRfT /friEiQ5XYRgUVRI3LGbuhbE75ADH00jitNZ5mEJjYgDhVny7LmHizBl8ybQAw5AxeRAKHNFG0Z QJahj4Dv0z3gisnnk9LMhu2MAi8j1uY7aQfijTavzmDi9pjd9tRVqIFQl5estdXABt3Pwz1QJih devUn7iWt3mYS4VNu3uqWb9NIIAZH1Eg== X-Received: by 2002:a05:620a:a13:b0:79f:1556:37c9 with SMTP id af79cd13be357-79f198e98d3mr81920885a.0.1720475739685; Mon, 08 Jul 2024 14:55:39 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHTMT/OKeMh7vZgTCdEn6Vg7yRvRPIacM/xcR6Apjdr9yu5OBZcwg9nO9A1LGya7GmMSN5vIA== X-Received: by 2002:a05:620a:a13:b0:79f:1556:37c9 with SMTP id af79cd13be357-79f198e98d3mr81918985a.0.1720475739296; Mon, 08 Jul 2024 14:55:39 -0700 (PDT) Received: from x1n.redhat.com (pool-99-254-121-117.cpe.net.cable.rogers.com. [99.254.121.117]) by smtp.gmail.com with ESMTPSA id af79cd13be357-79f18ff691bsm32294585a.21.2024.07.08.14.55.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 08 Jul 2024 14:55:38 -0700 (PDT) From: Peter Xu To: linux-mm@kvack.org, linux-kernel@vger.kernel.org Cc: peterx@redhat.com, Andrew Morton , Zi Yan , Yang Shi , Hugh Dickins , Baolin Wang , Huang Ying , David Hildenbrand Subject: [PATCH] mm/migrate: Putback split folios when numa hint migration fails Date: Mon, 8 Jul 2024 17:55:37 -0400 Message-ID: <20240708215537.2630610-1-peterx@redhat.com> X-Mailer: git-send-email 2.45.0 MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-Rspamd-Queue-Id: 66F3314001F X-Rspam-User: X-Rspamd-Server: rspam05 X-Stat-Signature: 4ckz5of565adrtqa7h46j67zwkneekgk X-HE-Tag: 1720475742-811508 X-HE-Meta: U2FsdGVkX18zI8REGjm5Q4aAzHpkNoNtlbUL75v+5UGGSf06HaY9RZsxz3U+gOYbPwyOSaQGcMiX5L0rcNQhX5j0jZXVfNcUh5165u7DuV/evA2Ruhux1afa1GiS7N/y4F/5ro+aL1mMbyKmhkz3kQ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KJzxVcU5rCcs6VBPcvhPdHS3UbHywzVlcP7p9iX6cvOJ1cJV8bjmEsVEKDaVWSLMfK+bibJGXGt12sd8pevjLMNXD9DfFD8ty9TUy3ty/MsXPl8SxzP62NDo97lB2fDEiLBHSgDUmC0VBIOlufA2nsLjyMOLYAkEJu6o8NppQojHo3Btjp8BJfpf3hpWNa8K8m4w5Pg+MVSgfdeHnj3/IiOR65EYXTsJ2BqYofht67iBPq12ZCwpovVuK4wrXRJcMo X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: This issue is not from any report yet, but by code observation only. This is yet another fix besides Hugh's patch [1] but on relevant code path, where eager split of folio can happen if the folio is already on deferred list during a folio migration. Here the issue is NUMA path (migrate_misplaced_folio()) may start to encounter such folio split now even with MR_NUMA_MISPLACED hint applied. Then when migrate_pages() didn't migrate all the folios, it's possible the split small folios be put onto the list instead of the original folio. Then putting back only the head page won't be enough. Fix it by putting back all the folios on the list. [1] https://lore.kernel.org/all/46c948b4-4dd8-6e03-4c7b-ce4e81cfa536@google.com/ Cc: Zi Yan Cc: Yang Shi Cc: Hugh Dickins Cc: Baolin Wang Cc: Huang Ying Cc: David Hildenbrand Fixes: 7262f208ca68 ("mm/migrate: split source folio if it is on deferred split list") Signed-off-by: Peter Xu Reviewed-by: Baolin Wang --- Don't need to copy stable if this can still hit 6.10.. Only smoke tested. --- mm/migrate.c | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/mm/migrate.c b/mm/migrate.c index e10d2445fbd8..20da2595527a 100644 --- a/mm/migrate.c +++ b/mm/migrate.c @@ -2615,14 +2615,8 @@ int migrate_misplaced_folio(struct folio *folio, struct vm_area_struct *vma, nr_remaining = migrate_pages(&migratepages, alloc_misplaced_dst_folio, NULL, node, MIGRATE_ASYNC, MR_NUMA_MISPLACED, &nr_succeeded); - if (nr_remaining) { - if (!list_empty(&migratepages)) { - list_del(&folio->lru); - node_stat_mod_folio(folio, NR_ISOLATED_ANON + - folio_is_file_lru(folio), -nr_pages); - folio_putback_lru(folio); - } - } + if (nr_remaining && !list_empty(&migratepages)) + putback_movable_pages(&migratepages); if (nr_succeeded) { count_vm_numa_events(NUMA_PAGE_MIGRATE, nr_succeeded); if (!node_is_toptier(folio_nid(folio)) && node_is_toptier(node))