Re: [REGRESSION] mm/mprotect: 2x+ slowdown for >=400KiB regions since PTE batching (cac1db8c3aad)
From: David Hildenbrand (Arm)
Date: Wed Feb 18 2026 - 08:30:21 EST
int main(int argc, char **argv)
{
int i, j, ret;
long long k;
if (argc < 4) {
printf("USAGE: %s region_size_kib region_count iterations\n", argv[0]);
printf("Creates multiple regions and times mprotect() calls\n");
return 1;
}
long region_size = atol(argv[1]) * 1024L;
int region_count = atoi(argv[2]);
int iterations = atoi(argv[3]);
int pagesize = sysconf(_SC_PAGESIZE);
vchar_t **regions = malloc(region_count * sizeof(vchar_t*));
if (!regions) {
perror("malloc");
return 1;
}
for (i = 0; i < region_count; i++) {
regions[i] = (vchar_t *) mmap(NULL, region_size,
PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANONYMOUS, -1, 0L);
I assume that the regression might be more pronounced with MAP_SHARED, because there we really didn't ever required the page/folio during mprotect() IIRC.
--
Cheers,
David