All of lore.kernel.org
 help / color / mirror / Atom feed
From: Yang Shi <yang@os.amperecomputing.com>
To: Ignacio Moreno Gonzalez <Ignacio.MorenoGonzalez@kuka.com>,
	Andrew Morton <akpm@linux-foundation.org>
Cc: lorenzo.stoakes@oracle.com, Liam.Howlett@oracle.com,
	linux-mm@kvack.org, linux-kernel@vger.kernel.org,
	Matthew Wilcox <willy@infradead.org>
Subject: Re: [PATCH v2 2/2] mm: madvise: no-op for MADV_NOHUGEPAGE if THP is disabled
Date: Wed, 7 May 2025 15:38:33 -0700	[thread overview]
Message-ID: <3c825374-8db3-413c-b4b0-ea95053be7d0@os.amperecomputing.com> (raw)
In-Reply-To: <af38b3dd-ca8f-4d18-b73c-8a2bb682f31a@kuka.com>



On 5/7/25 9:11 AM, Ignacio Moreno Gonzalez wrote:
> On 5/7/2025 5:57 PM, Yang Shi wrote:
>
>> Can you just simply include <linux/mman.h> ?
> This is what I tried first, but then it won't compile due to 'undeclared MADV_NOHUGEPAGE'

OK, I ran into some compilation errors, but it is not due to 'undeclared 
MADV_NOHUGEPAGE'. The compiler reports some inline functions are not 
declared. It may be because some circular dependency because 
linux/mman.h also includes linux/mm.h. But I didn't have too much time 
investigating it.

The below patch works for me:

diff --git a/include/linux/huge_mm.h b/include/linux/huge_mm.h
index 93e509b6c00e..750e17e552a0 100644
--- a/include/linux/huge_mm.h
+++ b/include/linux/huge_mm.h
@@ -475,6 +475,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;
@@ -558,6 +560,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)
  {
+       if (advice == MADV_NOHUGEPAGE)
+               return 0;
+
         return -EINVAL;
  }


This should be slightly better than yours?

Thanks,
Yang




  reply	other threads:[~2025-05-07 22:38 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-05-06 13:44 [PATCH v2 0/2] Map MAP_STACK to VM_NOHUGEPAGE only if THP is enabled Ignacio Moreno Gonzalez
2025-05-06 13:44 ` Ignacio Moreno Gonzalez via B4 Relay
2025-05-06 13:44 ` [PATCH v2 1/2] mm: mmap: map " Ignacio Moreno Gonzalez
2025-05-06 13:44   ` Ignacio Moreno Gonzalez via B4 Relay
2025-05-06 16:00   ` Liam R. Howlett
2025-05-06 23:43   ` Andrew Morton
2025-05-06 13:44 ` [PATCH v2 2/2] mm: madvise: no-op for MADV_NOHUGEPAGE if THP is disabled Ignacio Moreno Gonzalez
2025-05-06 13:44   ` Ignacio Moreno Gonzalez via B4 Relay
2025-05-06 16:00   ` Liam R. Howlett
2025-05-06 23:40   ` Andrew Morton
2025-05-07 11:44     ` Ignacio Moreno Gonzalez
2025-05-07 15:57       ` Yang Shi
2025-05-07 16:11         ` Ignacio Moreno Gonzalez
2025-05-07 22:38           ` Yang Shi [this message]
2025-05-06 14:28 ` [PATCH v2 0/2] Map MAP_STACK to VM_NOHUGEPAGE only if THP is enabled Lorenzo Stoakes
2025-05-06 15:12   ` Ignacio Moreno Gonzalez
2025-05-06 15:14     ` Lorenzo Stoakes

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=3c825374-8db3-413c-b4b0-ea95053be7d0@os.amperecomputing.com \
    --to=yang@os.amperecomputing.com \
    --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 \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.