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: Fri, 23 Feb 2024 10:56:48 +0800 [thread overview]
Message-ID: <0a06dc7f-3a49-42ba-8221-0b4a3777ac0b@linux.alibaba.com> (raw)
In-Reply-To: <ZdfHi142dvQuN7B-@localhost.localdomain>
On 2024/2/23 06:15, Oscar Salvador wrote:
> On Wed, Feb 21, 2024 at 05:27:54PM +0800, Baolin Wang wrote:
>> Based on the analysis of the various scenarios above, determine whether fallback is
>> permitted according to the migration reason in alloc_hugetlb_folio_nodemask().
>
> Hi Baolin,
>
> The high level reasoning makes sense to me, taking a step back and
> thinking about all cases and possible outcomes makes sense to me.
>
> I plan to look closer, but I something that caught my eye:
Thanks for reviewing.
>> }
>> spin_unlock_irq(&hugetlb_lock);
>>
>> + if (gfp_mask & __GFP_THISNODE)
>> + goto alloc_new;
>> +
>> + /*
>> + * Note: the memory offline, memory failure and migration syscalls can break
>> + * the per-node hugetlb pool. Other cases can not allocate new hugetlb on
>> + * other nodes.
>> + */
>> + switch (reason) {
>> + case MR_MEMORY_HOTPLUG:
>> + case MR_MEMORY_FAILURE:
>> + case MR_SYSCALL:
>> + case MR_MEMPOLICY_MBIND:
>> + allowed_fallback = true;
>> + break;
>> + default:
>> + break;
>> + }
>> +
>> + if (!allowed_fallback)
>> + gfp_mask |= __GFP_THISNODE;
>
> I think it would be better if instead of fiddling with gfp here,
> have htlb_alloc_mask() have a second argument with the MR_reason,
> do the switch there and enable GFP_THISNODE.
> Then alloc_hugetlb_folio_nodemask() would already get the right mask. >
> I think that that might be more clear as it gets encapsulated in the
> function that directly gives us the gfp.
>
> Does that makes sense?
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.
struct folio *alloc_hugetlb_folio_nodemask(struct hstate *h, int
preferred_nid,
nodemask_t *nmask, gfp_t gfp_mask)
{
spin_lock_irq(&hugetlb_lock);
if (available_huge_pages(h)) {
struct folio *folio;
folio = dequeue_hugetlb_folio_nodemask(h, gfp_mask,
preferred_nid, nmask);
if (folio) {
spin_unlock_irq(&hugetlb_lock);
return folio;
}
}
......
next prev parent reply other threads:[~2024-02-23 2:57 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 [this message]
2024-02-23 14:19 ` Oscar Salvador
2024-02-26 3:34 ` Baolin Wang
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=0a06dc7f-3a49-42ba-8221-0b4a3777ac0b@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