Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

selftests/mm: skip soft-dirty tests when CONFIG_MEM_SOFT_DIRTY is disabled

The madv_populate and soft-dirty kselftests currently fail on systems
where CONFIG_MEM_SOFT_DIRTY is disabled.

Introduce a new helper softdirty_supported() into vm_util.c/h to ensure
tests are properly skipped when the feature is not enabled.

Link: https://lkml.kernel.org/r/20250917133137.62802-1-lance.yang@linux.dev
Fixes: 9f3265db6ae8 ("selftests: vm: add test for Soft-Dirty PTE bit")
Signed-off-by: Lance Yang <lance.yang@linux.dev>
Acked-by: David Hildenbrand <david@redhat.com>
Suggested-by: David Hildenbrand <david@redhat.com>
Cc: Lorenzo Stoakes <lorenzo.stoakes@oracle.com>
Cc: Shuah Khan <shuah@kernel.org>
Cc: Gabriel Krisman Bertazi <krisman@collabora.com>
Cc: <stable@vger.kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>

authored by

Lance Yang and committed by
Andrew Morton
0389c305 8d009da3

+24 -20
+2 -19
tools/testing/selftests/mm/madv_populate.c
··· 264 264 munmap(addr, SIZE); 265 265 } 266 266 267 - static int system_has_softdirty(void) 268 - { 269 - /* 270 - * There is no way to check if the kernel supports soft-dirty, other 271 - * than by writing to a page and seeing if the bit was set. But the 272 - * tests are intended to check that the bit gets set when it should, so 273 - * doing that check would turn a potentially legitimate fail into a 274 - * skip. Fortunately, we know for sure that arm64 does not support 275 - * soft-dirty. So for now, let's just use the arch as a corse guide. 276 - */ 277 - #if defined(__aarch64__) 278 - return 0; 279 - #else 280 - return 1; 281 - #endif 282 - } 283 - 284 267 int main(int argc, char **argv) 285 268 { 286 269 int nr_tests = 16; ··· 271 288 272 289 pagesize = getpagesize(); 273 290 274 - if (system_has_softdirty()) 291 + if (softdirty_supported()) 275 292 nr_tests += 5; 276 293 277 294 ksft_print_header(); ··· 283 300 test_holes(); 284 301 test_populate_read(); 285 302 test_populate_write(); 286 - if (system_has_softdirty()) 303 + if (softdirty_supported()) 287 304 test_softdirty(); 288 305 289 306 err = ksft_get_fail_cnt();
+4 -1
tools/testing/selftests/mm/soft-dirty.c
··· 200 200 int pagesize; 201 201 202 202 ksft_print_header(); 203 - ksft_set_plan(15); 204 203 204 + if (!softdirty_supported()) 205 + ksft_exit_skip("soft-dirty is not support\n"); 206 + 207 + ksft_set_plan(15); 205 208 pagemap_fd = open(PAGEMAP_FILE_PATH, O_RDONLY); 206 209 if (pagemap_fd < 0) 207 210 ksft_exit_fail_msg("Failed to open %s\n", PAGEMAP_FILE_PATH);
+17
tools/testing/selftests/mm/vm_util.c
··· 449 449 return check_vmflag(addr, "pf"); 450 450 } 451 451 452 + bool softdirty_supported(void) 453 + { 454 + char *addr; 455 + bool supported = false; 456 + const size_t pagesize = getpagesize(); 457 + 458 + /* New mappings are expected to be marked with VM_SOFTDIRTY (sd). */ 459 + addr = mmap(0, pagesize, PROT_READ | PROT_WRITE, 460 + MAP_ANONYMOUS | MAP_PRIVATE, 0, 0); 461 + if (!addr) 462 + ksft_exit_fail_msg("mmap failed\n"); 463 + 464 + supported = check_vmflag(addr, "sd"); 465 + munmap(addr, pagesize); 466 + return supported; 467 + } 468 + 452 469 /* 453 470 * Open an fd at /proc/$pid/maps and configure procmap_out ready for 454 471 * PROCMAP_QUERY query. Returns 0 on success, or an error code otherwise.
+1
tools/testing/selftests/mm/vm_util.h
··· 104 104 int close_procmap(struct procmap_fd *procmap); 105 105 int write_sysfs(const char *file_path, unsigned long val); 106 106 int read_sysfs(const char *file_path, unsigned long *val); 107 + bool softdirty_supported(void); 107 108 108 109 static inline int open_self_procmap(struct procmap_fd *procmap_out) 109 110 {