linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Baolin Wang <baolin.wang@linux.alibaba.com>
To: Oscar Salvador <osalvador@suse.de>
Cc: akpm@linux-foundation.org, muchun.song@linux.dev,
	david@redhat.com, linmiaohe@huawei.com, naoya.horiguchi@nec.com,
	mhocko@kernel.org, linux-mm@kvack.org,
	linux-kernel@vger.kernel.org
Subject: Re: [RFC PATCH 2/3] mm: hugetlb: make the hugetlb migration strategy consistent
Date: Mon, 26 Feb 2024 11:34:51 +0800	[thread overview]
Message-ID: <9b49d2c8-4ace-4095-8610-8becf96eb023@linux.alibaba.com> (raw)
In-Reply-To: <ZdipdrJoN7LS3h9m@localhost.localdomain>



On 2024/2/23 22:19, Oscar Salvador wrote:
> On Fri, Feb 23, 2024 at 10:56:48AM +0800, Baolin Wang wrote:
>   
>> I previously considered passing the MR_reason argument to the
>> htlb_modify_alloc_mask(), which is only used by hugetlb migration.
>> But in alloc_hugetlb_folio_nodemask(), if there are available hugetlb on
>> other nodes, we should allow migrating, that will not break the per-node
>> hugetlb pool.
>>
>> That's why I just change the gfp_mask for allocating a new hguetlb when
>> migration, that can break the pool.
> 
> Code-wise I think this is good, but I'm having some feelings
> about where filter out the mask.
> Ok, I'm trying to get my head around this.
> It's been a while since I looked into hugetlb code, so here we go.
> 
> You mentioned that the only reason not to fiddle with gfp_mask before calling
> in alloc_hugetlb_folio_nodemask(), was that we might be able to find a hugetlb
> page in another node, and that that's ok because since all nodes remain with
> the same number of hugetlb pages, per-node pool doesn't get broken.
> 
> Now, I see that dequeue_hugetlb_folio_nodemask() first tries to get the zonelist
> of the preferred node, and AFAICS, if it has !GFP_THISNODE, it should also
> get the zonelists of all other nodes, so we might fallback.

Right.

> In the hope of finding a way to be able to filter out in htlb_modify_alloc_mask(),
> I was trying to see whether we could skip GFP_THISNODE in
> dequeue_hugetlb_folio_nodemask() but no because we might end up dequeueing
> a hugetlb which sits in another node, while we really specified __GFP_THISNODE.
> 
> The only way might be to somehow decouple dequeue_hugetlb_folio_nodemask()
> from alloc_hugetlb_folio_nodemask() and do some kind of gfp modification
> between the two calls.

IMO, I'm not sure whether it's appropriate to decouple 
dequeue_hugetlb_folio_nodemask() from alloc_hugetlb_folio_nodemask() 
into two separate functions for the users to call, because these details 
should be hidden within the hugetlb core implementation.

Instead, I can move the gfp_mask fiddling into a new helper, and move 
the helper into alloc_migrate_hugetlb_folio(). Temporary hugetlb 
allocation has its own gfp strategy seems reasonable to me.

> Another thing I dislike is the "-1" in alloc_hugetlb_folio_vma().
> I think at least it deserves a comment like "Passing -1 will make us stick
> to GFP_THISNODE".

Sure, will add some comments.

> Although that is another thing, we will pass "-1" which forces GFP_THISNODE
> when allocating a newly fresh hugetlb page, but in dequeue_hugetlb_folio_nodemask()
> we might get a page from a different node.
> That doesn't break per-node pool, but it is somehow odd?

Only hugetlb_mfill_atomic_pte() will use -1, which is used to allocate a 
temporary hugetlb to hold the copied content that will be immediately 
released if uffd copy completes (see commmit 8cc5fcbb5be8). Therefore, 
here it is allowed to fallback to available hugetlb on other nodes, but 
it is not allowed to break the per-node pool.


  reply	other threads:[~2024-02-26  3:35 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-02-21  9:27 [RFC PATCH 0/3] " Baolin Wang
2024-02-21  9:27 ` [RFC PATCH 1/3] mm: record the migration reason for struct migration_target_control Baolin Wang
2024-02-21  9:27 ` [RFC PATCH 2/3] mm: hugetlb: make the hugetlb migration strategy consistent Baolin Wang
2024-02-22 22:15   ` Oscar Salvador
2024-02-23  2:56     ` Baolin Wang
2024-02-23 14:19       ` Oscar Salvador
2024-02-26  3:34         ` Baolin Wang [this message]
2024-02-26  9:17           ` Oscar Salvador
2024-02-26  9:59             ` Baolin Wang
2024-02-21  9:27 ` [RFC PATCH 3/3] docs: hugetlbpage.rst: add hugetlb migration description Baolin Wang

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=9b49d2c8-4ace-4095-8610-8becf96eb023@linux.alibaba.com \
    --to=baolin.wang@linux.alibaba.com \
    --cc=akpm@linux-foundation.org \
    --cc=david@redhat.com \
    --cc=linmiaohe@huawei.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=mhocko@kernel.org \
    --cc=muchun.song@linux.dev \
    --cc=naoya.horiguchi@nec.com \
    --cc=osalvador@suse.de \
    /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