Skip to contentSkip to conversation

selftests-mm-hugepage_settings-add-apis-to-get-and-set-nr_hugepages.patch removed from -mm tree

merged mm-stable Andrew Morton 1 participant 1 message Jun 21

lore
Share & tools
lore

Andrew Morton

author tree notice Applied
#0 lore raw

The quilt patch titled
Subject: selftests/mm: hugepage_settings: add APIs to get and set nr_hugepages
has been removed from the -mm tree. Its filename was
selftests-mm-hugepage_settings-add-apis-to-get-and-set-nr_hugepages.patch

This patch was dropped because it was merged into the mm-stable branch of git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm

------------------------------------------------------
From: "Mike Rapoport (Microsoft)" <[email protected]>
Subject: selftests/mm: hugepage_settings: add APIs to get and set nr_hugepages
Date: Mon, 11 May 2026 19:28:10 +0300

Add APIs that allow reading and writing of

/sys/kernel/mm/hugepages/hugepages-NkB/nr_hugepages

to detect and change the amount of HugeTLB pages of different sizes.

Cc Baolin Wang <[email protected]>
Cc Barry Song <[email protected]>
Cc David Hildenbrand <[email protected]>
Cc Dev Jain <[email protected]>
Cc Donet Tom <[email protected]>
Cc Jason Gunthorpe <[email protected]>
Cc John Hubbard <[email protected]>
Cc Lance Yang <[email protected]>
Cc Leon Romanovsky <[email protected]>
Cc Liam Howlett <[email protected]>
Cc Li Wang <[email protected]>
Cc Lorenzo Stoakes <[email protected]>
Cc Mark Brown <[email protected]>
Cc Michal Hocko <[email protected]>
Cc Nico Pache <[email protected]>
Cc Peter Xu <[email protected]>
Cc Ryan Roberts <[email protected]>
Cc Shuah Khan <[email protected]>
Cc Suren Baghdasaryan <[email protected]>
Cc Vlastimil Babka <[email protected]>
Cc Zi Yan <[email protected]>

---

 tools/testing/selftests/mm/hugepage_settings.c |   25 +++++++++++++++
 tools/testing/selftests/mm/hugepage_settings.h |   23 +++++++++++++
 2 files changed, 48 insertions(+)
tools/testing/selftests/mm/hugepage_settings.c renamed from tools/testing/selftests/mm/hugepage_settings.c~selftests-mm-hugepage_settings-add-apis-to-get-and-set-nr_hugepages +25 -0
@@ -463,3 +463,28 @@ unsigned long get_free_hugepages(void)
 	fclose(f);
 	return fhp;
 }
+
+static void hugetlb_sysfs_path(char *buf, size_t buflen,
+			       unsigned long size, const char *attr)
+{
+	snprintf(buf, buflen, "/sys/kernel/mm/hugepages/hugepages-%lukB/%s",
+		 size / 1024, attr);
+}
+
+unsigned long hugetlb_nr_pages(unsigned long size)
+{
+	char path[PATH_MAX];
+
+	hugetlb_sysfs_path(path, sizeof(path), size, "nr_hugepages");
+
+	return read_num(path);
+}
+
+void hugetlb_set_nr_pages(unsigned long size, unsigned long nr)
+{
+	char path[PATH_MAX];
+
+	hugetlb_sysfs_path(path, sizeof(path), size, "nr_hugepages");
+
+	write_num(path, nr);
+}
tools/testing/selftests/mm/hugepage_settings.h renamed from tools/testing/selftests/mm/hugepage_settings.h~selftests-mm-hugepage_settings-add-apis-to-get-and-set-nr_hugepages +23 -0
@@ -94,4 +94,27 @@ int detect_hugetlb_page_sizes(unsigned l
 unsigned long default_huge_page_size(void);
 unsigned long get_free_hugepages(void);
 
+unsigned long hugetlb_nr_pages(unsigned long size);
+void hugetlb_set_nr_pages(unsigned long size, unsigned long nr);
+
+static inline unsigned long hugetlb_nr_default_pages(void)
+{
+	unsigned long size = default_huge_page_size();
+
+	if (!size)
+		return 0;
+
+	return hugetlb_nr_pages(size);
+}
+
+static inline void hugetlb_set_nr_default_pages(unsigned long nr)
+{
+	unsigned long size = default_huge_page_size();
+
+	if (!size)
+		return;
+
+	hugetlb_set_nr_pages(size, nr);
+}
+
 #endif /* __HUGEPAGE_SETTINGS_H__ */

_

Patches currently in -mm which might be from [email protected] are