linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Oscar Salvador <osalvador@suse.de>
To: Baolin Wang <baolin.wang@linux.alibaba.com>
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: Thu, 22 Feb 2024 23:15:39 +0100	[thread overview]
Message-ID: <ZdfHi142dvQuN7B-@localhost.localdomain> (raw)
In-Reply-To: <0514e5139b17ecf3cd9e09d86c93e586c56688dc.1708507022.git.baolin.wang@linux.alibaba.com>

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:


>  	}
>  	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?


-- 
Oscar Salvador
SUSE Labs


  reply	other threads:[~2024-02-22 22:14 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 [this message]
2024-02-23  2:56     ` Baolin Wang
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=ZdfHi142dvQuN7B-@localhost.localdomain \
    --to=osalvador@suse.de \
    --cc=akpm@linux-foundation.org \
    --cc=baolin.wang@linux.alibaba.com \
    --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 \
    /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