Skip to contentSkip to conversation

selftests/mm: remove PROT_EXEC req from file-collapse tests

PATCH Applied Zach O'Keefe 5 participants 6 messages Sep 9, 2025 – Sep 10, 2025

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 selftests/mm: remove PROT_EXEC req from file-collapse tests

As of v6.8 commit 7fbb5e188248 ("mm: remove VM_EXEC requirement for THP eligibility") thp collapse no longer requires file-backed mappings be created with PROT_EXEC.

Remove the overly-strict dependency from thp collapse tests so we test the least-strict requirement for success.

---
 tools/testing/selftests/mm/khugepaged.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tools/testing/selftests/mm/khugepaged.c +1 -1
index a18c50d51141..3fe7ef04ac62 100644
@@ -394,7 +394,7 @@ static void *file_setup_area(int nr_hpages)
 		perror("open()");
 		exit(EXIT_FAILURE);
 	}
-	p = mmap(BASE_ADDR, size, PROT_READ | PROT_EXEC,
+	p = mmap(BASE_ADDR, size, PROT_READ,
 		 MAP_PRIVATE, finfo.fd, 0);
 	if (p == MAP_FAILED || p != BASE_ADDR) {
 		perror("mmap()");
Signature · 1 line
2.51.0.384.g4c02a37b29-goog
reviewer Reviewed-by on v1 1/1
#1 lore raw
Quoted 9 lines · Zach O'Keefe

As of v6.8 commit 7fbb5e188248 ("mm: remove VM_EXEC requirement for THP eligibility") thp collapse no longer requires file-backed mappings be created with PROT_EXEC.

Remove the overly-strict dependency from thp collapse tests so we test the least-strict requirement for success.

---

LGTM.

Quoted 16 lines
  tools/testing/selftests/mm/khugepaged.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
tools/testing/selftests/mm/khugepaged.c +1 -1
index a18c50d51141..3fe7ef04ac62 100644
@@ -394,7 +394,7 @@ static void *file_setup_area(int nr_hpages)
  		perror("open()");
  		exit(EXIT_FAILURE);
  	}
-	p = mmap(BASE_ADDR, size, PROT_READ | PROT_EXEC,
+	p = mmap(BASE_ADDR, size, PROT_READ,
  		 MAP_PRIVATE, finfo.fd, 0);
  	if (p == MAP_FAILED || p != BASE_ADDR) {
  		perror("mmap()");
Acked-by on v1 1/1
#3 lore raw
In reply to Zach O'Keefe
Quoted 17 lines · Zach O'Keefe

As of v6.8 commit 7fbb5e188248 ("mm: remove VM_EXEC requirement for THP eligibility") thp collapse no longer requires file-backed mappings be created with PROT_EXEC.

Remove the overly-strict dependency from thp collapse tests so we test the least-strict requirement for success.

---
  tools/testing/selftests/mm/khugepaged.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
tools/testing/selftests/mm/khugepaged.c +0 -0
index a18c50d51141..3fe7ef04ac62 100644

tools/testing/selftests/mm/khugepaged.c static void *file_setup_area(int nr_hpages) · line 400

Quoted 8 lines
tools/testing/selftests/mm/khugepaged.c +1 -1
@@ -394,7 +394,7 @@ static void *file_setup_area(int nr_hpages)
  		perror("open()");
  		exit(EXIT_FAILURE);
  	}
-	p = mmap(BASE_ADDR, size, PROT_READ | PROT_EXEC,
+	p = mmap(BASE_ADDR, size, PROT_READ,
  		 MAP_PRIVATE, finfo.fd, 0);
  	if (p == MAP_FAILED || p != BASE_ADDR) {
  		perror("mmap()");
Signature · 3 lines
Cheers

David / dhildenb
#4 lore raw
In reply to Zach O'Keefe
Quoted 4 lines · Zach O'Keefe

As of v6.8 commit 7fbb5e188248 ("mm: remove VM_EXEC requirement for THP eligibility") thp collapse no longer requires file-backed mappings be created with PROT_EXEC.

One question, what if user run this new version test on old kernel?

Is there a guideline for user?

Quoted 24 lines

Remove the overly-strict dependency from thp collapse tests so we test the least-strict requirement for success.

---
tools/testing/selftests/mm/khugepaged.c | 2 +-

1 file changed, 1 insertion(+), 1 deletion(-)
tools/testing/selftests/mm/khugepaged.c +1 -1
index a18c50d51141..3fe7ef04ac62 100644
@@ -394,7 +394,7 @@ static void *file_setup_area(int nr_hpages)
 		perror("open()");
 		exit(EXIT_FAILURE);
 	}
-	p = mmap(BASE_ADDR, size, PROT_READ | PROT_EXEC,
+	p = mmap(BASE_ADDR, size, PROT_READ,
 		 MAP_PRIVATE, finfo.fd, 0);
 	if (p == MAP_FAILED || p != BASE_ADDR) {
 		perror("mmap()");
Signature · 1 line
2.51.0.384.g4c02a37b29-goog
Signature · 2 lines
Wei Yang
Help you, Help me
#5 lore raw
Quoted 9 lines · Wei Yang
Quoted 4 lines · Zach O'Keefe

As of v6.8 commit 7fbb5e188248 ("mm: remove VM_EXEC requirement for THP eligibility") thp collapse no longer requires file-backed mappings be created with PROT_EXEC.

One question, what if user run this new version test on old kernel?

Is there a guideline for user?

We try to keep some older kernel working as long as it is easy, so people have to do less manual work of filtering out false positives if they happen to run these tests on older kernels.

6.8 was from end 2023, not sure if we still care about that.

Signature · 3 lines
Cheers

David / dhildenb