From patchwork Fri Jun 24 02:53: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: 12893404 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 AA4DFCCA47C for ; Fri, 24 Jun 2022 02:53:37 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 32CDA8E01C0; Thu, 23 Jun 2022 22:53:37 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 269438E01BF; Thu, 23 Jun 2022 22:53:37 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 0BD268E01C0; Thu, 23 Jun 2022 22:53:36 -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 E59098E01B9 for ; Thu, 23 Jun 2022 22:53:36 -0400 (EDT) Received: from smtpin04.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id C559B61582 for ; Fri, 24 Jun 2022 02:53:36 +0000 (UTC) X-FDA: 79611608832.04.49A7BF4 Received: from mga04.intel.com (mga04.intel.com [192.55.52.120]) by imf24.hostedemail.com (Postfix) with ESMTP id 1B1FD180033 for ; Fri, 24 Jun 2022 02:53:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1656039216; x=1687575216; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=ttPBux1M2TE50CAmWMfHxZHCo/ZNYs4ZWZZeOnEKVN4=; b=kh7FnJMuUt6unkskCGovUFAQHjRq5uKeaoZP9BB+6oPqKp3vypsw+fs2 2+ijW+ipb6BHHvzqXz3oQ1F4IQrhQ+zpVsbHdDywvpBEKFh5kz5RXVogR FOpWmR1u8oCWl0CcAgk4HvB79q9ZhEL/y3qRTckU5p46f3vGHWGAHbNpT TTbMqcgyk5HnPLasmf3ecNYEj3jGCEXCfvhwBx0LIpDZZ/UoPn2ZFNplv hDDMOvhFcqoZlEJZOdwD2mBje7+LEzbLJtVAAr1KXGIeJgBaUPDUxb3Ay 5D8m7bUxbXxKfUHv+qFL57fZ4/TRBdAucZdibPzHz/o6yUMaR9teersvP g==; X-IronPort-AV: E=McAfee;i="6400,9594,10387"; a="279672714" X-IronPort-AV: E=Sophos;i="5.92,217,1650956400"; d="scan'208";a="279672714" Received: from fmsmga007.fm.intel.com ([10.253.24.52]) by fmsmga104.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 23 Jun 2022 19:53:33 -0700 X-IronPort-AV: E=Sophos;i="5.92,217,1650956400"; d="scan'208";a="593018066" Received: from yxia2-mobl1.ccr.corp.intel.com (HELO yhuang6-mobl1.ccr.corp.intel.com) ([10.254.214.143]) by fmsmga007-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 23 Jun 2022 19:53:31 -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 1/7] migrate: fix syscall move_pages() return value for failure Date: Fri, 24 Jun 2022 10:53:03 +0800 Message-Id: <20220624025309.1033400-2-ying.huang@intel.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220624025309.1033400-1-ying.huang@intel.com> References: <20220624025309.1033400-1-ying.huang@intel.com> MIME-Version: 1.0 ARC-Authentication-Results: i=1; imf24.hostedemail.com; dkim=pass header.d=intel.com header.s=Intel header.b=kh7FnJMu; dmarc=pass (policy=none) header.from=intel.com; spf=none (imf24.hostedemail.com: domain of ying.huang@intel.com has no SPF policy when checking 192.55.52.120) smtp.mailfrom=ying.huang@intel.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1656039216; 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=La0tuTyLQBKd2mrZ5M38lcWQaTwiCXVennnRxVNH9MY=; b=yhYT6V9GD7dCg8RDpH9QzYPYCi8FrAlqzqGKcwlhkpxKgvUGSW4iPq5n+jt/HgjrO7UnVD hQsliDBi8648PCd3DwUfmJ4JOys82SBvntAYVHEoUOs9Viq0QMYF7dZPXYtIFDLpdQXiop GJp7n3/J2y6w4A9bFjfNJSt2jAgfd20= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1656039216; a=rsa-sha256; cv=none; b=lgak6D0mSHopLtDWT9uBwePbuG4feEw//onsQ2V715JADr+FF1D5bAxNjgBsAhYUGEE593 IzHBF/GRGR+PUwyxZoRPAsTwbu9/IyYPAM3VlqHSwmi5EH9eqbBBAHWDREnWmpxs7G7h/m a7aQzWIKdqWjdDusHUJdihxnMx4D6fQ= X-Stat-Signature: wgj3g3m56bzxorx7sdtc115i9tbzsh8d X-Rspamd-Queue-Id: 1B1FD180033 X-Rspam-User: Authentication-Results: imf24.hostedemail.com; dkim=pass header.d=intel.com header.s=Intel header.b=kh7FnJMu; dmarc=pass (policy=none) header.from=intel.com; spf=none (imf24.hostedemail.com: domain of ying.huang@intel.com has no SPF policy when checking 192.55.52.120) smtp.mailfrom=ying.huang@intel.com X-Rspamd-Server: rspam12 X-HE-Tag: 1656039215-819895 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 --- mm/migrate.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/mm/migrate.c b/mm/migrate.c index e51588e95f57..a271554be7a1 100644 --- a/mm/migrate.c +++ b/mm/migrate.c @@ -1681,7 +1681,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); @@ -1767,8 +1767,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 Fri Jun 24 02:53: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: 12893405 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 26E8EC43334 for ; Fri, 24 Jun 2022 02:53:39 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 62E5F8E01B9; Thu, 23 Jun 2022 22:53:37 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 3F02B8E01C1; Thu, 23 Jun 2022 22:53:37 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 1F4048E01B9; Thu, 23 Jun 2022 22:53:37 -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 00C588E01BF for ; Thu, 23 Jun 2022 22:53:36 -0400 (EDT) Received: from smtpin30.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay13.hostedemail.com (Postfix) with ESMTP id CFE4060582 for ; Fri, 24 Jun 2022 02:53:36 +0000 (UTC) X-FDA: 79611608832.30.DFC1474 Received: from mga04.intel.com (mga04.intel.com [192.55.52.120]) by imf21.hostedemail.com (Postfix) with ESMTP id 13CBD1C0009 for ; Fri, 24 Jun 2022 02:53:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1656039216; x=1687575216; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=pJRtHCA5XeINaIi9YAR839UhUEC+OvL+5N+hlZMyJMg=; b=Z5I80ni/Lku8aFw6Iflr2McfmcYJ6W72h3KeSNHkGnnolWiZO9R6jyMY azEe+AFEogv9CVs1dWtL5Yjjs1wl4+7VLsQuXOCXhLdPfuCRbPOTzY+CU T50MoAWAbRFYtOwvew0383Si67UIwsYSD1/9hRNWWyicYpbN80UpGPeuX Sp9edVRKQaUj3iUUgBFWIY5F5I4aoSly5VUIC5/T88DJvNtwfGD80fUYS qPeJEG2MO/00+EQYmbL6qIY/Qs+GXSREEUKx9TD0pN9kfB95S15abOasO /CByPm6uD77EMbuPv+pe5ZHfYhgLqb9QHYIM7DcCg+L0pu0fKFkmVRat5 A==; X-IronPort-AV: E=McAfee;i="6400,9594,10387"; a="279672721" X-IronPort-AV: E=Sophos;i="5.92,217,1650956400"; d="scan'208";a="279672721" Received: from fmsmga007.fm.intel.com ([10.253.24.52]) by fmsmga104.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 23 Jun 2022 19:53:35 -0700 X-IronPort-AV: E=Sophos;i="5.92,217,1650956400"; d="scan'208";a="593018075" Received: from yxia2-mobl1.ccr.corp.intel.com (HELO yhuang6-mobl1.ccr.corp.intel.com) ([10.254.214.143]) by fmsmga007-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 23 Jun 2022 19:53:33 -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 2/7] migrate_pages(): remove unnecessary list_safe_reset_next() Date: Fri, 24 Jun 2022 10:53:04 +0800 Message-Id: <20220624025309.1033400-3-ying.huang@intel.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220624025309.1033400-1-ying.huang@intel.com> References: <20220624025309.1033400-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=1656039216; 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=oGOSco5OUDvPDNdnomthw5uZjK0xVj4XPif2nyx0gn8=; b=rMr/36RZ7Sy5brPBrnSJVMRIAeH4DYfD83xKoK6RxJRT7MhCNZWtR6Hplu2NPguh73cAnx zlvjQEZqwEy9L/+eMisvKr/ldNbUwafmT8UTPXIdi8+g2scqRLpaTsPw4nCQxQvsMNzF3T ByMNNVGTePnXdpYBBhlWV1y9tNCAZ2U= ARC-Authentication-Results: i=1; imf21.hostedemail.com; dkim=pass header.d=intel.com header.s=Intel header.b="Z5I80ni/"; dmarc=pass (policy=none) header.from=intel.com; spf=none (imf21.hostedemail.com: domain of ying.huang@intel.com has no SPF policy when checking 192.55.52.120) smtp.mailfrom=ying.huang@intel.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1656039216; a=rsa-sha256; cv=none; b=a5ULezXUmyhcjVnIp5XMaPYLpI/SizHGufItLjp34T/X2z+cnzt71iK2KmE56eFncaR1FE F5p2iOhnXMG9qADgBx973oPD8J5piVm5FANUB2ozqSC6FILMHxGWVnnEumzh8ipVHNFIIO 1B/GSwyJrSBWz3qBi+tlLV0sLUzXrPg= X-Rspamd-Queue-Id: 13CBD1C0009 Authentication-Results: imf21.hostedemail.com; dkim=pass header.d=intel.com header.s=Intel header.b="Z5I80ni/"; dmarc=pass (policy=none) header.from=intel.com; spf=none (imf21.hostedemail.com: domain of ying.huang@intel.com has no SPF policy when checking 192.55.52.120) smtp.mailfrom=ying.huang@intel.com X-Rspam-User: X-Rspamd-Server: rspam11 X-Stat-Signature: pm1ctaqepox8hthojb3mwffy78z85hzs X-HE-Tag: 1656039215-354085 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" Cc: Baolin Wang Cc: Zi Yan Cc: Yang Shi Reviewed-by: Baolin Wang --- mm/migrate.c | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/mm/migrate.c b/mm/migrate.c index a271554be7a1..82444e7df9f1 100644 --- a/mm/migrate.c +++ b/mm/migrate.c @@ -1300,16 +1300,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; } @@ -1413,7 +1410,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; } @@ -1432,7 +1429,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 Fri Jun 24 02:53: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: 12893406 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 C3244CCA47C for ; Fri, 24 Jun 2022 02:53:40 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 550F88E01C1; Thu, 23 Jun 2022 22:53:39 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 501088E01BF; Thu, 23 Jun 2022 22:53:39 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 379658E01C1; Thu, 23 Jun 2022 22:53:39 -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 250838E01BF for ; Thu, 23 Jun 2022 22:53:39 -0400 (EDT) Received: from smtpin23.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id 00BA6357F8 for ; Fri, 24 Jun 2022 02:53:38 +0000 (UTC) X-FDA: 79611608958.23.41F271A Received: from mga04.intel.com (mga04.intel.com [192.55.52.120]) by imf21.hostedemail.com (Postfix) with ESMTP id 482D71C0009 for ; Fri, 24 Jun 2022 02:53: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=1656039218; x=1687575218; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=zkfooEuAcL1s/GMfIWYGeryZUxTknJxESw3mSAR4BLA=; b=iV0ATAJh7iTeN4cpzWop1IC2/up34qM7616bvxeLY11rNyqUri21tlv0 Sin/uhIDEmB4IHzVE8+P7romRR3R0YfJvb53F9feiEz+Uje9kJPZMCeJq y5sCP9UHdOkBcK5jFbThTkBZo8/QwKvWy35tpjrMEsKex6nTUQYll6W2r TMoWrRYhlrniT3tRSgSkgQILmUXxFOqEr4epSsFj85cTx0b7xwUwWSpZa 2S+oMCxaIU7Ja3vRCdes6Izcppw3DSBiv5v9DMEzaJlOUuzlwt/qmcuXd zYMsJfmVWN2gnG2rfaQg0A044E+QQdI56PY/MnYwmow/9WgvGCt9A2j4Z Q==; X-IronPort-AV: E=McAfee;i="6400,9594,10387"; a="279672725" X-IronPort-AV: E=Sophos;i="5.92,217,1650956400"; d="scan'208";a="279672725" Received: from fmsmga007.fm.intel.com ([10.253.24.52]) by fmsmga104.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 23 Jun 2022 19:53:37 -0700 X-IronPort-AV: E=Sophos;i="5.92,217,1650956400"; d="scan'208";a="593018084" Received: from yxia2-mobl1.ccr.corp.intel.com (HELO yhuang6-mobl1.ccr.corp.intel.com) ([10.254.214.143]) by fmsmga007-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 23 Jun 2022 19:53:35 -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 3/7] migrate_pages(): fix THP failure counting for -ENOMEM Date: Fri, 24 Jun 2022 10:53:05 +0800 Message-Id: <20220624025309.1033400-4-ying.huang@intel.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220624025309.1033400-1-ying.huang@intel.com> References: <20220624025309.1033400-1-ying.huang@intel.com> MIME-Version: 1.0 ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1656039218; a=rsa-sha256; cv=none; b=Q8EpKh9k5uMdwygYqY5I5mIbEjMkY10IOpIVjNwYW0xY8rfuAWTHq5Wb+3wS71CUgUsxMJ nYhZbrpYo2BOZvH85sPFcVHmcqZNL21isRoA+FcSsaKNiA0wvYDYyHVGnSHT606+tFa6a+ aC2dIlqupkiUon68ayT5t5vZRZo+sO8= ARC-Authentication-Results: i=1; imf21.hostedemail.com; dkim=pass header.d=intel.com header.s=Intel header.b=iV0ATAJh; dmarc=pass (policy=none) header.from=intel.com; spf=none (imf21.hostedemail.com: domain of ying.huang@intel.com has no SPF policy when checking 192.55.52.120) smtp.mailfrom=ying.huang@intel.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1656039218; 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=pqEwmo4mshIJwpuC5Y/f3sNoNO7z9BHjjHKjvfR56j4=; b=8dSpOciAqHMzm5ZAqMV7hLktRV8RIcnxdqCTfuP3KdetDUyRxuyyAT9naDgLQ1EXdA9A8F +0zJxv3wqJB/oUTl8QNg6k9RHRavqqs5Dkc7WSuN8th7nMir1HtlWn5EJUbo7HnsiaiAtX xYd1qcEL9/39joEU0rcct2kYLaKuPh0= X-Stat-Signature: af7fe71qkfzkeuwwzi8hftzo8mqxtgwx X-Rspamd-Queue-Id: 482D71C0009 Authentication-Results: imf21.hostedemail.com; dkim=pass header.d=intel.com header.s=Intel header.b=iV0ATAJh; dmarc=pass (policy=none) header.from=intel.com; spf=none (imf21.hostedemail.com: domain of ying.huang@intel.com has no SPF policy when checking 192.55.52.120) smtp.mailfrom=ying.huang@intel.com X-Rspamd-Server: rspam10 X-Rspam-User: X-HE-Tag: 1656039218-43427 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 is fixed too, although that is not used actually. 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: Baolin Wang --- mm/migrate.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/mm/migrate.c b/mm/migrate.c index 82444e7df9f1..542533e4e3cf 100644 --- a/mm/migrate.c +++ b/mm/migrate.c @@ -1425,11 +1425,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,8 @@ int migrate_pages(struct list_head *from, new_page_t get_new_page, */ list_splice_init(&thp_split_pages, from); nr_thp_failed += thp_retry; + if (!no_subpage_counting) + nr_failed += retry; goto out; case -EAGAIN: if (is_thp) From patchwork Fri Jun 24 02:53: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: 12893407 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 34EFAC43334 for ; Fri, 24 Jun 2022 02:53:42 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 3A59A8E01C2; Thu, 23 Jun 2022 22:53:41 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 305AE8E01BF; Thu, 23 Jun 2022 22:53:41 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 1CFDC8E01C2; Thu, 23 Jun 2022 22:53:41 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id 00E4C8E01BF for ; Thu, 23 Jun 2022 22:53:40 -0400 (EDT) Received: from smtpin22.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay13.hostedemail.com (Postfix) with ESMTP id CB8E460582 for ; Fri, 24 Jun 2022 02:53:40 +0000 (UTC) X-FDA: 79611609000.22.408E200 Received: from mga04.intel.com (mga04.intel.com [192.55.52.120]) by imf21.hostedemail.com (Postfix) with ESMTP id 142871C0019 for ; Fri, 24 Jun 2022 02:53:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1656039220; x=1687575220; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=dyatKl+uw3fFNQdVpp0JrZk8BbuYdjsdo/ZbC0KvS1w=; b=J5k7PGe1St4QVzRSaLddEsEl0BkJhzcCJSPH4kMcDw5oydC4oyxZwX12 7QzG3PpWF7ts/htx+3l308bg08isf9n0RNUJYARJ8FCHCIr/MSLPKKdni vIY6RZj2ka4cNAv3GCsVQqNMLvbAf2jFlEb8zXliEbirHl4ttPlfmS3Qz AJD7SCK9krORsNRoPr9tx4HMW9QOSTPVQSpNMR8/qeYUeh2LaxNLX9BY9 slMVc2Nzq1FzqN1IUqXtqRj7b01ZoFDe+RPfzA5Iv66InlHVgdeETNzIY ZyGkQLxkC9Pa046+4Em3Hn/yI+c9fSCRrZn9TB7NnjQ8IDUC+6am19W94 g==; X-IronPort-AV: E=McAfee;i="6400,9594,10387"; a="279672731" X-IronPort-AV: E=Sophos;i="5.92,217,1650956400"; d="scan'208";a="279672731" Received: from fmsmga007.fm.intel.com ([10.253.24.52]) by fmsmga104.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 23 Jun 2022 19:53:39 -0700 X-IronPort-AV: E=Sophos;i="5.92,217,1650956400"; d="scan'208";a="593018090" Received: from yxia2-mobl1.ccr.corp.intel.com (HELO yhuang6-mobl1.ccr.corp.intel.com) ([10.254.214.143]) by fmsmga007-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 23 Jun 2022 19:53:37 -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 4/7] migrate_pages(): fix failure counting for THP subpages retrying Date: Fri, 24 Jun 2022 10:53:06 +0800 Message-Id: <20220624025309.1033400-5-ying.huang@intel.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220624025309.1033400-1-ying.huang@intel.com> References: <20220624025309.1033400-1-ying.huang@intel.com> MIME-Version: 1.0 ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1656039220; a=rsa-sha256; cv=none; b=fmbUbiLzMzH2hZq+CWJNOjUvciNAY28qqXLYvmpV2EnmnN5KGxAyoQ04+1JGHGbgV1Z9PK +dcA8k8kVGQBxsvApXtdqfFwed2ibFKz2fHNU+aKfwhRJHlIAzGj1J0Ph4Ucl+U1CRUwgc ttTie/oVlEr1YOu9a3b/TVfnh0LzsAE= ARC-Authentication-Results: i=1; imf21.hostedemail.com; dkim=pass header.d=intel.com header.s=Intel header.b=J5k7PGe1; dmarc=pass (policy=none) header.from=intel.com; spf=none (imf21.hostedemail.com: domain of ying.huang@intel.com has no SPF policy when checking 192.55.52.120) smtp.mailfrom=ying.huang@intel.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1656039220; 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=75uwcPONczZNaQCmnG1AhPpbl35dMc+qJFYG6J0RjEA=; b=AhmNoa2UjvFQwslRNDTTw6sIMpY4Hzit57/ebhvZYhw3bLuBTbPp6ViTFF9oB7qsFjZHQU hG8NlukZl2nqYJMva4gnA1ya1xa2E8v1qcMHlvoGkab+oCNk4j/9UHiQqNOl3vYIiu4Ge9 yHpveA/5xgXvnxOMo8e3HU9f75giVek= X-Stat-Signature: o98yb7dos8cf9qh4yfmofrs48okuj949 X-Rspamd-Queue-Id: 142871C0019 Authentication-Results: imf21.hostedemail.com; dkim=pass header.d=intel.com header.s=Intel header.b=J5k7PGe1; dmarc=pass (policy=none) header.from=intel.com; spf=none (imf21.hostedemail.com: domain of ying.huang@intel.com has no SPF policy when checking 192.55.52.120) smtp.mailfrom=ying.huang@intel.com X-Rspamd-Server: rspam10 X-Rspam-User: X-HE-Tag: 1656039219-104100 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") Cc: Baolin Wang Cc: Zi Yan Cc: Yang Shi Reviewed-by: Baolin Wang --- mm/migrate.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/mm/migrate.c b/mm/migrate.c index 542533e4e3cf..61dab3025a1d 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 Fri Jun 24 02:53: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: 12893408 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 D4B6ACCA47C for ; Fri, 24 Jun 2022 02:53:43 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 269F28E01C3; Thu, 23 Jun 2022 22:53:43 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 21C738E01BF; Thu, 23 Jun 2022 22:53:43 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 093D88E01C3; Thu, 23 Jun 2022 22:53:43 -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 EA1A78E01BF for ; Thu, 23 Jun 2022 22:53:42 -0400 (EDT) Received: from smtpin14.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id B515635A2E for ; Fri, 24 Jun 2022 02:53:42 +0000 (UTC) X-FDA: 79611609084.14.34904A2 Received: from mga04.intel.com (mga04.intel.com [192.55.52.120]) by imf21.hostedemail.com (Postfix) with ESMTP id 2938F1C0009 for ; Fri, 24 Jun 2022 02:53:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1656039222; x=1687575222; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=B27oFNEx1h03uzrh6vOGjjj8DzLgj+BCfNPDGu9pWbA=; b=bLL3yb+vEPaotJ9tyQ5z4piWPlXb1L3WYFtLraifsB0Car3DdAwdaACz hdixpHfr4fILRIbn59NqIuUYKXakpXoxK2/vWUKKc+N0w2UW99i5pNSo8 XUjplRnaOkIyeap5k6Q2+mlGnZQAFdjZzB4wJiI1DGhtbMi8RgcD1Cy+L PI/eMfs07mGs5PmuNtVXJZDQomCsX0WNcCJ0Zr1wNzk1mQVE4wW2CKr8T bEjP/6ZlQkP1YckNORLABZ5CDlBEwgarnBIAZzmyMldDuYJRM1zKIP86e aRA6biJGJ4kAqbgrZUG+i+GogPoV034mPeqAcVlV6A4+YOvenCuDI98iO g==; X-IronPort-AV: E=McAfee;i="6400,9594,10387"; a="279672740" X-IronPort-AV: E=Sophos;i="5.92,217,1650956400"; d="scan'208";a="279672740" Received: from fmsmga007.fm.intel.com ([10.253.24.52]) by fmsmga104.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 23 Jun 2022 19:53:41 -0700 X-IronPort-AV: E=Sophos;i="5.92,217,1650956400"; d="scan'208";a="593018097" Received: from yxia2-mobl1.ccr.corp.intel.com (HELO yhuang6-mobl1.ccr.corp.intel.com) ([10.254.214.143]) by fmsmga007-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 23 Jun 2022 19:53:39 -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 5/7] migrate_pages(): fix failure counting for THP on -ENOSYS Date: Fri, 24 Jun 2022 10:53:07 +0800 Message-Id: <20220624025309.1033400-6-ying.huang@intel.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220624025309.1033400-1-ying.huang@intel.com> References: <20220624025309.1033400-1-ying.huang@intel.com> MIME-Version: 1.0 ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1656039222; a=rsa-sha256; cv=none; b=M4Psdrx7PeaifIPr4rkSUmY1iDVh8/m6iYVm7bEyzF6FHGzO8bWJeZRShuI248aSLOtiGF fZUUTaP/iO25kGhbfBswaTwn6uK1ci5s2vYcV48do9NRsfjkERXk+7AXaPqYWdZJK3+KGM +F4KsV8+VVoOKdaHQXNaC0rpnLCnCAw= ARC-Authentication-Results: i=1; imf21.hostedemail.com; dkim=pass header.d=intel.com header.s=Intel header.b=bLL3yb+v; dmarc=pass (policy=none) header.from=intel.com; spf=none (imf21.hostedemail.com: domain of ying.huang@intel.com has no SPF policy when checking 192.55.52.120) smtp.mailfrom=ying.huang@intel.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1656039222; 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=8ZPXrIGcPs3eaaGXvVHrE0URvqPwlHQYUCLf0kkewac=; b=f0xbW2tRcnbm6uCgP/zwpk+RLCmBldyxsbtZJne0NM+nfHujmJ6W55deHKt7w80t5xK48J DUJ3aB0/XQkCk8UDk4WoI1etmCFBifY768ps8A5QPRcSI7SwppcJPsnbMBD2tVUsoH36pJ WAGfhablosOj9Yj8pZEP33gz0sZeBo0= X-Stat-Signature: ooyfhqpprq78cg1b3xg8xjaf3f5i69fk X-Rspamd-Queue-Id: 2938F1C0009 Authentication-Results: imf21.hostedemail.com; dkim=pass header.d=intel.com header.s=Intel header.b=bLL3yb+v; dmarc=pass (policy=none) header.from=intel.com; spf=none (imf21.hostedemail.com: domain of ying.huang@intel.com has no SPF policy when checking 192.55.52.120) smtp.mailfrom=ying.huang@intel.com X-Rspamd-Server: rspam10 X-Rspam-User: X-HE-Tag: 1656039221-347098 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") Cc: Baolin Wang Cc: Zi Yan Cc: Yang Shi Reviewed-by: Baolin Wang --- mm/migrate.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/mm/migrate.c b/mm/migrate.c index 61dab3025a1d..9d1883d5927f 100644 --- a/mm/migrate.c +++ b/mm/migrate.c @@ -1191,10 +1191,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. */ @@ -1391,6 +1389,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 */ @@ -1420,6 +1419,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 Jun 27 02:24:50 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Huang, Ying" X-Patchwork-Id: 12895973 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 2D84CC433EF for ; Mon, 27 Jun 2022 02:25:11 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 8E5636B0071; Sun, 26 Jun 2022 22:25:10 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 895EB6B0072; Sun, 26 Jun 2022 22:25:10 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 75CE28E0001; Sun, 26 Jun 2022 22:25:10 -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 6733D6B0071 for ; Sun, 26 Jun 2022 22:25:10 -0400 (EDT) Received: from smtpin01.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id 3926D32732 for ; Mon, 27 Jun 2022 02:25:10 +0000 (UTC) X-FDA: 79622423580.01.F086D18 Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) by imf20.hostedemail.com (Postfix) with ESMTP id CFC641C001F for ; Mon, 27 Jun 2022 02:25: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=1656296708; x=1687832708; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=xrLa/qvK6z+0n+mfC12qZ9ZlrFmavRnbmmLZYXho3nE=; b=FwOMBQpis0DS6E9AzunYz1hFQKMvOYJ1o3OC2hWU4JRiBWgJxyiIm/o1 1BmH4JEGvOX5UrZPYR8DIs0uju+4wd8pmA3f172kuoO4qi2ad3kM/sHsu 43Mg1FpWjSlE61kPjDyDC2Nam/LCBE4P56P9dQWYKOau1br5dMds7KYLP LFjWjIpj62/pFmEYQdZ1SfQVRyGsdJ/JtBVFrfP7wR5m2wVBt45eBWyVR KSLLkTa/+8Q2C0ILvKA9rjVkczQbgdW8aQjZFeKOkgJiB+r5mBmFx0Tv4 kXMWiya5AUpeTHurca2fa1ik9nKby8jVr36WBz1y+64ymg+zmMLmdJt7R A==; X-IronPort-AV: E=McAfee;i="6400,9594,10390"; a="306809154" X-IronPort-AV: E=Sophos;i="5.92,225,1650956400"; d="scan'208";a="306809154" Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by fmsmga101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 26 Jun 2022 19:25:07 -0700 X-IronPort-AV: E=Sophos;i="5.92,225,1650956400"; d="scan'208";a="835992361" Received: from yhuang6-mobl1.sh.intel.com ([10.67.65.240]) by fmsmga006-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 26 Jun 2022 19:25:04 -0700 From: Huang Ying To: akpm@linux-foundation.org Cc: baolin.wang@linux.alibaba.com, linux-kernel@vger.kernel.org, linux-mm@kvack.org, shy828301@gmail.com, ziy@nvidia.com, Huang Ying Subject: [PATCH 6/7] migrate_pages(): fix failure counting for THP splitting Date: Mon, 27 Jun 2022 10:24:50 +0800 Message-Id: <20220627022450.1067783-1-ying.huang@intel.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220624025309.1033400-1-ying.huang@intel.com> References: <20220624025309.1033400-1-ying.huang@intel.com> MIME-Version: 1.0 ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1656296709; a=rsa-sha256; cv=none; b=QLeS3bGT7nSz2BOyNChlRn/G31kY9Kj4axGCZRJURUqKakoYA0NJk3pUiPaPPGP7sZR29f L1EU81j0v+7I37NKLB7vnCoa71D6Uak9JjLq/kT5sOcgdOmquDITqhd1ch+8gdDRv3qAig y4ob9IAqDArGettsFrcr5Klg9Vr0oqs= ARC-Authentication-Results: i=1; imf20.hostedemail.com; dkim=pass header.d=intel.com header.s=Intel header.b=FwOMBQpi; dmarc=pass (policy=none) header.from=intel.com; spf=none (imf20.hostedemail.com: domain of ying.huang@intel.com has no SPF policy when checking 192.55.52.88) smtp.mailfrom=ying.huang@intel.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1656296709; 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=DAeFb13F5hzT8v1G0xlkz0ujhyPTSjF9it+rZMfPTdY=; b=46ilCa+Rw4lMTWUYBwoaZbL2FnLcrQ0JMZ4a/aaH323ooP7fh1xIa21qtiHU5igRX+A92G XFMc5jj1EF/qH6ltp2m8VJbLA93ajE5qyVTPtNNiyOA7qEzGDGaV1/YrecD2tiEvmmt/MA T7fzdeucLbZOkqQK3+BhNMV6JbA8ixE= X-Rspam-User: X-Stat-Signature: k3hpsfpz9yo387tjmcoynyohyca1gx8m X-Rspamd-Queue-Id: CFC641C001F Authentication-Results: imf20.hostedemail.com; dkim=pass header.d=intel.com header.s=Intel header.b=FwOMBQpi; dmarc=pass (policy=none) header.from=intel.com; spf=none (imf20.hostedemail.com: domain of ying.huang@intel.com has no SPF policy when checking 192.55.52.88) smtp.mailfrom=ying.huang@intel.com X-Rspamd-Server: rspam03 X-HE-Tag: 1656296708-293085 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") Cc: Baolin Wang Cc: Zi Yan Cc: Yang Shi Reviewed-by: Baolin Wang --- mm/migrate.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/mm/migrate.c b/mm/migrate.c index 9d1883d5927f..70a0e1f34c03 100644 --- a/mm/migrate.c +++ b/mm/migrate.c @@ -1305,6 +1305,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; } @@ -1364,7 +1366,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 @@ -1411,7 +1412,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) { @@ -1431,7 +1432,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 Jun 27 02:25:15 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Huang, Ying" X-Patchwork-Id: 12895974 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 DB142C43334 for ; Mon, 27 Jun 2022 02:25:25 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 515336B0071; Sun, 26 Jun 2022 22:25:25 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 4C5126B0072; Sun, 26 Jun 2022 22:25:25 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 38DBB8E0001; Sun, 26 Jun 2022 22:25:25 -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 29FD56B0071 for ; Sun, 26 Jun 2022 22:25:25 -0400 (EDT) Received: from smtpin10.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay13.hostedemail.com (Postfix) with ESMTP id 04E5760472 for ; Mon, 27 Jun 2022 02:25:24 +0000 (UTC) X-FDA: 79622424210.10.2A115AC Received: from mga06.intel.com (mga06b.intel.com [134.134.136.31]) by imf04.hostedemail.com (Postfix) with ESMTP id 5877540021 for ; Mon, 27 Jun 2022 02:25: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=1656296724; x=1687832724; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=Talc3qs8+aIEJrvLvRNy14H65O5Ln3+oQKwcRjbNGPk=; b=N4yyM2DrGHByNfWJmGKTHPLxYDI+w5+DqGekn1jVuTAmxRVRdj5BT9rX VzV69P4j0A9GLCHSH/FMn6MQ4FDhjMM9JZ9MoEqJOqOvYTsD76orfUwec eS4ql4AAM+zbSQPlmDY2oUAEiIyktpUaF2RjZ6DUmKYJQg5rP3Bt9WpKj L29WEGMLPAvf3hVsqKMCuH2BGvZ3o40TBTik2dmSYzyfK7x6mVLm71pMp V+g0JmjZrLDyxo0hELcpVl4+qlSlfkIdFjC1ix7pqDuNrQ6TO8bWtbQVm dJp3IUZHDHCrSIx5M8pcB795y/9VLjEeuBT5T1DQwOpo0LyJ0LmN3YtQ1 A==; X-IronPort-AV: E=McAfee;i="6400,9594,10390"; a="343022793" X-IronPort-AV: E=Sophos;i="5.92,225,1650956400"; d="scan'208";a="343022793" Received: from fmsmga005.fm.intel.com ([10.253.24.32]) by orsmga104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 26 Jun 2022 19:25:22 -0700 X-IronPort-AV: E=Sophos;i="5.92,225,1650956400"; d="scan'208";a="916513102" Received: from yhuang6-mobl1.sh.intel.com ([10.67.65.240]) by fmsmga005-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 26 Jun 2022 19:25:20 -0700 From: Huang Ying To: akpm@linux-foundation.org Cc: baolin.wang@linux.alibaba.com, linux-kernel@vger.kernel.org, linux-mm@kvack.org, shy828301@gmail.com, ziy@nvidia.com, Huang Ying Subject: [PATCH 7/7] migrate_pages(): fix failure counting for retry Date: Mon, 27 Jun 2022 10:25:15 +0800 Message-Id: <20220627022515.1067946-1-ying.huang@intel.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220624025309.1033400-1-ying.huang@intel.com> References: <20220624025309.1033400-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=1656296724; 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=Rqp54ieyemFjUI9psMcIkUe1NwqeI0+qW8kLkgrSV4U=; b=TVgW3fJoZtwYYGQSDWmx1kka+mbxwSsljPmoWmzbHgaPJGngeC6c8XeOE/pGDh/JvurQ1a PsTLYya3fD1S+slHdNnnb4m9cTleiyOejYye6a32/SoVQDxp+2CJixeKQERqK7kRXCWudZ NkLPnuFyDz5Hidnf/2dQ0GWVQbbHxKg= ARC-Authentication-Results: i=1; imf04.hostedemail.com; dkim=pass header.d=intel.com header.s=Intel header.b=N4yyM2Dr; spf=none (imf04.hostedemail.com: domain of ying.huang@intel.com has no SPF policy when checking 134.134.136.31) 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=1656296724; a=rsa-sha256; cv=none; b=Lu76voXGP0fxnbJDkNYGTYYFrC6JmE4qypQavMpVoJgMOEfYvNcpn3cvkmrMYHdYwcEgtk Uj8RKXbl9uD6uOhNxLeHUyfAIEstWOSqlZG5vVxiqDFxV3nlMJTiK0nCP5WFK8qr0pqAsA 0ZJC7rTWqc2YD0MGZ4WuL96EBhq1Nok= Authentication-Results: imf04.hostedemail.com; dkim=pass header.d=intel.com header.s=Intel header.b=N4yyM2Dr; spf=none (imf04.hostedemail.com: domain of ying.huang@intel.com has no SPF policy when checking 134.134.136.31) smtp.mailfrom=ying.huang@intel.com; dmarc=pass (policy=none) header.from=intel.com X-Rspam-User: X-Rspamd-Server: rspam06 X-Stat-Signature: a5nzztskj8xtmqtph3b77s6xohuzcqj5 X-Rspamd-Queue-Id: 5877540021 X-HE-Tag: 1656296724-641382 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") Cc: Baolin Wang Cc: Zi Yan Cc: Yang Shi Reviewed-by: Baolin Wang --- mm/migrate.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/mm/migrate.c b/mm/migrate.c index 70a0e1f34c03..e42bd409d3aa 100644 --- a/mm/migrate.c +++ b/mm/migrate.c @@ -1344,6 +1344,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; @@ -1364,6 +1365,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) { /* @@ -1449,12 +1451,14 @@ int migrate_pages(struct list_head *from, new_page_t get_new_page, nr_thp_failed += thp_retry; if (!no_subpage_counting) nr_failed += retry; + nr_failed_pages += nr_retry_pages; goto out; case -EAGAIN: if (is_thp) thp_retry++; else retry++; + nr_retry_pages += nr_subpages; break; case MIGRATEPAGE_SUCCESS: nr_succeeded += nr_subpages; @@ -1481,6 +1485,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