linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Miaohe Lin <linmiaohe@huawei.com>
To: Andrew Morton <akpm@linux-foundation.org>
Cc: Sidhartha Kumar <sidhartha.kumar@oracle.com>,
	<naoya.horiguchi@nec.com>, <osalvador@suse.de>,
	<linux-mm@kvack.org>, <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH v2] mm/memory-failure: fix deadlock when hugetlb_optimize_vmemmap is enabled
Date: Tue, 16 Apr 2024 11:23:01 +0800	[thread overview]
Message-ID: <e18fd131-2a31-48a6-d889-0a03ad1ffd38@huawei.com> (raw)
In-Reply-To: <20240412162111.10f67ad0f001734464b53ad8@linux-foundation.org>

On 2024/4/13 7:21, Andrew Morton wrote:
> On Fri, 12 Apr 2024 16:11:52 +0800 Miaohe Lin <linmiaohe@huawei.com> wrote:
> 
>>> I recently sent a patch[1] to convert dissolve_free_huge_page() to folios which changes the function name and the name referenced in the comment so this will conflict with my patch. It's in mm-unstable now, would you be able to rebase to that in a new version?
>>>
> 
> This patch is a hotfixes, cc:stable one so the mm-unstable material will be
> based on top of this change.
> 
> I've queued this change up as a -fix against v1.  And I've retained
> this changelog addition:
> 
> : This issue won't occur until commit a6b40850c442 ("mm: hugetlb: replace
> : hugetlb_free_vmemmap_enabled with a static_key").  As it introduced
> : rlock(cpu_hotplug_lock) in dissolve_free_huge_page() code path while
> : lock(pcp_batch_high_lock) is already in the __page_handle_poison().
> 
> And I've queued another -fix to reflow that block comment to 80 columns.
> 
> --- a/mm/memory-failure.c~mm-memory-failure-fix-deadlock-when-hugetlb_optimize_vmemmap-is-enabled-v2-fix
> +++ a/mm/memory-failure.c
> @@ -155,14 +155,16 @@ static int __page_handle_poison(struct p
>  	int ret;
>  
>  	/*
> -	 * zone_pcp_disable() can't be used here. It will hold pcp_batch_high_lock and
> -	 * dissolve_free_huge_page() might hold cpu_hotplug_lock via static_key_slow_dec()
> -	 * when hugetlb vmemmap optimization is enabled. This will break current lock
> -	 * dependency chain and leads to deadlock.
> -	 * Disabling pcp before dissolving the page was a deterministic approach because
> -	 * we made sure that those pages cannot end up in any PCP list. Draining PCP lists
> -	 * expels those pages to the buddy system, but nothing guarantees that those pages
> -	 * do not get back to a PCP queue if we need to refill those.
> +	 * zone_pcp_disable() can't be used here. It will
> +	 * hold pcp_batch_high_lock and dissolve_free_huge_page() might hold
> +	 * cpu_hotplug_lock via static_key_slow_dec() when hugetlb vmemmap
> +	 * optimization is enabled. This will break current lock dependency
> +	 * chain and leads to deadlock.
> +	 * Disabling pcp before dissolving the page was a deterministic
> +	 * approach because we made sure that those pages cannot end up in any
> +	 * PCP list. Draining PCP lists expels those pages to the buddy system,
> +	 * but nothing guarantees that those pages do not get back to a PCP
> +	 * queue if we need to refill those.
>  	 */
>  	ret = dissolve_free_huge_page(page);
>  	if (!ret) {
> _
> 

Many thanks for doing this. :)
.

> .
> 



  reply	other threads:[~2024-04-16  3:23 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-04-12  2:57 Miaohe Lin
2024-04-12  3:12 ` Sidhartha Kumar
2024-04-12  8:11   ` Miaohe Lin
2024-04-12 23:21     ` Andrew Morton
2024-04-16  3:23       ` Miaohe Lin [this message]
2024-04-16 17:54 ` Jane Chu

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=e18fd131-2a31-48a6-d889-0a03ad1ffd38@huawei.com \
    --to=linmiaohe@huawei.com \
    --cc=akpm@linux-foundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=naoya.horiguchi@nec.com \
    --cc=osalvador@suse.de \
    --cc=sidhartha.kumar@oracle.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