From patchwork Tue Mar 31 08:56:04 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: "Huang, Ying" X-Patchwork-Id: 11466973 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 5CD36912 for ; Tue, 31 Mar 2020 08:56:35 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 27FDC207FF for ; Tue, 31 Mar 2020 08:56:35 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 27FDC207FF 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 6F6926B0032; Tue, 31 Mar 2020 04:56:34 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 6A6F56B0037; Tue, 31 Mar 2020 04:56:34 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 595AB6B006C; Tue, 31 Mar 2020 04:56:34 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0190.hostedemail.com [216.40.44.190]) by kanga.kvack.org (Postfix) with ESMTP id 40AD86B0032 for ; Tue, 31 Mar 2020 04:56:34 -0400 (EDT) Received: from smtpin06.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id EBA70181AEF00 for ; Tue, 31 Mar 2020 08:56:33 +0000 (UTC) X-FDA: 76655051466.06.dust08_908fa1d6e6e4d X-Spam-Summary: 1,0,0,,d41d8cd98f00b204,ying.huang@intel.com,,RULES_HIT:30054:30064,0,RBL:134.134.136.31:@intel.com:.lbl8.mailshell.net-62.18.0.100 64.95.201.95,CacheIP:none,Bayesian:0.5,0.5,0.5,Netcheck:none,DomainCache:0,MSF:not bulk,SPF:ft,MSBL:0,DNSBL:none,Custom_rules:0:0:0,LFtime:23,LUA_SUMMARY:none X-HE-Tag: dust08_908fa1d6e6e4d X-Filterd-Recvd-Size: 3645 Received: from mga06.intel.com (mga06.intel.com [134.134.136.31]) by imf21.hostedemail.com (Postfix) with ESMTP for ; Tue, 31 Mar 2020 08:56:33 +0000 (UTC) IronPort-SDR: bXqnZGhozo0LL9dFxePSLinO1uQdqyt/jvDDZaJevfybJC3QZuXDZuUVZKlb13ADXBm5XhNhXd ICSMZMeoBMjA== X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by orsmga104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 31 Mar 2020 01:56:31 -0700 IronPort-SDR: rY2Lz/HrtN4L05LwqCHEIGPro6fjbVG88EiP8Yy2Btzm2jo0QEIOOymxovM50kXXzqYHbexX0Z aYptoeE+mgFQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.72,327,1580803200"; d="scan'208";a="450093037" Received: from yhuang-dev.sh.intel.com ([10.239.159.23]) by fmsmga006.fm.intel.com with ESMTP; 31 Mar 2020 01:56:28 -0700 From: "Huang, Ying" To: Andrew Morton Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, Huang Ying , Andrea Arcangeli , "Kirill A . Shutemov" , Zi Yan , Vlastimil Babka , Alexey Dobriyan , Michal Hocko , Konstantin Khlebnikov , =?utf-8?b?SsOpcsO0bWUg?= =?utf-8?b?R2xpc3Nl?= , Yang Shi Subject: [PATCH] /proc/PID/smaps: Add PMD migration entry parsing Date: Tue, 31 Mar 2020 16:56:04 +0800 Message-Id: <20200331085604.1260162-1-ying.huang@intel.com> X-Mailer: git-send-email 2.25.0 MIME-Version: 1.0 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: 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érôme Glisse" Cc: Yang Shi Reviewed-by: Zi Yan --- 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 = !!(vma->vm_flags & VM_LOCKED); struct page *page; - /* 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(is_swap_pmd(*pmd))) { + swp_entry_t entry = pmd_to_swp_entry(*pmd); + + VM_BUG_ON(!is_migration_entry(entry)); + page = 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 long addr, unsigned long end, ptl = 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; }