Received: by 2002:ab2:7041:0:b0:1f4:bcc8:f211 with SMTP id x1csp140381lql; Fri, 12 Apr 2024 06:19:59 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCV2IQmn4GVT/XhYhRjAuHgqWjshc8GoXq3MAvE1wXpaThjgZh3rhSmI0C43Hgey4NjCzkbMVivO2oHYpEp/ggXYxVmKZBtngFD+XIkG5g== X-Google-Smtp-Source: AGHT+IFzP4ucA6a+W3gA4dJtKtkWd9br/sWGUzSQRsao14giV57ksqOokuZVBSk+eYv1E2piMR2E X-Received: by 2002:ac8:5ac1:0:b0:434:68ad:bc6d with SMTP id d1-20020ac85ac1000000b0043468adbc6dmr3101914qtd.52.1712927999421; Fri, 12 Apr 2024 06:19:59 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1712927999; cv=pass; d=google.com; s=arc-20160816; b=BdsIW0rGwxL0/KonGZQuIzyPxkAL0uNykniXp59LgWO3Ufv2VyObo5HSEhA8ZSKF/C xdtUFnHZNSQrvR9M5eyXcXcg7m435t63ICasKQG2mM0PGuW1ASbXcaNboucE6UFL0ouc 6bsxtHWzlcghOKvDdGhsbTBNCYcsIbET/dksKYC8vGq+w8on6/c4i3QcrpRmhoVWR42Q ydpa6DJRKFFR6rGnuK8zU+4DVABBQmrsswq79nXfy1vZ3ROj2r0VoQJuL8Tw0yb5suFm NLXtjrCOMz3m4Y1i2x3P4xJhEcH1z36agKcPao4Ut1YeXT8ixoAMAUZq2OxwAMyJRV16 8Jjw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:message-id:date:subject:cc:to :from; bh=OpNzld7NXS2VaswWIDN9B4Loadh8NQY5Up4jtLxPrHQ=; fh=cUBUGupoZ3X2ahq2iHufaS2xvEmXEXz+/qGqVaLP5AU=; b=jV5GuyhZZ0vfTieM+1iGr1sNXE7PQKc5euoYJqiK0ThTB+OtHVifn2oB/Ziig2eLse J9wwSFbUxt6D9PPx6xDvZAU7LV4k8RNTr9d3P1+oDzMXdXWSPCLZoYkef7T+8G/kQckD IJor4LB+ONtIUWnZMGw69tktk4/CvDn6dc1KV6jonbwVEUuaCEju43p80JKzWm9J4D24 axTcDvt0WL5MvcCkBM749LqAaFrRd0eXH06itLE1XBY1HzPQKW8ERWAAncr70m5dW7/0 N2T4d7Y3X4AYYXyIKV03Wi3laVYURyTJ9whFrDgnn3ZljpkNllZtgQ2D76AWG66ISmMo QGXQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1 spf=pass spfdomain=arm.com dmarc=pass fromdomain=arm.com); spf=pass (google.com: domain of linux-kernel+bounces-142711-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-142711-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id v2-20020a05622a144200b004366ce6c2b8si1580845qtx.206.2024.04.12.06.19.59 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 12 Apr 2024 06:19:59 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-142711-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=arm.com dmarc=pass fromdomain=arm.com); spf=pass (google.com: domain of linux-kernel+bounces-142711-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-142711-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com 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 ny.mirrors.kernel.org (Postfix) with ESMTPS id 20E461C20E1B for ; Fri, 12 Apr 2024 13:19:59 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 70BAE824A5; Fri, 12 Apr 2024 13:19:22 +0000 (UTC) Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 67278824A0 for ; Fri, 12 Apr 2024 13:19:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.140.110.172 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712927961; cv=none; b=Pxswi36XTkUIdBL4SPyDuGtP2lRhO/j/kN9kYRyk0eosK9u1/kLHlJQ0cSzLnCHZGM4zU9t80s/0B0wRPQn294jqmqIcWWcdQhZvyMjSa9ZNvERU3BAKA4Ivk4usNjFFEnnj19wP3C+D1s6nz0gSQ87gQzGlGReCqveRjNwQc14= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712927961; c=relaxed/simple; bh=snRnpxvkyWnPsYC43Zoiypgop15LpRmxruQf/aQeNJs=; h=From:To:Cc:Subject:Date:Message-Id:MIME-Version; b=GSm1uM63vbo4c31Ok6jnq4SmG4Jl5OqXXpq8fNHTOFLUHFS6aGZKPgkMAfgPBkHPAe3AzhEA40jAOMkO5aQ27P6WFGn4R5rCTnfmEXJCQNZxTBNaPLlSFcH5+G1zB0QF5ZwgWscfyaDtvQdVggjVKuN0zBncAUePhH04uId6AdQ= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com; spf=pass smtp.mailfrom=arm.com; arc=none smtp.client-ip=217.140.110.172 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=arm.com Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id AF897339; Fri, 12 Apr 2024 06:19:47 -0700 (PDT) Received: from e125769.cambridge.arm.com (e125769.cambridge.arm.com [10.1.196.27]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 36B793F766; Fri, 12 Apr 2024 06:19:17 -0700 (PDT) From: Ryan Roberts To: Catalin Marinas , Will Deacon , Mark Rutland , Ard Biesheuvel , David Hildenbrand , Donald Dutile , Eric Chanudet Cc: Ryan Roberts , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH v3 0/3] Speed up boot with faster linear map creation Date: Fri, 12 Apr 2024 14:19:05 +0100 Message-Id: <20240412131908.433043-1-ryan.roberts@arm.com> X-Mailer: git-send-email 2.25.1 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Hi All, It turns out that creating the linear map can take a significant proportion of the total boot time, especially when rodata=full. And most of the time is spent waiting on superfluous tlb invalidation and memory barriers. This series reworks the kernel pgtable generation code to significantly reduce the number of those TLBIs, ISBs and DSBs. See each patch for details. The below shows the execution time of map_mem() across a couple of different systems with different RAM configurations. We measure after applying each patch and show the improvement relative to base (v6.9-rc2): | Apple M2 VM | Ampere Altra| Ampere Altra| Ampere Altra | VM, 16G | VM, 64G | VM, 256G | Metal, 512G ---------------|-------------|-------------|-------------|------------- | ms (%) | ms (%) | ms (%) | ms (%) ---------------|-------------|-------------|-------------|------------- base | 168 (0%) | 2198 (0%) | 8644 (0%) | 17447 (0%) no-cont-remap | 78 (-53%) | 435 (-80%) | 1723 (-80%) | 3779 (-78%) batch-barriers | 11 (-93%) | 161 (-93%) | 656 (-92%) | 1654 (-91%) no-alloc-remap | 10 (-94%) | 104 (-95%) | 438 (-95%) | 1223 (-93%) This series applies on top of v6.9-rc2. All mm selftests pass. I've compile and boot tested various PAGE_SIZE and VA size configs. --- Changes since v2 [2] ==================== - Independently increment ptep/pmdp in alloc_init_cont_[pte|pmd]() rather than return the incremented value from int_[pte|pmd]() (per Mark) - Removed explicit barriers from alloc_init_cont_pte() and instead rely on the barriers in pte_clear_fixmap() (per Mark) - Significantly simplify approach to avoiding fixmap during alloc (patch 3 reworked) (per Mark) - Dropped patch 4 - not possible with simplified patch 3 and improvement (~2%) didn't warrant complexity (per Mark) Changes since v1 [1] ==================== - Added Tested-by tags (thanks to Eric and Itaru) - Renamed ___set_pte() -> __set_pte_nosync() (per Ard) - Reordered patches (biggest impact & least controversial first) - Reordered alloc/map/unmap functions in mmu.c to aid reader - pte_clear() -> __pte_clear() in clear_fixmap_nosync() - Reverted generic p4d_index() which caused x86 build error. Replaced with unconditional p4d_index() define under arm64. [1] https://lore.kernel.org/linux-arm-kernel/20240326101448.3453626-1-ryan.roberts@arm.com/ [2] https://lore.kernel.org/linux-arm-kernel/20240404143308.2224141-1-ryan.roberts@arm.com/ Thanks, Ryan Ryan Roberts (3): arm64: mm: Don't remap pgtables per-cont(pte|pmd) block arm64: mm: Batch dsb and isb when populating pgtables arm64: mm: Don't remap pgtables for allocate vs populate arch/arm64/include/asm/pgtable.h | 9 ++- arch/arm64/mm/mmu.c | 101 +++++++++++++++++-------------- 2 files changed, 65 insertions(+), 45 deletions(-) -- 2.25.1