From patchwork Fri Oct 29 07:42:37 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Baolin Wang X-Patchwork-Id: 12591935 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 mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9199DC433EF for ; Fri, 29 Oct 2021 07:42:56 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 1806F610A0 for ; Fri, 29 Oct 2021 07:42:56 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 1806F610A0 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linux.alibaba.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=kvack.org Received: by kanga.kvack.org (Postfix) id 765336B0071; Fri, 29 Oct 2021 03:42:55 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 6C6C96B0072; Fri, 29 Oct 2021 03:42:55 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 542686B0073; Fri, 29 Oct 2021 03:42:55 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0087.hostedemail.com [216.40.44.87]) by kanga.kvack.org (Postfix) with ESMTP id 297176B0071 for ; Fri, 29 Oct 2021 03:42:55 -0400 (EDT) Received: from smtpin01.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id 9AF72181C98F4 for ; Fri, 29 Oct 2021 07:42:54 +0000 (UTC) X-FDA: 78748683510.01.0F18D32 Received: from out30-56.freemail.mail.aliyun.com (out30-56.freemail.mail.aliyun.com [115.124.30.56]) by imf26.hostedemail.com (Postfix) with ESMTP id A99D320019C6 for ; Fri, 29 Oct 2021 07:42:53 +0000 (UTC) X-Alimail-AntiSpam: AC=PASS;BC=-1|-1;BR=01201311R551e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=e01e04423;MF=baolin.wang@linux.alibaba.com;NM=1;PH=DS;RN=5;SR=0;TI=SMTPD_---0Uu6r.YH_1635493368; Received: from localhost(mailfrom:baolin.wang@linux.alibaba.com fp:SMTPD_---0Uu6r.YH_1635493368) by smtp.aliyun-inc.com(127.0.0.1); Fri, 29 Oct 2021 15:42:48 +0800 From: Baolin Wang To: akpm@linux-foundation.org Cc: shy828301@gmail.com, baolin.wang@linux.alibaba.com, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: [PATCH] mm: migrate: Correct the hugetlb migration stats Date: Fri, 29 Oct 2021 15:42:37 +0800 Message-Id: X-Mailer: git-send-email 1.8.3.1 X-Rspamd-Server: rspam06 X-Rspamd-Queue-Id: A99D320019C6 X-Stat-Signature: 67o1dirafkt81pcs6kdnfaq71upbpexk Authentication-Results: imf26.hostedemail.com; dkim=none; spf=pass (imf26.hostedemail.com: domain of baolin.wang@linux.alibaba.com designates 115.124.30.56 as permitted sender) smtp.mailfrom=baolin.wang@linux.alibaba.com; dmarc=pass (policy=none) header.from=alibaba.com X-HE-Tag: 1635493373-975824 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 hugetlb migration is also available for some scenarios, such as soft offling or memory compaction. So we should correct the migration stats for hugetlb with using compound_nr() instead of thp_nr_pages() to get the number of pages. Signed-off-by: Baolin Wang --- mm/migrate.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/mm/migrate.c b/mm/migrate.c index a11e948..2b45a29 100644 --- a/mm/migrate.c +++ b/mm/migrate.c @@ -1475,7 +1475,7 @@ int migrate_pages(struct list_head *from, new_page_t get_new_page, * during migration. */ is_thp = PageTransHuge(page) && !PageHuge(page); - nr_subpages = thp_nr_pages(page); + nr_subpages = compound_nr(page); cond_resched(); if (PageHuge(page)) @@ -1540,7 +1540,7 @@ int migrate_pages(struct list_head *from, new_page_t get_new_page, nr_failed += nr_subpages; goto out; } - nr_failed++; + nr_failed += nr_subpages; goto out; case -EAGAIN: if (is_thp) { @@ -1550,14 +1550,14 @@ int migrate_pages(struct list_head *from, new_page_t get_new_page, retry++; break; case MIGRATEPAGE_SUCCESS: + nr_succeeded += nr_subpages; if (is_thp) { nr_thp_succeeded++; - nr_succeeded += nr_subpages; break; } - nr_succeeded++; break; default: + nr_failed += nr_subpages; /* * Permanent failure (-EBUSY, etc.): * unlike -EAGAIN case, the failed page is @@ -1566,10 +1566,8 @@ int migrate_pages(struct list_head *from, new_page_t get_new_page, */ if (is_thp) { nr_thp_failed++; - nr_failed += nr_subpages; break; } - nr_failed++; break; } }