From patchwork Fri May 4 18:33:04 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Matthew Wilcox (Oracle)" X-Patchwork-Id: 10381359 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 4F01D60542 for ; Fri, 4 May 2018 18:59:06 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3EC292958D for ; Fri, 4 May 2018 18:59:06 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 338DE29597; Fri, 4 May 2018 18:59:06 +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 46E4429589 for ; Fri, 4 May 2018 18:59:04 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id BF2806B026A; Fri, 4 May 2018 14:33:24 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id BA5456B026C; Fri, 4 May 2018 14:33:24 -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 A43796B026B; Fri, 4 May 2018 14:33:24 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-pf0-f198.google.com (mail-pf0-f198.google.com [209.85.192.198]) by kanga.kvack.org (Postfix) with ESMTP id 61A476B0003 for ; Fri, 4 May 2018 14:33:24 -0400 (EDT) Received: by mail-pf0-f198.google.com with SMTP id l85so16154906pfb.18 for ; Fri, 04 May 2018 11:33: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=Eg1zr6bWU8fA+P/OQdItYS0BP3Xro99++zFSlQxEDlE=; b=uk3zGJzyfHWIjeR9KUz3LBHNuqmD35OA0uKVQmdAvcpXr0odGA5vQi9PCZ67hm0h+K /AVWGO+zyp2kkiKsHlGrIlvjtX1WFuxR2mGBt54SJtcH+glhsD+y+/nNIrRJq/Bq/wxe d/vw3ggZ+zKMZ/BxY2nLPwLcO2wc/DU8zzYrImRnbpEHyDdGrqSyj2osMjJtR2pLXORt RSGy5ISVDTXDLbBiK71uPs9EYRQlqt4KXKsapwcq/Igm/sLTPlfyPqW1kCnrUnWyoQxg mBhc1RSHlXzqRdlBAVDMa0BiFbtFWyk0paghjDzSEutHBgC6BKobOxRrHvmASZfL7Soi zt+g== X-Gm-Message-State: ALQs6tDaSQbEzj/aI4bBZApJKkK1y4hhMf7Zme0kStbCWwMPO26KflGv pYBBzBulkOk61vTBwJsPKVbzapb3LkofdCLYps/wciYkhdODTwOoZ2q173T2+wHSSQRDENrB/Q6 N6wvO4banpOWWsQ5xjejb9tIeQEM26GXEeNzP2nEunb2Am3Ur04W2ed28HmQxDdwFDw== X-Received: by 10.98.59.203 with SMTP id w72mr28015113pfj.129.1525458804065; Fri, 04 May 2018 11:33:24 -0700 (PDT) X-Google-Smtp-Source: AB8JxZpPOKHwYDZdjgF3vqel3vZqg7pZTDgE+59qzdFjImQKDyrTOfCUW5TaU0HmeMt4n3wzohio X-Received: by 10.98.59.203 with SMTP id w72mr28015050pfj.129.1525458802536; Fri, 04 May 2018 11:33:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1525458802; cv=none; d=google.com; s=arc-20160816; b=UZ+vNFLDgp5dFP6w4azIWjP/rCCqj3zWilMbTxiiNGFFtyHmRzIy2ovnkXNDDKiB2Y 9radjdtvKq8LQLol2GTQGFIBMZSD7+/3bjIRuFTcJw3sgwl3LGBZ/owrihP/XSmFYD63 d2aMFsp0n1I7dqMpt+OhPvjImxlEI7tmKVYye5bQfzQwEaO1sk/crTdzqclKkyba4fg8 hd7La6svHhRd+urJnt5kc0O2IkxoMsElMh3HvOyAmdIxiPkiUMDHW1GQIGtokxRXeXfL NxzCNBbht+PSwGjawASbTjzta0v7VhvZxvMjjzgLTeQmVWGSl+Cvt4uAZcPToWiXvZYc 5RGg== 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=Eg1zr6bWU8fA+P/OQdItYS0BP3Xro99++zFSlQxEDlE=; b=Snphsw/LudK9ugwrk3NNSjAcvYpvXHgyPA31cT0yX4K0MYtYTSyllHE+507+uj/vol GCR6Q3mvuN8T38GNe4RFhMZaZ4YGNCzkc3rwkncFRh4ZJvdDUQdqdq3Y4hx6jaSehF4T JbEP7wL4e+W/N596iAytSk6L7ltNwPmYFCqd4h3y3r6M2tJ1IyIJ0HUGQ7cdaw0WtAXI jyikj06ZJFQSu0RbhMo+GM8SLDZefkrzwOtgFAgPyykKkIofK1pMqtb2lHcJSNPTb5qO 65S0d5HsWVG5at5HpwoHzXq/V2jklm4vQrL6wZU6SCCw63i+cYOlb0niZx/gveCf7OSQ QeXg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=bombadil.20170209 header.b=udxVO9FL; 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 f5si11538473pfb.314.2018.05.04.11.33.22 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 04 May 2018 11:33:22 -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=udxVO9FL; 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=Eg1zr6bWU8fA+P/OQdItYS0BP3Xro99++zFSlQxEDlE=; b=udxVO9FLKOzCDEaFvlzMqSFrt cvAAIoD6GXU1jB/2R3cQ6I84wb+rKhaQNEKiNQ8p0FJGn6u8th5MNPgxTHfvyJML0Dh0IHomSvNlc Y4YuFaytHsdJT8Fgwiky48ahjgs9XZvOfkUaHO+jgLKd24dUwH6J2pu4zc4v4RKcI15yunpZ/LqfB 0mmHdLPIGeNquUZI2NwXc6l/pGDAw5flw15TxLZzI5h9CH48cwUXZnLo8yn+Vfg2nEtkgfB9RqUme 9l9uEomTXekCEg+S6irr1vvHJ3ovUGq1Pkqlc8LAwMRoHZIJzr6w/eu1nafDaJvql39/RyJzhVqIW x2iOeL1yg==; Received: from willy by bombadil.infradead.org with local (Exim 4.90_1 #2 (Red Hat Linux)) id 1fEfWC-0003lg-W5; Fri, 04 May 2018 18:33:20 +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 v5 03/17] mm: Mark pages in use for page tables Date: Fri, 4 May 2018 11:33:04 -0700 Message-Id: <20180504183318.14415-4-willy@infradead.org> X-Mailer: git-send-email 2.14.3 In-Reply-To: <20180504183318.14415-1-willy@infradead.org> References: <20180504183318.14415-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 974e8f8ffe03..5c6069219425 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",