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 02DB4C2D0F1 for ; Wed, 1 Apr 2020 02:31:11 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id BD01B20578 for ; Wed, 1 Apr 2020 02:31:10 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org BD01B20578 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 406006B0070; Tue, 31 Mar 2020 22:31:10 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 3B5C26B0071; Tue, 31 Mar 2020 22:31:10 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 2CB4C6B0072; Tue, 31 Mar 2020 22:31:10 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0082.hostedemail.com [216.40.44.82]) by kanga.kvack.org (Postfix) with ESMTP id 135BA6B0070 for ; Tue, 31 Mar 2020 22:31:10 -0400 (EDT) Received: from smtpin23.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with ESMTP id C704A824805A for ; Wed, 1 Apr 2020 02:31:09 +0000 (UTC) X-FDA: 76657709058.23.nerve90_272945d4f6c3e X-HE-Tag: nerve90_272945d4f6c3e X-Filterd-Recvd-Size: 4544 Received: from mga12.intel.com (mga12.intel.com [192.55.52.136]) by imf01.hostedemail.com (Postfix) with ESMTP for ; Wed, 1 Apr 2020 02:31:08 +0000 (UTC) IronPort-SDR: RcWd0mg321+3kjQ+jKvduy0Hi7F8DWcaolVOuPGkSm6+I4dWbE2RbcRUaRmOQNu8p2A9dXHIwn k3kC+NfGZoiA== X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga007.jf.intel.com ([10.7.209.58]) by fmsmga106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 31 Mar 2020 19:31:07 -0700 IronPort-SDR: mkxQL4GfjaPiHJkDgxEa8ej+AOXIVcRb79zvXmIGjlpTDcfnWQKS/u2c2Zc07tH0TNGk8wkKX4 s27I35EhfIOQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.72,330,1580803200"; d="scan'208";a="237910614" Received: from yhuang-dev.sh.intel.com (HELO yhuang-dev) ([10.239.159.23]) by orsmga007.jf.intel.com with ESMTP; 31 Mar 2020 19:31:04 -0700 From: "Huang\, Ying" To: Konstantin Khlebnikov Cc: Andrew Morton , , , Andrea Arcangeli , "Kirill A . Shutemov" , Zi Yan , Vlastimil Babka , Alexey Dobriyan , Michal Hocko , =?utf-8?B?SsOp?= =?utf-8?B?csO0bWU=?= Glisse , Yang Shi Subject: Re: [PATCH] /proc/PID/smaps: Add PMD migration entry parsing References: <20200331085604.1260162-1-ying.huang@intel.com> <49386753-5984-f708-4153-e9c6de632439@yandex-team.ru> Date: Wed, 01 Apr 2020 10:31:03 +0800 In-Reply-To: <49386753-5984-f708-4153-e9c6de632439@yandex-team.ru> (Konstantin Khlebnikov's message of "Tue, 31 Mar 2020 12:51:38 +0300") Message-ID: <87mu7whr88.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: Konstantin Khlebnikov writes: > On 31/03/2020 11.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; > > struct page *page =3D NULL; Looks good. Will do 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_DUMP); >> + } else if (unlikely(is_swap_pmd(*pmd))) { >> + swp_entry_t entry =3D pmd_to_swp_entry(*pmd); >> + >> + VM_BUG_ON(!is_migration_entry(entry)); >> + page =3D migration_entry_to_page(entry); > > if (is_migration_entry(entry)) > page =3D migration_entry_to_page(entry); > > Seems safer and doesn't add much code. With this, we lose an opportunity to capture some bugs during debugging. Right? Best Regards, Huang, Ying >> + } 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; >> } >>