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=-6.8 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED 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 8C4E4C2D0E8 for ; Wed, 1 Apr 2020 02:25:06 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 38FE62071A for ; Wed, 1 Apr 2020 02:25:05 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 38FE62071A 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 8779D6B0070; Tue, 31 Mar 2020 22:25:05 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 801006B0071; Tue, 31 Mar 2020 22:25:05 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 6EFBD6B0072; Tue, 31 Mar 2020 22:25:05 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0060.hostedemail.com [216.40.44.60]) by kanga.kvack.org (Postfix) with ESMTP id 54CC96B0070 for ; Tue, 31 Mar 2020 22:25:05 -0400 (EDT) Received: from smtpin23.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id 1F74B4DB1 for ; Wed, 1 Apr 2020 02:25:05 +0000 (UTC) X-FDA: 76657693770.23.trip86_8390a31bb453b X-HE-Tag: trip86_8390a31bb453b X-Filterd-Recvd-Size: 5096 Received: from mga05.intel.com (mga05.intel.com [192.55.52.43]) by imf35.hostedemail.com (Postfix) with ESMTP for ; Wed, 1 Apr 2020 02:25:03 +0000 (UTC) IronPort-SDR: Ceq1uvjzc+MapZeXF5Eh1dtkyKSG/ngQ8IXd5c0pA6GPMYXH1Lh1lfuFVEgJsaSYp0sxrkmLc3 vP964lFJfiPQ== X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga002.jf.intel.com ([10.7.209.21]) by fmsmga105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 31 Mar 2020 19:25:02 -0700 IronPort-SDR: TEKnx2kKbIT40xo5i2aKSPEQj9sBD0onCN8ZiknGVHuh6htt3o18xyK/5ulbIZSm20MP2vXw7x UHg+JM86z4zg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.72,330,1580803200"; d="scan'208";a="267488669" Received: from yhuang-dev.sh.intel.com (HELO yhuang-dev) ([10.239.159.23]) by orsmga002.jf.intel.com with ESMTP; 31 Mar 2020 19:24:58 -0700 From: "Huang\, Ying" To: Zi Yan Cc: Andrew Morton , , , Andrea Arcangeli , "Kirill A . Shutemov" , Vlastimil Babka , Alexey Dobriyan , Michal Hocko , Konstantin Khlebnikov , =?utf-8?B?SsOpcsO0bWU=?= Glisse , Yang Shi Subject: Re: [PATCH] /proc/PID/smaps: Add PMD migration entry parsing References: <20200331085604.1260162-1-ying.huang@intel.com> <965DC015-7D6F-430D-8FB7-A24A814C13BE@nvidia.com> Date: Wed, 01 Apr 2020 10:24:57 +0800 In-Reply-To: <965DC015-7D6F-430D-8FB7-A24A814C13BE@nvidia.com> (Zi Yan's message of "Tue, 31 Mar 2020 08:24:07 -0400") Message-ID: <87r1x8hrie.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=utf-8 Content-Transfer-Encoding: quoted-printable 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: Zi Yan writes: > On 31 Mar 2020, at 4:56, 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. >> >> Signed-off-by: "Huang, Ying" >> Cc: Andrea Arcangeli >> Cc: Kirill A. Shutemov >> Cc: Zi Yan >> Cc: Vlastimil Babka >> Cc: Alexey Dobriyan >> Cc: Michal Hocko >> Cc: Konstantin Khlebnikov >> Cc: "J=C3=A9r=C3=B4me Glisse" >> Cc: Yang Shi >> --- >> fs/proc/task_mmu.c | 16 ++++++++++++---- >> 1 file changed, 12 insertions(+), 4 deletions(-) >> >> diff --git a/fs/proc/task_mmu.c b/fs/proc/task_mmu.c >> index 8d382d4ec067..b5b3aef8cb3b 100644 >> --- a/fs/proc/task_mmu.c >> +++ b/fs/proc/task_mmu.c >> @@ -548,8 +548,17 @@ static void smaps_pmd_entry(pmd_t *pmd, unsigned = long addr, >> bool locked =3D !!(vma->vm_flags & VM_LOCKED); >> struct page *page; > > Like Konstantin pointed out in another email, you could initialize page= to NULL here. > Plus you do not need the =E2=80=9Celse-return=E2=80=9D below, if you do= that. Yes. That looks better. Will change this in the next version. >> >> - /* FOLL_DUMP will return -EFAULT on huge zero page */ >> - page =3D follow_trans_huge_pmd(vma, addr, pmd, FOLL_DUMP); >> + if (pmd_present(*pmd)) { >> + /* FOLL_DUMP will return -EFAULT on huge zero page */ >> + page =3D follow_trans_huge_pmd(vma, addr, pmd, FOLL_DU= MP); >> + } else if (unlikely(is_swap_pmd(*pmd))) { > > Should be: > } else if (unlikely(thp_migration_support() && is_swap_pmd(*p= md))) { > > Otherwise, when THP migration is disabled and the PMD is under splittin= g, VM_BUG_ON > will be triggered. We hold the PMD page table lock when call smaps_pmd_entry(). How does PMD splitting trigger VM_BUG_ON()? >> + swp_entry_t entry =3D pmd_to_swp_entry(*pmd); >> + >> + VM_BUG_ON(!is_migration_entry(entry)); >> + page =3D migration_entry_to_page(entry); >> + } else { >> + return; >> + } >> if (IS_ERR_OR_NULL(page)) >> return; >> if (PageAnon(page)) >> @@ -578,8 +587,7 @@ static int smaps_pte_range(pmd_t *pmd, unsigned lo= ng addr, unsigned long end, >> >> ptl =3D pmd_trans_huge_lock(pmd, vma); >> if (ptl) { >> - if (pmd_present(*pmd)) >> - smaps_pmd_entry(pmd, addr, walk); >> + smaps_pmd_entry(pmd, addr, walk); >> spin_unlock(ptl); >> goto out; >> } >> -- >> 2.25.0 > > Everything else looks good to me. Thanks. > > With the fixes mentioned above, you can add > Reviewed-by: Zi Yan Thanks! Best Regards, Huang, Ying