From patchwork Tue Aug 22 00:53:52 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Baolin Wang X-Patchwork-Id: 13360023 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 500DBEE49A6 for ; Tue, 22 Aug 2023 00:54:23 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id A8EDD28000D; Mon, 21 Aug 2023 20:54:18 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 9F07828000B; Mon, 21 Aug 2023 20:54:18 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 86A8028000D; Mon, 21 Aug 2023 20:54:18 -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 75D8C28000B for ; Mon, 21 Aug 2023 20:54:18 -0400 (EDT) Received: from smtpin01.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id 4204AC016E for ; Tue, 22 Aug 2023 00:54:18 +0000 (UTC) X-FDA: 81149919396.01.264A573 Received: from out30-124.freemail.mail.aliyun.com (out30-124.freemail.mail.aliyun.com [115.124.30.124]) by imf05.hostedemail.com (Postfix) with ESMTP id 1307E100017 for ; Tue, 22 Aug 2023 00:54:15 +0000 (UTC) Authentication-Results: imf05.hostedemail.com; dkim=none; spf=pass (imf05.hostedemail.com: domain of baolin.wang@linux.alibaba.com designates 115.124.30.124 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=1692665656; a=rsa-sha256; cv=none; b=0khUyXxAAux4XKXnUY+JyMDFQziwfp0mz1gt2CsngWgRZd6OdCZOpvHaYhukJKIyOkaygd MXp2mDMOiVqkfOdNGEme+lZ3xC3iZZJ1p9fFx98sNALXx3NDexZUHlU2g041AvqVVQQrVL xPbP33bakEl1jVoCiArwIjouymtdE04= ARC-Authentication-Results: i=1; imf05.hostedemail.com; dkim=none; spf=pass (imf05.hostedemail.com: domain of baolin.wang@linux.alibaba.com designates 115.124.30.124 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=1692665656; 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=yVDhgbFmYSfxlu1ENlgkUpOD4znVYtMHFKsHUNldCus=; b=dUBnwIPoZjxBDk1WoRLuCx5aBkaRQOmDf8Kpu68D/6O6X01U+kA3Hmvs1r2f15M3zg4SAC 6+T7I4roxHxnC2SSnJemo1Ly1c9ZuBOTlnNI4LNumoS6ZfoPLj9y/N+cAxk+ywygdhhAEC 6J9fTW5pZCVL6EoEX9JMgQxp+Gs41ho= 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=ay29a033018045170;MF=baolin.wang@linux.alibaba.com;NM=1;PH=DS;RN=8;SR=0;TI=SMTPD_---0VqJzDob_1692665651; Received: from localhost(mailfrom:baolin.wang@linux.alibaba.com fp:SMTPD_---0VqJzDob_1692665651) by smtp.aliyun-inc.com; Tue, 22 Aug 2023 08:54:12 +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 v2 4/4] mm: migrate: change to return the number of pages migrated successfully Date: Tue, 22 Aug 2023 08:53:52 +0800 Message-Id: <9688ba40be86d7d0af0961e74d2a182ce65f5f8c.1692665449.git.baolin.wang@linux.alibaba.com> X-Mailer: git-send-email 2.39.3 In-Reply-To: References: MIME-Version: 1.0 X-Rspam-User: X-Rspamd-Server: rspam06 X-Rspamd-Queue-Id: 1307E100017 X-Stat-Signature: he1rc3xe75ixq5fn1gkmbh8p1hk4ix5x X-HE-Tag: 1692665655-734431 X-HE-Meta: U2FsdGVkX1+qZo6hDqr4dQgMFpK+5zlTj2ACr0BFkthKoQCBRLQKcP20oMqpnnxVCurWEXRj2A3kaXL11VBn/AAvjV/B3OFpMVFt4q9PKDO9IEY3V1FWZ8XIoTdgYiQ+YF9NXG5xApf3jIfYd12hlVR0XHjhpFv3i/kEKVrGW0Lt0ln90cIIYS9lP53iYlthbd6rM12ihP62Z9UdKOQF1ZHU5IXI18L3cBX1z4J6Wl0ZjCCrnNFEnB3Vf53b1zYxmAsjGvCRCwpiDYZJHzBN9usjYmiZv2Oiz2rujrKzYXHiHvPbtppaRbv8N1qljQNiXEJs8FGxdcPh+RX6QTWSF4wmuiFGH9FEBEDtTZJmoI/R7tIv5PZaryW5rzqzEWfTCfEROqXVidbycCsnkLMVj/G3v3puwT9Ywx+XAWw4N126i8ID4os4QGzSvWpr+45QDiIk51XVgf9/0cgL1BPwepta5JQbPnFunOECvYAgST1Z6oAQvrPNsp0MWkJZUhCNLVyCANmYzYM6Q+SP0FQHFrb3feE8jsc3XB/PaAL5GXID9knnojUk7su0xME3d6g/SOCb9gXUvRefhOpghud5ajtwhOUxCR3Sd8Gr4R3czr+kkY+J/zBLfkVHZ26iqrdRiHC2mBKvlMirJdNOsMSP11kt6cbvkX9ulw6tMjfK9HP27qKdNKqKJCYCleJyXY1NZZ569g1qQNvkJeF8bXzOrUN77qQm//xv+y2C3YiTQcFZ8Q71GHWqs2xwGJ0Hzr1AU5nuu8l99qyRlvPceMjbPHCvjT1TSJI6g8U1KpfIrCE/BYEbQDU/uQyFfIPzi3TH3x2Loxwp6Q7b6cPfGudO5/FihPkSG13pY+f56fm3Uey+G9Ibxo0H1xCWF1WNwSbejW5frNfpY6KGcHeKWBr2+NysXeCpGJ+z7AkE71D/OU5+lFXtwa4g+rGBjJJGuekL+IYNZQ/cHXXlRTrQ9op M42O1/1z v1DZBHid7YxLlgEGFcSF8DL+cZ/maiSKM90cMuGxH927EHGQ+EQwXTXBL8VerkF6K6hKFVmNHTSCmwblFYI50JLJ5Zcf6AV9NFy9DVknwXSfsI5tTltwxO1Dmu4t7ABZ4q3Fq 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. For the compound page's NUMA balancing support, it is possible that partial pages were successfully migrated, so it is necessary to return the number of pages that were successfully migrated from migrate_misplaced_page(). Signed-off-by: Baolin Wang --- mm/huge_memory.c | 9 +++++---- mm/memory.c | 4 +++- mm/migrate.c | 5 +---- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/mm/huge_memory.c b/mm/huge_memory.c index 4401a3493544..951f73d6b5bf 100644 --- a/mm/huge_memory.c +++ b/mm/huge_memory.c @@ -1494,10 +1494,11 @@ 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; LIST_HEAD(migratepages); + int nr_successed; vmf->ptl = pmd_lock(vma->vm_mm, vmf->pmd); if (unlikely(!pmd_same(oldpmd, *vmf->pmd))) { @@ -1554,9 +1555,9 @@ 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 9e417e8dd5d5..2773cd804ee9 100644 --- a/mm/memory.c +++ b/mm/memory.c @@ -4771,6 +4771,7 @@ static vm_fault_t do_numa_page(struct vm_fault *vmf) int flags = 0; pg_data_t *pgdat; LIST_HEAD(migratepages); + int nr_succeeded; /* * The "pte" at this point cannot be used safely without @@ -4854,7 +4855,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 fae7224b8e64..5435cfb225ab 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 */