From mboxrd@z Thu Jan 1 00:00:00 1970 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 7E2AE202C29 for ; Wed, 8 Apr 2026 02:51:39 +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=1775616699; cv=none; b=Wp3lhm2fYGfHCSOsD9GWuZNTLcdPU6vSGjk2Z8HlGIu35D8t6QpxtDe/7Y+5gb2jKIGZLPymFVhb2Ueffvs2s2sdshP8QyYXyKnIB8RUtkZHES9eW3vAQO8sli4zqGirWedI7Eil0PSvVEpC9ikzlVyT/8z7K49exCVwE2bWsfQ= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775616699; c=relaxed/simple; bh=WaU87kHk5fdaxiwAyibksVupa8Ba+++SUKhvjx8Yo4g=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=EXyFfYvx511ZXRW61ggozRBGUcmcmslWc01DGh5RpbFihtX0UM9dTlrTFipMwaIUhOvzdjqrESN7xg2aEtD4GuBZNdCKDSonDaxrFls7Rirj/lFS0mNhC4hGxpjZTNZjuNhG065pJpvC8LxFW1mLiyNe5VymIkcVPuY+vCMZ/OU= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=dx7NiL2d; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="dx7NiL2d" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 715D1C19424; Wed, 8 Apr 2026 02:51:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1775616699; bh=WaU87kHk5fdaxiwAyibksVupa8Ba+++SUKhvjx8Yo4g=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=dx7NiL2d22U6fw3kZORHXgxH7PInpyHrU15js7b2oe2n3ns+9bjxR6fCg5/6GWmbZ X100BzWea1lmMJjJ6MdI4MUdHcBeVF7B5uM/WEvWcCEm8BVy6Pbh1p/3A+RD0RPLyd ibBOiRdc68xmP+7tu0ifGfDelO2NXJ+pGkpj3oWQRlDQvP2UoUKzd/9deSD6GkZpfj CWHUftf54l4oWYzxj53bFKSLczJLFYUKvXew2QSbMul0LTXPMa71Mw+zyAJ6cgsVd6 2i+tgpHiraeRUGyW7OH5pBqjXSAwzzFJJYGcfEpN75VTBYNu2rwUlTiNTjPq/GQsBi vAmBHA+W6YXnA== From: "Barry Song (Xiaomi)" To: linux-mm@kvack.org, linux-arm-kernel@lists.infradead.org, catalin.marinas@arm.com, will@kernel.org, akpm@linux-foundation.org, urezki@gmail.com Cc: linux-kernel@vger.kernel.org, anshuman.khandual@arm.com, ryan.roberts@arm.com, ajd@linux.ibm.com, rppt@kernel.org, david@kernel.org, Xueyuan.chen21@gmail.com, "Barry Song (Xiaomi)" Subject: [RFC PATCH 2/8] arm64/vmalloc: Allow arch_vmap_pte_range_map_size to batch multiple CONT_PTE Date: Wed, 8 Apr 2026 10:51:09 +0800 Message-Id: <20260408025115.27368-3-baohua@kernel.org> X-Mailer: git-send-email 2.39.3 (Apple Git-146) In-Reply-To: <20260408025115.27368-1-baohua@kernel.org> References: <20260408025115.27368-1-baohua@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Allow arch_vmap_pte_range_map_size to batch multiple CONT_PTE hugepages, reducing both PTE setup and TLB flush iterations. Signed-off-by: Barry Song (Xiaomi) --- arch/arm64/include/asm/vmalloc.h | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/arch/arm64/include/asm/vmalloc.h b/arch/arm64/include/asm/vmalloc.h index 4ec1acd3c1b3..9eea06d0f75d 100644 --- a/arch/arm64/include/asm/vmalloc.h +++ b/arch/arm64/include/asm/vmalloc.h @@ -23,6 +23,8 @@ static inline unsigned long arch_vmap_pte_range_map_size(unsigned long addr, unsigned long end, u64 pfn, unsigned int max_page_shift) { + unsigned long size; + /* * If the block is at least CONT_PTE_SIZE in size, and is naturally * aligned in both virtual and physical space, then we can pte-map the @@ -40,7 +42,9 @@ static inline unsigned long arch_vmap_pte_range_map_size(unsigned long addr, if (!IS_ALIGNED(PFN_PHYS(pfn), CONT_PTE_SIZE)) return PAGE_SIZE; - return CONT_PTE_SIZE; + size = min3(end - addr, 1UL << max_page_shift, PMD_SIZE >> 1); + size = 1UL << (fls(size) - 1); + return size; } #define arch_vmap_pte_range_unmap_size arch_vmap_pte_range_unmap_size -- 2.39.3 (Apple Git-146)