Received: by 2002:ab2:6991:0:b0:1f2:fff1:ace7 with SMTP id v17csp142707lqo; Wed, 27 Mar 2024 09:02:20 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCW88JIFXQzF3yetoYjpGlRq/mzLpDeEzToCBIBE3vbaT3GuuTIc5QhoMh4xF2T28KfAoNIMJ2J0auL8rEoujpwkLrFyibrQ3JhMk5dc9Q== X-Google-Smtp-Source: AGHT+IFXjWf6sA8PFDF38yj37XzpqD/sbzcctt581GimSySoP5atyZt4iA7h+M2l/UFsFYTcVPHj X-Received: by 2002:a17:906:6d9:b0:a47:669:d0f2 with SMTP id v25-20020a17090606d900b00a470669d0f2mr1388831ejb.50.1711555338116; Wed, 27 Mar 2024 09:02:18 -0700 (PDT) Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id i16-20020a170906a29000b00a461a8f8beesi4719215ejz.978.2024.03.27.09.02.17 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 27 Mar 2024 09:02:18 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-121579-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@kernel.org header.s=k20201202 header.b=NZrQJifP; arc=fail (body hash mismatch); spf=pass (google.com: domain of linux-kernel+bounces-121579-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-121579-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id DC0931F34838 for ; Wed, 27 Mar 2024 15:58:26 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 3B57712EBD5; Wed, 27 Mar 2024 15:58:10 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="NZrQJifP" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 67C754F890 for ; Wed, 27 Mar 2024 15:58:09 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711555089; cv=none; b=bTzGGsdQj5Nh1IDtijLjPshC9C44NiCxh1AIysNPXcCFQo2DnDdgWMfNn9Fq5v5P8BdjHgB7gYzFMPpGvQbVE1PJMllJ0bFDpjCn4dlJUu2/7Xu2o55dyBvrV072AWRJXTKaSaL9t7gOdKpU/0uD5nhbCh0VLSiRYRJenfQWj2Q= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711555089; c=relaxed/simple; bh=HNMz2aWlmehG41cOCB1cvONMDtg23aN/Dbw96CBAx9A=; h=MIME-Version:References:In-Reply-To:From:Date:Message-ID:Subject: To:Cc:Content-Type; b=IfdiUevo0iAJGwEST6wfd/yAE3bpZfPoXT14tw9hVYvZnZ0skmLnkM5IIG5DkkoWSPjlCoZGJQhxbz0lPoBlD8OovJII9A5CB5fYMwt6mAi3vUVunwxUqy/TuSAxAOs9NOAKRomPKlSeLDjOGL1DdZNO1Fu1730pG+V4IQK3DeU= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=NZrQJifP; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 0639EC433F1 for ; Wed, 27 Mar 2024 15:58:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1711555089; bh=HNMz2aWlmehG41cOCB1cvONMDtg23aN/Dbw96CBAx9A=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=NZrQJifPMMyA5hKKh2Hcx2KLYYuoN3aDm6QSEyeDB1ejV87RlOVGLGpBQRwofEp/N +tu0Xx20i4GFn+2n3RD6tMPVl1MlPKgpBbNtKz4MjIvm4cxHP7nZc1F/eo776Fwu92 iVjw0N+VKKmGriQiKcC+r7m3m7VuzrB5Xxkcjy2QHXCFpLIJkUmwi6vXXppdP7cpIQ MxH804AdTe4RKY7YN3lxgO1PchQ6Po6SYWITYrDaY5q01htVPJwFg0HxI6bpxT8mqE P2cTPhXROouH1Doee82D8xPjUU+LSw5Cf4Tnf6NkEk2JAL675denshpeljWN3Cr/wJ SWl6Su/blIbXA== Received: by mail-lf1-f51.google.com with SMTP id 2adb3069b0e04-515b3077d09so2603105e87.1 for ; Wed, 27 Mar 2024 08:58:08 -0700 (PDT) X-Forwarded-Encrypted: i=1; AJvYcCVYoYgqybgsR7C1jVEs8nWH5HDvm4rbNV/njy52bS5Ex/ldlt1+m0JW+96WUZ/iD+vYRZ8gRN7HARKPIKi5vykRzDq4Q/LGlfvatUKA X-Gm-Message-State: AOJu0YzOu4m5AXO16bZfhaP+Yser3e+wVmWRqw9B1N3ZKtj5XmOhKl6o C84F0+7dil+FeBs8TOBAhKo0FCh3SvYvSK2DRMDvNkTXVtrt81w9O3s4+7qZbczATsd50Vno48N Fo1DAOLNCJWmVJCi5m6K7PLMHano= X-Received: by 2002:ac2:4d9a:0:b0:515:95cd:68a9 with SMTP id g26-20020ac24d9a000000b0051595cd68a9mr1435049lfe.24.1711555087376; Wed, 27 Mar 2024 08:58:07 -0700 (PDT) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 References: <20240326101448.3453626-1-ryan.roberts@arm.com> <7f69758c-b849-48ca-b279-569469183e91@arm.com> In-Reply-To: <7f69758c-b849-48ca-b279-569469183e91@arm.com> From: Ard Biesheuvel Date: Wed, 27 Mar 2024 17:57:55 +0200 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH v1 0/3] Speed up boot with faster linear map creation To: Ryan Roberts Cc: Catalin Marinas , Will Deacon , Mark Rutland , David Hildenbrand , Donald Dutile , Eric Chanudet , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Content-Type: text/plain; charset="UTF-8" On Wed, 27 Mar 2024 at 17:01, Ryan Roberts wrote: > > On 27/03/2024 13:36, Ard Biesheuvel wrote: > > On Wed, 27 Mar 2024 at 12:43, Ryan Roberts wrote: > >> > >> On 27/03/2024 10:09, Ard Biesheuvel wrote: .. > > > > I think a mix of the fixmap approach with a 1:1 map could work here: > > - use TTBR0 to create a temp 1:1 map of DRAM > > - map page tables lazily as they are allocated but using a coarse mapping > > - avoid all TLB maintenance except at the end when tearing down the 1:1 mapping. > > Yes that could work I think. So to make sure I've understood: > > - create a 1:1 map for all of DRAM using block and cont mappings where possible > - use memblock_phys_alloc_*() to allocate pgtable memory > - access via fixmap (should be minimal due to block mappings) Yes but you'd only need the fixmap for pages that are not in the 1:1 map yet, so after an initial ramp up you wouldn't need it at all, assuming locality of memblock allocations and the use of PMD mappings. The only tricky thing here is ensuring that we are not mapping memory that we shouldn't be touching. > - install it in TTBR0 > - create all the swapper mappings as normal (no block or cont mappings) > - use memblock_phys_alloc_*() to alloc pgtable memory > - phys address is also virtual address due to installed 1:1 map > - Remove 1:1 map from TTBR0 > - memblock_phys_free() all the memory associated with 1:1 map > Indeed. > That sounds doable on top of the first 2 patches in this series - I'll have a > crack. The only missing piece is depth-first 1:1 map traversal to free the > tables. I'm guessing something already exists that I can repurpose? > Not that I am aware of, but that doesn't sound too complicated.