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

parisc: Align parisc MADV_XXX constants with all other architectures

Adjust some MADV_XXX constants to be in sync what their values are on
all other platforms. There is currently no reason to have an own
numbering on parisc, but it requires workarounds in many userspace
sources (e.g. glibc, qemu, ...) - which are often forgotten and thus
introduce bugs and different behaviour on parisc.

A wrapper avoids an ABI breakage for existing userspace applications by
translating any old values to the new ones, so this change allows us to
move over all programs to the new ABI over time.

Signed-off-by: Helge Deller <deller@gmx.de>

+49 -34
+14 -15
arch/parisc/include/uapi/asm/mman.h
··· 49 49 #define MADV_DONTFORK 10 /* don't inherit across fork */ 50 50 #define MADV_DOFORK 11 /* do inherit across fork */ 51 51 52 + #define MADV_MERGEABLE 12 /* KSM may merge identical pages */ 53 + #define MADV_UNMERGEABLE 13 /* KSM may not merge identical pages */ 54 + 55 + #define MADV_HUGEPAGE 14 /* Worth backing with hugepages */ 56 + #define MADV_NOHUGEPAGE 15 /* Not worth backing with hugepages */ 57 + 58 + #define MADV_DONTDUMP 16 /* Explicity exclude from the core dump, 59 + overrides the coredump filter bits */ 60 + #define MADV_DODUMP 17 /* Clear the MADV_NODUMP flag */ 61 + 62 + #define MADV_WIPEONFORK 18 /* Zero memory on fork, child only */ 63 + #define MADV_KEEPONFORK 19 /* Undo MADV_WIPEONFORK */ 64 + 52 65 #define MADV_COLD 20 /* deactivate these pages */ 53 66 #define MADV_PAGEOUT 21 /* reclaim these pages */ 54 67 ··· 70 57 71 58 #define MADV_DONTNEED_LOCKED 24 /* like DONTNEED, but drop locked pages too */ 72 59 73 - #define MADV_MERGEABLE 65 /* KSM may merge identical pages */ 74 - #define MADV_UNMERGEABLE 66 /* KSM may not merge identical pages */ 75 - 76 - #define MADV_HUGEPAGE 67 /* Worth backing with hugepages */ 77 - #define MADV_NOHUGEPAGE 68 /* Not worth backing with hugepages */ 78 - 79 - #define MADV_DONTDUMP 69 /* Explicity exclude from the core dump, 80 - overrides the coredump filter bits */ 81 - #define MADV_DODUMP 70 /* Clear the MADV_NODUMP flag */ 82 - 83 - #define MADV_WIPEONFORK 71 /* Zero memory on fork, child only */ 84 - #define MADV_KEEPONFORK 72 /* Undo MADV_WIPEONFORK */ 85 - 86 - #define MADV_COLLAPSE 73 /* Synchronous hugepage collapse */ 60 + #define MADV_COLLAPSE 25 /* Synchronous hugepage collapse */ 87 61 88 62 #define MADV_HWPOISON 100 /* poison a page for testing */ 89 63 #define MADV_SOFT_OFFLINE 101 /* soft offline page for testing */ 90 64 91 65 /* compatibility flags */ 92 66 #define MAP_FILE 0 93 - #define MAP_VARIABLE 0 94 67 95 68 #define PKEY_DISABLE_ACCESS 0x1 96 69 #define PKEY_DISABLE_WRITE 0x2
+28
arch/parisc/kernel/sys_parisc.c
··· 465 465 flags = FIX_O_NONBLOCK(flags); 466 466 return sys_inotify_init1(flags); 467 467 } 468 + 469 + /* 470 + * madvise() wrapper 471 + * 472 + * Up to kernel v6.1 parisc has different values than all other 473 + * platforms for the MADV_xxx flags listed below. 474 + * To keep binary compatibility with existing userspace programs 475 + * translate the former values to the new values. 476 + * 477 + * XXX: Remove this wrapper in year 2025 (or later) 478 + */ 479 + 480 + asmlinkage notrace long parisc_madvise(unsigned long start, size_t len_in, int behavior) 481 + { 482 + switch (behavior) { 483 + case 65: behavior = MADV_MERGEABLE; break; 484 + case 66: behavior = MADV_UNMERGEABLE; break; 485 + case 67: behavior = MADV_HUGEPAGE; break; 486 + case 68: behavior = MADV_NOHUGEPAGE; break; 487 + case 69: behavior = MADV_DONTDUMP; break; 488 + case 70: behavior = MADV_DODUMP; break; 489 + case 71: behavior = MADV_WIPEONFORK; break; 490 + case 72: behavior = MADV_KEEPONFORK; break; 491 + case 73: behavior = MADV_COLLAPSE; break; 492 + } 493 + 494 + return sys_madvise(start, len_in, behavior); 495 + }
+1 -1
arch/parisc/kernel/syscalls/syscall.tbl
··· 131 131 116 common sysinfo sys_sysinfo compat_sys_sysinfo 132 132 117 common shutdown sys_shutdown 133 133 118 common fsync sys_fsync 134 - 119 common madvise sys_madvise 134 + 119 common madvise parisc_madvise 135 135 120 common clone sys_clone_wrapper 136 136 121 common setdomainname sys_setdomainname 137 137 122 common sendfile sys_sendfile compat_sys_sendfile
+6 -6
tools/arch/parisc/include/uapi/asm/mman.h
··· 1 1 /* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ 2 2 #ifndef TOOLS_ARCH_PARISC_UAPI_ASM_MMAN_FIX_H 3 3 #define TOOLS_ARCH_PARISC_UAPI_ASM_MMAN_FIX_H 4 - #define MADV_DODUMP 70 4 + #define MADV_DODUMP 17 5 5 #define MADV_DOFORK 11 6 - #define MADV_DONTDUMP 69 6 + #define MADV_DONTDUMP 16 7 7 #define MADV_DONTFORK 10 8 8 #define MADV_DONTNEED 4 9 9 #define MADV_FREE 8 10 - #define MADV_HUGEPAGE 67 11 - #define MADV_MERGEABLE 65 12 - #define MADV_NOHUGEPAGE 68 10 + #define MADV_HUGEPAGE 14 11 + #define MADV_MERGEABLE 12 12 + #define MADV_NOHUGEPAGE 15 13 13 #define MADV_NORMAL 0 14 14 #define MADV_RANDOM 1 15 15 #define MADV_REMOVE 9 16 16 #define MADV_SEQUENTIAL 2 17 - #define MADV_UNMERGEABLE 66 17 + #define MADV_UNMERGEABLE 13 18 18 #define MADV_WILLNEED 3 19 19 #define MAP_ANONYMOUS 0x10 20 20 #define MAP_DENYWRITE 0x0800
-12
tools/perf/bench/bench.h
··· 10 10 * The madvise transparent hugepage constants were added in glibc 11 11 * 2.13. For compatibility with older versions of glibc, define these 12 12 * tokens if they are not already defined. 13 - * 14 - * PA-RISC uses different madvise values from other architectures and 15 - * needs to be special-cased. 16 13 */ 17 - #ifdef __hppa__ 18 - # ifndef MADV_HUGEPAGE 19 - # define MADV_HUGEPAGE 67 20 - # endif 21 - # ifndef MADV_NOHUGEPAGE 22 - # define MADV_NOHUGEPAGE 68 23 - # endif 24 - #else 25 14 # ifndef MADV_HUGEPAGE 26 15 # define MADV_HUGEPAGE 14 27 16 # endif 28 17 # ifndef MADV_NOHUGEPAGE 29 18 # define MADV_NOHUGEPAGE 15 30 19 # endif 31 - #endif 32 20 33 21 int bench_numa(int argc, const char **argv); 34 22 int bench_sched_messaging(int argc, const char **argv);