From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.3 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI,NICE_REPLY_A, SPF_HELO_NONE,SPF_PASS,USER_AGENT_SANE_1 autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 73D2DC4727F for ; Tue, 29 Sep 2020 06:03:22 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id DC88F20BED for ; Tue, 29 Sep 2020 06:03:21 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org DC88F20BED Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=arm.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 30FD16B005C; Tue, 29 Sep 2020 02:03:21 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 2C1BD6B005D; Tue, 29 Sep 2020 02:03:21 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 1B1286B0062; Tue, 29 Sep 2020 02:03:21 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0062.hostedemail.com [216.40.44.62]) by kanga.kvack.org (Postfix) with ESMTP id 02D716B005C for ; Tue, 29 Sep 2020 02:03:20 -0400 (EDT) Received: from smtpin07.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with ESMTP id AD2E48249980 for ; Tue, 29 Sep 2020 06:03:20 +0000 (UTC) X-FDA: 77315056560.07.birth52_5e0cfe627187 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin07.hostedemail.com (Postfix) with ESMTP id 880AD18013204 for ; Tue, 29 Sep 2020 06:03:20 +0000 (UTC) X-HE-Tag: birth52_5e0cfe627187 X-Filterd-Recvd-Size: 4320 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by imf22.hostedemail.com (Postfix) with ESMTP for ; Tue, 29 Sep 2020 06:03:19 +0000 (UTC) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 228D331B; Mon, 28 Sep 2020 23:03:19 -0700 (PDT) Received: from [10.163.73.175] (unknown [10.163.73.175]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 29F053F6CF; Mon, 28 Sep 2020 23:03:16 -0700 (PDT) Subject: Re: [RFC] mm/vmstat: Add events for HugeTLB migration To: Mike Kravetz , linux-mm@kvack.org Cc: Daniel Jordan , Zi Yan , John Hubbard , Andrew Morton , linux-kernel@vger.kernel.org References: <1601025149-13311-1-git-send-email-anshuman.khandual@arm.com> <78e77883-9ba9-159c-200a-e8303bbfc206@oracle.com> From: Anshuman Khandual Message-ID: <4b6a2b8b-5370-ac5d-dd41-38b800dd0e3a@arm.com> Date: Tue, 29 Sep 2020 11:32:43 +0530 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.9.1 MIME-Version: 1.0 In-Reply-To: <78e77883-9ba9-159c-200a-e8303bbfc206@oracle.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit 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: On 09/29/2020 03:34 AM, Mike Kravetz wrote: > On 9/25/20 2:12 AM, Anshuman Khandual wrote: >> Add following new vmstat events which will track HugeTLB page migration. >> >> 1. HUGETLB_MIGRATION_SUCCESS >> 2. HUGETLB_MIGRATION_FAILURE >> >> It follows the existing semantics to accommodate HugeTLB subpages in total >> page migration statistics. While here, this updates current trace event >> "mm_migrate_pages" to accommodate now available HugeTLB based statistics. > > Thanks. This makes sense with recent THP changes. > >> diff --git a/mm/migrate.c b/mm/migrate.c >> index 3ab965f83029..d53dd101ffff 100644 >> --- a/mm/migrate.c >> +++ b/mm/migrate.c >> @@ -1415,13 +1415,17 @@ int migrate_pages(struct list_head *from, new_page_t get_new_page, >> { >> int retry = 1; >> int thp_retry = 1; >> + int hugetlb_retry = 1; >> int nr_failed = 0; >> int nr_succeeded = 0; >> int nr_thp_succeeded = 0; >> int nr_thp_failed = 0; >> int nr_thp_split = 0; >> + int nr_hugetlb_succeeded = 0; >> + int nr_hugetlb_failed = 0; >> int pass = 0; >> bool is_thp = false; >> + bool is_hugetlb = false; >> struct page *page; >> struct page *page2; >> int swapwrite = current->flags & PF_SWAPWRITE; >> @@ -1433,6 +1437,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; >> + hugetlb_retry = 0; >> >> list_for_each_entry_safe(page, page2, from, lru) { >> retry: >> @@ -1442,7 +1447,12 @@ int migrate_pages(struct list_head *from, new_page_t get_new_page, >> * during migration. >> */ >> is_thp = PageTransHuge(page) && !PageHuge(page); >> + is_hugetlb = PageTransHuge(page) && PageHuge(page); > > PageHuge does not depend on PageTransHuge. So, this could just be > is_hugetlb = PageHuge(page); Sure. > > Actually, the current version of PageHuge is more expensive than PageTransHuge. > So, the most optimal way to set these would be something like. > if (PageTransHuge(page)) > if (PageHuge(page)) > is_hugetlb = true; > else > is_thp = true; > > Although, the compiler may be able to optimize. I did not check. Both is_hugetlb and is_thp need to have either a true or false value during each iteration as they are not getting reset otherwise. Hence basically it should either be is_thp = PageTransHuge(page) && !PageHuge(page); is_hugetlb = PageHuge(page); OR is_hugetlb = false; is_thp = false; if (PageTransHuge(page)) if (PageHuge(page)) is_hugetlb = true; else is_thp = true; } > >> + >> nr_subpages = thp_nr_pages(page); >> + if (is_hugetlb) >> + nr_subpages = pages_per_huge_page(page_hstate(page)); > > Can we just use compound_order() here for all cases? Sure but we could also directly use compound_nr().