From patchwork Wed Aug 17 08:14:01 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Huang, Ying" X-Patchwork-Id: 12945627 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 A7776C32772 for ; Wed, 17 Aug 2022 08:14:26 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id DF6478D0003; Wed, 17 Aug 2022 04:14:25 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id D7CA78D0001; Wed, 17 Aug 2022 04:14:25 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id BCEAE8D0003; Wed, 17 Aug 2022 04:14:25 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id B03848D0001 for ; Wed, 17 Aug 2022 04:14:25 -0400 (EDT) Received: from smtpin14.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id 7D242A03E4 for ; Wed, 17 Aug 2022 08:14:25 +0000 (UTC) X-FDA: 79808372490.14.2A6D28A Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) by imf21.hostedemail.com (Postfix) with ESMTP id E21D71C01F2 for ; Wed, 17 Aug 2022 08:14:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1660724064; x=1692260064; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=xjmwUhmqYGhaMRwm5D3DkxjF2iYcxiuJ/Jn14RhEMRc=; b=eVxdgSvSW0q4aTjDZ1TslBq0f6r/eA+x9UdjA2B98GAAbICu/cuAZRAv 3agb0cCZFyN7HNfPgPGWFe4xilgFbKlLL4IhNVmO6kIt4jr99bkwwf6z7 9px9Z8c2zEGdi8pJ9V1B31qL5OeKFCgtqnt/AKoR5xKYBP/K4gnfN7WwL koudTlfpmKIgEZ0xw0AO4UoEmM9Ae8m5NX38s7XotOmZKQGxTQ0uhCHu/ feP8J00t3BQ2/abNwqg6yr0ct1b1yziKNDD0x9b7k2/r0t9OU+EmZp9z3 qjX7reDbKGfGjHhlks4uQnVCtZxV38aoPeIBMThyi1grTkHw552MAGoHY Q==; X-IronPort-AV: E=McAfee;i="6400,9594,10441"; a="293710770" X-IronPort-AV: E=Sophos;i="5.93,242,1654585200"; d="scan'208";a="293710770" Received: from orsmga006.jf.intel.com ([10.7.209.51]) by orsmga103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 Aug 2022 01:14:23 -0700 X-IronPort-AV: E=Sophos;i="5.93,242,1654585200"; d="scan'208";a="583668075" Received: from yhuang6-mobl1.sh.intel.com ([10.238.6.172]) by orsmga006-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 Aug 2022 01:14:21 -0700 From: Huang Ying To: Andrew Morton Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, Huang Ying , Oscar Salvador , Baolin Wang , Zi Yan , Yang Shi Subject: [PATCH -V3 1/8] migrate: fix syscall move_pages() return value for failure Date: Wed, 17 Aug 2022 16:14:01 +0800 Message-Id: <20220817081408.513338-2-ying.huang@intel.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220817081408.513338-1-ying.huang@intel.com> References: <20220817081408.513338-1-ying.huang@intel.com> MIME-Version: 1.0 ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1660724065; 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-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=epU+Qv3p1YaWrIBOTr/p7waIlCtL9i+O0jnMIHmixdk=; b=I8RyW1nbonICGKNGWiK5RXgB3JmAbcfPpxYiNFEalniiXbGD4bftegBN5tx9vtBimMzjsz 5zjjoZ/TqWDFga2oLlIp93DLkx5f4o4XCNERi9u13TzGNkpHPRzx+UcGOzBj+78YW1SabU VPwgwK1PU/Wk8nWxSjuS/Gz2yDQgO2s= ARC-Authentication-Results: i=1; imf21.hostedemail.com; dkim=none ("invalid DKIM record") header.d=intel.com header.s=Intel header.b=eVxdgSvS; dmarc=pass (policy=none) header.from=intel.com; spf=pass (imf21.hostedemail.com: domain of ying.huang@intel.com designates 134.134.136.65 as permitted sender) smtp.mailfrom=ying.huang@intel.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1660724065; a=rsa-sha256; cv=none; b=rSN/OSefeSYN5NkXAr3WGjFa2xJ7bUbavGuRsK3flcJfLUxK0gbMRDnqT4R8CWFSfMztD7 hSM5aKEQsEe9IedWsjzG6XG9nez3zibgqzgkDM6gFOwIfBUB37yf1KDPk5w5LgZ/61/SOy 7gqieH9dcTdwXaWkyNINf6YwOsuG5rA= Authentication-Results: imf21.hostedemail.com; dkim=none ("invalid DKIM record") header.d=intel.com header.s=Intel header.b=eVxdgSvS; dmarc=pass (policy=none) header.from=intel.com; spf=pass (imf21.hostedemail.com: domain of ying.huang@intel.com designates 134.134.136.65 as permitted sender) smtp.mailfrom=ying.huang@intel.com X-Rspam-User: X-Stat-Signature: cywayaf3sq5qiryahy8dct6dtzzwpabp X-Rspamd-Queue-Id: E21D71C01F2 X-Rspamd-Server: rspam11 X-HE-Tag: 1660724064-902794 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: The return value of move_pages() syscall is incorrect when counting the remaining pages to be migrated. For example, for the following test program, " #define _GNU_SOURCE #include #include #include #include #include #include #include #include #include #include #include #include #ifndef MADV_FREE #define MADV_FREE 8 /* free pages only if memory pressure */ #endif #define ONE_MB (1024 * 1024) #define MAP_SIZE (16 * ONE_MB) #define THP_SIZE (2 * ONE_MB) #define THP_MASK (THP_SIZE - 1) #define ERR_EXIT_ON(cond, msg) \ do { \ int __cond_in_macro = (cond); \ if (__cond_in_macro) \ error_exit(__cond_in_macro, (msg)); \ } while (0) void error_msg(int ret, int nr, int *status, const char *msg) { int i; fprintf(stderr, "Error: %s, ret : %d, error: %s\n", msg, ret, strerror(errno)); if (!nr) return; fprintf(stderr, "status: "); for (i = 0; i < nr; i++) fprintf(stderr, "%d ", status[i]); fprintf(stderr, "\n"); } void error_exit(int ret, const char *msg) { error_msg(ret, 0, NULL, msg); exit(1); } int page_size; bool do_vmsplice; bool do_thp; static int pipe_fds[2]; void *addr; char *pn; char *pn1; void *pages[2]; int status[2]; void prepare() { int ret; struct iovec iov; if (addr) { munmap(addr, MAP_SIZE); close(pipe_fds[0]); close(pipe_fds[1]); } ret = pipe(pipe_fds); ERR_EXIT_ON(ret, "pipe"); addr = mmap(NULL, MAP_SIZE, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANONYMOUS, -1, 0); ERR_EXIT_ON(addr == MAP_FAILED, "mmap"); if (do_thp) { ret = madvise(addr, MAP_SIZE, MADV_HUGEPAGE); ERR_EXIT_ON(ret, "advise hugepage"); } pn = (char *)(((unsigned long)addr + THP_SIZE) & ~THP_MASK); pn1 = pn + THP_SIZE; pages[0] = pn; pages[1] = pn1; *pn = 1; if (do_vmsplice) { iov.iov_base = pn; iov.iov_len = page_size; ret = vmsplice(pipe_fds[1], &iov, 1, 0); ERR_EXIT_ON(ret < 0, "vmsplice"); } status[0] = status[1] = 1024; } void test_migrate() { int ret; int nodes[2] = { 1, 1 }; pid_t pid = getpid(); prepare(); ret = move_pages(pid, 1, pages, nodes, status, MPOL_MF_MOVE_ALL); error_msg(ret, 1, status, "move 1 page"); prepare(); ret = move_pages(pid, 2, pages, nodes, status, MPOL_MF_MOVE_ALL); error_msg(ret, 2, status, "move 2 pages, page 1 not mapped"); prepare(); *pn1 = 1; ret = move_pages(pid, 2, pages, nodes, status, MPOL_MF_MOVE_ALL); error_msg(ret, 2, status, "move 2 pages"); prepare(); *pn1 = 1; nodes[1] = 0; ret = move_pages(pid, 2, pages, nodes, status, MPOL_MF_MOVE_ALL); error_msg(ret, 2, status, "move 2 pages, page 1 to node 0"); } int main(int argc, char *argv[]) { numa_run_on_node(0); page_size = getpagesize(); test_migrate(); fprintf(stderr, "\nMake page 0 cannot be migrated:\n"); do_vmsplice = true; test_migrate(); fprintf(stderr, "\nTest THP:\n"); do_thp = true; do_vmsplice = false; test_migrate(); fprintf(stderr, "\nTHP: make page 0 cannot be migrated:\n"); do_vmsplice = true; test_migrate(); return 0; } " The output of the current kernel is, " Error: move 1 page, ret : 0, error: Success status: 1 Error: move 2 pages, page 1 not mapped, ret : 0, error: Success status: 1 -14 Error: move 2 pages, ret : 0, error: Success status: 1 1 Error: move 2 pages, page 1 to node 0, ret : 0, error: Success status: 1 0 Make page 0 cannot be migrated: Error: move 1 page, ret : 0, error: Success status: 1024 Error: move 2 pages, page 1 not mapped, ret : 1, error: Success status: 1024 -14 Error: move 2 pages, ret : 0, error: Success status: 1024 1024 Error: move 2 pages, page 1 to node 0, ret : 1, error: Success status: 1024 1024 " While the expected output is, " Error: move 1 page, ret : 0, error: Success status: 1 Error: move 2 pages, page 1 not mapped, ret : 0, error: Success status: 1 -14 Error: move 2 pages, ret : 0, error: Success status: 1 1 Error: move 2 pages, page 1 to node 0, ret : 0, error: Success status: 1 0 Make page 0 cannot be migrated: Error: move 1 page, ret : 1, error: Success status: 1024 Error: move 2 pages, page 1 not mapped, ret : 1, error: Success status: 1024 -14 Error: move 2 pages, ret : 1, error: Success status: 1024 1024 Error: move 2 pages, page 1 to node 0, ret : 2, error: Success status: 1024 1024 " Fix this via correcting the remaining pages counting. With the fix, the output for the test program as above is expected. Signed-off-by: "Huang, Ying" Fixes: 5984fabb6e82 ("mm: move_pages: report the number of non-attempted pages") Reviewed-by: Oscar Salvador Cc: Baolin Wang Cc: Zi Yan Cc: Yang Shi --- mm/migrate.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/mm/migrate.c b/mm/migrate.c index a35eba462e61..1758fd215c0a 100644 --- a/mm/migrate.c +++ b/mm/migrate.c @@ -1751,7 +1751,7 @@ static int move_pages_and_store_status(struct mm_struct *mm, int node, * well. */ if (err > 0) - err += nr_pages - i - 1; + err += nr_pages - i; return err; } return store_status(status, start, node, i - start); @@ -1837,8 +1837,12 @@ static int do_pages_move(struct mm_struct *mm, nodemask_t task_nodes, err = move_pages_and_store_status(mm, current_node, &pagelist, status, start, i, nr_pages); - if (err) + if (err) { + /* We have accounted for page i */ + if (err > 0) + err--; goto out; + } current_node = NUMA_NO_NODE; } out_flush: From patchwork Wed Aug 17 08:14:02 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Huang, Ying" X-Patchwork-Id: 12945628 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 CBB75C25B08 for ; Wed, 17 Aug 2022 08:14:28 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 6A13A8D0005; Wed, 17 Aug 2022 04:14:28 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 650318D0001; Wed, 17 Aug 2022 04:14:28 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 518B88D0005; Wed, 17 Aug 2022 04:14:28 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id 43A9B8D0001 for ; Wed, 17 Aug 2022 04:14:28 -0400 (EDT) Received: from smtpin20.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id 2093B1606A7 for ; Wed, 17 Aug 2022 08:14:28 +0000 (UTC) X-FDA: 79808372616.20.B70E723 Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) by imf01.hostedemail.com (Postfix) with ESMTP id 6FAAE40061 for ; Wed, 17 Aug 2022 08:14:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1660724067; x=1692260067; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=AkZ/4tTRl3ObNiVYse3xCB7TE9jVqTapi3ezPGjzMTg=; b=H0YGdnMr8kKbHL9AbgN+bD8FN2k9DLLECZDVzL0r4seigiTow9be5TkT U62UM7LVDuTFP20RzzYGJaDa8XFK87DFqQ2t4F17NB+K15NJ9yERN/V/M phzIKvXbEhGCME4e3P7+HD8DKzvgKgLOlQfYHHSnQfF6wvfy8xumJJhOt eTOKRUUT+LJBDm3pz/1SPyOFpat0NqRmCE+W4lmVakPNXL5+crZjshuUe ty0JiNSQKvzAQn4PMp92VvHEO/M9LAjgrIs22gIIDGfftq5vg6feUfTpJ RE0mPQakRZZvU7GkVTeEkr4AKijU7fSfMVIM7tHpSvSu7JLUG1FrqVr97 Q==; X-IronPort-AV: E=McAfee;i="6400,9594,10441"; a="293710782" X-IronPort-AV: E=Sophos;i="5.93,242,1654585200"; d="scan'208";a="293710782" Received: from orsmga006.jf.intel.com ([10.7.209.51]) by orsmga103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 Aug 2022 01:14:25 -0700 X-IronPort-AV: E=Sophos;i="5.93,242,1654585200"; d="scan'208";a="583668087" Received: from yhuang6-mobl1.sh.intel.com ([10.238.6.172]) by orsmga006-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 Aug 2022 01:14:23 -0700 From: Huang Ying To: Andrew Morton Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, Huang Ying , Baolin Wang , Oscar Salvador , Zi Yan , Yang Shi Subject: [PATCH -V3 2/8] migrate_pages(): remove unnecessary list_safe_reset_next() Date: Wed, 17 Aug 2022 16:14:02 +0800 Message-Id: <20220817081408.513338-3-ying.huang@intel.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220817081408.513338-1-ying.huang@intel.com> References: <20220817081408.513338-1-ying.huang@intel.com> MIME-Version: 1.0 ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1660724067; a=rsa-sha256; cv=none; b=yVMDy/lR5kS4vbpd00VpfdZCs1Jf+pnr0u4hWPoc2ajqBeq8A7aC4jewqq+g6vlm8KXhM5 XXEqUOXd1CqwSGCODMKNs1v08dDVIXotgsuHFcfDKHR5azbCFJ8eGYoOAei27NVGV9J3aW OV54hKgLAB8hOyqxVZ48wQiHepRN7Tw= ARC-Authentication-Results: i=1; imf01.hostedemail.com; dkim=none ("invalid DKIM record") header.d=intel.com header.s=Intel header.b=H0YGdnMr; spf=pass (imf01.hostedemail.com: domain of ying.huang@intel.com designates 134.134.136.65 as permitted sender) smtp.mailfrom=ying.huang@intel.com; dmarc=pass (policy=none) header.from=intel.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1660724067; 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-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=s3LB+xcdSjYxZiInSPMFO4rGt9qSqxWXamUp2Qs/flo=; b=BWBdjzunanPPoJZ5edpI95ZqVL6RMgYK+4geA3gfSTk02y3ZSylqj/khzkLlETQROQWmWb +oVHkWj9yi6jRKz64lvT6v1fhJOW4asXKJ1y4uxcXznoHFxRmlMXKSEGkEflpJrqwf8/5a sduKsMv91wN8kgbKWJgeoUdukGbE2AA= Authentication-Results: imf01.hostedemail.com; dkim=none ("invalid DKIM record") header.d=intel.com header.s=Intel header.b=H0YGdnMr; spf=pass (imf01.hostedemail.com: domain of ying.huang@intel.com designates 134.134.136.65 as permitted sender) smtp.mailfrom=ying.huang@intel.com; dmarc=pass (policy=none) header.from=intel.com X-Rspam-User: X-Stat-Signature: 1mwixmrkf3dg6hz46tsy8f63wgyc5sen X-Rspamd-Queue-Id: 6FAAE40061 X-Rspamd-Server: rspam06 X-HE-Tag: 1660724067-66900 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: Before commit b5bade978e9b ("mm: migrate: fix the return value of migrate_pages()"), the tail pages of THP will be put in the "from" list directly. So one of the loop cursors (page2) needs to be reset, as is done in try_split_thp() via list_safe_reset_next(). But after the commit, the tail pages of THP will be put in a dedicated list (thp_split_pages). That is, the "from" list will not be changed during splitting. So, it's unnecessary to call list_safe_reset_next() anymore. This is a code cleanup, no functionality changes are expected. Signed-off-by: "Huang, Ying" Reviewed-by: Baolin Wang Reviewed-by: Oscar Salvador Cc: Zi Yan Cc: Yang Shi --- mm/migrate.c | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/mm/migrate.c b/mm/migrate.c index 1758fd215c0a..19a9b26af7e2 100644 --- a/mm/migrate.c +++ b/mm/migrate.c @@ -1369,16 +1369,13 @@ static int unmap_and_move_huge_page(new_page_t get_new_page, return rc; } -static inline int try_split_thp(struct page *page, struct page **page2, - struct list_head *from) +static inline int try_split_thp(struct page *page, struct list_head *split_pages) { - int rc = 0; + int rc; lock_page(page); - rc = split_huge_page_to_list(page, from); + rc = split_huge_page_to_list(page, split_pages); unlock_page(page); - if (!rc) - list_safe_reset_next(page, *page2, lru); return rc; } @@ -1482,7 +1479,7 @@ int migrate_pages(struct list_head *from, new_page_t get_new_page, /* THP migration is unsupported */ if (is_thp) { nr_thp_failed++; - if (!try_split_thp(page, &page2, &thp_split_pages)) { + if (!try_split_thp(page, &thp_split_pages)) { nr_thp_split++; goto retry; } @@ -1501,7 +1498,7 @@ int migrate_pages(struct list_head *from, new_page_t get_new_page, */ if (is_thp && !nosplit) { nr_thp_failed++; - if (!try_split_thp(page, &page2, &thp_split_pages)) { + if (!try_split_thp(page, &thp_split_pages)) { nr_thp_split++; goto retry; } From patchwork Wed Aug 17 08:14:03 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Huang, Ying" X-Patchwork-Id: 12945629 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 8F9EDC32772 for ; Wed, 17 Aug 2022 08:14:30 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 40DD68D0006; Wed, 17 Aug 2022 04:14:29 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 3920D8D0001; Wed, 17 Aug 2022 04:14:29 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 25AFA8D0006; Wed, 17 Aug 2022 04:14:29 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id 16AC28D0001 for ; Wed, 17 Aug 2022 04:14:29 -0400 (EDT) Received: from smtpin18.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id CDD28C077E for ; Wed, 17 Aug 2022 08:14:28 +0000 (UTC) X-FDA: 79808372616.18.53BCFA6 Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) by imf01.hostedemail.com (Postfix) with ESMTP id 44C4140061 for ; Wed, 17 Aug 2022 08:14:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1660724068; x=1692260068; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=DKaFW9nCQZCfgbnugNhK3BHbzcTIAzrfbLSevgdOECU=; b=hOJLViGJDeG0qBsrnrzllQvV86KvQYgUKIdQaTeYo1JOKXpXCHlZgvBf d1JpoC0HHwa/4cSm4shQEdMH3dyPHzhXp1XALW9uYHHfJWnLUNmwy3dOa BX7urKtZJ6WEiCi/6UQcbHQBIKCNnaP+Wt83G+ao6ZirdmctS0BAOONR4 zq6tMZe2F2b73evJWWnCagyVQBQY84a9PQR81QSgNmn+sROXGqEC1J/k4 TT0jM0VXHDkNTqKJTEbb9I+nMDakm94eqQF7lnjRPC2L7X52Nmievp9fh T77Nh/VKjup1uhrWxX+ssy6cSC3TPx1aMz9qn+3a1sUhpQAbDM2UZT4Zl Q==; X-IronPort-AV: E=McAfee;i="6400,9594,10441"; a="293710789" X-IronPort-AV: E=Sophos;i="5.93,242,1654585200"; d="scan'208";a="293710789" Received: from orsmga006.jf.intel.com ([10.7.209.51]) by orsmga103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 Aug 2022 01:14:27 -0700 X-IronPort-AV: E=Sophos;i="5.93,242,1654585200"; d="scan'208";a="583668098" Received: from yhuang6-mobl1.sh.intel.com ([10.238.6.172]) by orsmga006-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 Aug 2022 01:14:25 -0700 From: Huang Ying To: Andrew Morton Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, Huang Ying , Baolin Wang , Oscar Salvador , Zi Yan , Yang Shi Subject: [PATCH -V3 3/8] migrate_pages(): fix THP failure counting for -ENOMEM Date: Wed, 17 Aug 2022 16:14:03 +0800 Message-Id: <20220817081408.513338-4-ying.huang@intel.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220817081408.513338-1-ying.huang@intel.com> References: <20220817081408.513338-1-ying.huang@intel.com> MIME-Version: 1.0 ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1660724068; a=rsa-sha256; cv=none; b=BymCsp2/M9MD72qett1x19arv+kMpG0YRMEu+YAzokKBo13ejg/NPT8pM1dbN07OrGmBw/ EFyfgCYE1LVoOKgRAc24TuNCf1GkIli4phKqPBn9T+3LIF3/yIkKybAXACzhefLva+NDw2 DCMcZRjRBnJXGy6aWt6mcX+1iXG9EPU= ARC-Authentication-Results: i=1; imf01.hostedemail.com; dkim=none ("invalid DKIM record") header.d=intel.com header.s=Intel header.b=hOJLViGJ; spf=pass (imf01.hostedemail.com: domain of ying.huang@intel.com designates 134.134.136.65 as permitted sender) smtp.mailfrom=ying.huang@intel.com; dmarc=pass (policy=none) header.from=intel.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1660724068; 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-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=3rgRyEL+fj98TS9NcA+HYi+3Duv9VVgqi06kn1oee5E=; b=4Y+Z1QdxUvtTLDX8GqPsOQV/+Ew64uIyeE+SIYjSNRgch5coUi2EVwrjIBpSP/AN67M2Kt VNIeX30yWNChW4fPA09UpsumtDBRIeh9lw4BhwUEz5yRza9xx9jca7sTJ23XhwkHri36GE ZQnZCkd/rMFgIVi5MkW1YpTQfP33NV8= Authentication-Results: imf01.hostedemail.com; dkim=none ("invalid DKIM record") header.d=intel.com header.s=Intel header.b=hOJLViGJ; spf=pass (imf01.hostedemail.com: domain of ying.huang@intel.com designates 134.134.136.65 as permitted sender) smtp.mailfrom=ying.huang@intel.com; dmarc=pass (policy=none) header.from=intel.com X-Rspam-User: X-Stat-Signature: uhc6c4upmk55jfga35pamfjmygyumq4x X-Rspamd-Queue-Id: 44C4140061 X-Rspamd-Server: rspam06 X-HE-Tag: 1660724068-423133 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: In unmap_and_move(), if the new THP cannot be allocated, -ENOMEM will be returned, and migrate_pages() will try to split the THP unless "reason" is MR_NUMA_MISPLACED (that is, nosplit == true). But when nosplit == true, the THP migration failure will not be counted. This is incorrect. So in this patch, the THP migration failure will be counted for -ENOMEM regardless of nosplit is true or false. The nr_failed counting isn't fixed because it's not used. Added some comments for it per Baolin's suggestion. Signed-off-by: "Huang, Ying" Fixes: 5984fabb6e82 ("mm: move_pages: report the number of non-attempted pages") Reviewed-by: Baolin Wang Reviewed-by: Oscar Salvador Cc: Zi Yan Cc: Yang Shi --- mm/migrate.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/mm/migrate.c b/mm/migrate.c index 19a9b26af7e2..ae55f08e72ce 100644 --- a/mm/migrate.c +++ b/mm/migrate.c @@ -1494,11 +1494,11 @@ int migrate_pages(struct list_head *from, new_page_t get_new_page, /* * When memory is low, don't bother to try to migrate * other pages, just exit. - * THP NUMA faulting doesn't split THP to retry. */ - if (is_thp && !nosplit) { + if (is_thp) { nr_thp_failed++; - if (!try_split_thp(page, &thp_split_pages)) { + /* THP NUMA faulting doesn't split THP to retry. */ + if (!nosplit && !try_split_thp(page, &thp_split_pages)) { nr_thp_split++; goto retry; } @@ -1514,6 +1514,7 @@ int migrate_pages(struct list_head *from, new_page_t get_new_page, * the caller otherwise the page refcnt will be leaked. */ list_splice_init(&thp_split_pages, from); + /* nr_failed isn't updated for not used */ nr_thp_failed += thp_retry; goto out; case -EAGAIN: From patchwork Wed Aug 17 08:14:04 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Huang, Ying" X-Patchwork-Id: 12945630 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 6AF39C32774 for ; Wed, 17 Aug 2022 08:14:32 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id CE3F98D0007; Wed, 17 Aug 2022 04:14:31 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id C92788D0001; Wed, 17 Aug 2022 04:14:31 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id B332F8D0007; Wed, 17 Aug 2022 04:14:31 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id A13988D0001 for ; Wed, 17 Aug 2022 04:14:31 -0400 (EDT) Received: from smtpin01.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id 4B01A1405D2 for ; Wed, 17 Aug 2022 08:14:31 +0000 (UTC) X-FDA: 79808372742.01.C33E746 Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) by imf01.hostedemail.com (Postfix) with ESMTP id 9121240061 for ; Wed, 17 Aug 2022 08:14:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1660724070; x=1692260070; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=yhmojqv78CNeejAgfGN/fV62nXwRC1Wfl6ID7EB6l2s=; b=DkUHTahSJjstfVA2rihTgjMiBK1j/gUFjf8OSmxC/dGqsdOU1ivvSE3F W4lDJzg9Kw4Wyl5vWPYrMnGsq3+Cm64auvq7cw7A35e5SMqY3+/B2a6N+ EmcOlfQcxpcFbdMjmXyoNfZQ5bAbt22Y/ckHh300NW6CLVFb2nuw56+Ip oZsFV+IQyFyhOdaNL8DMiy1aGZZX0EeOJuk6qok0wRVdrrxHJ4OJhZssy f7mmvmhDS0axxXl/E55/vMLfKCHfmck4mlqQTV78/cWMFQrfpCpAiFBFo 0p4IK568/kB3hiT4ZCqFyH8PhP0qSKMtKwGedJeUZVSLPOYUXFTahpH7F A==; X-IronPort-AV: E=McAfee;i="6400,9594,10441"; a="293710798" X-IronPort-AV: E=Sophos;i="5.93,242,1654585200"; d="scan'208";a="293710798" Received: from orsmga006.jf.intel.com ([10.7.209.51]) by orsmga103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 Aug 2022 01:14:30 -0700 X-IronPort-AV: E=Sophos;i="5.93,242,1654585200"; d="scan'208";a="583668113" Received: from yhuang6-mobl1.sh.intel.com ([10.238.6.172]) by orsmga006-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 Aug 2022 01:14:28 -0700 From: Huang Ying To: Andrew Morton Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, Huang Ying , Baolin Wang , Oscar Salvador , Zi Yan , Yang Shi Subject: [PATCH -V3 4/8] migrate_pages(): fix failure counting for THP subpages retrying Date: Wed, 17 Aug 2022 16:14:04 +0800 Message-Id: <20220817081408.513338-5-ying.huang@intel.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220817081408.513338-1-ying.huang@intel.com> References: <20220817081408.513338-1-ying.huang@intel.com> MIME-Version: 1.0 ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1660724071; a=rsa-sha256; cv=none; b=6OLgXwcNBYx5ZRXmQiODzwrzdqf49BvHw16F/pxB09oB4rbALAqBCbjde7312oMjIrGCwA QMBs3y/PMecYxsOQd0Vy657oU6dZQO1HAIp4LN69Y/EZFUqJjPftcUuMYu/XQa0KgP3Skr aWWMCx78fsE4YTNYBpujPXn757+XLN0= ARC-Authentication-Results: i=1; imf01.hostedemail.com; dkim=none ("invalid DKIM record") header.d=intel.com header.s=Intel header.b=DkUHTahS; spf=pass (imf01.hostedemail.com: domain of ying.huang@intel.com designates 134.134.136.65 as permitted sender) smtp.mailfrom=ying.huang@intel.com; dmarc=pass (policy=none) header.from=intel.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1660724070; 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-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=af0MvMD5wRuTieQ2n5wEH/zhtSaeiOWYrnvmG1YndxA=; b=vpCv1Zz+v8GOGFyCZSkK4Pmk2qxuyRP4frVj3j+5t3si9gbqROswqhLCxhhhQYCfhBlfED lzcHaNC0dSJETZltkHNYMm46GMZynIC6JokoWoe+LQZJ4oA47uj0TSnpzJhZ1yckXhIGd7 c1kLmJHU7F21XlmEC3vF6Nz5D8Sbyhc= Authentication-Results: imf01.hostedemail.com; dkim=none ("invalid DKIM record") header.d=intel.com header.s=Intel header.b=DkUHTahS; spf=pass (imf01.hostedemail.com: domain of ying.huang@intel.com designates 134.134.136.65 as permitted sender) smtp.mailfrom=ying.huang@intel.com; dmarc=pass (policy=none) header.from=intel.com X-Rspam-User: X-Stat-Signature: m9ehyqq4uh5bfo9afjzqzgcy4sdeedkr X-Rspamd-Queue-Id: 9121240061 X-Rspamd-Server: rspam06 X-HE-Tag: 1660724070-189916 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: If THP is failed to be migrated for -ENOSYS and -ENOMEM, the THP will be split into thp_split_pages, and after other pages are migrated, pages in thp_split_pages will be migrated with no_subpage_counting == true, because its failure have been counted already. If some pages in thp_split_pages are retried during migration, we should not count their failure if no_subpage_counting == true too. This is done this patch to fix the failure counting for THP subpages retrying. Signed-off-by: "Huang, Ying" Fixes: 5984fabb6e82 ("mm: move_pages: report the number of non-attempted pages") Reviewed-by: Baolin Wang Reviewed-by: Oscar Salvador Cc: Zi Yan Cc: Yang Shi --- mm/migrate.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/mm/migrate.c b/mm/migrate.c index ae55f08e72ce..0018b5191799 100644 --- a/mm/migrate.c +++ b/mm/migrate.c @@ -1545,7 +1545,8 @@ int migrate_pages(struct list_head *from, new_page_t get_new_page, } } } - nr_failed += retry; + if (!no_subpage_counting) + nr_failed += retry; nr_thp_failed += thp_retry; /* * Try to migrate subpages of fail-to-migrate THPs, no nr_failed From patchwork Wed Aug 17 08:14:05 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Huang, Ying" X-Patchwork-Id: 12945631 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 6C1F5C25B08 for ; Wed, 17 Aug 2022 08:14:34 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 03B1C8D0008; Wed, 17 Aug 2022 04:14:34 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id EDBCB8D0001; Wed, 17 Aug 2022 04:14:33 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id D56128D0008; Wed, 17 Aug 2022 04:14:33 -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 BD57F8D0001 for ; Wed, 17 Aug 2022 04:14:33 -0400 (EDT) Received: from smtpin04.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id 9584540837 for ; Wed, 17 Aug 2022 08:14:33 +0000 (UTC) X-FDA: 79808372826.04.EFAFAF5 Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) by imf01.hostedemail.com (Postfix) with ESMTP id D82F540061 for ; Wed, 17 Aug 2022 08:14:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1660724072; x=1692260072; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=MlvM1YeTzqz/XZ0HlO1MJjt5fs4jtidIiLiwDXYc78E=; b=Nb9whxfjeWAqQ39KJLyJHU2+odA18aCHNQWVv72UTrAIyQEzpiKZQH4H 6BeReGBAqlSbiqC2g4YV2Y0ewu8THtEEJ8vilgaFmuKCR0fcFRQUXtrO0 Mw/iMslBSb2luW+CsRSsygi2PJMk7JnIn5AryIUKgTcNsLwn6ZH67158R i088ZYNw/2TP7TRoi4k+P8kiMHMJp8XQeMTS1FkIYUaIrNAHMRZNKppRp vZyvtWSo6EfvKGjyzh5poSAeT1zQGuCPWw18ztSK5DXYrO2Htdup35mF0 3ZsM7dEKEUorLu4ylDXyFEnVKr+OY1/kCtmZVlZRCLF5hfDRxZyvAObZQ w==; X-IronPort-AV: E=McAfee;i="6400,9594,10441"; a="293710805" X-IronPort-AV: E=Sophos;i="5.93,242,1654585200"; d="scan'208";a="293710805" Received: from orsmga006.jf.intel.com ([10.7.209.51]) by orsmga103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 Aug 2022 01:14:32 -0700 X-IronPort-AV: E=Sophos;i="5.93,242,1654585200"; d="scan'208";a="583668126" Received: from yhuang6-mobl1.sh.intel.com ([10.238.6.172]) by orsmga006-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 Aug 2022 01:14:30 -0700 From: Huang Ying To: Andrew Morton Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, Huang Ying , Baolin Wang , Zi Yan , Yang Shi Subject: [PATCH -V3 5/8] migrate_pages(): fix failure counting for THP on -ENOSYS Date: Wed, 17 Aug 2022 16:14:05 +0800 Message-Id: <20220817081408.513338-6-ying.huang@intel.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220817081408.513338-1-ying.huang@intel.com> References: <20220817081408.513338-1-ying.huang@intel.com> MIME-Version: 1.0 ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1660724073; a=rsa-sha256; cv=none; b=nf3ujywp0xlqcYvnGLSSNC7TQmreMgcp96qwkDMY0vYsH7EiZJgFnEarKat6iFKHmQMZR5 Qe5IBmYXXF0J5TygObSicLSgATt1aqCdyxN4eNVQlDpW9MtogQC22c0yvLsDgyYrTXjq5m bnwFDlduUxyyfSZQjEQbL/KdxfzFz0o= ARC-Authentication-Results: i=1; imf01.hostedemail.com; dkim=none ("invalid DKIM record") header.d=intel.com header.s=Intel header.b=Nb9whxfj; spf=pass (imf01.hostedemail.com: domain of ying.huang@intel.com designates 134.134.136.65 as permitted sender) smtp.mailfrom=ying.huang@intel.com; dmarc=pass (policy=none) header.from=intel.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1660724073; 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-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=rYbnGMlCuuC1ziCG1b20LFaHoSCb2dcImktp1rk/cdY=; b=GgTRgZhcMWh5Gqd38jsxffi296pcZs02mwSeFPABucuGDOavltKZ5hrgSO4Jj06QT7dTre CyOyU3+o1p7sDQ7VF9SWi4g/LhIfL5CWZy+SvhMp7g8SdmOzw1yVuJQuiAgnB4EBu5I+CQ UYQd7O7UvYex1vgPOd5+aYuswYeu6sY= Authentication-Results: imf01.hostedemail.com; dkim=none ("invalid DKIM record") header.d=intel.com header.s=Intel header.b=Nb9whxfj; spf=pass (imf01.hostedemail.com: domain of ying.huang@intel.com designates 134.134.136.65 as permitted sender) smtp.mailfrom=ying.huang@intel.com; dmarc=pass (policy=none) header.from=intel.com X-Rspam-User: X-Stat-Signature: z7c5cwdxiikbcjk4ar4h9oygjjqn9dyo X-Rspamd-Queue-Id: D82F540061 X-Rspamd-Server: rspam06 X-HE-Tag: 1660724072-923069 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: If THP or hugetlbfs page migration isn't supported, unmap_and_move() or unmap_and_move_huge_page() will return -ENOSYS. For THP, splitting will be tried, but if splitting doesn't succeed, the THP will be left in "from" list wrongly. If some other pages are retried, the THP migration failure will counted again. This is fixed via moving the failure THP from "from" to "ret_pages". Another issue of the original code is that the unsupported failure processing isn't consistent between THP and hugetlbfs page. Make them consistent in this patch to make the code easier to be understood too. Signed-off-by: "Huang, Ying" Fixes: 5984fabb6e82 ("mm: move_pages: report the number of non-attempted pages") Reviewed-by: Baolin Wang Cc: Zi Yan Cc: Yang Shi --- mm/migrate.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/mm/migrate.c b/mm/migrate.c index 0018b5191799..0223673e42d1 100644 --- a/mm/migrate.c +++ b/mm/migrate.c @@ -1260,10 +1260,8 @@ static int unmap_and_move_huge_page(new_page_t get_new_page, * tables or check whether the hugepage is pmd-based or not before * kicking migration. */ - if (!hugepage_migration_supported(page_hstate(hpage))) { - list_move_tail(&hpage->lru, ret); + if (!hugepage_migration_supported(page_hstate(hpage))) return -ENOSYS; - } if (page_count(hpage) == 1) { /* page was freed from under us. So we are done. */ @@ -1460,6 +1458,7 @@ int migrate_pages(struct list_head *from, new_page_t get_new_page, * page will be put back * -EAGAIN: stay on the from list * -ENOMEM: stay on the from list + * -ENOSYS: stay on the from list * Other errno: put on ret_pages list then splice to * from list */ @@ -1489,6 +1488,7 @@ int migrate_pages(struct list_head *from, new_page_t get_new_page, } nr_failed_pages += nr_subpages; + list_move_tail(&page->lru, &ret_pages); break; case -ENOMEM: /* From patchwork Wed Aug 17 08:14:06 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Huang, Ying" X-Patchwork-Id: 12945632 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 495A7C25B08 for ; Wed, 17 Aug 2022 08:14:39 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id D31018D0009; Wed, 17 Aug 2022 04:14:38 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id CE03E8D0001; Wed, 17 Aug 2022 04:14:38 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id B80CF8D0009; Wed, 17 Aug 2022 04:14:38 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id A01728D0001 for ; Wed, 17 Aug 2022 04:14:38 -0400 (EDT) Received: from smtpin31.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id 73436A0873 for ; Wed, 17 Aug 2022 08:14:38 +0000 (UTC) X-FDA: 79808373036.31.A4BF4D8 Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) by imf01.hostedemail.com (Postfix) with ESMTP id AB95240061 for ; Wed, 17 Aug 2022 08:14:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1660724077; x=1692260077; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=hLXpcVQ48bukYRKZHdLPgeEwQ0PlwBGDjboqajk5r+E=; b=KWvycQs0GQYtj+PDAMiDvdq5wSKYDgYMkGNhjCPqB4OVcehbsUQZlIx8 LNZ++tUfhBa6P13Fd6I7aa1kdUPpknlct3OngVT7jxnBVFMYS7U6vucGx DDhVjM3S53OiAB56kqYF/YTPvhDexWM55N8LNtW3+oremOhDVyl8v3NzE pyvNXmIXjl+v0Jir+BVHmi+ye3Sd4NmoGlhT87GPiubRgjLMtvw76BU+9 jdIWjYnZWoyYCzPkeb/irKc6GzTkyUVHxoDA4jQBpvL81tuDVrSSScmjg 843JxInnvd6k7s1WT4ULpOGGXInmob1iU2upBNURBWfdxyjWlmzqgexZx g==; X-IronPort-AV: E=McAfee;i="6400,9594,10441"; a="293710817" X-IronPort-AV: E=Sophos;i="5.93,242,1654585200"; d="scan'208";a="293710817" Received: from orsmga006.jf.intel.com ([10.7.209.51]) by orsmga103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 Aug 2022 01:14:36 -0700 X-IronPort-AV: E=Sophos;i="5.93,242,1654585200"; d="scan'208";a="583668137" Received: from yhuang6-mobl1.sh.intel.com ([10.238.6.172]) by orsmga006-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 Aug 2022 01:14:32 -0700 From: Huang Ying To: Andrew Morton Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, Huang Ying , Baolin Wang , Oscar Salvador , Zi Yan , Yang Shi Subject: [PATCH -V3 6/8] migrate_pages(): fix failure counting for THP splitting Date: Wed, 17 Aug 2022 16:14:06 +0800 Message-Id: <20220817081408.513338-7-ying.huang@intel.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220817081408.513338-1-ying.huang@intel.com> References: <20220817081408.513338-1-ying.huang@intel.com> MIME-Version: 1.0 ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1660724078; a=rsa-sha256; cv=none; b=sENMSnqhfkqLSVuTcut361Wvma0pOlXC+s0tBq2y/N/kZlmKV3/k/h8s2djMyEaLBKOH+L fm29QouM+CbGi2MaSH8XRV4b9TJHJYby2wmpaJDKU0SL4Hiftk1pzFS5lx/9U/Y+v+UCSd tySyrOtADmt/b7d8mdhh4bH5qC0GWT8= ARC-Authentication-Results: i=1; imf01.hostedemail.com; dkim=none ("invalid DKIM record") header.d=intel.com header.s=Intel header.b=KWvycQs0; spf=pass (imf01.hostedemail.com: domain of ying.huang@intel.com designates 134.134.136.65 as permitted sender) smtp.mailfrom=ying.huang@intel.com; dmarc=pass (policy=none) header.from=intel.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1660724078; 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-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=C6STe6ymkMpd6AGDuaLcdKWhOr960aMqpj0Mbf7jNY0=; b=4gjcf1IRNHIF3mdJSNMdcJHnkX+gKb097B1RVEZpAakFpd5F3gWnPKVGhmKLn7wuidh+JR oFw2A3QYPUTbeh1Pea9fLHHINPUxMYF7VwlyAVroFMVVKm/iUReEfwLkNoUgjaGJe/37AQ f3KoCJ0/wxpRdZxxMo2Ij7NTIOW8AnQ= Authentication-Results: imf01.hostedemail.com; dkim=none ("invalid DKIM record") header.d=intel.com header.s=Intel header.b=KWvycQs0; spf=pass (imf01.hostedemail.com: domain of ying.huang@intel.com designates 134.134.136.65 as permitted sender) smtp.mailfrom=ying.huang@intel.com; dmarc=pass (policy=none) header.from=intel.com X-Rspam-User: X-Stat-Signature: xhnsha7fjhepat75emo7zf3gg8run53u X-Rspamd-Queue-Id: AB95240061 X-Rspamd-Server: rspam06 X-HE-Tag: 1660724076-582797 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: If THP is failed to be migrated, it may be split and retry. But after splitting, the head page will be left in "from" list, although THP migration failure has been counted already. If the head page is failed to be migrated too, the failure will be counted twice incorrectly. So this is fixed in this patch via moving the head page of THP after splitting to "thp_split_pages" too. Signed-off-by: "Huang, Ying" Fixes: 5984fabb6e82 ("mm: move_pages: report the number of non-attempted pages") Reviewed-by: Baolin Wang Reviewed-by: Oscar Salvador Cc: Zi Yan Cc: Yang Shi --- mm/migrate.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/mm/migrate.c b/mm/migrate.c index 0223673e42d1..81daa4dd3bb6 100644 --- a/mm/migrate.c +++ b/mm/migrate.c @@ -1374,6 +1374,8 @@ static inline int try_split_thp(struct page *page, struct list_head *split_pages lock_page(page); rc = split_huge_page_to_list(page, split_pages); unlock_page(page); + if (!rc) + list_move_tail(&page->lru, split_pages); return rc; } @@ -1433,7 +1435,6 @@ int migrate_pages(struct list_head *from, new_page_t get_new_page, thp_retry = 0; list_for_each_entry_safe(page, page2, from, lru) { -retry: /* * THP statistics is based on the source huge page. * Capture required information that might get lost @@ -1469,10 +1470,9 @@ int migrate_pages(struct list_head *from, new_page_t get_new_page, * retry on the same page with the THP split * to base pages. * - * Head page is retried immediately and tail - * pages are added to the tail of the list so - * we encounter them after the rest of the list - * is processed. + * Sub-pages are put in thp_split_pages, and + * we will migrate them after the rest of the + * list is processed. */ case -ENOSYS: /* THP migration is unsupported */ @@ -1480,7 +1480,7 @@ int migrate_pages(struct list_head *from, new_page_t get_new_page, nr_thp_failed++; if (!try_split_thp(page, &thp_split_pages)) { nr_thp_split++; - goto retry; + break; } /* Hugetlb migration is unsupported */ } else if (!no_subpage_counting) { @@ -1500,7 +1500,7 @@ int migrate_pages(struct list_head *from, new_page_t get_new_page, /* THP NUMA faulting doesn't split THP to retry. */ if (!nosplit && !try_split_thp(page, &thp_split_pages)) { nr_thp_split++; - goto retry; + break; } } else if (!no_subpage_counting) { nr_failed++; From patchwork Wed Aug 17 08:14:07 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Huang, Ying" X-Patchwork-Id: 12945633 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 E7F0AC32772 for ; Wed, 17 Aug 2022 08:14:40 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id E91448D000A; Wed, 17 Aug 2022 04:14:39 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id D7D248D0001; Wed, 17 Aug 2022 04:14:39 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id BF6568D000A; Wed, 17 Aug 2022 04:14:39 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id AB1118D0001 for ; Wed, 17 Aug 2022 04:14:39 -0400 (EDT) Received: from smtpin02.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id 848031A07B0 for ; Wed, 17 Aug 2022 08:14:39 +0000 (UTC) X-FDA: 79808373078.02.5E61752 Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) by imf24.hostedemail.com (Postfix) with ESMTP id A005B1801D5 for ; Wed, 17 Aug 2022 08:14:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1660724078; x=1692260078; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=3FCN6Jt3Sb1+/b+KmRNGXeRqM8oFvsuaOTMG3DWs02g=; b=JT61dFbc6R4+8Lr+EZto86WHHZh2sQqrgYz+NjgLTfmJ6Evi4QvDtcMu atCFXNEd2EK7fF/M+b2ieqE0evvhCHeAS6USmSIYaD/Mm3ZEfgvImHxFJ Za6l3bxlVuoPRzYlKO4cWVfOshmNJlFO6lbLhpss2Encul3sxe3oVsTyL 8hW2C42GpbZP1boI5XuFqEh08yDX8MQy+2Euq0zg+DpbeJoZUuj2A36Hc oTfTgcTcthUaBL1aUdsr8RpywffAOxNv8RWPuHUTkqYb0ss0m8O+yUEDF y5O5Qgi97g14MW2KsYWRjtDNcWKuQmYrQVU1Ivsk7UooH6I51YwMg7gO+ g==; X-IronPort-AV: E=McAfee;i="6400,9594,10441"; a="293710821" X-IronPort-AV: E=Sophos;i="5.93,242,1654585200"; d="scan'208";a="293710821" Received: from orsmga006.jf.intel.com ([10.7.209.51]) by orsmga103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 Aug 2022 01:14:37 -0700 X-IronPort-AV: E=Sophos;i="5.93,242,1654585200"; d="scan'208";a="583668141" Received: from yhuang6-mobl1.sh.intel.com ([10.238.6.172]) by orsmga006-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 Aug 2022 01:14:34 -0700 From: Huang Ying To: Andrew Morton Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, Huang Ying , Baolin Wang , Oscar Salvador , Zi Yan , Yang Shi Subject: [PATCH -V3 7/8] migrate_pages(): fix failure counting for retry Date: Wed, 17 Aug 2022 16:14:07 +0800 Message-Id: <20220817081408.513338-8-ying.huang@intel.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220817081408.513338-1-ying.huang@intel.com> References: <20220817081408.513338-1-ying.huang@intel.com> MIME-Version: 1.0 ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1660724079; 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-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=0CEPt2mvRCaJmjgKqzhFE6NL6/HNq1d55MwRyas7yzA=; b=itiVndt5j850BJ+OPaxS16MTTmVUytAPBLbynTrdcVPhy6+rE+WhH1ww+PqB8EcCA5Eqj0 MhLLT7KAzroK5iea+rDyv4QDP6l2/YqZEBdeD9WN9TMLfWBUYarSHh5Tbdh9DflaG7yfV4 5hZExxxTwgAhetsGR4aZ43wXcOy1ZlE= ARC-Authentication-Results: i=1; imf24.hostedemail.com; dkim=none ("invalid DKIM record") header.d=intel.com header.s=Intel header.b=JT61dFbc; dmarc=pass (policy=none) header.from=intel.com; spf=pass (imf24.hostedemail.com: domain of ying.huang@intel.com designates 134.134.136.65 as permitted sender) smtp.mailfrom=ying.huang@intel.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1660724079; a=rsa-sha256; cv=none; b=084ZhLKEgTXxkwfAYlq1U2/BT82YEuVHoC1/t91AOEs7+IZ6UkJmF0DgYAxZGgr6KJ8B2H Vv22pRngbs+c+JE457uikXB+6TaFt2WYpzuTKWd6LxxwXbG/yCkPUtBFHzHEhr0hRnX4Uv QxuAWs5CH7iyQkMG2EH5k3uDNyJVhl0= Authentication-Results: imf24.hostedemail.com; dkim=none ("invalid DKIM record") header.d=intel.com header.s=Intel header.b=JT61dFbc; dmarc=pass (policy=none) header.from=intel.com; spf=pass (imf24.hostedemail.com: domain of ying.huang@intel.com designates 134.134.136.65 as permitted sender) smtp.mailfrom=ying.huang@intel.com X-Rspam-User: X-Stat-Signature: qzfcsamymkkmhysz3tb6mkqph9fm3gs1 X-Rspamd-Queue-Id: A005B1801D5 X-Rspamd-Server: rspam11 X-HE-Tag: 1660724078-460212 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: After 10 retries, we will give up and the remaining pages will be counted as failure in nr_failed and nr_thp_failed. We should count the failure in nr_failed_pages too. This is done in this patch. Signed-off-by: "Huang, Ying" Fixes: 5984fabb6e82 ("mm: move_pages: report the number of non-attempted pages") Reviewed-by: Baolin Wang Reviewed-by: Oscar Salvador Cc: Zi Yan Cc: Yang Shi --- mm/migrate.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/mm/migrate.c b/mm/migrate.c index 81daa4dd3bb6..55fbf9669431 100644 --- a/mm/migrate.c +++ b/mm/migrate.c @@ -1413,6 +1413,7 @@ int migrate_pages(struct list_head *from, new_page_t get_new_page, int thp_retry = 1; int nr_failed = 0; int nr_failed_pages = 0; + int nr_retry_pages = 0; int nr_succeeded = 0; int nr_thp_succeeded = 0; int nr_thp_failed = 0; @@ -1433,6 +1434,7 @@ int migrate_pages(struct list_head *from, new_page_t get_new_page, for (pass = 0; pass < 10 && (retry || thp_retry); pass++) { retry = 0; thp_retry = 0; + nr_retry_pages = 0; list_for_each_entry_safe(page, page2, from, lru) { /* @@ -1506,7 +1508,7 @@ int migrate_pages(struct list_head *from, new_page_t get_new_page, nr_failed++; } - nr_failed_pages += nr_subpages; + nr_failed_pages += nr_subpages + nr_retry_pages; /* * There might be some subpages of fail-to-migrate THPs * left in thp_split_pages list. Move them back to migration @@ -1522,6 +1524,7 @@ int migrate_pages(struct list_head *from, new_page_t get_new_page, thp_retry++; else retry++; + nr_retry_pages += nr_subpages; break; case MIGRATEPAGE_SUCCESS: nr_succeeded += nr_subpages; @@ -1548,6 +1551,7 @@ int migrate_pages(struct list_head *from, new_page_t get_new_page, if (!no_subpage_counting) nr_failed += retry; nr_thp_failed += thp_retry; + nr_failed_pages += nr_retry_pages; /* * Try to migrate subpages of fail-to-migrate THPs, no nr_failed * counting in this round, since all subpages of a THP is counted From patchwork Wed Aug 17 08:14:08 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Huang, Ying" X-Patchwork-Id: 12945634 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 93FAEC25B08 for ; Wed, 17 Aug 2022 08:14:42 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 2B6348D000B; Wed, 17 Aug 2022 04:14:42 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 1E5908D0001; Wed, 17 Aug 2022 04:14:42 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 00F398D000B; Wed, 17 Aug 2022 04:14:41 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id E8B658D0001 for ; Wed, 17 Aug 2022 04:14:41 -0400 (EDT) Received: from smtpin27.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id CEEDEAAC37 for ; Wed, 17 Aug 2022 08:14:41 +0000 (UTC) X-FDA: 79808373162.27.5F7FE90 Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) by imf13.hostedemail.com (Postfix) with ESMTP id 2C46A201C9 for ; Wed, 17 Aug 2022 08:14:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1660724081; x=1692260081; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=CfWZdev3ddt5aOgW4WxIwyKcDYIQwXT1f+c+rDGkzjw=; b=T+C0sOZFP/Byu50d4FjifGGJCKSti2mOq7zZ4IA6suFdlX1ulqucx1KV rG4UHZW3IURhvyFjEQA9s7dhy5dt22ZzS4zCgV7VQG+BVh1T8h4OpU5yu Jn41IlVqGAQdglBgEg9O9YaXmcV3u8+ywmFKFb33vXeRXLWc8uj+U38DT 6aqDIch5Gk6tEytG9xA1UKSswTzz5aaMc8K3L6o+jtC4ckHALMTcTA6I/ 39dAlfujugPw0LKVUVU2t9OK/fkxd4pyr1ZvNmbF+IwOxoFKuK3D4hwDz 46GamjMOuYrIMx72Ltje8Lc1z+7MdWAnz0ZhyAhCnpbl3lCR+HO7N7WFO g==; X-IronPort-AV: E=McAfee;i="6400,9594,10441"; a="293710843" X-IronPort-AV: E=Sophos;i="5.93,242,1654585200"; d="scan'208";a="293710843" Received: from orsmga006.jf.intel.com ([10.7.209.51]) by orsmga103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 Aug 2022 01:14:39 -0700 X-IronPort-AV: E=Sophos;i="5.93,242,1654585200"; d="scan'208";a="583668162" Received: from yhuang6-mobl1.sh.intel.com ([10.238.6.172]) by orsmga006-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 Aug 2022 01:14:37 -0700 From: Huang Ying To: Andrew Morton Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, Baolin Wang , "Huang, Ying" , Oscar Salvador , Zi Yan , Yang Shi Subject: [PATCH -V3 8/8] mm: migrate: Do not retry 10 times for the subpages of fail-to-migrate THP Date: Wed, 17 Aug 2022 16:14:08 +0800 Message-Id: <20220817081408.513338-9-ying.huang@intel.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220817081408.513338-1-ying.huang@intel.com> References: <20220817081408.513338-1-ying.huang@intel.com> MIME-Version: 1.0 ARC-Authentication-Results: i=1; imf13.hostedemail.com; dkim=none ("invalid DKIM record") header.d=intel.com header.s=Intel header.b=T+C0sOZF; spf=pass (imf13.hostedemail.com: domain of ying.huang@intel.com designates 134.134.136.65 as permitted sender) smtp.mailfrom=ying.huang@intel.com; dmarc=pass (policy=none) header.from=intel.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1660724081; a=rsa-sha256; cv=none; b=8iaRL3ITb18ujkoESd/DHICAyjX4s6ccCQxfmVsPaoiS7dtUAEcS56WwkojEkiGdsDSe35 /EnKcQIlIMlY4jd031TDvu5HOXDkT0ZamJPbRHeGjV2i2gKij56eNMsYdpoyUYLyXVB5Nl ceROLJCjuGeMQESxI8HqRQqfjqE5FxY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1660724081; 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-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=4qRB0Lv47nO4CdWGbeMW0y9JkeWb7W1yANC/ZxSHt7U=; b=rYpcz6ksSvRNHyYXj0pNNOdyINIO2Y8Pp/6iotkIijDAUgWWrtjMJlm2p+B3CaSM2jBL4G OiyD7GlwC+sxZZiCCPG8VdxZYwsDSjhm/IeBFHuY3PIeKF2MM1SHKUGuBSO0OR1AanPkYG xj/v+5qts0Lur3eCtxSSdrAbVW+9mzk= Authentication-Results: imf13.hostedemail.com; dkim=none ("invalid DKIM record") header.d=intel.com header.s=Intel header.b=T+C0sOZF; spf=pass (imf13.hostedemail.com: domain of ying.huang@intel.com designates 134.134.136.65 as permitted sender) smtp.mailfrom=ying.huang@intel.com; dmarc=pass (policy=none) header.from=intel.com X-Rspam-User: X-Rspamd-Server: rspam12 X-Stat-Signature: 3qm6da7y1y71gnbnpszd6n36j5g5ukkd X-Rspamd-Queue-Id: 2C46A201C9 X-HE-Tag: 1660724080-787526 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: From: Baolin Wang If THP is failed to migrate due to -ENOSYS or -ENOMEM case, the THP will be split, and the subpages of fail-to-migrate THP will be tried to migrate again, so we should not account the retry counter in the second loop, since we already accounted 'nr_thp_failed' in the first loop. Moreover we also do not need retry 10 times for -EAGAIN case for the subpages of fail-to-migrate THP in the second loop, since we already regarded the THP as migration failure, and save some migration time (for the worst case, will try 512 * 10 times) according to previous discussion [1]. [1] https://lore.kernel.org/linux-mm/87r13a7n04.fsf@yhuang6-desk2.ccr.corp.intel.com/ Tested-by: "Huang, Ying" Signed-off-by: Baolin Wang Signed-off-by: "Huang, Ying" Cc: Oscar Salvador Cc: Zi Yan Cc: Yang Shi --- mm/migrate.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/mm/migrate.c b/mm/migrate.c index 55fbf9669431..06a653977835 100644 --- a/mm/migrate.c +++ b/mm/migrate.c @@ -1522,7 +1522,7 @@ int migrate_pages(struct list_head *from, new_page_t get_new_page, case -EAGAIN: if (is_thp) thp_retry++; - else + else if (!no_subpage_counting) retry++; nr_retry_pages += nr_subpages; break; @@ -1548,8 +1548,7 @@ int migrate_pages(struct list_head *from, new_page_t get_new_page, } } } - if (!no_subpage_counting) - nr_failed += retry; + nr_failed += retry; nr_thp_failed += thp_retry; nr_failed_pages += nr_retry_pages; /*