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 8724F4D90B5 for ; Mon, 11 May 2026 21:35:57 +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=1778535357; cv=none; b=rrzPBbvz7KagDRNaRdcKLezQIrlcZYV8qOaHIJ97lQCdEzaVtDYdoTqWqN7qot9ID6ONgTe7NtCdKhOyJ4G3eRCiZ5mQ1ToZP1SfySaMqpS0LhZMM439SkSRY5F7ZJL298GpwCm0zEoVbZLiAxdspMSgaHuDD37U/nNVjxc2byc= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778535357; c=relaxed/simple; bh=I8fQz8UVY+9a4lXsg8X3dvYSD+ikOlE9oGG4k+9ty2k=; h=Date:To:From:Subject:Message-Id; b=slHoQO/KUgsC7hp/EbeDkJzIUM7EeUQbqsP0Anlu11Dw4VIj8Cu+L9j2ZfYfdeLPdMJVkLXzkb8xxUca1lBKSio2vYkAhSbK7je7kjsLbYIRzjvOSGQvLAO71j7aAwcKDYbf9JCwz+2moH6RprHBg8hnoRdwfJL40fMoYIW1HR8= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux-foundation.org header.i=@linux-foundation.org header.b=1pYk+m2D; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux-foundation.org header.i=@linux-foundation.org header.b="1pYk+m2D" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 60EC3C2BCF5; Mon, 11 May 2026 21:35:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linux-foundation.org; s=korg; t=1778535357; bh=I8fQz8UVY+9a4lXsg8X3dvYSD+ikOlE9oGG4k+9ty2k=; h=Date:To:From:Subject:From; b=1pYk+m2DCheQHpxX90ty91U+avTjr3/tqFAnDM6wzwzJ5g8dcSdWsNF23sgjHMVJe K3ylqsWPJQdgurc/ol99upCfOlgXLhCE4yS2QY0Z955nFhbpYNWvWQMMlvEmHcIDks UZPuHn3XOByLPzxjMO+Ab+KNV1LFH/f0VhViQ0So= Date: Mon, 11 May 2026 14:35:56 -0700 To: mm-commits@vger.kernel.org,rppt@kernel.org,akpm@linux-foundation.org From: Andrew Morton Subject: + selftests-mm-protection_keys-use-library-code-for-hugetlb-setup.patch added to mm-new branch Message-Id: <20260511213557.60EC3C2BCF5@smtp.kernel.org> Precedence: bulk X-Mailing-List: mm-commits@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: The patch titled Subject: selftests/mm: protection_keys: use library code for HugeTLB setup has been added to the -mm mm-new branch. Its filename is selftests-mm-protection_keys-use-library-code-for-hugetlb-setup.patch This patch will shortly appear at https://git.kernel.org/pub/scm/linux/kernel/git/akpm/25-new.git/tree/patches/selftests-mm-protection_keys-use-library-code-for-hugetlb-setup.patch This patch will later appear in the mm-new branch at git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm Note, mm-new is a provisional staging ground for work-in-progress patches, and acceptance into mm-new is a notification for others take notice and to finish up reviews. Please do not hesitate to respond to review feedback and post updated versions to replace or incrementally fixup patches in mm-new. The mm-new branch of mm.git is not included in linux-next If a few days of testing in mm-new is successful, the patch will me moved into mm.git's mm-unstable branch, which is included in linux-next Before you just go and hit "reply", please: a) Consider who else should be cc'ed b) Prefer to cc a suitable mailing list as well c) Ideally: find the original patch on the mailing list and do a reply-to-all to that, adding suitable additional cc's *** Remember to use Documentation/process/submit-checklist.rst when testing your code *** The -mm tree is included into linux-next via various branches at git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm and is updated there most days ------------------------------------------------------ From: "Mike Rapoport (Microsoft)" Subject: selftests/mm: protection_keys: use library code for HugeTLB setup Date: Mon, 11 May 2026 19:28:31 +0300 protection_keys open codes setup of HugeTLB pages. Replace it with the library functions from hugepage_setup. Replace exit() calls with _exit() to avoid restoring HugeTLB settings in the middle of test. Link: https://lore.kernel.org/20260511162840.375890-48-rppt@kernel.org Signed-off-by: Mike Rapoport (Microsoft) Tested-by: Luiz Capitulino Cc: Baolin Wang Cc: Barry Song Cc: David Hildenbrand Cc: Dev Jain Cc: Donet Tom Cc: Jason Gunthorpe Cc: John Hubbard Cc: Lance Yang Cc: Leon Romanovsky Cc: Liam Howlett Cc: Li Wang Cc: Lorenzo Stoakes Cc: Mark Brown Cc: Michal Hocko Cc: Nico Pache Cc: Peter Xu Cc: Ryan Roberts Cc: Sarthak Sharma Cc: Shuah Khan Cc: Suren Baghdasaryan Cc: Vlastimil Babka Cc: Zi Yan Signed-off-by: Andrew Morton --- tools/testing/selftests/mm/protection_keys.c | 50 ++++------------- 1 file changed, 14 insertions(+), 36 deletions(-) --- a/tools/testing/selftests/mm/protection_keys.c~selftests-mm-protection_keys-use-library-code-for-hugetlb-setup +++ a/tools/testing/selftests/mm/protection_keys.c @@ -62,6 +62,7 @@ noinline int read_ptr(int *ptr) return *ptr; } +#if CONTROL_TRACING > 0 static void cat_into_file(char *str, char *file) { int fd = open(file, O_RDWR); @@ -87,7 +88,6 @@ static void cat_into_file(char *str, cha close(fd); } -#if CONTROL_TRACING > 0 static int warned_tracing; static int tracing_root_ok(void) { @@ -710,50 +710,28 @@ static void *malloc_pkey_anon_huge(long } static int hugetlb_setup_ok; -#define SYSFS_FMT_NR_HUGE_PAGES "/sys/kernel/mm/hugepages/hugepages-%ldkB/nr_hugepages" #define GET_NR_HUGE_PAGES 10 static void setup_hugetlbfs(void) { - int err; - int fd; - char buf[256]; - long hpagesz_kb; - long hpagesz_mb; + long hpagesz_mb = HPAGE_SIZE / 1024 / 1024; + unsigned long free_pages; if (geteuid() != 0) { ksft_print_msg("WARNING: not run as root, can not do hugetlb test\n"); return; } - cat_into_file(__stringify(GET_NR_HUGE_PAGES), "/proc/sys/vm/nr_hugepages"); - /* - * Now go make sure that we got the pages and that they + * Make sure that we got the pages and that they * are PMD-level pages. Someone might have made PUD-level * pages the default. */ - hpagesz_kb = HPAGE_SIZE / 1024; - hpagesz_mb = hpagesz_kb / 1024; - sprintf(buf, SYSFS_FMT_NR_HUGE_PAGES, hpagesz_kb); - fd = open(buf, O_RDONLY); - if (fd < 0) { - fprintf(stderr, "opening sysfs %ldM hugetlb config: %s\n", - hpagesz_mb, strerror(errno)); - return; - } - - /* -1 to guarantee leaving the trailing \0 */ - err = read(fd, buf, sizeof(buf)-1); - close(fd); - if (err <= 0) { - fprintf(stderr, "reading sysfs %ldM hugetlb config: %s\n", - hpagesz_mb, strerror(errno)); - return; - } - - if (atoi(buf) != GET_NR_HUGE_PAGES) { - fprintf(stderr, "could not confirm %ldM pages, got: '%s' expected %d\n", - hpagesz_mb, buf, GET_NR_HUGE_PAGES); + hugetlb_save_settings(); + hugetlb_set_nr_pages(HPAGE_SIZE, GET_NR_HUGE_PAGES); + free_pages = hugetlb_free_pages(HPAGE_SIZE); + if (free_pages < GET_NR_HUGE_PAGES) { + ksft_print_msg("could not confirm %ldM pages, got: '%lu' expected %d\n", + hpagesz_mb, free_pages, GET_NR_HUGE_PAGES); return; } @@ -1130,7 +1108,7 @@ static void become_child(void) /* in the child */ return; } - exit(0); + _exit(0); } /* Assumes that all pkeys other than 'pkey' are unallocated */ @@ -1509,18 +1487,18 @@ static void test_ptrace_modifies_pkru(in * checking */ if (__read_pkey_reg() != new_pkru) - exit(1); + _exit(1); /* Stop and allow the tracer to clear XSTATE_BV for PKRU */ raise(SIGSTOP); if (__read_pkey_reg() != 0) - exit(1); + _exit(1); /* Stop and allow the tracer to examine PKRU */ raise(SIGSTOP); - exit(0); + _exit(0); } pkey_assert(child == waitpid(child, &status, 0)); _ Patches currently in -mm which might be from rppt@kernel.org are maintainers-add-tree-for-kdump-and-kexec.patch maintainers-add-kexec-list-to-live-update-entry.patch sh-fix-fallout-from-zero_page-consolidation.patch selftests-mm-hugetlb-read-hwpoison-add-sigbus-handler.patch selftests-mm-migration-dont-assume-huge-page-is-twomeg.patch selftests-mm-migration-make-nthreads-represent-number-of-working-threads.patch selftests-mm-migration-properly-cleanup-forked-processes.patch selftests-mm-run_vmtestssh-dont-gate-thp-and-ksm-tests-on-have_hugepages.patch selftests-mm-merge-map_hugetlb-into-hugepage-mmap.patch selftests-mm-rename-hugepage-tests-to-hugetlb.patch selftests-mm-hugetlb-shm-use-kselftest-framework.patch selftests-mm-hugetlb-vmemmap-use-kselftest-framework.patch selftests-mm-hugetlb-madvise-use-kselftest-framework.patch selftests-mm-hugetlb_madv_vs_map-use-kselftest-framework.patch selftests-mm-hugetlb-read-hwpoison-use-kselftest-framework.patch selftests-mm-khugepaged-group-tests-in-an-array.patch selftests-mm-khugepaged-use-ksefltest-framework.patch selftests-mm-ksm_tests-use-kselftest-framework.patch selftests-mm-protection_keys-use-descriptive-test-names-in-the-output.patch selftests-mm-protection_keys-use-kselftest-framework.patch selftests-mm-uffd-common-use-kselftest-framework.patch selftests-mm-uffd-stress-use-kselftest-framework.patch selftests-mm-uffd-unit-tests-use-kselftest-framework.patch selftests-mm-va_high_addr_switch-use-kselftest-framework.patch selftests-mm-add-atexit-and-signal-handlers-to-thp_settings.patch selftests-mm-rename-thp_settings-to-hugepage_settings.patch selftests-mm-move-hugetlb-helpers-to-hugepage_settings.patch selftests-mm-hugepage_settings-use-unsigned-long-in-detect_hugetlb_page_size.patch selftests-mm-hugepage_settings-add-apis-to-get-and-set-nr_hugepages.patch selftests-mm-hugepage_settings-rename-and-rework-get_free_hugepages.patch selftests-mm-hugepage_settings-add-apis-for-hugetlb-setup-and-teardown.patch selftests-mm-move-read_file-read_num-and-write_num-to-vm_util.patch selftests-mm-vm_util-add-helpers-to-set-and-restore-shm-limits.patch selftests-mm-compaction_test-use-hugetlb-helpers.patch selftests-mm-cow-add-setup-of-hugetlb-pages.patch selftests-mm-gup_longterm-add-setup-of-hugetlb-pages.patch selftests-mm-gup_test-add-setup-of-hugetlb-pages.patch selftests-mm-hmm-tests-add-setup-of-hugetlb-pages.patch selftests-mm-hugepage_dio-add-setup-of-hugetlb-pages.patch selftests-mm-hugetlb_fault_after_madv-add-setup-of-hugetlb-pages.patch selftests-mm-hugetlb-madvise-add-setup-of-hugetlb-pages.patch selftests-mm-hugetlb_madv_vs_map-add-setup-of-hugetlb-pages.patch selftests-mm-hugetlb-mmap-add-setup-of-hugetlb-pages.patch selftests-mm-hugetlb-mremap-add-setup-of-hugetlb-pages.patch selftests-mm-hugetlb-shm-add-setup-of-hugetlb-pages.patch selftests-mm-hugetlb-soft-offline-add-setup-of-hugetlb-pages.patch selftests-mm-hugetlb-vmemmap-add-setup-of-hugetlb-pages.patch selftests-mm-migration-add-setup-of-hugetlb-pages.patch selftests-mm-pagemap_ioctl-add-setup-of-hugetlb-pages.patch selftests-mm-protection_keys-use-library-code-for-hugetlb-setup.patch selftests-mm-thuge-gen-add-setup-of-hugetlb-pages.patch selftests-mm-uffd-stress-use-hugetlb_save-and-alloc-huge-pages.patch selftests-mm-uffd-unit-tests-add-setup-of-hugetlb-pages.patch selftests-mm-uffd-wp-mremap-add-setup-of-hugetlb-pages.patch selftests-mm-va_high_addr_switch-add-setup-of-hugetlb-pages.patch selftests-mm-va_high_addr_switchsh-drop-huge-pages-setup.patch selftests-mm-run_vmtestssh-free-memory-if-available-memory-is-low.patch selftests-mm-run_vmtestssh-drop-detection-and-setup-of-hugetlb.patch