From patchwork Fri May 18 19:45:05 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthew Wilcox X-Patchwork-Id: 10411969 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 5AD866031B for ; Fri, 18 May 2018 19:45:27 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 417DD286AA for ; Fri, 18 May 2018 19:45:27 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 32F4E289F0; Fri, 18 May 2018 19:45:27 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE,T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7AC2C286AA for ; Fri, 18 May 2018 19:45:26 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 4B5DF6B065F; Fri, 18 May 2018 15:45:25 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 44F7F6B0663; Fri, 18 May 2018 15:45:25 -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 240FD6B0662; Fri, 18 May 2018 15:45:25 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-pl0-f71.google.com (mail-pl0-f71.google.com [209.85.160.71]) by kanga.kvack.org (Postfix) with ESMTP id CEB3E6B065F for ; Fri, 18 May 2018 15:45:24 -0400 (EDT) Received: by mail-pl0-f71.google.com with SMTP id o23-v6so5575881pll.12 for ; Fri, 18 May 2018 12:45:24 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:dkim-signature:from:to:cc:subject:date :message-id:in-reply-to:references; bh=rRhQjijvGT+Nom4boZTNpbgU+TSdEorFgkf6u49Q1A8=; b=h6Z4QEVXiP4NuzjVB1qidW/wkDSGvcXsccpsooFyf+1C1AAXGJNevPgm5/W/x9KX6N wOcX6H7OOp+s0Gq86LMuwvJJPK70oN1onI8BH2NhhPmb3p4Vo2IQECjyJ2afJFHNKhbH NAHZimhJkHV8IXM0gNM+0xkBY57s6UHOWFAcNeD4VOhrQjpV4bBvUIZQ3b72u9pDS0fu uTuf5wVoeCgNmuDJJe3S+UHMjKedKj4JAXusFCUXlbKZQpMsZ8D0LO61fmoIvHr4euzM N3KkTRhcZXZhBawqNCHlhvOZQ7HJBEt7scSNYh1VgiA8B96W2GLmlGdzHReJf44tHeLn 92FA== X-Gm-Message-State: ALKqPwcUq2fTd63Ueb/daf65y3QCFgaugKnxpZULyD4srHWmNFwsdq4M bYoB30ErKJ48QOOmrZ0597rlrkIyECkg/jeAiY9F7K1oSfkuZTtmE4dZtGe8USQY7yjtQOBsPF6 vyzQx+ZJGlhYMeRwozJRLPLLQqupagXxZnlTvfgtvQtXl0LYQTkcHVf3Wgpnop16MoQ== X-Received: by 2002:a63:b307:: with SMTP id i7-v6mr8402330pgf.28.1526672724481; Fri, 18 May 2018 12:45:24 -0700 (PDT) X-Google-Smtp-Source: AB8JxZpTRG7h+YJijlv8sFcLIhSP3aGchzrvLVTOPckIBf0olG3xa9R1dqh2uU+M/XWbvFCr2Xki X-Received: by 2002:a63:b307:: with SMTP id i7-v6mr8402301pgf.28.1526672723483; Fri, 18 May 2018 12:45:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1526672723; cv=none; d=google.com; s=arc-20160816; b=nT3Q7kxF4Nd+5/8b/WMPnau9n/4m5Y9dR9eXM84r7aWLOEAhl2F3WjQrbcs3hDAT/c b7Wmz7nUTF8Jz+/hzUImSBskFYu70w8kabwu0gEpL6A58Y7H6EqbWlRYIey/ul4RmMSb 8CMwKu3iXUtP/zdPV7QOEM6MoAjOeeNiRjOZdsbZ7qVck6ry5P/IeJmLL/Rmj7eO5fcu K89WOfzBEqrEOVjXmA4Yrv1alOgy1JzniyYZZugdQxR7+pHjmHjxCS382+SIWtD5RdeB ACFvRApMM7gzkEQG+JLjZ1XToJozu8ikSePiBgUlg+5CsbkwTrcVpp2TmybQsAI0n8qH 8vtA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature:arc-authentication-results; bh=rRhQjijvGT+Nom4boZTNpbgU+TSdEorFgkf6u49Q1A8=; b=xeDkCQQATpYN90/bv/Gr6b3/Fd31H++rwYxfD3bXWeC0TwWd90+ekEoNmMJrAmSdOf 7D1RakJchlz0cfLWSEql8GJ5eUf9527ziEcb10qRfuakluXp3dXmPiNLkrAW/Y4Y8ANI nQMOylIUQaNlHO+1fRbJtwob0juirHqdXeN7R9p2UrGtsKjqHVyRHjOcxVgP+NPjVvHk md3KdED6LW2T5Y/SfwmgjMFIGHRS6e1HB+jypjOA+LJFKMcuf+sEZM6eQauQRJvuLljd oQuTMCVf7dscy00mBrLZkBJ1csJci+PVzVPSDDBzoHkdwP1CW+nHTTdrDYhvAjcmptge eYmA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=bombadil.20170209 header.b=Ix5ytZ9E; spf=pass (google.com: best guess record for domain of willy@infradead.org designates 2607:7c80:54:e::133 as permitted sender) smtp.mailfrom=willy@infradead.org Received: from bombadil.infradead.org (bombadil.infradead.org. [2607:7c80:54:e::133]) by mx.google.com with ESMTPS id u6-v6si8122009pls.462.2018.05.18.12.45.23 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 18 May 2018 12:45:23 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of willy@infradead.org designates 2607:7c80:54:e::133 as permitted sender) client-ip=2607:7c80:54:e::133; Authentication-Results: mx.google.com; dkim=pass header.i=@infradead.org header.s=bombadil.20170209 header.b=Ix5ytZ9E; spf=pass (google.com: best guess record for domain of willy@infradead.org designates 2607:7c80:54:e::133 as permitted sender) smtp.mailfrom=willy@infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20170209; h=References:In-Reply-To:Message-Id: Date:Subject:Cc:To:From:Sender:Reply-To:MIME-Version:Content-Type: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=rRhQjijvGT+Nom4boZTNpbgU+TSdEorFgkf6u49Q1A8=; b=Ix5ytZ9EoULOZ/Q/6aK6KfJC6 XI9OFprR68At3TFGx6qCXl1tBWCz4tVQfn1U+xXEeEB5Tm8VsxMV1kGBnJDzvh6zV7SpSHjZ7b46w R8FZ12UJfeku1RF9jOUo1AzJ2vxrv5WzindzYnHu4IRbgvGvPQiS3cFb6L5FtOOGNyKTvKo1RZLnd 6cITx+pToKlbeRjocE5PyKzMSXCxtcvpbmI8ao52ScRM/CPIMXjslGvc1wWZYArUjq3PxZ8hk5Hvh k2u9rYi0604YUQ7KpsahuZk2Z+DAdPCPE9qFLvurMjaMGzURpPeLlLMwQ5DzdcyRZe9BjXyhyy6ic RIDV5FTBA==; Received: from willy by bombadil.infradead.org with local (Exim 4.90_1 #2 (Red Hat Linux)) id 1fJlJa-00010f-5L; Fri, 18 May 2018 19:45:22 +0000 From: Matthew Wilcox To: linux-mm@kvack.org Cc: Matthew Wilcox , Andrew Morton , "Kirill A . Shutemov" , Christoph Lameter , Lai Jiangshan , Pekka Enberg , Vlastimil Babka , Dave Hansen , =?UTF-8?q?J=C3=A9r=C3=B4me=20Glisse?= Subject: [PATCH v6 03/17] mm: Mark pages in use for page tables Date: Fri, 18 May 2018 12:45:05 -0700 Message-Id: <20180518194519.3820-4-willy@infradead.org> X-Mailer: git-send-email 2.14.3 In-Reply-To: <20180518194519.3820-1-willy@infradead.org> References: <20180518194519.3820-1-willy@infradead.org> 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: X-Virus-Scanned: ClamAV using ClamSMTP From: Matthew Wilcox Define a new PageTable bit in the page_type and use it to mark pages in use as page tables. This can be helpful when debugging crashdumps or analysing memory fragmentation. Add a KPF flag to report these pages to userspace and update page-types.c to interpret that flag. Note that only pages currently accounted as NR_PAGETABLES are tracked as PageTable; this does not include pgd/p4d/pud/pmd pages. Those will be the subject of a later patch. Signed-off-by: Matthew Wilcox Acked-by: Kirill A. Shutemov Acked-by: Vlastimil Babka --- fs/proc/page.c | 2 ++ include/linux/mm.h | 2 ++ include/linux/page-flags.h | 6 ++++++ include/uapi/linux/kernel-page-flags.h | 2 +- tools/vm/page-types.c | 1 + 5 files changed, 12 insertions(+), 1 deletion(-) diff --git a/fs/proc/page.c b/fs/proc/page.c index 1491918a33c3..792c78a49174 100644 --- a/fs/proc/page.c +++ b/fs/proc/page.c @@ -154,6 +154,8 @@ u64 stable_page_flags(struct page *page) if (PageBalloon(page)) u |= 1 << KPF_BALLOON; + if (PageTable(page)) + u |= 1 << KPF_PGTABLE; if (page_is_idle(page)) u |= 1 << KPF_IDLE; diff --git a/include/linux/mm.h b/include/linux/mm.h index bd6588479d36..d4e9286a6402 100644 --- a/include/linux/mm.h +++ b/include/linux/mm.h @@ -1819,6 +1819,7 @@ static inline bool pgtable_page_ctor(struct page *page) { if (!ptlock_init(page)) return false; + __SetPageTable(page); inc_zone_page_state(page, NR_PAGETABLE); return true; } @@ -1826,6 +1827,7 @@ static inline bool pgtable_page_ctor(struct page *page) static inline void pgtable_page_dtor(struct page *page) { pte_lock_deinit(page); + __ClearPageTable(page); dec_zone_page_state(page, NR_PAGETABLE); } diff --git a/include/linux/page-flags.h b/include/linux/page-flags.h index 8c25b28a35aa..901943e4754b 100644 --- a/include/linux/page-flags.h +++ b/include/linux/page-flags.h @@ -655,6 +655,7 @@ PAGEFLAG_FALSE(DoubleMap) #define PG_buddy 0x00000080 #define PG_balloon 0x00000100 #define PG_kmemcg 0x00000200 +#define PG_table 0x00000400 #define PageType(page, flag) \ ((page->page_type & (PAGE_TYPE_BASE | flag)) == PAGE_TYPE_BASE) @@ -693,6 +694,11 @@ PAGE_TYPE_OPS(Balloon, balloon) */ PAGE_TYPE_OPS(Kmemcg, kmemcg) +/* + * Marks pages in use as page tables. + */ +PAGE_TYPE_OPS(Table, table) + extern bool is_free_buddy_page(struct page *page); __PAGEFLAG(Isolated, isolated, PF_ANY); diff --git a/include/uapi/linux/kernel-page-flags.h b/include/uapi/linux/kernel-page-flags.h index fa139841ec18..21b9113c69da 100644 --- a/include/uapi/linux/kernel-page-flags.h +++ b/include/uapi/linux/kernel-page-flags.h @@ -35,6 +35,6 @@ #define KPF_BALLOON 23 #define KPF_ZERO_PAGE 24 #define KPF_IDLE 25 - +#define KPF_PGTABLE 26 #endif /* _UAPILINUX_KERNEL_PAGE_FLAGS_H */ diff --git a/tools/vm/page-types.c b/tools/vm/page-types.c index a8783f48f77f..cce853dca691 100644 --- a/tools/vm/page-types.c +++ b/tools/vm/page-types.c @@ -131,6 +131,7 @@ static const char * const page_flag_names[] = { [KPF_KSM] = "x:ksm", [KPF_THP] = "t:thp", [KPF_BALLOON] = "o:balloon", + [KPF_PGTABLE] = "g:pgtable", [KPF_ZERO_PAGE] = "z:zero_page", [KPF_IDLE] = "i:idle_page",