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 2AB093803C5; Mon, 6 Apr 2026 14:21:32 +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=1775485292; cv=none; b=bam46cjPSdh8pzNa9WmcePytjI23f+1X9FWdiVaWCEF3gvDG+cvv5iOKHahrgilk9MhMQpAFOH4foGWAGvyag/Ptn5PgYbPFvMjsOLmjdqBfUI14RU4NyA7j/siyqLXnYFIuX68JAgfUD++qNEm/BdpxuzQY/np+O6uERH8aB5I= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775485292; c=relaxed/simple; bh=53qqY7PQB/uAj+zPP1JxuvnMAG3AtCcj7DDDSb0K5uw=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=hOMDNTQEjopHlZY1Qsz3LxJ+wzaNifiq3weWQNBlFgZgUjpFWLBHY8ZOrS1wPiXDIJ5VrzrAz3Jang3lgfRjts2v7l/+amseCgM3m7as9PxQuS88Pwlk/aAwxmBwOiX8X9/NnnFkOja3+Xz3/pVzjc/MXCqz6mCp+ku6ub86S2U= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=TAdJCPE9; 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="TAdJCPE9" Received: by smtp.kernel.org (Postfix) with ESMTPSA id C13EFC2BCB2; Mon, 6 Apr 2026 14:21:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1775485292; bh=53qqY7PQB/uAj+zPP1JxuvnMAG3AtCcj7DDDSb0K5uw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=TAdJCPE9O8ff2Xunk0iUh1hSJscOC/eHqdSPiWd7BoHpI6bwE61qLpf+8pUD36Skt /oYHytW5tcFZ/DpIjaukljiuLAmI1Wg/ugS7TFYC1FpaKXBrLlBxN1e8Ct0uPMh6GR lrvCUkD88cJ0NNMaT32kx7gYtTvXQ7NOUY3KXVMI/Dv/SFuf7DKY+f+s5KHj+morqF 8WKx4mzVHDOmhH55hMB4XTI65CsYhAQRbz46OHqvJGZ7dPYxqhp04NjeMRjCYVSyKU +7hcuINHOe674eEUMlXR+ewBIfct/CTF3w2OvQErftx8uuNzo9watAoW/TOfeUs31M IKeXmLQ582D9w== From: Mike Rapoport To: Andrew Morton , David Hildenbrand Cc: Baolin Wang , Barry Song , Dev Jain , Jason Gunthorpe , John Hubbard , "Liam R. Howlett" , Lance Yang , Leon Romanovsky , Lorenzo Stoakes , Mark Brown , Michal Hocko , Mike Rapoport , Nico Pache , Peter Xu , Ryan Roberts , Shuah Khan , Suren Baghdasaryan , Vlastimil Babka , Zi Yan , linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, linux-mm@kvack.org Subject: [PATCH 39/53] selftests/mm: hugetlb-mremap: add setup of HugeTLB pages Date: Mon, 6 Apr 2026 17:17:21 +0300 Message-ID: <20260406141735.2179309-40-rppt@kernel.org> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260406141735.2179309-1-rppt@kernel.org> References: <20260406141735.2179309-1-rppt@kernel.org> Precedence: bulk X-Mailing-List: linux-kselftest@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit From: "Mike Rapoport (Microsoft)" hugetlb-mremap test fails if there are no free huge pages prepared by a wrapper script. Add setup of HugeTLB pages to the test and make sure that the original settings are restored on the test exit. Signed-off-by: Mike Rapoport (Microsoft) --- tools/testing/selftests/mm/hugetlb-mremap.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/tools/testing/selftests/mm/hugetlb-mremap.c b/tools/testing/selftests/mm/hugetlb-mremap.c index 1c87c39780c5..09241a279ec2 100644 --- a/tools/testing/selftests/mm/hugetlb-mremap.c +++ b/tools/testing/selftests/mm/hugetlb-mremap.c @@ -26,6 +26,7 @@ #include #include "kselftest.h" #include "vm_util.h" +#include "hugepage_settings.h" #define DEFAULT_LENGTH_MB 10UL #define MB_TO_BYTES(x) (x * 1024 * 1024) @@ -108,8 +109,9 @@ static void register_region_with_uffd(char *addr, size_t len) int main(int argc, char *argv[]) { + unsigned long hugepage_size; + int ret = 0, fd, nr; size_t length = 0; - int ret = 0, fd; ksft_print_header(); ksft_set_plan(1); @@ -125,7 +127,14 @@ int main(int argc, char *argv[]) else length = DEFAULT_LENGTH_MB; + hugepage_size = default_huge_page_size(); length = MB_TO_BYTES(length); + length = (length + hugepage_size) & ~(hugepage_size - 1); + nr = length / hugepage_size; + + if (!hugetlb_setup_default(nr)) + ksft_exit_skip("Not enough huge pages\n"); + fd = memfd_create(argv[0], MFD_HUGETLB); if (fd < 0) ksft_exit_fail_msg("Open failed: %s\n", strerror(errno)); -- 2.53.0