From patchwork Mon Jul 11 08:49:42 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Huang, Ying" X-Patchwork-Id: 12913155 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 60AC3CCA480 for ; Mon, 11 Jul 2022 08:50:08 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 90BEC6B00A5; Mon, 11 Jul 2022 04:50:07 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 8BB8F6B00A6; Mon, 11 Jul 2022 04:50:07 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 70D156B00A7; Mon, 11 Jul 2022 04:50:07 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id 635A56B00A5 for ; Mon, 11 Jul 2022 04:50:07 -0400 (EDT) Received: from smtpin11.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay12.hostedemail.com (Postfix) with ESMTP id 3821F120647 for ; Mon, 11 Jul 2022 08:50:07 +0000 (UTC) X-FDA: 79674196854.11.C1FD322 Received: from mga06.intel.com (mga06b.intel.com [134.134.136.31]) by imf16.hostedemail.com (Postfix) with ESMTP id 889E1180052 for ; Mon, 11 Jul 2022 08:50:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1657529407; x=1689065407; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=k6KsRMZKO7LW82txBmvjqn++nQe1Xz6fEXzoYPfl0xs=; b=EP2Tws721airyxBA32wkQAhyc5fEFCZyG5/2AJYNjp6uWdYjaFHTf82J x0+oJ+VUgOHKjk9LnDGkmAblPUAKVH/MAlx8PqXVAOW710HVlk68Q0Moc NNXE09F9o6IvyNqpDqNqNB0AOYfKAWyC9SA9hiXvqoJGY8XCinB/DCMGa Auc2N/HaGGnJjw1JhpqTdH9BioqVHjbgXXvmtNfG5EDwezeT40+Gz2Hhe S34e1KddjITfxOijZ907eDwpt6nTQhMbVYXd5zL6rgpDdP/f6EJjyzH2v 5Hi7NEkANIXN5GPbLxKD9RUeH8c8C8B6vP1ZVHcn7ADEyQPSnaj2rqc5k Q==; X-IronPort-AV: E=McAfee;i="6400,9594,10404"; a="346296539" X-IronPort-AV: E=Sophos;i="5.92,262,1650956400"; d="scan'208";a="346296539" Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by orsmga104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 11 Jul 2022 01:50:06 -0700 X-IronPort-AV: E=Sophos;i="5.92,262,1650956400"; d="scan'208";a="652374103" Received: from yhuang6-mobl1.sh.intel.com ([10.238.5.168]) by fmsmga008-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 11 Jul 2022 01:50:03 -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 -V2 1/7] migrate: fix syscall move_pages() return value for failure Date: Mon, 11 Jul 2022 16:49:42 +0800 Message-Id: <20220711084948.274787-2-ying.huang@intel.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220711084948.274787-1-ying.huang@intel.com> References: <20220711084948.274787-1-ying.huang@intel.com> MIME-Version: 1.0 ARC-Authentication-Results: i=1; imf16.hostedemail.com; dkim=pass header.d=intel.com header.s=Intel header.b=EP2Tws72; dmarc=pass (policy=none) header.from=intel.com; spf=none (imf16.hostedemail.com: domain of ying.huang@intel.com has no SPF policy when checking 134.134.136.31) smtp.mailfrom=ying.huang@intel.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1657529406; 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=dKNkigsNvhxWmUE2cwMNm9zmuB5LrI4q4OSm/h9NOdg=; b=CsgtyUgmSsV4ALhP/05TQTLvRCChi51+lf5gyH/BOL4pbo78zSpdcEDkarrw/hFY277GDj TU4Vjn51pRIkviQjZqWnZU6fAlZuH1QoVr1UwsYKARxZKeL75zIy47XAvNgLbpTvGGwWdF 77gTOcpi4gR50jnWBQYFTEF2dmN7Ass= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1657529406; a=rsa-sha256; cv=none; b=4XIYdP1pyIS4bPEzd27T0LU3fSFfXZszLFuxgHI0VUxr+0uwS+xYvE/Y81vznyQ9wDWxim yeHVWvhqR7NTYpAcyzX0QSj7P/43k8lCM/EXDRFJE02QJIwv1BDRerSt0MEq67jC07T9/x WkqqIxCkYz7tIBsdXn+xTuudnBNXV9I= Authentication-Results: imf16.hostedemail.com; dkim=pass header.d=intel.com header.s=Intel header.b=EP2Tws72; dmarc=pass (policy=none) header.from=intel.com; spf=none (imf16.hostedemail.com: domain of ying.huang@intel.com has no SPF policy when checking 134.134.136.31) smtp.mailfrom=ying.huang@intel.com X-Rspam-User: X-Rspamd-Server: rspam08 X-Stat-Signature: 66qdrg5hpy4faox4th3b49wmfxe6853d X-Rspamd-Queue-Id: 889E1180052 X-HE-Tag: 1657529406-105891 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") Cc: Baolin Wang Cc: Zi Yan Cc: Yang Shi Reviewed-by: Oscar Salvador --- mm/migrate.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/mm/migrate.c b/mm/migrate.c index 6c1ea61f39d8..472335f0aaa3 100644 --- a/mm/migrate.c +++ b/mm/migrate.c @@ -1682,7 +1682,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); @@ -1768,8 +1768,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 stored status of page i */ + if (err > 0) + err--; goto out; + } current_node = NUMA_NO_NODE; } out_flush: From patchwork Mon Jul 11 08:49:43 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Huang, Ying" X-Patchwork-Id: 12913156 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 83FE7C433EF for ; Mon, 11 Jul 2022 08:50:10 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id DC8E26B00A7; Mon, 11 Jul 2022 04:50:09 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id D29046B00A8; Mon, 11 Jul 2022 04:50:09 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id B7AD76B00A9; Mon, 11 Jul 2022 04:50:09 -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 97D5B6B00A7 for ; Mon, 11 Jul 2022 04:50:09 -0400 (EDT) Received: from smtpin26.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id 6B6472059B for ; Mon, 11 Jul 2022 08:50:09 +0000 (UTC) X-FDA: 79674196938.26.638ABE4 Received: from mga06.intel.com (mga06b.intel.com [134.134.136.31]) by imf16.hostedemail.com (Postfix) with ESMTP id 9A906180052 for ; Mon, 11 Jul 2022 08:50:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1657529409; x=1689065409; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=vvKkq5Wh9qU1+bVN3sbnuKnqAwdqqSdZhV8kZWnGHQU=; b=kb2jPwWAq+sg13mys8kle8CJrB0o0hxhqx2skQgmFXKI0Y7UeAaIt7c1 FWY1DRcCY7YXH8pP1D4jOoF5bh65d58eoDUVE+dL+YzZhLAD0180l9OkS j2z5RMmBHh0RT2UTErsy3nsmf6guC7jSB0efcBODsFD7rn66mTDywreu9 E6PHUJeQEH+0u/eCiCob8uzb8XNitwMrv8MOEjWGNPDM6TElh7EDQ4h/7 ik0wqesb78GvpuG5fupvGu2I0ti+v5N2AScYyNT591xXK/Csh0geiArju 9GZLxCXL32B3EHQz0HDCVI6saNwh+Nfo4SnPQc0mA0SfMDWl6OLaIFNhN w==; X-IronPort-AV: E=McAfee;i="6400,9594,10404"; a="346296563" X-IronPort-AV: E=Sophos;i="5.92,262,1650956400"; d="scan'208";a="346296563" Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by orsmga104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 11 Jul 2022 01:50:08 -0700 X-IronPort-AV: E=Sophos;i="5.92,262,1650956400"; d="scan'208";a="652374122" Received: from yhuang6-mobl1.sh.intel.com ([10.238.5.168]) by fmsmga008-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 11 Jul 2022 01:50:05 -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 -V2 2/7] migrate_pages(): remove unnecessary list_safe_reset_next() Date: Mon, 11 Jul 2022 16:49:43 +0800 Message-Id: <20220711084948.274787-3-ying.huang@intel.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220711084948.274787-1-ying.huang@intel.com> References: <20220711084948.274787-1-ying.huang@intel.com> MIME-Version: 1.0 ARC-Authentication-Results: i=1; imf16.hostedemail.com; dkim=pass header.d=intel.com header.s=Intel header.b=kb2jPwWA; dmarc=pass (policy=none) header.from=intel.com; spf=none (imf16.hostedemail.com: domain of ying.huang@intel.com has no SPF policy when checking 134.134.136.31) smtp.mailfrom=ying.huang@intel.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1657529409; 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=pI1RtOKJCRJm9FFT4rgbcvkDoy2Sw79LerayXescY/E=; b=p0ZPrfsjekCpbybRZ3PcdsmN/MTzsrZKau6oGbT9t4Ph9QWwa+pfSY/rKq7kiFsS+rWjEv MSUDIfDFxFSD/XVuG+csZcOqmC1YpzsbvANTiN5udOtvZ3GqxbNrK1YdHxuYGP7jou4rqK wscWoMO5HcKctXEiViW3AJBNYZiV9o8= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1657529409; a=rsa-sha256; cv=none; b=Yv8doAtf+Gtyy5CmTfIIpsIArTEqjqZvJOMfMTQkhHkezbjkGB9EpJqiDIzsTk19NIPtLQ 1Esr+0uoOkbfV5dNPe7zZbzhEnJ7lNYAvLMHcG+CT+WhkN0y6g0qMhut38zuxRq927hIYF G20cbqbz0Xi546+jeFrDpDAkRSo7t6E= Authentication-Results: imf16.hostedemail.com; dkim=pass header.d=intel.com header.s=Intel header.b=kb2jPwWA; dmarc=pass (policy=none) header.from=intel.com; spf=none (imf16.hostedemail.com: domain of ying.huang@intel.com has no SPF policy when checking 134.134.136.31) smtp.mailfrom=ying.huang@intel.com X-Rspamd-Server: rspam06 X-Rspam-User: X-Stat-Signature: hurni4iq6as9bcy578o1gfhorjs4y13m X-Rspamd-Queue-Id: 9A906180052 X-HE-Tag: 1657529408-481467 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 Cc: Zi Yan Cc: Yang Shi Reviewed-by: Oscar Salvador --- mm/migrate.c | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/mm/migrate.c b/mm/migrate.c index 472335f0aaa3..794312072eb3 100644 --- a/mm/migrate.c +++ b/mm/migrate.c @@ -1301,16 +1301,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; } @@ -1414,7 +1411,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; } @@ -1433,7 +1430,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 Mon Jul 11 08:49:44 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Huang, Ying" X-Patchwork-Id: 12913157 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 D623BCCA480 for ; Mon, 11 Jul 2022 08:50:11 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 0A6DB6B00A8; Mon, 11 Jul 2022 04:50:11 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 008CC6B00A9; Mon, 11 Jul 2022 04:50:10 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id D789E6B00AB; Mon, 11 Jul 2022 04:50:10 -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 B93446B00A8 for ; Mon, 11 Jul 2022 04:50:10 -0400 (EDT) Received: from smtpin02.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id 8D77034916 for ; Mon, 11 Jul 2022 08:50:10 +0000 (UTC) X-FDA: 79674196980.02.D191F4F Received: from mga06.intel.com (mga06b.intel.com [134.134.136.31]) by imf16.hostedemail.com (Postfix) with ESMTP id E7F2C180061 for ; Mon, 11 Jul 2022 08:50:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1657529410; x=1689065410; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=+5a4TVD9cAS8BYvma0cNTLvM2floEItwSC7MbOeP6I8=; b=mVuvG7lOCHsKBlgNQ9l7uOnhHM9UUdSh2qGbxiCElCztDxV46qN4KCae WKl5XVGPdGHCLJJVYQQqhBVSPZ2IunixPyJnC5I7+LGjHNnci76L7/J/w ISHFHb0/NWq8a12pUrJ5CtKyTdfw8DOKu5a7AEvRkrJ6erU7wh6ZQW4vH 0S34zFqOrvUvlZ0zca15EsIWo/d7LF33mw1Lqv8SxKxjqwxRPIuiuC2Fq gE4jF05Su05pJwWV5kx+5sCCnEM3/U+NybKLgBSuhV+5sdK0Y1vh7axl4 cuQUjI/m4OZi0U1DEE+U5D+zkcowyJBeKghbWFg18iCKIpCxMqMMKsfvV A==; X-IronPort-AV: E=McAfee;i="6400,9594,10404"; a="346296572" X-IronPort-AV: E=Sophos;i="5.92,262,1650956400"; d="scan'208";a="346296572" Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by orsmga104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 11 Jul 2022 01:50:10 -0700 X-IronPort-AV: E=Sophos;i="5.92,262,1650956400"; d="scan'208";a="652374135" Received: from yhuang6-mobl1.sh.intel.com ([10.238.5.168]) by fmsmga008-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 11 Jul 2022 01:50:07 -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 -V2 3/7] migrate_pages(): fix THP failure counting for -ENOMEM Date: Mon, 11 Jul 2022 16:49:44 +0800 Message-Id: <20220711084948.274787-4-ying.huang@intel.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220711084948.274787-1-ying.huang@intel.com> References: <20220711084948.274787-1-ying.huang@intel.com> MIME-Version: 1.0 ARC-Authentication-Results: i=1; imf16.hostedemail.com; dkim=pass header.d=intel.com header.s=Intel header.b=mVuvG7lO; dmarc=pass (policy=none) header.from=intel.com; spf=none (imf16.hostedemail.com: domain of ying.huang@intel.com has no SPF policy when checking 134.134.136.31) smtp.mailfrom=ying.huang@intel.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1657529410; 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=MYmXTDDSAKaMZ0moFrCqojrhvfKgUJoKAZAj0wawY/w=; b=6xXB8KPZK/LVXnS3EhqhhTkuAfH+Z4syRs73+Jr9+F7eRPRX23rOwYEmn7thwx8ztcQ4gx s+3MOl6BxIxJWNZNdL/0v/3xvIagyoBx3o9nspctWboxwaVGap7dRl4VwkNN6TiPX9WrRZ 0auMKWbPCwu4DvNvqwXaHg/2fFLGhwQ= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1657529410; a=rsa-sha256; cv=none; b=DOq7Hx9EJZeeCl+MQc3SAijUkzDJNu9tnSh7ztxUyNpJPhwpcYDVpzYB12FMg3y7+7uJFq uLiGE1dp79y20f1kfptQOkncs1UnOXJjYFMaqUIRpW7NqI8+6LeIjQoIOuyC8R/rBeczJ/ FSRV2aeT6PqzU6cUkq5R081rtNq/XqM= Authentication-Results: imf16.hostedemail.com; dkim=pass header.d=intel.com header.s=Intel header.b=mVuvG7lO; dmarc=pass (policy=none) header.from=intel.com; spf=none (imf16.hostedemail.com: domain of ying.huang@intel.com has no SPF policy when checking 134.134.136.31) smtp.mailfrom=ying.huang@intel.com X-Rspamd-Server: rspam06 X-Rspam-User: X-Stat-Signature: rsg9qg8ruo61yr1w9ehujarjsby3eqcm X-Rspamd-Queue-Id: E7F2C180061 X-HE-Tag: 1657529409-47668 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 Cc: Zi Yan Cc: Yang Shi Reviewed-by: Oscar Salvador --- mm/migrate.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/mm/migrate.c b/mm/migrate.c index 794312072eb3..38e2c789a9c3 100644 --- a/mm/migrate.c +++ b/mm/migrate.c @@ -1426,11 +1426,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; } @@ -1446,6 +1446,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 Mon Jul 11 08:49:45 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Huang, Ying" X-Patchwork-Id: 12913158 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 AA5C1C43334 for ; Mon, 11 Jul 2022 08:50:13 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 49E4E6B00AB; Mon, 11 Jul 2022 04:50:13 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 450766B00AC; Mon, 11 Jul 2022 04:50:13 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 2A2456B00AD; Mon, 11 Jul 2022 04:50:13 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id 0D4EF6B00AB for ; Mon, 11 Jul 2022 04:50:13 -0400 (EDT) Received: from smtpin18.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id D4850209BA for ; Mon, 11 Jul 2022 08:50:12 +0000 (UTC) X-FDA: 79674197064.18.EB6DD07 Received: from mga06.intel.com (mga06b.intel.com [134.134.136.31]) by imf16.hostedemail.com (Postfix) with ESMTP id F3CB6180052 for ; Mon, 11 Jul 2022 08:50:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1657529412; x=1689065412; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=RJQzdlyWZrxxXfyYtTiwuvRSPwvEeRLnDLri6vLxLHk=; b=TOKpT6pR1U1LzB7XBa1oHctWh6EiPL/5ri70cGYABs8BcFFDFp3iB+4a HiXiO2+cDY1rRBCtgzaOT9vPWbM0cl9Y3gNYawoHRzujwZF+wk5QacpJv rtF7WYOAq16RoPBKtrcb8xnj6pLIowHeJ6MdPQsZGs1wYDI2GFkK9gOx0 8RKKSDZ1fnZXW5vNTwHIE8jI/fi28osh6yBcB6Lx8/oof8SKatdPWeERT 1GE3h94GHpV+2RK3hj4AZ/aipC0AuDwjqPSA34QFSEvxxCVw/7wFeY+UI zBzpqBw++Eq3vcWcLC30m5HMiW5g1o6p5c7YF1Xt/IQ+z7XrVHbQPY+GY Q==; X-IronPort-AV: E=McAfee;i="6400,9594,10404"; a="346296583" X-IronPort-AV: E=Sophos;i="5.92,262,1650956400"; d="scan'208";a="346296583" Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by orsmga104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 11 Jul 2022 01:50:12 -0700 X-IronPort-AV: E=Sophos;i="5.92,262,1650956400"; d="scan'208";a="652374146" Received: from yhuang6-mobl1.sh.intel.com ([10.238.5.168]) by fmsmga008-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 11 Jul 2022 01:50:09 -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 -V2 4/7] migrate_pages(): fix failure counting for THP subpages retrying Date: Mon, 11 Jul 2022 16:49:45 +0800 Message-Id: <20220711084948.274787-5-ying.huang@intel.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220711084948.274787-1-ying.huang@intel.com> References: <20220711084948.274787-1-ying.huang@intel.com> MIME-Version: 1.0 ARC-Authentication-Results: i=1; imf16.hostedemail.com; dkim=pass header.d=intel.com header.s=Intel header.b=TOKpT6pR; dmarc=pass (policy=none) header.from=intel.com; spf=none (imf16.hostedemail.com: domain of ying.huang@intel.com has no SPF policy when checking 134.134.136.31) smtp.mailfrom=ying.huang@intel.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1657529412; 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=S9MFN4kO+WfAxtgos/kaj8PiWvHeOvqgIr9oLoMgLIc=; b=dQ1GpPHAaVZDsRoJAtq4xV/KCPKZGm5FRnraaMgQoDsRD5kIY/3L8CDOxaKVFG69WWi9z5 r7NV2wOcluGUF/0MRwsxVnETT9BuunsIzY29SVcOz6Vpq9qYp4P3T0ncTTgqGEjwmuf6J4 QKyZ+/t1QTDZIrgrxkzSht6fwGdJZ9c= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1657529412; a=rsa-sha256; cv=none; b=ez3IXGyY1LIRDNXPlWeiEHiXp/B0+Ukln4RQISlSIPTKPz6dA7okyXzTTq41m241aA5+Fm 8eWd2U5ewFn37XpceFg9MyvB1/Yllh4adxREha9bvmgUTMnQrascRbi9oa1I3D7MwTRtKq Zeftlcu5bJ1uKHL5iDXN4UrAyKZYySU= Authentication-Results: imf16.hostedemail.com; dkim=pass header.d=intel.com header.s=Intel header.b=TOKpT6pR; dmarc=pass (policy=none) header.from=intel.com; spf=none (imf16.hostedemail.com: domain of ying.huang@intel.com has no SPF policy when checking 134.134.136.31) smtp.mailfrom=ying.huang@intel.com X-Rspamd-Server: rspam06 X-Rspam-User: X-Stat-Signature: fygnohqo187ke57kjehuw5a8f4r1j1fq X-Rspamd-Queue-Id: F3CB6180052 X-HE-Tag: 1657529411-545720 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 Cc: Zi Yan Cc: Yang Shi Reviewed-by: Oscar Salvador --- mm/migrate.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/mm/migrate.c b/mm/migrate.c index 38e2c789a9c3..4bceba143db0 100644 --- a/mm/migrate.c +++ b/mm/migrate.c @@ -1477,7 +1477,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 Mon Jul 11 08:49:46 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Huang, Ying" X-Patchwork-Id: 12913159 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 A5706C43334 for ; Mon, 11 Jul 2022 08:50:15 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 319D36B00AD; Mon, 11 Jul 2022 04:50:15 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 2C7FD6B00AE; Mon, 11 Jul 2022 04:50:15 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 168906B00AF; Mon, 11 Jul 2022 04:50:15 -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 F0BD56B00AD for ; Mon, 11 Jul 2022 04:50:14 -0400 (EDT) Received: from smtpin21.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id BF21233513 for ; Mon, 11 Jul 2022 08:50:14 +0000 (UTC) X-FDA: 79674197148.21.E077020 Received: from mga06.intel.com (mga06b.intel.com [134.134.136.31]) by imf16.hostedemail.com (Postfix) with ESMTP id 1727C180052 for ; Mon, 11 Jul 2022 08:50:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1657529414; x=1689065414; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=tbVtvIK8XMk4xb1SU8xCdADdmx3jSPLB5EdXqTq3PBc=; b=Ux06BiEHYrjtywykn3AJ+imdmz96I/Fzz+OFXLy2lBUrgxb9ZJdYJNG5 ycxkXrQZzU3psGcKJb4vZ1qCUeQrHTgH5jdvloIgVRxVSJye2cYm3QuIl Imc0zhGPnr9W7iCp3qio2BbYAd+C8dCIK/s8wX/Uv6dGCWBWq6TaWiQzj oNKHfMFlPCvo6NJkF9E67eH9ublDSvLz+RrM7VFkRL3awfwJL3brxH+45 wy/kAWMogLdZKMb3+jSZCkphjf7IpLB79cCm/+yvp4kKpflQA1jtwUglA hOBOSG69/cRtfQHAKOIycth1uYp642LZ8aBdBfO9tgEvXQsKFWOwwdgtU g==; X-IronPort-AV: E=McAfee;i="6400,9594,10404"; a="346296593" X-IronPort-AV: E=Sophos;i="5.92,262,1650956400"; d="scan'208";a="346296593" Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by orsmga104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 11 Jul 2022 01:50:14 -0700 X-IronPort-AV: E=Sophos;i="5.92,262,1650956400"; d="scan'208";a="652374162" Received: from yhuang6-mobl1.sh.intel.com ([10.238.5.168]) by fmsmga008-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 11 Jul 2022 01:50:11 -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 -V2 5/7] migrate_pages(): fix failure counting for THP on -ENOSYS Date: Mon, 11 Jul 2022 16:49:46 +0800 Message-Id: <20220711084948.274787-6-ying.huang@intel.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220711084948.274787-1-ying.huang@intel.com> References: <20220711084948.274787-1-ying.huang@intel.com> MIME-Version: 1.0 ARC-Authentication-Results: i=1; imf16.hostedemail.com; dkim=pass header.d=intel.com header.s=Intel header.b=Ux06BiEH; dmarc=pass (policy=none) header.from=intel.com; spf=none (imf16.hostedemail.com: domain of ying.huang@intel.com has no SPF policy when checking 134.134.136.31) smtp.mailfrom=ying.huang@intel.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1657529414; 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=uDNhiNVaova0EQaX6/hQMRj+3qJNe2j96GTWAnJLGnI=; b=IBsh5Ll84DeOg9RPffLi1s/qPOnSaKIB2qzctGBZGO0YbxvwwbFn1jaoiLCA9SyfwAl+bQ GbWccBBTOQw3KXNE8TGFFqyp9Doq1GIw/3BSLqH5Pr6uolBL2fSC/ml7erbUA+n62fdpiL BTbXzQ1t8EQnJwwqcrEXqCn+eOnQtFw= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1657529414; a=rsa-sha256; cv=none; b=RVzQvIpe4pykkCCVg6g/NlsrR/Y5ITIVQJMIpb7byaMjCjl7ANt0U+e8IglvPxsibuVw+v NuYCMCcH6is1I69H9tYitnXO7w3AiEGdd8+KjGeHQ5g2S9wMXDpQziZG4Qet5XNTNeIpiU FuCfLvweCwxxiXkO8JpPf/VJQG2gBBo= Authentication-Results: imf16.hostedemail.com; dkim=pass header.d=intel.com header.s=Intel header.b=Ux06BiEH; dmarc=pass (policy=none) header.from=intel.com; spf=none (imf16.hostedemail.com: domain of ying.huang@intel.com has no SPF policy when checking 134.134.136.31) smtp.mailfrom=ying.huang@intel.com X-Rspamd-Server: rspam06 X-Rspam-User: X-Stat-Signature: qdiec8uz9zk37n9dw1yoopoyw3jtyto8 X-Rspamd-Queue-Id: 1727C180052 X-HE-Tag: 1657529413-238157 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 4bceba143db0..8cce73b7c046 100644 --- a/mm/migrate.c +++ b/mm/migrate.c @@ -1192,10 +1192,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. */ @@ -1392,6 +1390,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 */ @@ -1421,6 +1420,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 Mon Jul 11 08:49:47 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Huang, Ying" X-Patchwork-Id: 12913160 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 CCB00C43334 for ; Mon, 11 Jul 2022 08:50:17 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 675936B00B0; Mon, 11 Jul 2022 04:50:17 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 623E56B00B1; Mon, 11 Jul 2022 04:50:17 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 477DA6B00B2; Mon, 11 Jul 2022 04:50:17 -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 20C386B00B0 for ; Mon, 11 Jul 2022 04:50:17 -0400 (EDT) Received: from smtpin09.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id E67E72049F for ; Mon, 11 Jul 2022 08:50:16 +0000 (UTC) X-FDA: 79674197232.09.CAF191B Received: from mga06.intel.com (mga06b.intel.com [134.134.136.31]) by imf16.hostedemail.com (Postfix) with ESMTP id 34322180060 for ; Mon, 11 Jul 2022 08:50:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1657529417; x=1689065417; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=bnF/J3cdzcNa2nvmNTqNXDVKtTT8seBOtgR5lAaUQZU=; b=nsqddFg0Sfd/KT/7f5ENo3Ztq30ISYFcicYrRE24C1LP5nY4QiS2S0tN jop1s+A0AyC0xBkpUdqgwYZXEWu0zOTmtHgulZApelBOys8U+1acN7BCG eVbfUKsG9KZzVdheP0i/RGyHwrOi7RnIxGNI8y+kPiIbzFEE/OOTHqn7N eVzvWiQDExRirGn9qXo73kxs64z7GFZFa48Rj2/cFN6mv6su8fUgvQV/F WHIxqSTt9t8PVZGi9g2vnMzIHpbaHZBQpcQVMYVtI5PVsfesls6+NhuP2 wtPXa9SksEO6mSeeSSvyoKRsiMc2LcBFh3VY/4JSjCGXLfglMws7RJOnn A==; X-IronPort-AV: E=McAfee;i="6400,9594,10404"; a="346296604" X-IronPort-AV: E=Sophos;i="5.92,262,1650956400"; d="scan'208";a="346296604" Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by orsmga104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 11 Jul 2022 01:50:16 -0700 X-IronPort-AV: E=Sophos;i="5.92,262,1650956400"; d="scan'208";a="652374174" Received: from yhuang6-mobl1.sh.intel.com ([10.238.5.168]) by fmsmga008-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 11 Jul 2022 01:50:13 -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 -V2 6/7] migrate_pages(): fix failure counting for THP splitting Date: Mon, 11 Jul 2022 16:49:47 +0800 Message-Id: <20220711084948.274787-7-ying.huang@intel.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220711084948.274787-1-ying.huang@intel.com> References: <20220711084948.274787-1-ying.huang@intel.com> MIME-Version: 1.0 ARC-Authentication-Results: i=1; imf16.hostedemail.com; dkim=pass header.d=intel.com header.s=Intel header.b=nsqddFg0; dmarc=pass (policy=none) header.from=intel.com; spf=none (imf16.hostedemail.com: domain of ying.huang@intel.com has no SPF policy when checking 134.134.136.31) smtp.mailfrom=ying.huang@intel.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1657529416; 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=+h5CYeMM4q8D1gWVaLUvW4VrJXXibkXozsNUEdEqf3A=; b=2kqMsnGcP/OT75W0ThMA9ygC0hmD+bFEjkqSHnpYyngEDE03jg43ZAXl7N5Itjcuhm7Nks oofv4tNsVmkAqCsfqzIMK311Q477dzgiT2wt4hPu9N44Aw88reQe1z+hi5l1Y+8tb160D7 0ggEOTIb1hVSXw4QNl1qd/z01vszVbk= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1657529416; a=rsa-sha256; cv=none; b=RXInHBPaf/Qh0Ww4gaxNBz4XHDXDYaD3B2spYEP5+lMgtLW1MbxyTBDy0jUBsWowdFKCTz eXL+gPHj6dkkLl5sprj6+9i2S2hb3cQ5b214LpPnE3T9y9MRakdf1Oh1HXWZyFiOlmMVpM nnw/MAALpNp7+QaQpmyNfJZvS8rB1I8= Authentication-Results: imf16.hostedemail.com; dkim=pass header.d=intel.com header.s=Intel header.b=nsqddFg0; dmarc=pass (policy=none) header.from=intel.com; spf=none (imf16.hostedemail.com: domain of ying.huang@intel.com has no SPF policy when checking 134.134.136.31) smtp.mailfrom=ying.huang@intel.com X-Rspamd-Server: rspam06 X-Rspam-User: X-Stat-Signature: dwrmyu3rnhokj7hmzxx16cngdgdjzbkw X-Rspamd-Queue-Id: 34322180060 X-HE-Tag: 1657529416-78460 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 Cc: Zi Yan Cc: Yang Shi Reviewed-by: Oscar Salvador --- mm/migrate.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/mm/migrate.c b/mm/migrate.c index 8cce73b7c046..557708ce13a1 100644 --- a/mm/migrate.c +++ b/mm/migrate.c @@ -1306,6 +1306,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; } @@ -1365,7 +1367,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 @@ -1412,7 +1413,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) { @@ -1432,7 +1433,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 Mon Jul 11 08:49:48 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Huang, Ying" X-Patchwork-Id: 12913161 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 B2CFCCCA47B for ; Mon, 11 Jul 2022 08:50:19 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 2F1206B00B1; Mon, 11 Jul 2022 04:50:19 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 27A006B00B3; Mon, 11 Jul 2022 04:50:19 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 0F46E6B00B4; Mon, 11 Jul 2022 04:50:19 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id F077D6B00B1 for ; Mon, 11 Jul 2022 04:50:18 -0400 (EDT) Received: from smtpin18.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id C31E2340D7 for ; Mon, 11 Jul 2022 08:50:18 +0000 (UTC) X-FDA: 79674197316.18.F3306EC Received: from mga06.intel.com (mga06b.intel.com [134.134.136.31]) by imf16.hostedemail.com (Postfix) with ESMTP id 390EC180056 for ; Mon, 11 Jul 2022 08:50:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1657529419; x=1689065419; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=pYmlZTWW8T052yrvDTxhlle8aydW1U/tmRbuqMhTmdg=; b=T4fIoUS7/kU8EYav+SODvJCWfsyGOeXy5NxFIBt0EbHXWYeqVbSWY2UW idKM6Q60EKEk9E98c/PozX2psdMlvgZRZtEwHl9km+MyyyhWF7/sxScpQ EAz8O60f3NT06xfQJYhT0pcjjGcOMDy9Xd+CV0fHFIQxlh2fhq7Wk9cIT YNRhtxvBPv/ibhLbdaXrBhojC50FjD/18kamgDcaKgsBONma+zLGUAGQq +JkTIN7jZOQ+tBj71mpRAslhbUevYh7wdsj6WblIM2AE6wYa9zLbilPew 2crPjrv73jcwTgCYkflPh5qpAjd2HIVT5Q+3MTg2Wu6LJC7LsnsPQzzIY A==; X-IronPort-AV: E=McAfee;i="6400,9594,10404"; a="346296616" X-IronPort-AV: E=Sophos;i="5.92,262,1650956400"; d="scan'208";a="346296616" Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by orsmga104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 11 Jul 2022 01:50:18 -0700 X-IronPort-AV: E=Sophos;i="5.92,262,1650956400"; d="scan'208";a="652374188" Received: from yhuang6-mobl1.sh.intel.com ([10.238.5.168]) by fmsmga008-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 11 Jul 2022 01:50:16 -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 -V2 7/7] migrate_pages(): fix failure counting for retry Date: Mon, 11 Jul 2022 16:49:48 +0800 Message-Id: <20220711084948.274787-8-ying.huang@intel.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220711084948.274787-1-ying.huang@intel.com> References: <20220711084948.274787-1-ying.huang@intel.com> MIME-Version: 1.0 ARC-Authentication-Results: i=1; imf16.hostedemail.com; dkim=pass header.d=intel.com header.s=Intel header.b=T4fIoUS7; dmarc=pass (policy=none) header.from=intel.com; spf=none (imf16.hostedemail.com: domain of ying.huang@intel.com has no SPF policy when checking 134.134.136.31) smtp.mailfrom=ying.huang@intel.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1657529418; 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=+WxijoM26Zyr9Tm/zCbdNSVlsPAIjKiv0YB4dMEFsi0=; b=F8wP5jbP+hESeyI3f+/40RJHVkFucCIYdgXhKgk1ugZhtsj5fbyWQe8kcdX/Rh3qhTaX+Y WgNJSrJqmMhP0jblL6U201RYHLAFY5bHnD1YjV0gsHcVspRbyLwvnDLTgW++DgbOQae+et prOiME8XdubNgdz7akylnxPvg4/P4iA= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1657529418; a=rsa-sha256; cv=none; b=o4HvvgxFhMWMMcNExtOPWRv0Sm77NJm53xVRJPY7sqifpVUwe/eDudcd2/+t1w4iVZ/dZX nUEXEY9FRXvHvXbzN0y722aYXdjlB5BM9Fez8w58V/ATsQ+V/t5cscCYLGYfOBEZNG/8nT r4QIUsCSm46aBHzPtjy6TiBrAQx+Tuk= Authentication-Results: imf16.hostedemail.com; dkim=pass header.d=intel.com header.s=Intel header.b=T4fIoUS7; dmarc=pass (policy=none) header.from=intel.com; spf=none (imf16.hostedemail.com: domain of ying.huang@intel.com has no SPF policy when checking 134.134.136.31) smtp.mailfrom=ying.huang@intel.com X-Rspamd-Server: rspam06 X-Rspam-User: X-Stat-Signature: gxatyyiy7tsioqgpwfad3hok9xwkduyt X-Rspamd-Queue-Id: 390EC180056 X-HE-Tag: 1657529418-23700 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 Cc: Zi Yan Cc: Yang Shi Reviewed-by: Oscar Salvador --- mm/migrate.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/mm/migrate.c b/mm/migrate.c index 557708ce13a1..cee6fc5a2d31 100644 --- a/mm/migrate.c +++ b/mm/migrate.c @@ -1345,6 +1345,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; @@ -1365,6 +1366,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) { /* @@ -1439,7 +1441,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 @@ -1455,6 +1457,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; @@ -1481,6 +1484,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