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 3D2EDC43331 for ; Thu, 2 Apr 2020 08:10:39 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 05CDE2078B for ; Thu, 2 Apr 2020 08:10:38 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 05CDE2078B 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 893728E0008; Thu, 2 Apr 2020 04:10:38 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 843F38E0007; Thu, 2 Apr 2020 04:10:38 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 75A228E0008; Thu, 2 Apr 2020 04:10:38 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0151.hostedemail.com [216.40.44.151]) by kanga.kvack.org (Postfix) with ESMTP id 5D4CA8E0007 for ; Thu, 2 Apr 2020 04:10:38 -0400 (EDT) Received: from smtpin19.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with ESMTP id 203142480 for ; Thu, 2 Apr 2020 08:10:38 +0000 (UTC) X-FDA: 76662193356.19.need46_572c8883d035 X-HE-Tag: need46_572c8883d035 X-Filterd-Recvd-Size: 4830 Received: from mga07.intel.com (mga07.intel.com [134.134.136.100]) by imf09.hostedemail.com (Postfix) with ESMTP for ; Thu, 2 Apr 2020 08:10:37 +0000 (UTC) IronPort-SDR: HDx5kAB2dU1cGrDDBe7rnn3IIdEy/AJTJR9bE6CfwC2tOrKuBjTq8PZVMA4apAHGz8u8kh/PH+ Z8BBO54clX7w== X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga001.jf.intel.com ([10.7.209.18]) by orsmga105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 02 Apr 2020 01:10:35 -0700 IronPort-SDR: j8nb0nIeu0p2sBqESdka+ajHuo9lFE4L+gTfBcdZAcOWOAkt/OCMDVMCG4tGGkuDLLLHjy+AvQ LwD6KBVkw4jw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.72,335,1580803200"; d="scan'208";a="328739839" Received: from yhuang-dev.sh.intel.com (HELO yhuang-dev) ([10.239.159.23]) by orsmga001.jf.intel.com with ESMTP; 02 Apr 2020 01:10:32 -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> <87zhbufjyc.fsf@yhuang-dev.intel.com> <20200402074411.GH22681@dhcp22.suse.cz> Date: Thu, 02 Apr 2020 16:10:29 +0800 In-Reply-To: <20200402074411.GH22681@dhcp22.suse.cz> (Michal Hocko's message of "Thu, 2 Apr 2020 09:44:11 +0200") Message-ID: <87v9mifgui.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 15:03:23, Huang, Ying wrote: >> 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. > > Please add that information to the changelog. I was probably too > optimistic about the migration duration because I found it highly > unlikely to be visible. I was clearly wrong here. Sure. Will add that in the next version. >> >> 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. > > I haven't checked other migration code paths but what is the reason to > add the warning here? Even if this shouldn't happen, smaps is perfectly > fine to ignore that situation, no? Yes. smaps itself is perfectly fine to ignore it. I think this is used to find bugs in other code paths such as THP migration related. Best Regards, Huang, Ying