Received: by 2002:a05:6a10:17d3:0:0:0:0 with SMTP id hz19csp80954pxb; Thu, 15 Apr 2021 23:38:04 -0700 (PDT) X-Google-Smtp-Source: ABdhPJybSSn84WOna77oX3Tq+tFDxTpQ5LfJ+VLsiOw2M5aPXjQDBSvOS2N5nX+YrivRkVXu0h3p X-Received: by 2002:a17:906:f1d0:: with SMTP id gx16mr6999814ejb.340.1618555084677; Thu, 15 Apr 2021 23:38:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1618555084; cv=none; d=google.com; s=arc-20160816; b=lvbd8eC7ZkofMqaEXY+ikjyt9jasqiCXn4PqRs3n9Wv/8HmFJnoegFPJJr/rdHm/7x hhUiOrKuQmdoI61RQGLEMRaEWPt8F9kNGCvSRX7En9O32CqZnnZW2GdnQsDHLk5Yz1qG SWtWwzQHIu5nXDaHGph7F4qbLqwVJN1a93zV9b2Bamdc5JHA5XeUJARD0YbO63osFFnB bGA4nCqin+kcvj4Yl1gT8I2h/UVBEpwhYz8Jd8eWgCPoSMftRQXhUAgsKR9iqogMzsNL H05GCHhhcbQ9QKEmUuDwzQZfNtWdMUXlOtKqTugQ7gjz5YQUJcMiHSiw7+3phRu9oTwp gIvg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :in-reply-to:mime-version:user-agent:date:message-id:from:references :cc:to:subject; bh=A6KPRQGRVA4xNZXcXEz8s6U1mU+el1jbxaGJ0CBwm08=; b=VlGiL6UH1YLuZl5RZUmMqNUuEsKlzSqFxe/NwVhprxiJ8fi5kc7ggyrz8LiylXCIBp b4svG4ArpXAqlfO5JHMk4wwp31pS4FKaPcl4KfF9ZjQ+e3q9cfLylX3A5/kI//AZu/SB nTB4OkFUODvHJgDVe3YEQLCDOuhhydNjQhDRYWOtz+ZAHFKBd2OKCuzB2nb1X2UzbeLj 8cknRnrsOQlErCNeNGuwMX3yRhBHIILZseOKLGt/oAV7FHc1E63p5iSageWNNPj58hTw 6dsjMZrE0Wv+vPfgxTAo83Rm3GtSSm6ZR1+9gnibFDDw3bmhpKtC5B+Z9rdZkdTnHxTp S3FQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id fs20si3697438ejc.630.2021.04.15.23.37.39; Thu, 15 Apr 2021 23:38:04 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234969AbhDPF0E (ORCPT + 99 others); Fri, 16 Apr 2021 01:26:04 -0400 Received: from pegase1.c-s.fr ([93.17.236.30]:47140 "EHLO pegase1.c-s.fr" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229955AbhDPF0E (ORCPT ); Fri, 16 Apr 2021 01:26:04 -0400 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 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Daniel, Le 16/04/2021 à 01:29, Daniel Axtens a écrit : > Hi Christophe, > >> 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); > > 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 unnecessary impact on all architectures and would duplicate the re-calculation of the level whereas in most cases we get it for free from the caller. > > Kind regards, > Daniel > >> >> return 0; >> } >> -- >> 2.25.0