From: Ignacio Moreno Gonzalez <Ignacio.MorenoGonzalez@kuka.com>
VM_NOHUGEPAGE is a no-op if CONFIG_TRANSPARENT_HUGEPAGE is disabled. So
it makes no sense to return an error when calling madvise() with
MADV_NOHUGEPAGE in that case.
Suggested-by: Matthew Wilcox <willy@infradead.org>
Signed-off-by: Ignacio Moreno Gonzalez <Ignacio.MorenoGonzalez@kuka.com>
Reviewed-by: Yang Shi <yang@os.amperecomputing.com>
Acked-by: David Hildenbrand <david@redhat.com>
Reviewed-by: Lorenzo Stoakes <lorenzo.stoakes@oracle.com>
Signed-off-by: Lorenzo Stoakes <lorenzo.stoakes@oracle.com>
---
include/linux/huge_mm.h | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/include/linux/huge_mm.h b/include/linux/huge_mm.h
index 2f190c90192d..1a8082c61e01 100644
--- a/include/linux/huge_mm.h
+++ b/include/linux/huge_mm.h
@@ -506,6 +506,8 @@ bool unmap_huge_pmd_locked(struct vm_area_struct *vma, unsigned long addr,
#else /* CONFIG_TRANSPARENT_HUGEPAGE */
+#include <uapi/asm/mman.h>
+
static inline bool folio_test_pmd_mappable(struct folio *folio)
{
return false;
@@ -595,6 +597,9 @@ static inline bool unmap_huge_pmd_locked(struct vm_area_struct *vma,
static inline int hugepage_madvise(struct vm_area_struct *vma,
unsigned long *vm_flags, int advice)
{
+ /* On a !THP kernel, MADV_NOHUGEPAGE is a no-op, but MADV_HUGEPAGE is not supported */
+ if (advice == MADV_NOHUGEPAGE)
+ return 0;
return -EINVAL;
}
--
2.49.0
* Lorenzo Stoakes <lorenzo.stoakes@oracle.com> [250515 16:15]:
> From: Ignacio Moreno Gonzalez <Ignacio.MorenoGonzalez@kuka.com>
>
> VM_NOHUGEPAGE is a no-op if CONFIG_TRANSPARENT_HUGEPAGE is disabled. So
> it makes no sense to return an error when calling madvise() with
> MADV_NOHUGEPAGE in that case.
>
> Suggested-by: Matthew Wilcox <willy@infradead.org>
> Signed-off-by: Ignacio Moreno Gonzalez <Ignacio.MorenoGonzalez@kuka.com>
> Reviewed-by: Yang Shi <yang@os.amperecomputing.com>
> Acked-by: David Hildenbrand <david@redhat.com>
> Reviewed-by: Lorenzo Stoakes <lorenzo.stoakes@oracle.com>
Nice to see you review this for yourself :)
> Signed-off-by: Lorenzo Stoakes <lorenzo.stoakes@oracle.com>
Reviewed-by: Liam R. Howlett <Liam.Howlett@oracle.com>
> ---
> include/linux/huge_mm.h | 5 +++++
> 1 file changed, 5 insertions(+)
>
> diff --git a/include/linux/huge_mm.h b/include/linux/huge_mm.h
> index 2f190c90192d..1a8082c61e01 100644
> --- a/include/linux/huge_mm.h
> +++ b/include/linux/huge_mm.h
> @@ -506,6 +506,8 @@ bool unmap_huge_pmd_locked(struct vm_area_struct *vma, unsigned long addr,
>
> #else /* CONFIG_TRANSPARENT_HUGEPAGE */
>
> +#include <uapi/asm/mman.h>
> +
> static inline bool folio_test_pmd_mappable(struct folio *folio)
> {
> return false;
> @@ -595,6 +597,9 @@ static inline bool unmap_huge_pmd_locked(struct vm_area_struct *vma,
> static inline int hugepage_madvise(struct vm_area_struct *vma,
> unsigned long *vm_flags, int advice)
> {
> + /* On a !THP kernel, MADV_NOHUGEPAGE is a no-op, but MADV_HUGEPAGE is not supported */
> + if (advice == MADV_NOHUGEPAGE)
> + return 0;
> return -EINVAL;
> }
>
> --
> 2.49.0
>
On Fri, May 16, 2025 at 11:40:23AM -0400, Liam R. Howlett wrote:
> * Lorenzo Stoakes <lorenzo.stoakes@oracle.com> [250515 16:15]:
> > From: Ignacio Moreno Gonzalez <Ignacio.MorenoGonzalez@kuka.com>
> >
> > VM_NOHUGEPAGE is a no-op if CONFIG_TRANSPARENT_HUGEPAGE is disabled. So
> > it makes no sense to return an error when calling madvise() with
> > MADV_NOHUGEPAGE in that case.
> >
> > Suggested-by: Matthew Wilcox <willy@infradead.org>
> > Signed-off-by: Ignacio Moreno Gonzalez <Ignacio.MorenoGonzalez@kuka.com>
> > Reviewed-by: Yang Shi <yang@os.amperecomputing.com>
> > Acked-by: David Hildenbrand <david@redhat.com>
> > Reviewed-by: Lorenzo Stoakes <lorenzo.stoakes@oracle.com>
>
> Nice to see you review this for yourself :)
Haha yeah... this is a Lorenzo-getting-confused-by-kernel-process situation
again, this is 100% Ignacio's patch, I just bundled it up in this series to
enforce ordering.
>
> > Signed-off-by: Lorenzo Stoakes <lorenzo.stoakes@oracle.com>
...But of course I did format-patch -s so I signed it off as well :P
At any rate the From: field and Ignacio's S-o-b should make everything correct
in the wash. I think.
Andrew - this is Ignacio's patch for avoidance of doubt :P
>
> Reviewed-by: Liam R. Howlett <Liam.Howlett@oracle.com>
>
> > ---
> > include/linux/huge_mm.h | 5 +++++
> > 1 file changed, 5 insertions(+)
> >
> > diff --git a/include/linux/huge_mm.h b/include/linux/huge_mm.h
> > index 2f190c90192d..1a8082c61e01 100644
> > --- a/include/linux/huge_mm.h
> > +++ b/include/linux/huge_mm.h
> > @@ -506,6 +506,8 @@ bool unmap_huge_pmd_locked(struct vm_area_struct *vma, unsigned long addr,
> >
> > #else /* CONFIG_TRANSPARENT_HUGEPAGE */
> >
> > +#include <uapi/asm/mman.h>
> > +
> > static inline bool folio_test_pmd_mappable(struct folio *folio)
> > {
> > return false;
> > @@ -595,6 +597,9 @@ static inline bool unmap_huge_pmd_locked(struct vm_area_struct *vma,
> > static inline int hugepage_madvise(struct vm_area_struct *vma,
> > unsigned long *vm_flags, int advice)
> > {
> > + /* On a !THP kernel, MADV_NOHUGEPAGE is a no-op, but MADV_HUGEPAGE is not supported */
> > + if (advice == MADV_NOHUGEPAGE)
> > + return 0;
> > return -EINVAL;
> > }
> >
> > --
> > 2.49.0
> >
>
* Lorenzo Stoakes <lorenzo.stoakes@oracle.com> [250516 11:43]:
> On Fri, May 16, 2025 at 11:40:23AM -0400, Liam R. Howlett wrote:
> > * Lorenzo Stoakes <lorenzo.stoakes@oracle.com> [250515 16:15]:
> > > From: Ignacio Moreno Gonzalez <Ignacio.MorenoGonzalez@kuka.com>
> > >
> > > VM_NOHUGEPAGE is a no-op if CONFIG_TRANSPARENT_HUGEPAGE is disabled. So
> > > it makes no sense to return an error when calling madvise() with
> > > MADV_NOHUGEPAGE in that case.
> > >
> > > Suggested-by: Matthew Wilcox <willy@infradead.org>
> > > Signed-off-by: Ignacio Moreno Gonzalez <Ignacio.MorenoGonzalez@kuka.com>
> > > Reviewed-by: Yang Shi <yang@os.amperecomputing.com>
> > > Acked-by: David Hildenbrand <david@redhat.com>
> > > Reviewed-by: Lorenzo Stoakes <lorenzo.stoakes@oracle.com>
> >
> > Nice to see you review this for yourself :)
>
> Haha yeah... this is a Lorenzo-getting-confused-by-kernel-process situation
> again, this is 100% Ignacio's patch, I just bundled it up in this series to
> enforce ordering.
>
> >
> > > Signed-off-by: Lorenzo Stoakes <lorenzo.stoakes@oracle.com>
>
> ...But of course I did format-patch -s so I signed it off as well :P
>
> At any rate the From: field and Ignacio's S-o-b should make everything correct
> in the wash. I think.
>
> Andrew - this is Ignacio's patch for avoidance of doubt :P
Oh yes, I missed the initial sign off. I think this is okay, but maybe
you didn't need your own RB?
>
> >
> > Reviewed-by: Liam R. Howlett <Liam.Howlett@oracle.com>
> >
> > > ---
> > > include/linux/huge_mm.h | 5 +++++
> > > 1 file changed, 5 insertions(+)
> > >
> > > diff --git a/include/linux/huge_mm.h b/include/linux/huge_mm.h
> > > index 2f190c90192d..1a8082c61e01 100644
> > > --- a/include/linux/huge_mm.h
> > > +++ b/include/linux/huge_mm.h
> > > @@ -506,6 +506,8 @@ bool unmap_huge_pmd_locked(struct vm_area_struct *vma, unsigned long addr,
> > >
> > > #else /* CONFIG_TRANSPARENT_HUGEPAGE */
> > >
> > > +#include <uapi/asm/mman.h>
> > > +
> > > static inline bool folio_test_pmd_mappable(struct folio *folio)
> > > {
> > > return false;
> > > @@ -595,6 +597,9 @@ static inline bool unmap_huge_pmd_locked(struct vm_area_struct *vma,
> > > static inline int hugepage_madvise(struct vm_area_struct *vma,
> > > unsigned long *vm_flags, int advice)
> > > {
> > > + /* On a !THP kernel, MADV_NOHUGEPAGE is a no-op, but MADV_HUGEPAGE is not supported */
> > > + if (advice == MADV_NOHUGEPAGE)
> > > + return 0;
> > > return -EINVAL;
> > > }
> > >
> > > --
> > > 2.49.0
> > >
> >
© 2016 - 2025 Red Hat, Inc.