linux-mm.kvack.org archive mirror
 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 08:57:07 -0700	[thread overview]
Message-ID: <0856412f-048e-4698-bd9d-83393fe93ec5@os.amperecomputing.com> (raw)
In-Reply-To: <968a59cb-2d10-444a-bdcf-55525159f1ba@kuka.com>



On 5/7/25 4:44 AM, Ignacio Moreno Gonzalez wrote:
> This patch resulted from the discussion on [0]. The issue I described there consisted of two aspects:
>
>    - CRIU saw a memory mapping containing the "nh" flag on a !THP kernel. This was addressed by my submission.
>    - CRIU tried to set the "nh" flag with madvise(), which resulted on -EINVAL.
>
> The issue is actually solved with the patch I submitted. But it was also discussed that calling madvise() with VM_NOHUGEPAGE should be a no-op and should not fail. That's why this patch was created.
>
> On 5/7/2025 1:40 AM, Andrew Morton wrote:
>>> +#ifndef CONFIG_TRANSPARENT_HUGEPAGE
>>> +#include <uapi/asm-generic/mman-common.h>
>>> +#endif
>> Why is the #ifndef here?
> Because this is only included for the definition of VM_NOHUGEPAGE, which is only needed for the !THP case.

Can you just simply include <linux/mman.h> ?

Thanks,
Yang

>> This is the only file under include/linux which directly includes
>> something from uapi/asm-generic.  Indicates that we're doing something
>> wrong.
> If we want to differentiate the behavior of hugepage_madvise() depending on the advice, then we need the definitions for the different advices... Maybe this is not the correct place to do this? We could also do that differentiation in madvise.c.
>
>> If this hunk is truly the correct approach then I think we need a
>> comment here fully explaining what is going on.   Because it looks odd!
> To me, differentiating the behaviour of madvise() for MADV_HUGEPAGE and MADV_NOHUGEPAGE seems ok, and that was also the consensus on [0]. However, I lack the expertise to determine if this is the best place in the code to implement this change. Perhaps Lorenzo or Matthew can provide feedback here.
>
>
> [0]: https://lore.kernel.org/linux-mm/20250502-map-map_stack-to-vm_nohugepage-only-if-thp-is-enabled-v1-1-113cc634cd51@kuka.com/



  reply	other threads:[~2025-05-07 15:57 UTC|newest]

Thread overview: 14+ 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 via B4 Relay
2025-05-06 13:44 ` [PATCH v2 1/2] mm: mmap: map " 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 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 [this message]
2025-05-07 16:11         ` Ignacio Moreno Gonzalez
2025-05-07 22:38           ` Yang Shi
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=0856412f-048e-4698-bd9d-83393fe93ec5@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox