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 */