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=-3.8 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=no 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 3B8DDC43331 for ; Thu, 2 Apr 2020 07:03:33 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 085A120784 for ; Thu, 2 Apr 2020 07:03:32 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 085A120784 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=intel.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 829798E000A; Thu, 2 Apr 2020 03:03:32 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 7B2E38E0008; Thu, 2 Apr 2020 03:03:32 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 67C278E000A; Thu, 2 Apr 2020 03:03:32 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id 4DA028E0008 for ; Thu, 2 Apr 2020 03:03:32 -0400 (EDT) Received: from smtpin04.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with ESMTP id 03377180AD817 for ; Thu, 2 Apr 2020 07:03:32 +0000 (UTC) X-FDA: 76662024264.04.rate46_1a720c28671c X-HE-Tag: rate46_1a720c28671c X-Filterd-Recvd-Size: 3937 Received: from mga12.intel.com (mga12.intel.com [192.55.52.136]) by imf45.hostedemail.com (Postfix) with ESMTP for ; Thu, 2 Apr 2020 07:03:31 +0000 (UTC) IronPort-SDR: ZyQEf66rmWZXf2J9WKl7nBwUO5Lp8f75XmYSlOVo85zCYw0NOuyfd3Y7EDJIMSiZ+fg6ccRLI9 Bp9/B+bpNazQ== X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga005.fm.intel.com ([10.253.24.32]) by fmsmga106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 02 Apr 2020 00:03:28 -0700 IronPort-SDR: aSpLOR9pE9wRLwAadXA1Q8rq5KShoc5lgo6LSlb9qE2ytaG04q2cF4lukrRvPtbItQUG43EYym w1U6QukXnfnQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.72,334,1580803200"; d="scan'208";a="449512335" Received: from yhuang-dev.sh.intel.com (HELO yhuang-dev) ([10.239.159.23]) by fmsmga005.fm.intel.com with ESMTP; 02 Apr 2020 00:03:25 -0700 From: "Huang\, Ying" To: Michal Hocko Cc: Andrew Morton , , , Zi Yan , Andrea Arcangeli , "Kirill A . Shutemov" , Vlastimil Babka , "Alexey Dobriyan" , Konstantin Khlebnikov , Jérôme Glisse , Yang Shi Subject: Re: [PATCH -V2] /proc/PID/smaps: Add PMD migration entry parsing References: <20200402020031.1611223-1-ying.huang@intel.com> <20200402064437.GC22681@dhcp22.suse.cz> Date: Thu, 02 Apr 2020 15:03:23 +0800 In-Reply-To: <20200402064437.GC22681@dhcp22.suse.cz> (Michal Hocko's message of "Thu, 2 Apr 2020 08:44:37 +0200") Message-ID: <87zhbufjyc.fsf@yhuang-dev.intel.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.1 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=ascii 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: Michal Hocko writes: > On Thu 02-04-20 10:00:31, Huang, Ying wrote: >> From: Huang Ying >> >> Now, when read /proc/PID/smaps, the PMD migration entry in page table is simply >> ignored. To improve the accuracy of /proc/PID/smaps, its parsing and processing >> is added. >> >> Before the patch, for a fully populated 400 MB anonymous VMA, sometimes some THP >> pages under migration may be lost as follows. > > Interesting. How did you reproduce this? > [...] I run the pmbench in background to eat memory, then run `/usr/bin/migratepages` and `cat /proc/PID/smaps` every second. The issue can be reproduced within 60 seconds. >> diff --git a/fs/proc/task_mmu.c b/fs/proc/task_mmu.c >> index 8d382d4ec067..9c72f9ce2dd8 100644 >> --- a/fs/proc/task_mmu.c >> +++ b/fs/proc/task_mmu.c >> @@ -546,10 +546,19 @@ static void smaps_pmd_entry(pmd_t *pmd, unsigned long addr, >> struct mem_size_stats *mss = walk->private; >> struct vm_area_struct *vma = walk->vma; >> bool locked = !!(vma->vm_flags & VM_LOCKED); >> - struct page *page; >> + struct page *page = NULL; >> >> - /* FOLL_DUMP will return -EFAULT on huge zero page */ >> - page = follow_trans_huge_pmd(vma, addr, pmd, FOLL_DUMP); >> + if (pmd_present(*pmd)) { >> + /* FOLL_DUMP will return -EFAULT on huge zero page */ >> + page = follow_trans_huge_pmd(vma, addr, pmd, FOLL_DUMP); >> + } else if (unlikely(thp_migration_supported() && is_swap_pmd(*pmd))) { >> + swp_entry_t entry = pmd_to_swp_entry(*pmd); >> + >> + if (is_migration_entry(entry)) >> + page = migration_entry_to_page(entry); >> + else >> + VM_WARN_ON_ONCE(1); > > Could you explain why do we need this WARN_ON? I haven't really checked > the swap support for THP but cannot we have normal swap pmd entries? I have some patches to add the swap pmd entry support, but they haven't been merged yet. Similar checks are for all THP migration code paths, so I follow the same style. Best Regards, Huang, Ying