From patchwork Thu Apr 15 17:18:17 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christophe Leroy X-Patchwork-Id: 12205855 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=-13.8 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,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 52B6EC433B4 for ; Thu, 15 Apr 2021 17:18:25 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id E25F76117A for ; Thu, 15 Apr 2021 17:18:24 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org E25F76117A Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=csgroup.eu Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 5C4D16B0072; Thu, 15 Apr 2021 13:18:20 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 552FA6B0073; Thu, 15 Apr 2021 13:18:20 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 418776B0074; Thu, 15 Apr 2021 13:18:20 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0090.hostedemail.com [216.40.44.90]) by kanga.kvack.org (Postfix) with ESMTP id 106A26B0073 for ; Thu, 15 Apr 2021 13:18:20 -0400 (EDT) Received: from smtpin17.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id C62A75847 for ; Thu, 15 Apr 2021 17:18:19 +0000 (UTC) X-FDA: 78035259918.17.0281433 Received: from pegase1.c-s.fr (pegase1.c-s.fr [93.17.236.30]) by imf14.hostedemail.com (Postfix) with ESMTP id D91C2C0007D7 for ; Thu, 15 Apr 2021 17:18:10 +0000 (UTC) Received: from localhost (mailhub1-int [192.168.12.234]) by localhost (Postfix) with ESMTP id 4FLmJV2HD4z9twp2; Thu, 15 Apr 2021 19:18:18 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at c-s.fr Received: from pegase1.c-s.fr ([192.168.12.234]) by localhost (pegase1.c-s.fr [192.168.12.234]) (amavisd-new, port 10024) with ESMTP id sbTtLwb0wT4h; Thu, 15 Apr 2021 19:18:18 +0200 (CEST) Received: from messagerie.si.c-s.fr (messagerie.si.c-s.fr [192.168.25.192]) by pegase1.c-s.fr (Postfix) with ESMTP id 4FLmJV1TDDz9twp0; Thu, 15 Apr 2021 19:18:18 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by messagerie.si.c-s.fr (Postfix) with ESMTP id 080EE8B805; Thu, 15 Apr 2021 19:18:18 +0200 (CEST) X-Virus-Scanned: amavisd-new at c-s.fr Received: from messagerie.si.c-s.fr ([127.0.0.1]) by localhost (messagerie.si.c-s.fr [127.0.0.1]) (amavisd-new, port 10023) with ESMTP id 0MknObgQkv_3; Thu, 15 Apr 2021 19:18:17 +0200 (CEST) Received: from po16121vm.idsi0.si.c-s.fr (unknown [192.168.4.90]) by messagerie.si.c-s.fr (Postfix) with ESMTP id B838C8B7F6; Thu, 15 Apr 2021 19:18:17 +0200 (CEST) Received: by po16121vm.idsi0.si.c-s.fr (Postfix, from userid 0) id 96B23679F6; Thu, 15 Apr 2021 17:18:17 +0000 (UTC) Message-Id: In-Reply-To: References: From: Christophe Leroy Subject: [PATCH v1 4/5] mm: ptdump: Support hugepd table entries To: Benjamin Herrenschmidt , Paul Mackerras , Michael Ellerman , Steven Price , akpm@linux-foundation.org Cc: linux-arch@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-kernel@vger.kernel.org, linux-s390@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-riscv@lists.infradead.org, x86@kernel.org, linux-mm@kvack.org Date: Thu, 15 Apr 2021 17:18:17 +0000 (UTC) X-Rspamd-Server: rspam01 X-Rspamd-Queue-Id: D91C2C0007D7 X-Stat-Signature: 79fx517hbwdymyo47y7j7bhmhnpzmhhs Received-SPF: none (csgroup.eu>: No applicable sender policy available) receiver=imf14; identity=mailfrom; envelope-from=""; helo=pegase1.c-s.fr; client-ip=93.17.236.30 X-HE-DKIM-Result: none/none X-HE-Tag: 1618507090-219964 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: Which hugepd, page table entries can be at any level and can be of any size. Add support for them. Signed-off-by: Christophe Leroy --- mm/ptdump.c | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/mm/ptdump.c b/mm/ptdump.c index 61cd16afb1c8..6efdb8c15a7d 100644 --- a/mm/ptdump.c +++ b/mm/ptdump.c @@ -112,11 +112,24 @@ static int ptdump_pte_entry(pte_t *pte, unsigned long addr, { struct ptdump_state *st = walk->private; pte_t val = ptep_get(pte); + unsigned long page_size = next - addr; + int level; + + if (page_size >= PGDIR_SIZE) + level = 0; + else if (page_size >= P4D_SIZE) + level = 1; + else if (page_size >= PUD_SIZE) + level = 2; + else if (page_size >= PMD_SIZE) + level = 3; + else + level = 4; if (st->effective_prot) - st->effective_prot(st, 4, pte_val(val)); + st->effective_prot(st, level, pte_val(val)); - st->note_page(st, addr, 4, pte_val(val), PAGE_SIZE); + st->note_page(st, addr, level, pte_val(val), page_size); return 0; }