From mboxrd@z Thu Jan 1 00:00:00 1970 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=-15.3 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,NICE_REPLY_A,SPF_HELO_NONE,SPF_PASS,USER_AGENT_SANE_1 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 15EAAC43460 for ; Fri, 16 Apr 2021 05:25:42 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id AE6A76113D for ; Fri, 16 Apr 2021 05:25:41 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org AE6A76113D 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 2B1A96B008A; Fri, 16 Apr 2021 01:25:41 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 2621A6B008C; Fri, 16 Apr 2021 01:25:41 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 103036B0092; Fri, 16 Apr 2021 01:25:41 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0050.hostedemail.com [216.40.44.50]) by kanga.kvack.org (Postfix) with ESMTP id E81066B008A for ; Fri, 16 Apr 2021 01:25:40 -0400 (EDT) Received: from smtpin11.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with ESMTP id A9D03182EFDCF for ; Fri, 16 Apr 2021 05:25:40 +0000 (UTC) X-FDA: 78037092840.11.B03CD64 Received: from pegase1.c-s.fr (pegase1.c-s.fr [93.17.236.30]) by imf24.hostedemail.com (Postfix) with ESMTP id 8A5F0A0000FF for ; Fri, 16 Apr 2021 05:25:33 +0000 (UTC) Received: from localhost (mailhub1-int [192.168.12.234]) by localhost (Postfix) with ESMTP id 4FM4Rj5BTJzB09bL; Fri, 16 Apr 2021 07:25:37 +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 IiPlMveTf2d4; Fri, 16 Apr 2021 07:25:37 +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 4FM4Rj3d6HzB09bK; Fri, 16 Apr 2021 07:25:37 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by messagerie.si.c-s.fr (Postfix) with ESMTP id 4E55D8B81C; Fri, 16 Apr 2021 07:25:38 +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 2-smQfjtxhxm; Fri, 16 Apr 2021 07:25:38 +0200 (CEST) Received: from [192.168.4.90] (unknown [192.168.4.90]) by messagerie.si.c-s.fr (Postfix) with ESMTP id 7F75E8B81A; Fri, 16 Apr 2021 07:25:37 +0200 (CEST) Subject: Re: [PATCH v1 4/5] mm: ptdump: Support hugepd table entries To: Daniel Axtens , Benjamin Herrenschmidt , Paul Mackerras , Michael Ellerman , Steven Price , akpm@linux-foundation.org Cc: linux-arch@vger.kernel.org, linux-s390@vger.kernel.org, x86@kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, linux-riscv@lists.infradead.org, linuxppc-dev@lists.ozlabs.org, linux-arm-kernel@lists.infradead.org References: <87zgxzyvn3.fsf@dja-thinkpad.axtens.net> From: Christophe Leroy Message-ID: <0e7b9312-888c-2e53-b7fd-a887fd9fb429@csgroup.eu> Date: Fri, 16 Apr 2021 07:25:36 +0200 User-Agent: Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:78.0) Gecko/20100101 Thunderbird/78.9.1 MIME-Version: 1.0 In-Reply-To: <87zgxzyvn3.fsf@dja-thinkpad.axtens.net> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: fr X-Rspamd-Server: rspam05 X-Rspamd-Queue-Id: 8A5F0A0000FF X-Stat-Signature: 66ddhojiqx9ubranu9rdfee4fi53wcz7 Received-SPF: none (csgroup.eu>: No applicable sender policy available) receiver=imf24; identity=mailfrom; envelope-from=""; helo=pegase1.c-s.fr; client-ip=93.17.236.30 X-HE-DKIM-Result: none/none X-HE-Tag: 1618550733-642845 Content-Transfer-Encoding: quoted-printable 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: Hi Daniel, Le 16/04/2021 =C3=A0 01:29, Daniel Axtens a =C3=A9crit=C2=A0: > Hi Christophe, >=20 >> 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 =3D walk->private; >> pte_t val =3D ptep_get(pte); >> + unsigned long page_size =3D next - addr; >> + int level; >> + >> + if (page_size >=3D PGDIR_SIZE) >> + level =3D 0; >> + else if (page_size >=3D P4D_SIZE) >> + level =3D 1; >> + else if (page_size >=3D PUD_SIZE) >> + level =3D 2; >> + else if (page_size >=3D PMD_SIZE) >> + level =3D 3; >> + else >> + level =3D 4; >> =20 >> if (st->effective_prot) >> - st->effective_prot(st, 4, pte_val(val)); >> + st->effective_prot(st, level, pte_val(val)); >> =20 >> - st->note_page(st, addr, 4, pte_val(val), PAGE_SIZE); >> + st->note_page(st, addr, level, pte_val(val), page_size); >=20 > It seems to me that passing both level and page_size is a bit redundant= , > but I guess it does reduce the impact on each arch's code? Exactly, as shown above, the level can be re-calculated based on the page= size, but it would be a=20 unnecessary impact on all architectures and would duplicate the re-calcul= ation of the level whereas=20 in most cases we get it for free from the caller. >=20 > Kind regards, > Daniel >=20 >> =20 >> return 0; >> } >> --=20 >> 2.25.0