# Re: \[RFC PATCH v1 1/4\] mm: introduce VM\_VOLATILE and MADV\_VOLATILE/MADV\_NONVOLATILE VMA handling

- From: sashiko-bot@kernel.org
- Date: 2026-12-01 08:36:16 
- List: linux-trace-kernel
- Page: https://ratatoskr.run/linux-trace-kernel/2026/12/18058091
- Thread: https://ratatoskr.run/linux-mm/2026/11/18048701/t.md

```text
Thank you for your contribution! Sashiko AI review found 2 potential
issues to consider:
- [High] mm: missing MADV_VOLATILE UAPI definitions on alpha, mips,
  parisc, xtensa
- [Low] mm: madvise_behavior_valid() accepts MADV_VOLATILE on
  !CONFIG_64BIT
--

commit ab93af5a4c34f06ecde808f11b3ce153dea7ddf6
Author: Hirotaka Yamagata [ref]

mm: introduce VM_VOLATILE and MADV_VOLATILE/MADV_NONVOLATILE VMA handling

This commit introduces the VM_VOLATILE VMA flag on 64-bit architectures and
adds VMA handling for the MADV_VOLATILE and MADV_NONVOLATILE madvise()
behaviors.

Link: https://lore.kernel.org/1398806483-19122-1-git-send-email-john.stultz@linaro.org

> diff --git a/include/uapi/asm-generic/mman-common.h b/include/uapi/asm-generic/mman-common.h
> index ef1c27fa3c570..cfaa94aea62af 100644
> --- a/include/uapi/asm-generic/mman-common.h
> +++ b/include/uapi/asm-generic/mman-common.h
> @@ -79,6 +79,9 @@
>  
>  #define MADV_COLLAPSE	25		/* Synchronous hugepage collapse */
>  
> +#define MADV_VOLATILE	26		/* Mark pages as volatile */
> +#define MADV_NONVOLATILE 27		/* Mark pages non-volatile, report if purged */
> +
>  #define MADV_GUARD_INSTALL 102		/* fatal signal on access to range */
>  #define MADV_GUARD_REMOVE 103		/* unguard range */

[Severity: High]
Should MADV_VOLATILE and MADV_NONVOLATILE also be defined in the
arch-specific UAPI asm/mman.h headers for alpha, mips, parisc and xtensa?

Those four architectures define their MADV_* constants directly rather than
including asm-generic/mman-common.h, while mm/madvise.c and mm/mvolatile.c
reference MADV_VOLATILE and MADV_NONVOLATILE unconditionally, causing the
build to fail on alpha, mips, parisc and xtensa.

> diff --git a/mm/madvise.c b/mm/madvise.c
> index 96f2387b2f46d..d9d9d5a7221fa 100644
> --- a/mm/madvise.c
> +++ b/mm/madvise.c
[ ... ]
> @@ -1548,6 +1549,8 @@ madvise_behavior_valid(int behavior)
>  	case MADV_KEEPONFORK:
>  	case MADV_GUARD_INSTALL:
>  	case MADV_GUARD_REMOVE:
> +	case MADV_VOLATILE:
> +	case MADV_NONVOLATILE:
>  #ifdef CONFIG_MEMORY_FAILURE
>  	case MADV_SOFT_OFFLINE:
>  	case MADV_HWPOISON:

[Severity: Low]
Should MADV_VOLATILE and MADV_NONVOLATILE in madvise_behavior_valid() be
guarded by #ifdef CONFIG_64BIT?

On 32-bit kernels where volatile ranges are unsupported, do_madvise() checks
if (error || !len_in) return error; before reaching the !CONFIG_64BIT
madvise_volatile() stub, so a zero-length madvise(addr, 0, MADV_VOLATILE)
call returns 0 instead of -EINVAL.

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261130083407.2669584-1-hiro@pisnp.net?part=1
```
