From patchwork Mon Sep 28 17:54:21 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zi Yan X-Patchwork-Id: 11804485 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 57001618 for ; Mon, 28 Sep 2020 17:56:22 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 17598221E7 for ; Mon, 28 Sep 2020 17:56:21 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=sent.com header.i=@sent.com header.b="SothXaKe"; dkim=temperror (0-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="KJiZvA+m" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 17598221E7 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=sent.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 779F6900019; Mon, 28 Sep 2020 13:55:30 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 701EA90000D; Mon, 28 Sep 2020 13:55:30 -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 5C98C900019; Mon, 28 Sep 2020 13:55:30 -0400 (EDT) X-Original-To: linux-mm@kvack.org 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 44C9890000D for ; Mon, 28 Sep 2020 13:55:30 -0400 (EDT) Received: from smtpin18.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id 0B55C181AE86D for ; Mon, 28 Sep 2020 17:55:30 +0000 (UTC) X-FDA: 77313222420.18.net14_0e031a227183 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin18.hostedemail.com (Postfix) with ESMTP id DBB1B1016E295 for ; Mon, 28 Sep 2020 17:55:29 +0000 (UTC) X-Spam-Summary: 1,0,0,2439975788510d0f,d41d8cd98f00b204,zi.yan@sent.com,,RULES_HIT:41:355:379:541:800:960:973:988:989:1260:1261:1311:1314:1345:1359:1437:1515:1535:1542:1711:1730:1747:1777:1792:2393:2559:2562:3138:3139:3140:3141:3142:3354:3865:3867:3870:3871:4117:4321:5007:6119:6120:6261:6653:6742:7576:7901:8660:9036:10004:11026:11473:11658:11914:12043:12291:12296:12438:12555:12679:12683:12895:12986:13148:13230:13894:14096:14110:14181:14721:21080:21627:21939:21990:30054:30064,0,RBL:64.147.123.17:@sent.com:.lbl8.mailshell.net-64.100.201.100 62.18.0.100;04y8oity3mtg5cxjcx6z4xjkbi6yiycijb5qbdmmbk18jimy7mehz9sf3ac7wri.pc3as5kasmcnd89r84q5guewaazbe4rx1d1q1rjse3pskdjtid9cfaxot1xzmh5.n-lbl8.mailshell.net-223.238.255.100,CacheIP:none,Bayesian:0.5,0.5,0.5,Netcheck:none,DomainCache:0,MSF:not bulk,SPF:fp,MSBL:0,DNSBL:neutral,Custom_rules:0:0:0,LFtime:23,LUA_SUMMARY:none X-HE-Tag: net14_0e031a227183 X-Filterd-Recvd-Size: 6618 Received: from wnew3-smtp.messagingengine.com (wnew3-smtp.messagingengine.com [64.147.123.17]) by imf19.hostedemail.com (Postfix) with ESMTP for ; Mon, 28 Sep 2020 17:55:29 +0000 (UTC) Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailnew.west.internal (Postfix) with ESMTP id 29242EAA; Mon, 28 Sep 2020 13:55:27 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute4.internal (MEProxy); Mon, 28 Sep 2020 13:55:28 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sent.com; h=from :to:cc:subject:date:message-id:in-reply-to:references:reply-to :mime-version:content-transfer-encoding; s=fm1; bh=wDKwPLy4VFcLp paBAPPIxv3ZweIVcEaNjmSuTChBG+s=; b=SothXaKew0HL/ALe/TnCgWjpYQ8pC tbv2CUOxJpzhRqjkYJEqAITyyGHHLYx7HlbnSDIOgqOP05pVD20Fx/8RA//b2x2/ Z1xVLe9KUT8sEtlUHEqqf5SFtimaePtA51rd30UoAsDR9vGF2J38J+VerOqycBi2 31m5zQUUEVEnvAsH9pE8VxCrkwWFaWAIi55dcO1K/llRiEPi4EZoRx+Aar4dmIiI Zxlyj2p9rQnMWwWlp2BJ7SikpQ4pc3G8rzCYJRkay8qyaSZShbYnSMKqvnyaycC/ RMYSep9fZEskFD01A6N/VgWnM3D/xQBE/+9pQGy7vx0Lpe0ZskOKEQPfQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:date:from :in-reply-to:message-id:mime-version:references:reply-to:subject :to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s= fm3; bh=wDKwPLy4VFcLppaBAPPIxv3ZweIVcEaNjmSuTChBG+s=; b=KJiZvA+m GN9UiZpcZOT2xWfn4MVpTO8SvyzBqPJ8am2es2pJitbp7NKnX6q1fSntWVgm6Kzd pSCe8IzArU7X+/c3+F6kyae20+LriQLBV01kl077B8g/fqA+Ny9ikJDkBOv/YsfL 6zeLtdZrwowN9W26Xt9+dA//vy79oPcMSFr66NgKRPDtKxEpgntDWrmQ1V7emwJd x3f8gIGOhZKNC4CjVesuqwS+M0FEl/0Acxzyt29RmkonR9/6saL1iV8OG9SOemGg GYs2N4KGk5qsBsE5muwou6VbOgRBMEvQEaoOs/IrioGyZZS8r+tHT/X+JwKw9UnH Ly/Eg3biRTGyrQ== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedujedrvdeigdeliecutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenuc fjughrpefhvffufffkofgjfhhrggfgsedtkeertdertddtnecuhfhrohhmpegkihcujggr nhcuoeiiihdrhigrnhesshgvnhhtrdgtohhmqeenucggtffrrghtthgvrhhnpeduhfffve ektdduhfdutdfgtdekkedvhfetuedufedtgffgvdevleehheevjefgtdenucfkphepuddv rdegiedruddtiedrudeigeenucevlhhushhtvghrufhiiigvpeduvdenucfrrghrrghmpe hmrghilhhfrhhomhepiihirdihrghnsehsvghnthdrtghomh X-ME-Proxy: Received: from nvrsysarch6.NVidia.COM (unknown [12.46.106.164]) by mail.messagingengine.com (Postfix) with ESMTPA id 3C9EF306467E; Mon, 28 Sep 2020 13:55:26 -0400 (EDT) From: Zi Yan To: linux-mm@kvack.org Cc: "Kirill A . Shutemov" , Roman Gushchin , Rik van Riel , Matthew Wilcox , Shakeel Butt , Yang Shi , Jason Gunthorpe , Mike Kravetz , Michal Hocko , David Hildenbrand , William Kucharski , Andrea Arcangeli , John Hubbard , David Nellans , linux-kernel@vger.kernel.org, Zi Yan Subject: [RFC PATCH v2 23/30] mm: support PUD THP pagemap support. Date: Mon, 28 Sep 2020 13:54:21 -0400 Message-Id: <20200928175428.4110504-24-zi.yan@sent.com> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200928175428.4110504-1-zi.yan@sent.com> References: <20200928175428.4110504-1-zi.yan@sent.com> Reply-To: Zi Yan 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: Zi Yan pagemap_pud_range is added to print pud page flags properly. Signed-off-by: Zi Yan --- fs/proc/task_mmu.c | 63 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 63 insertions(+) diff --git a/fs/proc/task_mmu.c b/fs/proc/task_mmu.c index 077196182288..04a3158d0d5b 100644 --- a/fs/proc/task_mmu.c +++ b/fs/proc/task_mmu.c @@ -1553,6 +1553,68 @@ static int pagemap_pmd_range(pmd_t pmd, pmd_t *pmdp, unsigned long addr, return err; } +static int pagemap_pud_range(pud_t pud, pud_t *pudp, unsigned long addr, + unsigned long end, struct mm_walk *walk) +{ + struct vm_area_struct *vma = walk->vma; + struct pagemapread *pm = walk->private; + spinlock_t *ptl; + int err = 0; + +#ifdef CONFIG_HAVE_ARCH_TRANSPARENT_HUGEPAGE_PUD + ptl = pud_trans_huge_lock(pudp, vma); + if (ptl) { + u64 flags = 0, frame = 0; + struct page *page = NULL; + + if (memcmp(pudp, &pud, sizeof(pud)) != 0) { + walk->action = ACTION_AGAIN; + spin_unlock(ptl); + return 0; + } + if (vma->vm_flags & VM_SOFTDIRTY) + flags |= PM_SOFT_DIRTY; + + if (pud_present(pud)) { + page = pud_page(pud); + + flags |= PM_PRESENT; + if (pud_soft_dirty(pud)) + flags |= PM_SOFT_DIRTY; + if (pm->show_pfn) + frame = pud_pfn(pud) + + ((addr & ~PUD_MASK) >> PAGE_SHIFT); + } + + if (page && page_mapcount(page) == 1) + flags |= PM_MMAP_EXCLUSIVE; + + for (; addr != end; addr += PAGE_SIZE) { + pagemap_entry_t pme = make_pme(frame, flags); + + err = add_to_pagemap(addr, &pme, pm); + if (err) + break; + if (pm->show_pfn) { + if (flags & PM_PRESENT) + frame++; + else if (flags & PM_SWAP) + frame += (1 << MAX_SWAPFILES_SHIFT); + } + } + spin_unlock(ptl); + walk->action = ACTION_CONTINUE; + return err; + } + + if (pud_trans_unstable(&pud)) { + walk->action = ACTION_AGAIN; + return 0; + } +#endif /* CONFIG_HAVE_ARCH_TRANSPARENT_HUGEPAGE_PUD */ + return err; +} + #ifdef CONFIG_HUGETLB_PAGE /* This function walks within one hugetlb entry in the single call */ static int pagemap_hugetlb_range(pte_t *ptep, unsigned long hmask, @@ -1603,6 +1665,7 @@ static int pagemap_hugetlb_range(pte_t *ptep, unsigned long hmask, #endif /* HUGETLB_PAGE */ static const struct mm_walk_ops pagemap_ops = { + .pud_entry = pagemap_pud_range, .pmd_entry = pagemap_pmd_range, .pte_hole = pagemap_pte_hole, .hugetlb_entry = pagemap_hugetlb_range,