linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Ignacio Moreno Gonzalez via B4 Relay <devnull+Ignacio.MorenoGonzalez.kuka.com@kernel.org>
To: Andrew Morton <akpm@linux-foundation.org>,
	 Lorenzo Stoakes <lorenzo.stoakes@oracle.com>,
	 "Liam R. Howlett" <Liam.Howlett@oracle.com>
Cc: yang@os.amperecomputing.com, willy@infradead.org,
	linux-mm@kvack.org,  linux-kernel@vger.kernel.org,
	 Ignacio Moreno Gonzalez <Ignacio.MorenoGonzalez@kuka.com>
Subject: [PATCH] mm: madvise: make MADV_NOHUGEPAGE a no-op if !THP
Date: Thu, 08 May 2025 12:20:27 +0200	[thread overview]
Message-ID: <20250508-madvise-nohugepage-noop-without-thp-v1-1-e7ceffb197f3@kuka.com> (raw)

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>
---
https://lore.kernel.org/linux-mm/20250502-map-map_stack-to-vm_nohugepage-only-if-thp-is-enabled-v1-1-113cc634cd51@kuka.com

Here it is presented as a separate thread to avoid mixing stable and
non-stable patches.

This change makes calling madvise(addr, size, MADV_NOHUGEPAGE) on !THP
kernels to return 0 instead of -EINVAL.
---
 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 e893d546a49f464f7586db639fe216231f03651a..5fca742dc5ba784ffccea055b07247707d16cc67 100644
--- a/include/linux/huge_mm.h
+++ b/include/linux/huge_mm.h
@@ -509,6 +509,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;
@@ -598,6 +600,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_NOHUGEPAGE is not supported */
+	if (advice == MADV_NOHUGEPAGE)
+		return 0;
 	return -EINVAL;
 }
 

---
base-commit: fc96b232f8e7c0a6c282f47726b2ff6a5fb341d2
change-id: 20250508-madvise-nohugepage-noop-without-thp-e0721b973d82

Best regards,
-- 
Ignacio Moreno Gonzalez <Ignacio.MorenoGonzalez@kuka.com>




             reply	other threads:[~2025-05-08 10:20 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-05-08 10:20 Ignacio Moreno Gonzalez via B4 Relay [this message]
2025-05-08 11:49 ` Lorenzo Stoakes
2025-05-08 15:06 ` David Hildenbrand
2025-05-08 15:32 ` Yang Shi
2025-05-08 19:04 ` Liam R. Howlett
2025-05-09  5:47   ` Ignacio Moreno Gonzalez
2025-05-09 17:24     ` Liam R. Howlett
2025-05-14 13:52 ` Lorenzo Stoakes
2025-05-14 15:07   ` Ignacio Moreno Gonzalez
2025-05-14 15:25     ` Yang Shi
2025-05-14 15:29       ` Lorenzo Stoakes
2025-05-14 16:54         ` Yang Shi
2025-05-14 15:27     ` Lorenzo Stoakes
2025-05-14 15:59       ` Ignacio Moreno Gonzalez
2025-05-14 22:36         ` Andrew Morton
2025-05-15  5:30           ` Lorenzo Stoakes
2025-05-14 20:15 ` James Houghton
2025-05-15  7:03   ` Ignacio Moreno Gonzalez
2025-05-15 13:03     ` Lorenzo Stoakes
2025-05-15 14:42       ` Ignacio Moreno Gonzalez

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20250508-madvise-nohugepage-noop-without-thp-v1-1-e7ceffb197f3@kuka.com \
    --to=devnull+ignacio.morenogonzalez.kuka.com@kernel.org \
    --cc=Ignacio.MorenoGonzalez@kuka.com \
    --cc=Liam.Howlett@oracle.com \
    --cc=akpm@linux-foundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=lorenzo.stoakes@oracle.com \
    --cc=willy@infradead.org \
    --cc=yang@os.amperecomputing.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox