Received: by 2002:a25:6193:0:0:0:0:0 with SMTP id v141csp4019839ybb; Mon, 6 Apr 2020 22:13:17 -0700 (PDT) X-Google-Smtp-Source: APiQypJFEZxr69aRExd4SJVUWsPgaGFzeNBf6vhEqk2XuSM3rGg42u75Q9451CLxgFfISpluXb0L X-Received: by 2002:aca:c45:: with SMTP id i5mr381997oiy.101.1586236397617; Mon, 06 Apr 2020 22:13:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1586236397; cv=none; d=google.com; s=arc-20160816; b=IMzCqTfOMZwfcOUWA/nMhFtYoUIjejmsd0U5vKtVgIwfCPYYLTNrZyUU8J4yzC9k4C p0PD45lN6U+Ay9H/5V1fOXmFhdw6McIe4xrPkUC60BU8E0LYdzYkYzLuAxFwn4xpbQ5x 5afRjAWa2AIksxWJkYlgbJgq8gpcXir1fjbDNMxIjhULKZ4S8LGVIuK52qEiiZr9MGL2 PQjwDkYO59Eh22STk9ZLt6z8MGSKYZH4+vuzMy2033S4DSCtQZOTkDMAqjcgapkJd61A t6rmzfWPl6Vq84rtKmA/JIxYDDhyu3dc7g5orYOqUpdN1VX0QqH5KJ+wRyo63ZkSaGpT jQlA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:references:cc:to:subject:from; bh=eh+Ragx6cMrdIV92NsdyArN/rHbCMJQopzJN4+wc1gw=; b=qKzGn8aP+1q0whqZaXO8Ej34BGhHpEtKbxTmBjvJQoWy8uvDhVz5PyuV6olbJ2l+bg RY/FNVwo2TJmNz9uqwfscKbNtWLiP1Sq6iZr0uR9puorCfdUHnJTUx0H5UkTodo6FHtA VkZQv1kTm75gJ7rtfs9HqNjsN+o5S1c6mwJQYfpbtC4dDCzt1CafpmE9xMVPINXQyfBW 0vQIPldNvv7x/rs2tTVJIgp3srLEDj5df0KBpxBBf4+AFqS2HBHWKtyhqt6C0fkACkmI And9ZcZmRXHVK/P1M9VbkOhZgF0TLcRNMmzX9vrqbFRICGfoEpr5Q+RxAaJOy5ztWTfx pIZQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id z24si645215ool.40.2020.04.06.22.13.05; Mon, 06 Apr 2020 22:13:17 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726716AbgDGFMS (ORCPT + 99 others); Tue, 7 Apr 2020 01:12:18 -0400 Received: from relay7-d.mail.gandi.net ([217.70.183.200]:44873 "EHLO relay7-d.mail.gandi.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726232AbgDGFMS (ORCPT ); Tue, 7 Apr 2020 01:12:18 -0400 X-Originating-IP: 2.7.45.25 Received: from [192.168.1.101] (lfbn-lyo-1-453-25.w2-7.abo.wanadoo.fr [2.7.45.25]) (Authenticated sender: alex@ghiti.fr) by relay7-d.mail.gandi.net (Postfix) with ESMTPSA id BDA4920007; Tue, 7 Apr 2020 05:12:15 +0000 (UTC) From: Alex Ghiti Subject: Re: [RFC PATCH 1/7] riscv: Get rid of compile time logic with MAX_EARLY_MAPPING_SIZE To: Palmer Dabbelt Cc: anup@brainfault.org, linux-kernel@vger.kernel.org, zong.li@sifive.com, Paul Walmsley , linux-riscv@lists.infradead.org, Christoph Hellwig References: Message-ID: Date: Tue, 7 Apr 2020 01:12:15 -0400 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.3.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 4/3/20 11:17 AM, Palmer Dabbelt wrote: > On Sun, 22 Mar 2020 04:00:22 PDT (-0700), alex@ghiti.fr wrote: >> There is no need to compare at compile time MAX_EARLY_MAPPING_SIZE value >> with PGDIR_SIZE since MAX_EARLY_MAPPING_SIZE is set to 128MB which is >> less >> than PGDIR_SIZE that is equal to 1GB: that allows to simplify early_pmd >> definition. >> >> Signed-off-by: Alexandre Ghiti >> --- >>  arch/riscv/mm/init.c | 16 ++++------------ >>  1 file changed, 4 insertions(+), 12 deletions(-) >> >> diff --git a/arch/riscv/mm/init.c b/arch/riscv/mm/init.c >> index 238bd0033c3f..18bbb426848e 100644 >> --- a/arch/riscv/mm/init.c >> +++ b/arch/riscv/mm/init.c >> @@ -247,13 +247,7 @@ static void __init create_pte_mapping(pte_t *ptep, >> >>  pmd_t trampoline_pmd[PTRS_PER_PMD] __page_aligned_bss; >>  pmd_t fixmap_pmd[PTRS_PER_PMD] __page_aligned_bss; >> - >> -#if MAX_EARLY_MAPPING_SIZE < PGDIR_SIZE >> -#define NUM_EARLY_PMDS        1UL >> -#else >> -#define NUM_EARLY_PMDS        (1UL + MAX_EARLY_MAPPING_SIZE / >> PGDIR_SIZE) >> -#endif >> -pmd_t early_pmd[PTRS_PER_PMD * NUM_EARLY_PMDS] __initdata >> __aligned(PAGE_SIZE); >> +pmd_t early_pmd[PTRS_PER_PMD] __initdata __aligned(PAGE_SIZE); >> >>  static pmd_t *__init get_pmd_virt(phys_addr_t pa) >>  { >> @@ -267,14 +261,12 @@ static pmd_t *__init get_pmd_virt(phys_addr_t pa) >> >>  static phys_addr_t __init alloc_pmd(uintptr_t va) >>  { >> -    uintptr_t pmd_num; >> - >>      if (mmu_enabled) >>          return memblock_phys_alloc(PAGE_SIZE, PAGE_SIZE); >> >> -    pmd_num = (va - PAGE_OFFSET) >> PGDIR_SHIFT; >> -    BUG_ON(pmd_num >= NUM_EARLY_PMDS); >> -    return (uintptr_t)&early_pmd[pmd_num * PTRS_PER_PMD]; >> +    BUG_ON((va - PAGE_OFFSET) >> PGDIR_SHIFT); >> + >> +    return (uintptr_t)early_pmd; >>  } >> >>  static void __init create_pmd_mapping(pmd_t *pmdp, > > My specific worry here was that allyesconfig kernels are quite large, > and that > dropping the code to handle large kernels would make it even harder to boot > them.  That said, I can't actually get one to boot so I'm happy to just > push > that off until later and drop the code we can't practically use. > > Reviewed-by: Palmer Dabbelt > > Thanks! > Thanks, Alex