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 4A08443C04C; Mon, 11 May 2026 16:33:25 +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=1778517205; cv=none; b=eMULy/JB5Kk+97mpzqh8NICLq1ax0ZQ0w2rVAZFI+wWS8Bi+USyT8m9C8kePbM8Cusd6vsXDY9zm3/+Yrkk+LfcfA3W0DuOAV0w+gzP8y4JahVF3ernt7ftnY1Qpq2ffvc1MU8WYrcmqSCs4ETj6rG9wHS8Phgi30gimHyOJzzE= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778517205; c=relaxed/simple; bh=VvPKft7e4UoRoweRQCK7NLFIkQJlSJ9NiMh48taBM8A=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Fp/VZsTORGRZTrvQBKVn6zFrBJuk3fzkTzIKgkogA4nQ4azWGiACuY+c2oFKKTxv/VsZx8nJBKiKqkvp7YxPIh5LfhFRB52Gg4Ly2bjndDrwSel9V5iiK6xfaHdAR/KKP9DyrrPDiB+QMs7exCPDDybiDGUyjg1cS2Wy6Q3psj4= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=k42HtboT; 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="k42HtboT" Received: by smtp.kernel.org (Postfix) with ESMTPSA id C9ED1C2BCB0; Mon, 11 May 2026 16:33:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1778517204; bh=VvPKft7e4UoRoweRQCK7NLFIkQJlSJ9NiMh48taBM8A=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=k42HtboTV8WAKRm3MxaH6S1Fe0FPHMkER5ce0wi0S+aT7ULqqZAz4NMQA1WDrjSK2 SvvFtQ702xMTDD/uAf969iyT0LGZEEmh9HydRh6VzswJQ4j2uX2wng1vRPDyUpZu2v A8oq6F9wNCzYg2P1BkL+mnL2XxTWivRWTo88zCh7RYPb55j+S0erpB597LyFGba2rY sDIyDl0Usd4fP1U7SBOV4c3tn7cJ93nJR+N9cq4W60YOGraMpIy4qwOUjUEoTu3Zgv iU51eq33HRgj0FYan7F6IB1NcN1YpTEOWc8qoVb/f5VJMGRZYAYOcXIk7ObOhfF5I3 bLuJMLVxPSHWg== From: Mike Rapoport To: Andrew Morton , David Hildenbrand Cc: Baolin Wang , Barry Song , Dev Jain , Donet Tom , Jason Gunthorpe , John Hubbard , "Liam R. Howlett" , Lance Yang , Li Wang , Leon Romanovsky , Lorenzo Stoakes , Luiz Capitulino , Mark Brown , Michal Hocko , Mike Rapoport , Nico Pache , Peter Xu , Ryan Roberts , Sarthak Sharma , Shuah Khan , Suren Baghdasaryan , Vlastimil Babka , Zi Yan , linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, linux-mm@kvack.org Subject: [PATCH v4 42/55] selftests/mm: hugetlb-shm: add setup of HugeTLB pages Date: Mon, 11 May 2026 19:28:26 +0300 Message-ID: <20260511162840.375890-43-rppt@kernel.org> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260511162840.375890-1-rppt@kernel.org> References: <20260511162840.375890-1-rppt@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 From: "Mike Rapoport (Microsoft)" hugetlb-shm test fails if there are no free huge pages prepared by a wrapper script and shm liimts in proc are too low. Add setup of HugeTLB pages and shm limits to the test and make sure that the original settings are restored on the test exit. Tested-by: Luiz Capitulino Tested-by: Sarthak Sharma Signed-off-by: Mike Rapoport (Microsoft) --- tools/testing/selftests/mm/hugetlb-shm.c | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/tools/testing/selftests/mm/hugetlb-shm.c b/tools/testing/selftests/mm/hugetlb-shm.c index c2c7aee85b96..3ff7f062b7eb 100644 --- a/tools/testing/selftests/mm/hugetlb-shm.c +++ b/tools/testing/selftests/mm/hugetlb-shm.c @@ -29,9 +29,27 @@ #include #include "vm_util.h" +#include "hugepage_settings.h" #define LENGTH (256UL*1024*1024) +static void prepare(void) +{ + unsigned long length, hugepage_size, nr; + + hugepage_size = default_huge_page_size(); + if (!hugepage_size) + ksft_exit_skip("Unable to determine huge page size\n"); + + length = (LENGTH + hugepage_size - 1) & ~(hugepage_size - 1); + nr = length / hugepage_size; + + if (!hugetlb_setup_default(nr)) + ksft_exit_skip("Not enough free huge pages\n"); + + shm_limits_prepare(length); +} + int main(void) { int shmid; @@ -41,6 +59,8 @@ int main(void) ksft_print_header(); ksft_set_plan(1); + prepare(); + shmid = shmget(2, LENGTH, SHM_HUGETLB | IPC_CREAT | SHM_R | SHM_W); if (shmid < 0) ksft_exit_fail_perror("shmget"); @@ -76,3 +96,5 @@ int main(void) ksft_test_result_pass("hugepage using SysV shmget/shmat\n"); ksft_finished(); } + +SHM_LIMITS_RESTORE() -- 2.53.0