From patchwork Sat Aug 19 10:52:34 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Baolin Wang X-Patchwork-Id: 13358591 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 4DB6AEE49AC for ; Sat, 19 Aug 2023 10:52:58 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id A834D90000C; Sat, 19 Aug 2023 06:52:53 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id A3332900004; Sat, 19 Aug 2023 06:52:53 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 9216B90000C; Sat, 19 Aug 2023 06:52:53 -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 83EA8900004 for ; Sat, 19 Aug 2023 06:52:53 -0400 (EDT) Received: from smtpin29.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id 51171120843 for ; Sat, 19 Aug 2023 10:52:53 +0000 (UTC) X-FDA: 81140541426.29.D08AABC Received: from out30-130.freemail.mail.aliyun.com (out30-130.freemail.mail.aliyun.com [115.124.30.130]) by imf27.hostedemail.com (Postfix) with ESMTP id 5848540009 for ; Sat, 19 Aug 2023 10:52:49 +0000 (UTC) Authentication-Results: imf27.hostedemail.com; dkim=none; dmarc=pass (policy=none) header.from=alibaba.com; spf=pass (imf27.hostedemail.com: domain of baolin.wang@linux.alibaba.com designates 115.124.30.130 as permitted sender) smtp.mailfrom=baolin.wang@linux.alibaba.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1692442370; 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; bh=7UucgbnKEMrd4OyT3sJC+JcNECE5MZSvFXPNqHzVTco=; b=0lbT6i6WrDeKENRAshJqsSfhH8q9NkKuzXlOy3pUHMWn5Q4eyQ27ceUJhvLMdDYxUGxPH/ uRR/YPm8WwZ6jxx4njU++8rB3Kg0M0qzesu/1g6Vgvqkzaf354JKjCm8wckecm6NneQADi O9rrcSrM0RMiptLGPlowf3040twWbDA= ARC-Authentication-Results: i=1; imf27.hostedemail.com; dkim=none; dmarc=pass (policy=none) header.from=alibaba.com; spf=pass (imf27.hostedemail.com: domain of baolin.wang@linux.alibaba.com designates 115.124.30.130 as permitted sender) smtp.mailfrom=baolin.wang@linux.alibaba.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1692442370; a=rsa-sha256; cv=none; b=veN3OEqkqNG8+6OwPN6S+KG6M7oicEwFDU22Jk264/23M6eqe/rmEwYDT7/QHmxlboRB2A YdlyFOiBKc3OXa7KAzybrJS3B5tAw5dhflOpo2oA77XA3tQxebRUYtztHQLK2YHK3mc5wK HbM4uBWRfho9oQj/itFLmflhN54tPho= X-Alimail-AntiSpam: AC=PASS;BC=-1|-1;BR=01201311R131e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=ay29a033018046050;MF=baolin.wang@linux.alibaba.com;NM=1;PH=DS;RN=8;SR=0;TI=SMTPD_---0Vq58.Rv_1692442362; Received: from localhost(mailfrom:baolin.wang@linux.alibaba.com fp:SMTPD_---0Vq58.Rv_1692442362) by smtp.aliyun-inc.com; Sat, 19 Aug 2023 18:52:43 +0800 From: Baolin Wang To: akpm@linux-foundation.org Cc: mgorman@techsingularity.net, shy828301@gmail.com, david@redhat.com, ying.huang@intel.com, baolin.wang@linux.alibaba.com, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: [PATCH 1/4] mm: migrate: move migration validation into numa_migrate_prep() Date: Sat, 19 Aug 2023 18:52:34 +0800 Message-Id: X-Mailer: git-send-email 2.39.3 In-Reply-To: References: MIME-Version: 1.0 X-Rspamd-Queue-Id: 5848540009 X-Rspam-User: X-Rspamd-Server: rspam05 X-Stat-Signature: spopyhoezqwn36ys7fs868gg6yo7k9hu X-HE-Tag: 1692442369-183195 X-HE-Meta: U2FsdGVkX1//dlfww7fl0yFOVcHpZUElTUOssefseBznvtCnhUyBy8fZvftneyfmGFywqZouXqN/wZtg1imIdRgNdde/t/UPm2m1aHAhou7mqc1qlFS4nUyq4yum04SanTt+/Zedqj40a7Q14eEWtdwnNIe0xUnoMA26J3+EVQj8zb7TgiJVXFTVWQ02eLZ/3/9aOLF2zRVuBZjTjbXKlp84H8E1xxX/sATyUUo3xiM0YEEdL4CrHSPFwTK+XvpoTyq4KMrY7SgwT/fe9FwqhrekLSqfaMKN53sCBal64XXtjmmxVROEjAwgshhRrDe5j3e4oivYfA4KCL9kl9y7z+GvSXLdWeoMyr2YmEqg9HzjFk5m08PfFfRIFDich+pIKcTeG0waNLLrPeqYc9MEzjAIpRvFRYSaPAW9OnwVXwe5r4fRwYJq1z8DY1kth5TYoKgRgA7jpfe31o9Qb3FUd8CDCKEgT348fILn+roFokOllFlrK0NYcFedebdq7LaLepLuIQHweItLRsFnjBByr7VCgyxh69lK1ehN8DeZkxw7bNTlDj/NQpncY7FuRc6kSquz8Qyx82THONo2b97LYSJa5gNUQ9XCmH31Daxi+nSccaVrxgQjFYGo4mBQ0b0ApxUVRkf67bjNpwfjZgEsfERTAss6djjBfttJ9JiOO61M++K29V4ORfalPBryAqfYS/CE35htJVI2K6eDRwRCcYYD6RaUR9qDqjgKuihX+SnyHcpKMJLEMFMX03b6M6nXFATSfmBthWpLffwXli5sYwsT2qTyX2boOTgCkh7zS0mD0zQR6xsgJ5szlOk/G5h138OjLrjqz+3pe6MWOVCJrQgFA3mVDdtrYoT/4YM6Y9hk1Ub/n6QgDmlncf+0fMAXFyjS9mEdmMqrP1y5g1JwYYku8mQwfzXcW9DmewUIYkF2t6BTOvxXELNaJ4IFalgAx2t3GWw8H17nUC8sy3v 9oUQl9cN cVUiXjOWazv9BffHxuXRxvuXqbeBg3PoRWZ2a4QXnuAAEGOYva50ecNgIP5N7B2/XGPG/GjTDgA7IVhlzGjdD1QXbWMkE3MnCGZQ/2GvSuoNtxBVN4U+RGqaurLd7l7oXRgy288rS/GWa784= 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: Now there are 3 places will validate if a page can mirate or not, and some validations are performed later, which will waste some CPU to call numa_migrate_prep(). Thus we can move all the migration validation into numa_migrate_prep(), which is more maintainable as well as saving some CPU resources. Another benefit is that it can serve as a preparation for supporting batch migration in do_numa_page() in future. Signed-off-by: Baolin Wang --- mm/memory.c | 19 +++++++++++++++++++ mm/migrate.c | 19 ------------------- 2 files changed, 19 insertions(+), 19 deletions(-) diff --git a/mm/memory.c b/mm/memory.c index d003076b218d..bee9b1e86ef0 100644 --- a/mm/memory.c +++ b/mm/memory.c @@ -4747,6 +4747,25 @@ int numa_migrate_prep(struct page *page, struct vm_area_struct *vma, *flags |= TNF_FAULT_LOCAL; } + /* + * Don't migrate file pages that are mapped in multiple processes + * with execute permissions as they are probably shared libraries. + */ + if (page_mapcount(page) != 1 && page_is_file_lru(page) && + (vma->vm_flags & VM_EXEC)) + return NUMA_NO_NODE; + + /* + * Also do not migrate dirty pages as not all filesystems can move + * dirty pages in MIGRATE_ASYNC mode which is a waste of cycles. + */ + if (page_is_file_lru(page) && PageDirty(page)) + return NUMA_NO_NODE; + + /* Do not migrate THP mapped by multiple processes */ + if (PageTransHuge(page) && total_mapcount(page) > 1) + return NUMA_NO_NODE; + return mpol_misplaced(page, vma, addr); } diff --git a/mm/migrate.c b/mm/migrate.c index e21d5a7e7447..9cc98fb1d6ec 100644 --- a/mm/migrate.c +++ b/mm/migrate.c @@ -2485,10 +2485,6 @@ static int numamigrate_isolate_page(pg_data_t *pgdat, struct page *page) VM_BUG_ON_PAGE(order && !PageTransHuge(page), page); - /* Do not migrate THP mapped by multiple processes */ - if (PageTransHuge(page) && total_mapcount(page) > 1) - return 0; - /* Avoid migrating to a node that is nearly full */ if (!migrate_balanced_pgdat(pgdat, nr_pages)) { int z; @@ -2533,21 +2529,6 @@ int migrate_misplaced_page(struct page *page, struct vm_area_struct *vma, LIST_HEAD(migratepages); int nr_pages = thp_nr_pages(page); - /* - * Don't migrate file pages that are mapped in multiple processes - * with execute permissions as they are probably shared libraries. - */ - if (page_mapcount(page) != 1 && page_is_file_lru(page) && - (vma->vm_flags & VM_EXEC)) - goto out; - - /* - * Also do not migrate dirty pages as not all filesystems can move - * dirty pages in MIGRATE_ASYNC mode which is a waste of cycles. - */ - if (page_is_file_lru(page) && PageDirty(page)) - goto out; - isolated = numamigrate_isolate_page(pgdat, page); if (!isolated) goto out; From patchwork Sat Aug 19 10:52:35 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Baolin Wang X-Patchwork-Id: 13358590 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 0BE94EE49A8 for ; Sat, 19 Aug 2023 10:52:56 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 4B6F790000A; Sat, 19 Aug 2023 06:52:53 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 4403D900004; Sat, 19 Aug 2023 06:52:53 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 26BD790000A; Sat, 19 Aug 2023 06:52:53 -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 032EB900004 for ; Sat, 19 Aug 2023 06:52:53 -0400 (EDT) Received: from smtpin02.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id E472D120843 for ; Sat, 19 Aug 2023 10:52:51 +0000 (UTC) X-FDA: 81140541342.02.EE677F4 Received: from out30-111.freemail.mail.aliyun.com (out30-111.freemail.mail.aliyun.com [115.124.30.111]) by imf22.hostedemail.com (Postfix) with ESMTP id A8D7EC0006 for ; Sat, 19 Aug 2023 10:52:47 +0000 (UTC) Authentication-Results: imf22.hostedemail.com; dkim=none; spf=pass (imf22.hostedemail.com: domain of baolin.wang@linux.alibaba.com designates 115.124.30.111 as permitted sender) smtp.mailfrom=baolin.wang@linux.alibaba.com; dmarc=pass (policy=none) header.from=alibaba.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1692442370; 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; bh=Gno/qmUTlW9t9/wqxr/fxCmzyH/MTCfjhdDmjzbuz2c=; b=ozpzHTr3oBU8EYFDzbshjBAOaAxqMNVY1jeCRT/fmmdRuf96DlfXWg0Jrd28lGO1AkMmCS 22h5zMOq7pzxBGs49QEz9FU4z29oIQV8WVc5X/b4UnaaDFxgao8JyfyS7kptUy6SCEoVbc IXwQAUDAI74nLEmLAQSoyZcSoX78VKg= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1692442370; a=rsa-sha256; cv=none; b=Tyhh0FtMEDXteOqjbIKzaOfJPQGqnmH3Y/aQrcfjwa1Zzq5NuDyYJ9geVcNWxYBqrTDEvf 8klkhfi5J/t+CrdpwDiA6my9J3jQ8gGTGJOxMjtu4MDRx1b6A2moSf057USV/RzJ2FAl7C uQFpPztkiWMVxE6E+FudKQm1kmDLEwg= ARC-Authentication-Results: i=1; imf22.hostedemail.com; dkim=none; spf=pass (imf22.hostedemail.com: domain of baolin.wang@linux.alibaba.com designates 115.124.30.111 as permitted sender) smtp.mailfrom=baolin.wang@linux.alibaba.com; dmarc=pass (policy=none) header.from=alibaba.com X-Alimail-AntiSpam: AC=PASS;BC=-1|-1;BR=01201311R831e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=ay29a033018045168;MF=baolin.wang@linux.alibaba.com;NM=1;PH=DS;RN=8;SR=0;TI=SMTPD_---0Vq58.SR_1692442363; Received: from localhost(mailfrom:baolin.wang@linux.alibaba.com fp:SMTPD_---0Vq58.SR_1692442363) by smtp.aliyun-inc.com; Sat, 19 Aug 2023 18:52:44 +0800 From: Baolin Wang To: akpm@linux-foundation.org Cc: mgorman@techsingularity.net, shy828301@gmail.com, david@redhat.com, ying.huang@intel.com, baolin.wang@linux.alibaba.com, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: [PATCH 2/4] mm: migrate: move the numamigrate_isolate_page() into do_numa_page() Date: Sat, 19 Aug 2023 18:52:35 +0800 Message-Id: X-Mailer: git-send-email 2.39.3 In-Reply-To: References: MIME-Version: 1.0 X-Rspamd-Queue-Id: A8D7EC0006 X-Rspam-User: X-Stat-Signature: 83or8ni966us5bmrihac5k467hjf8ato X-Rspamd-Server: rspam03 X-HE-Tag: 1692442367-434453 X-HE-Meta: U2FsdGVkX1+o0jESX5hmq47Q3sBJNKNGl26Gadk1iX2FoE45VId8Vm+TPXEBsTnduSTZaYQOkR4jLBEhhUwM3nKSmxkSkvA6UQvJPBaUgMtrJ7cMM+2FIQTHIO2SPMjp/m941CZ4E7EaUmxVupFpIPbDZ0AYfE32ngWsO+7uaOY6RkCCjHakzHjQOmYzsLdNpZ/PvN+GE0MS8/IqbMmQdpRzpEc8+l+ScK6qh1CIfAfwUU43HHXrffRDTyF3b06ZrtX1OMspOgZpY+7gGpACPz3ODvJM+Zuvrx7PneMWOj/y/R4LFHBSOj92JHgF7AUpkXF11spx+5mBieKjJrV38yu0o134C01KR3/GiAW/pWgpQsuBGmSnN/Lhq0uUGIgkmKxaTKc/EiFD0V+Od1DvlgJ1upS520RxrdDXz6B6E6FuaGyFNRFKKUoU4Og2zKewerOJZuNqB4DTwP41bN7odVYwsYkGK+10cEgSILko9c/Bsei15ytj5LJMYPNCFzi1vk6S3UueRA05RJMDNyq0vk/tnJn0jXXAEvfxvRoAP5GmG9AtO7+1pfkqoQqTLfxe18Mg1gdLpG4oQgTzowMm9jgrQmqn+vJi9MCw/+ZJK8U0DS5/tPwFYU6vQTJtCTQTa04EsGyF5xoHjSI65+V7VwoNqJpZGBxzvhZwdUOt43thXWKXzeqxHY9l79nFSv3ViTpOe71m/1ZwirVTA3icPb58qc5FbHydduSk54yCvnJWdyvt0jmQwBDWCJIki7tNVSOyWwigjaBCB3bfQ0yrGGV+4lhWHI8ego6UR3XGfYsF/dCZWK1BB8CnTrKCGkpSCBtIsEkp4MBGRXeg/qEOQvGuThgROEfUrlODSQOHZ9Dc4NtfWQuhkdRl/hjGvybfazcTk+Uu0Rclcj79Y+nyYLzVySZZ8DqskHF09sWrUPUE6XGZb6G4L8bufc6WV1J5Wcxk87BKi62hriiY1oz 2YFNx/RV kYr6TvsKRPAv6NdaBrV08pLg8SyiOTcrVPC/gKHEhtv1BD9lVNiYE85G23vlC9G/GL4mkmRcy4p9vAUFigtB/hRZKr8jF+2rHppk+g8oAEOefTnrbmG4MxLc+LfmZgE/fHSjZUL9FgEcgA34= 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: Move the numamigrate_isolate_page() into do_numa_page() to simplify the migrate_misplaced_page(), which now only focuses on page migration, and it also serves as a preparation for supporting batch migration for NUMA balancing. Signed-off-by: Baolin Wang --- include/linux/migrate.h | 6 ++++++ mm/huge_memory.c | 10 ++++++++++ mm/memory.c | 10 ++++++++++ mm/migrate.c | 16 ++++------------ 4 files changed, 30 insertions(+), 12 deletions(-) diff --git a/include/linux/migrate.h b/include/linux/migrate.h index 711dd9412561..7c5189043707 100644 --- a/include/linux/migrate.h +++ b/include/linux/migrate.h @@ -144,12 +144,18 @@ const struct movable_operations *page_movable_ops(struct page *page) #ifdef CONFIG_NUMA_BALANCING int migrate_misplaced_page(struct page *page, struct vm_area_struct *vma, int node); +int numamigrate_isolate_page(pg_data_t *pgdat, struct page *page); #else static inline int migrate_misplaced_page(struct page *page, struct vm_area_struct *vma, int node) { return -EAGAIN; /* can't migrate now */ } + +static inline int numamigrate_isolate_page(pg_data_t *pgdat, struct page *page) +{ + return -EAGAIN; +} #endif /* CONFIG_NUMA_BALANCING */ #ifdef CONFIG_MIGRATION diff --git a/mm/huge_memory.c b/mm/huge_memory.c index cb4432792b88..b7cc6828ce9e 100644 --- a/mm/huge_memory.c +++ b/mm/huge_memory.c @@ -1496,6 +1496,8 @@ vm_fault_t do_huge_pmd_numa_page(struct vm_fault *vmf) int target_nid, last_cpupid = (-1 & LAST_CPUPID_MASK); bool migrated = false, writable = false; int flags = 0; + pg_data_t *pgdat; + int isolated; vmf->ptl = pmd_lock(vma->vm_mm, vmf->pmd); if (unlikely(!pmd_same(oldpmd, *vmf->pmd))) { @@ -1540,11 +1542,19 @@ vm_fault_t do_huge_pmd_numa_page(struct vm_fault *vmf) spin_unlock(vmf->ptl); writable = false; + pgdat = NODE_DATA(target_nid); + isolated = numamigrate_isolate_page(pgdat, page); + if (!isolated) { + put_page(page); + goto isolate_fail; + } + migrated = migrate_misplaced_page(page, vma, target_nid); if (migrated) { flags |= TNF_MIGRATED; page_nid = target_nid; } else { +isolate_fail: flags |= TNF_MIGRATE_FAIL; vmf->ptl = pmd_lock(vma->vm_mm, vmf->pmd); if (unlikely(!pmd_same(oldpmd, *vmf->pmd))) { diff --git a/mm/memory.c b/mm/memory.c index bee9b1e86ef0..01b1980d4fb7 100644 --- a/mm/memory.c +++ b/mm/memory.c @@ -4779,6 +4779,8 @@ static vm_fault_t do_numa_page(struct vm_fault *vmf) int target_nid; pte_t pte, old_pte; int flags = 0; + pg_data_t *pgdat; + int isolated; /* * The "pte" at this point cannot be used safely without @@ -4849,11 +4851,19 @@ static vm_fault_t do_numa_page(struct vm_fault *vmf) pte_unmap_unlock(vmf->pte, vmf->ptl); writable = false; + pgdat = NODE_DATA(target_nid); + isolated = numamigrate_isolate_page(pgdat, page); + if (!isolated) { + put_page(page); + goto isolate_fail; + } + /* Migrate to the requested node */ if (migrate_misplaced_page(page, vma, target_nid)) { page_nid = target_nid; flags |= TNF_MIGRATED; } else { +isolate_fail: flags |= TNF_MIGRATE_FAIL; vmf->pte = pte_offset_map_lock(vma->vm_mm, vmf->pmd, vmf->address, &vmf->ptl); diff --git a/mm/migrate.c b/mm/migrate.c index 9cc98fb1d6ec..5eeeb2cda21c 100644 --- a/mm/migrate.c +++ b/mm/migrate.c @@ -2478,7 +2478,7 @@ static struct folio *alloc_misplaced_dst_folio(struct folio *src, return __folio_alloc_node(gfp, order, nid); } -static int numamigrate_isolate_page(pg_data_t *pgdat, struct page *page) +int numamigrate_isolate_page(pg_data_t *pgdat, struct page *page) { int nr_pages = thp_nr_pages(page); int order = compound_order(page); @@ -2523,16 +2523,12 @@ int migrate_misplaced_page(struct page *page, struct vm_area_struct *vma, int node) { pg_data_t *pgdat = NODE_DATA(node); - int isolated; + int migrated = 1; int nr_remaining; unsigned int nr_succeeded; LIST_HEAD(migratepages); int nr_pages = thp_nr_pages(page); - isolated = numamigrate_isolate_page(pgdat, page); - if (!isolated) - goto out; - list_add(&page->lru, &migratepages); nr_remaining = migrate_pages(&migratepages, alloc_misplaced_dst_folio, NULL, node, MIGRATE_ASYNC, @@ -2544,7 +2540,7 @@ int migrate_misplaced_page(struct page *page, struct vm_area_struct *vma, page_is_file_lru(page), -nr_pages); putback_lru_page(page); } - isolated = 0; + migrated = 0; } if (nr_succeeded) { count_vm_numa_events(NUMA_PAGE_MIGRATE, nr_succeeded); @@ -2553,11 +2549,7 @@ int migrate_misplaced_page(struct page *page, struct vm_area_struct *vma, nr_succeeded); } BUG_ON(!list_empty(&migratepages)); - return isolated; - -out: - put_page(page); - return 0; + return migrated; } #endif /* CONFIG_NUMA_BALANCING */ #endif /* CONFIG_NUMA */ From patchwork Sat Aug 19 10:52:36 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Baolin Wang X-Patchwork-Id: 13358589 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 64E6DEE49AC for ; Sat, 19 Aug 2023 10:52:54 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id C0981900007; Sat, 19 Aug 2023 06:52:52 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id BB977900004; Sat, 19 Aug 2023 06:52:52 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id AA88C900007; Sat, 19 Aug 2023 06:52:52 -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 9E612900004 for ; Sat, 19 Aug 2023 06:52:52 -0400 (EDT) Received: from smtpin29.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id 5BD9F1A06FB for ; Sat, 19 Aug 2023 10:52:52 +0000 (UTC) X-FDA: 81140541384.29.1E6D803 Received: from out30-130.freemail.mail.aliyun.com (out30-130.freemail.mail.aliyun.com [115.124.30.130]) by imf07.hostedemail.com (Postfix) with ESMTP id 485794000F for ; Sat, 19 Aug 2023 10:52:49 +0000 (UTC) Authentication-Results: imf07.hostedemail.com; dkim=none; spf=pass (imf07.hostedemail.com: domain of baolin.wang@linux.alibaba.com designates 115.124.30.130 as permitted sender) smtp.mailfrom=baolin.wang@linux.alibaba.com; dmarc=pass (policy=none) header.from=alibaba.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1692442370; 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; bh=0rt+ALKo4EqL8ciztB1XVFtEoBaR8AO72C9HhYNyCKs=; b=CBjHR5Z8GQlcpfGUvKuNITVIbYwuqKzeGEInSZs54gD8OM+zUqkeP/YEhepdV40YYIDBuc Leupv21XD1MDXqygT0p6CKvf+4+seUzwasS5sJLdtyK5vClnYdTWvX52dqyaxp0U4LT305 47SD2Ek3zi/5P/xTYiJe1KxTJ40aV7Q= ARC-Authentication-Results: i=1; imf07.hostedemail.com; dkim=none; spf=pass (imf07.hostedemail.com: domain of baolin.wang@linux.alibaba.com designates 115.124.30.130 as permitted sender) smtp.mailfrom=baolin.wang@linux.alibaba.com; dmarc=pass (policy=none) header.from=alibaba.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1692442370; a=rsa-sha256; cv=none; b=sN3ykPJIZjW6/nMCAAl0VD4f1VRA05sS3klnUc4yXm2nVkU+UxhF76kYZNeAI44U5HOYC0 V4oZXsta9fdm7LSrSj+jSQi64KtrKH9Bf6U3gwduNkUT5Pfln46kH7HjwuUxzozheowuBW cpe8OYKUqNpHmIlqT5aKKuWpoorLoE0= X-Alimail-AntiSpam: AC=PASS;BC=-1|-1;BR=01201311R131e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=ay29a033018046050;MF=baolin.wang@linux.alibaba.com;NM=1;PH=DS;RN=8;SR=0;TI=SMTPD_---0Vq56wHJ_1692442364; Received: from localhost(mailfrom:baolin.wang@linux.alibaba.com fp:SMTPD_---0Vq56wHJ_1692442364) by smtp.aliyun-inc.com; Sat, 19 Aug 2023 18:52:45 +0800 From: Baolin Wang To: akpm@linux-foundation.org Cc: mgorman@techsingularity.net, shy828301@gmail.com, david@redhat.com, ying.huang@intel.com, baolin.wang@linux.alibaba.com, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: [PATCH 3/4] mm: migrate: change migrate_misplaced_page() to support multiple pages migration Date: Sat, 19 Aug 2023 18:52:36 +0800 Message-Id: <2aa06e6f1addbfeb8784b4c282f1d4e4eee3f560.1692440586.git.baolin.wang@linux.alibaba.com> X-Mailer: git-send-email 2.39.3 In-Reply-To: References: MIME-Version: 1.0 X-Rspamd-Queue-Id: 485794000F X-Rspam-User: X-Stat-Signature: h74r6135eq4wkdse4n9kjie3yzmm48q8 X-Rspamd-Server: rspam01 X-HE-Tag: 1692442369-992842 X-HE-Meta: U2FsdGVkX1/ugKO5W4y7VXyusLL53wEY1SQmqx03BcJt5QBTV4r17Q61xWEbr4f5F5mbhGAUv1G66nxjmWOc0HByV/fHx35txyuM627d6y6rIdCEPBiJjM3fdTzOejqUS+WHM+Jc//AnA5qa2iPeUlGpN4+JRiItlJpc3EfkWtoSK+4WEQHOibP+eqCL5gRIx1tO3DJMWp+xS2XVmM3cuBgbaAHb56H64htdvybFBDqzLU2UxwYzkVOfh0YDMHnTfiFKVPTeQ/gu3cbkNuA8ldXGi8fxSXgn+fGLNWbb8xk2/PgccOXBe0p2TTRGg5dQQWruT2y4dCdva6bodcndJC7+ugGOWzGHmDfrj1bFcQUK9cJ6BJ8V4br6ex8Ejo2fXaS3jYXUypleg/hgQLRxjLdBEWNpdOl0ZFD9vE3JFMdEsoTer1Kp8zgkt/STI4oQKIuiuYw0VVdJO7zEwO7+q0SgMVIVa+XI2uLjyH7mCfKH3v4az7wJnp6WFpMW3DCoW+Jd0ajvCzUxtOdy3zLk9w1oJpRUZOkm7HfXydAo66nOxR8yZqdjJj5+vwjZImwyW2H27WCYeOYoCPmET9WNNNxsX3F+wZaLRSZ91bbtwGEDPKvV59cArJPzyjKHk7R8beH64w431frf7h5fTxr6ktpOY2xMW27M726lraqle2Kk8U3bm5HeGPm4IK84CRkVghgfJ5mhmZptKAEP+APXQLwDjkUdh6yXyc+OBSwdjuBMXKMoQg3zMqeWGhX5byiHwg58zz9wrDQJQ1TNDPaVIww+mVnjVUe3WV0BzWjfjuZKp4IZ0hh1ZP3aTZOgeFa+c9hIbqDxs/oog/eNLP6fDVukcCPcswh1YPknngdc0f8GvZE9qAP5MWuBgvakt229sm1VlcFjf6VCFwl8ytSbt128CKCQ4piU9FfYVNbneqs9Zp3FF4u1fIalwFoSf9JJQNZlBTNcfXG+Tx9Pgtn VdPOGJoM j0sPrmuWyKpcGOMi/JI78IcIlSDhiXeFdOCbdNiXVdu1J3PhR+RsIUnv6OiYYE1N5OnTqisyeF9UrwsKaD2atV7ASpd1Gr2ya55DovhAv4zfK4QswaFqKQClgLaXxIDA/W8ENxUfQ+VqrSq0= 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: Expanding the migrate_misplaced_page() function to allow passing in a list to support multiple pages migration as a preparation to support batch migration for NUMA balancing. Signed-off-by: Baolin Wang --- include/linux/migrate.h | 9 +++++---- mm/huge_memory.c | 4 +++- mm/memory.c | 4 +++- mm/migrate.c | 26 ++++++++++---------------- 4 files changed, 21 insertions(+), 22 deletions(-) diff --git a/include/linux/migrate.h b/include/linux/migrate.h index 7c5189043707..2599f95d6c9e 100644 --- a/include/linux/migrate.h +++ b/include/linux/migrate.h @@ -142,12 +142,13 @@ const struct movable_operations *page_movable_ops(struct page *page) } #ifdef CONFIG_NUMA_BALANCING -int migrate_misplaced_page(struct page *page, struct vm_area_struct *vma, - int node); +int migrate_misplaced_page(struct list_head *migratepages, struct vm_area_struct *vma, + int source_nid, int target_nid); int numamigrate_isolate_page(pg_data_t *pgdat, struct page *page); #else -static inline int migrate_misplaced_page(struct page *page, - struct vm_area_struct *vma, int node) +static inline int migrate_misplaced_page(struct list_head *migratepages, + struct vm_area_struct *vma, + int source_nid, int target_nid) { return -EAGAIN; /* can't migrate now */ } diff --git a/mm/huge_memory.c b/mm/huge_memory.c index b7cc6828ce9e..53a9d63cfb1e 100644 --- a/mm/huge_memory.c +++ b/mm/huge_memory.c @@ -1498,6 +1498,7 @@ vm_fault_t do_huge_pmd_numa_page(struct vm_fault *vmf) int flags = 0; pg_data_t *pgdat; int isolated; + LIST_HEAD(migratepages); vmf->ptl = pmd_lock(vma->vm_mm, vmf->pmd); if (unlikely(!pmd_same(oldpmd, *vmf->pmd))) { @@ -1549,7 +1550,8 @@ vm_fault_t do_huge_pmd_numa_page(struct vm_fault *vmf) goto isolate_fail; } - migrated = migrate_misplaced_page(page, vma, target_nid); + list_add(&page->lru, &migratepages); + migrated = migrate_misplaced_page(&migratepages, vma, page_nid, target_nid); if (migrated) { flags |= TNF_MIGRATED; page_nid = target_nid; diff --git a/mm/memory.c b/mm/memory.c index 01b1980d4fb7..973403a83797 100644 --- a/mm/memory.c +++ b/mm/memory.c @@ -4781,6 +4781,7 @@ static vm_fault_t do_numa_page(struct vm_fault *vmf) int flags = 0; pg_data_t *pgdat; int isolated; + LIST_HEAD(migratepages); /* * The "pte" at this point cannot be used safely without @@ -4858,8 +4859,9 @@ static vm_fault_t do_numa_page(struct vm_fault *vmf) goto isolate_fail; } + list_add(&page->lru, &migratepages); /* Migrate to the requested node */ - if (migrate_misplaced_page(page, vma, target_nid)) { + if (migrate_misplaced_page(&migratepages, vma, page_nid, target_nid)) { page_nid = target_nid; flags |= TNF_MIGRATED; } else { diff --git a/mm/migrate.c b/mm/migrate.c index 5eeeb2cda21c..93d359471b95 100644 --- a/mm/migrate.c +++ b/mm/migrate.c @@ -2519,36 +2519,30 @@ int numamigrate_isolate_page(pg_data_t *pgdat, struct page *page) * node. Caller is expected to have an elevated reference count on * the page that will be dropped by this function before returning. */ -int migrate_misplaced_page(struct page *page, struct vm_area_struct *vma, - int node) +int migrate_misplaced_page(struct list_head *migratepages, struct vm_area_struct *vma, + int source_nid, int target_nid) { - pg_data_t *pgdat = NODE_DATA(node); + pg_data_t *pgdat = NODE_DATA(target_nid); int migrated = 1; int nr_remaining; unsigned int nr_succeeded; - LIST_HEAD(migratepages); - int nr_pages = thp_nr_pages(page); - list_add(&page->lru, &migratepages); - nr_remaining = migrate_pages(&migratepages, alloc_misplaced_dst_folio, - NULL, node, MIGRATE_ASYNC, + nr_remaining = migrate_pages(migratepages, alloc_misplaced_dst_folio, + NULL, target_nid, MIGRATE_ASYNC, MR_NUMA_MISPLACED, &nr_succeeded); if (nr_remaining) { - if (!list_empty(&migratepages)) { - list_del(&page->lru); - mod_node_page_state(page_pgdat(page), NR_ISOLATED_ANON + - page_is_file_lru(page), -nr_pages); - putback_lru_page(page); - } + if (!list_empty(migratepages)) + putback_movable_pages(migratepages); + migrated = 0; } if (nr_succeeded) { count_vm_numa_events(NUMA_PAGE_MIGRATE, nr_succeeded); - if (!node_is_toptier(page_to_nid(page)) && node_is_toptier(node)) + if (!node_is_toptier(source_nid) && node_is_toptier(target_nid)) mod_node_page_state(pgdat, PGPROMOTE_SUCCESS, nr_succeeded); } - BUG_ON(!list_empty(&migratepages)); + BUG_ON(!list_empty(migratepages)); return migrated; } #endif /* CONFIG_NUMA_BALANCING */ From patchwork Sat Aug 19 10:52:37 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Baolin Wang X-Patchwork-Id: 13358592 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 B0ACFEE49A8 for ; Sat, 19 Aug 2023 10:53:00 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id F3FCE90000E; Sat, 19 Aug 2023 06:52:53 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id EEEC4900004; Sat, 19 Aug 2023 06:52:53 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id DDC6B90000E; Sat, 19 Aug 2023 06:52:53 -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 D19DD900004 for ; Sat, 19 Aug 2023 06:52:53 -0400 (EDT) Received: from smtpin25.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id 932601C955D for ; Sat, 19 Aug 2023 10:52:52 +0000 (UTC) X-FDA: 81140541384.25.C153E9B Received: from out30-98.freemail.mail.aliyun.com (out30-98.freemail.mail.aliyun.com [115.124.30.98]) by imf27.hostedemail.com (Postfix) with ESMTP id 8810E4000C for ; Sat, 19 Aug 2023 10:52:50 +0000 (UTC) Authentication-Results: imf27.hostedemail.com; dkim=none; spf=pass (imf27.hostedemail.com: domain of baolin.wang@linux.alibaba.com designates 115.124.30.98 as permitted sender) smtp.mailfrom=baolin.wang@linux.alibaba.com; dmarc=pass (policy=none) header.from=alibaba.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1692442371; 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; bh=NVfxIFpzUqEqqP2hfbOTsF5yBYikaGXOv+U0WqJGCFI=; b=Ep99Ho2Na6shfNms9Aqhz1Z7JfdSNEbreQY8YgNAZzLrWPdFiVYQyjy3LOZ9JAhCJan2zt 6TB0WM72Mj3royPi3In2LJMCaa9j2WZ7FEkxAmF2IZCZCb0oIPDYeiZG2x4+Yo9dKpMbGu dseSZSzf0POqKjP4m2av9PF0b5jrs+c= ARC-Authentication-Results: i=1; imf27.hostedemail.com; dkim=none; spf=pass (imf27.hostedemail.com: domain of baolin.wang@linux.alibaba.com designates 115.124.30.98 as permitted sender) smtp.mailfrom=baolin.wang@linux.alibaba.com; dmarc=pass (policy=none) header.from=alibaba.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1692442371; a=rsa-sha256; cv=none; b=ZfzTkjVxEvngvJxVjVbx7yQzeZQ6a+sCg6pcw6C/J2la7j9oXOm6j0lVhbHsbEBaxriRFt J4+zeKFfyfShznn0Lo170w+7pr3CdVIXv6y58Q4JBGgI4zAbMcz+p9iZWOJpM45IQLF8ga rszqYCBtCrAn/sD00LvAFVWLjfLT+r8= X-Alimail-AntiSpam: AC=PASS;BC=-1|-1;BR=01201311R741e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=ay29a033018046059;MF=baolin.wang@linux.alibaba.com;NM=1;PH=DS;RN=8;SR=0;TI=SMTPD_---0Vq58.Sy_1692442365; Received: from localhost(mailfrom:baolin.wang@linux.alibaba.com fp:SMTPD_---0Vq58.Sy_1692442365) by smtp.aliyun-inc.com; Sat, 19 Aug 2023 18:52:46 +0800 From: Baolin Wang To: akpm@linux-foundation.org Cc: mgorman@techsingularity.net, shy828301@gmail.com, david@redhat.com, ying.huang@intel.com, baolin.wang@linux.alibaba.com, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: [PATCH 4/4] mm: migrate: change to return the number of pages migrated successfully Date: Sat, 19 Aug 2023 18:52:37 +0800 Message-Id: X-Mailer: git-send-email 2.39.3 In-Reply-To: References: MIME-Version: 1.0 X-Rspamd-Queue-Id: 8810E4000C X-Rspam-User: X-Stat-Signature: syxaxwin4z6iodfg3q5od5d4mabyyxde X-Rspamd-Server: rspam01 X-HE-Tag: 1692442370-234054 X-HE-Meta: U2FsdGVkX1+VV4D1AZ/9HxhxUGhnfmWYshAonvfnlCsp2WymqoGCODewBdv5K7C+m5WrnG2hz+oe9/ECAERSscydLKgER4kEtIrudpoDEFPlNP4m+xfd+vlcMDdi+YsCurScd/D86NnJw0y8EZBA/qKICrqqf4p2rQOnIBMI7feHBt18rN2oJKAgFQkCfbw8tS3MopHSOQvwQ9XPfvZn617HrNWZa55C4CGoHGiWlNL1NC1VqA0ATMabKSjrhBptF8s7CIM4Qyt/SwdESyS4hXEK56gsu5mwED60gCNy2Ftbnhsz8yBd30JVJuUG03oHlnGLDJafPtFohChNC0eUeWAS8f24VWu/DQitw2jYegv8/NLX9P3OlBof700IylgQK8aDCqbCGmJ2uyTK0SS7/Hx7xjWd67ARTUcA04pu/ul9UwsZBsmlC25P6BM5AageKt5K/s1YU/acWc21OyyrG+Nrueldn/zx4Co0WnYhW28sa1GL1VhC8QUgKeSwHEEM0A+QeT6RGaN3F6u30rBdP/6cHuuJUw6gLOnJpAyby9ewat7cadgmDXy7BYzaQo5PtYR8ILTXvCA4/suR1paa1oaZzRvH73gQFhjHz4DKSix3IKBNbNo7TCp0Rk3N67Ll+UUTPLMFvpXn9l0qUvyqX3hRBKmN3EoANXWVC3hKo3XTuEUZ1o38ZftrC8PfUuvh43VvWXXc8WM5gbUPU7MitZ9qCmRL5hsMVp1ognaP3VeF/rvsI0qEi/OSSeAxxMkzwnyGG7YJcD4U6tutOW9ZD1S1PSlCiTdFosGqZwAPPlDOyop53XfSE7LjTNWkmW8WW+6kuSMAXoUMwJruKc4AHwQuSohmXPiX+t+Mo46QFEHOUaYndmwCqquZzWWcUGOfYlfRlkvKgnciAsT+8gH9TT2O4kk4V0Fyrj35y7LmjinGB69c59E4QzAjc/rM/mN4JF8I7++GBQOmHkKBd5o d4Wgtq4l U0YRf4gmg5rqhxwxLrPrrZVPY8oK2T+e24+SlJ7qQ4om6UVNMXhXtNgmKZBCS5aJ/OqO52SRWmb7aIKt/HqwHWLsqSlBITSApKMScJ9eYowjUvGhGL5s54SQIHBWJf2oCj5yG 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: Change the migrate_misplaced_page() to return the number of pages migrated successfully, which is used to calculate how many pages are failed to migrate for batch migration. Signed-off-by: Baolin Wang --- mm/huge_memory.c | 7 ++++--- mm/memory.c | 5 +++-- mm/migrate.c | 5 +---- 3 files changed, 8 insertions(+), 9 deletions(-) diff --git a/mm/huge_memory.c b/mm/huge_memory.c index 53a9d63cfb1e..a9c454160984 100644 --- a/mm/huge_memory.c +++ b/mm/huge_memory.c @@ -1494,11 +1494,12 @@ vm_fault_t do_huge_pmd_numa_page(struct vm_fault *vmf) unsigned long haddr = vmf->address & HPAGE_PMD_MASK; int page_nid = NUMA_NO_NODE; int target_nid, last_cpupid = (-1 & LAST_CPUPID_MASK); - bool migrated = false, writable = false; + bool writable = false; int flags = 0; pg_data_t *pgdat; int isolated; LIST_HEAD(migratepages); + int nr_successed = 0; vmf->ptl = pmd_lock(vma->vm_mm, vmf->pmd); if (unlikely(!pmd_same(oldpmd, *vmf->pmd))) { @@ -1551,8 +1552,8 @@ vm_fault_t do_huge_pmd_numa_page(struct vm_fault *vmf) } list_add(&page->lru, &migratepages); - migrated = migrate_misplaced_page(&migratepages, vma, page_nid, target_nid); - if (migrated) { + nr_successed = migrate_misplaced_page(&migratepages, vma, page_nid, target_nid); + if (nr_successed) { flags |= TNF_MIGRATED; page_nid = target_nid; } else { diff --git a/mm/memory.c b/mm/memory.c index 973403a83797..edfd2d528e7e 100644 --- a/mm/memory.c +++ b/mm/memory.c @@ -4780,7 +4780,7 @@ static vm_fault_t do_numa_page(struct vm_fault *vmf) pte_t pte, old_pte; int flags = 0; pg_data_t *pgdat; - int isolated; + int isolated, nr_succeeded; LIST_HEAD(migratepages); /* @@ -4861,7 +4861,8 @@ static vm_fault_t do_numa_page(struct vm_fault *vmf) list_add(&page->lru, &migratepages); /* Migrate to the requested node */ - if (migrate_misplaced_page(&migratepages, vma, page_nid, target_nid)) { + nr_succeeded = migrate_misplaced_page(&migratepages, vma, page_nid, target_nid); + if (nr_succeeded) { page_nid = target_nid; flags |= TNF_MIGRATED; } else { diff --git a/mm/migrate.c b/mm/migrate.c index 93d359471b95..45f92376ba6f 100644 --- a/mm/migrate.c +++ b/mm/migrate.c @@ -2523,7 +2523,6 @@ int migrate_misplaced_page(struct list_head *migratepages, struct vm_area_struct int source_nid, int target_nid) { pg_data_t *pgdat = NODE_DATA(target_nid); - int migrated = 1; int nr_remaining; unsigned int nr_succeeded; @@ -2533,8 +2532,6 @@ int migrate_misplaced_page(struct list_head *migratepages, struct vm_area_struct if (nr_remaining) { if (!list_empty(migratepages)) putback_movable_pages(migratepages); - - migrated = 0; } if (nr_succeeded) { count_vm_numa_events(NUMA_PAGE_MIGRATE, nr_succeeded); @@ -2543,7 +2540,7 @@ int migrate_misplaced_page(struct list_head *migratepages, struct vm_area_struct nr_succeeded); } BUG_ON(!list_empty(migratepages)); - return migrated; + return nr_succeeded; } #endif /* CONFIG_NUMA_BALANCING */ #endif /* CONFIG_NUMA */