mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "Aithal, Srikanth" <sraithal@amd.com>
To: "Kirill A. Shutemov" <kirill.shutemov@linux.intel.com>,
	Tom Lendacky <thomas.lendacky@amd.com>
Cc: Steven Rostedt <rostedt@goodmis.org>,
	Jason Baron <jbaron@akamai.com>,
	Peter Zijlstra <peterz@infradead.org>,
	Josh Poimboeuf <jpoimboe@kernel.org>,
	Ard Biesheuvel <ardb@kernel.org>,
	Linux-Next Mailing List <linux-next@vger.kernel.org>,
	open list <linux-kernel@vger.kernel.org>,
	"Roth, Michael" <Michael.Roth@amd.com>
Subject: Re: linux-next regression: SNP Guest boot hangs with certain cpu/mem config combination
Date: Fri, 28 Mar 2025 14:09:18 +0530	[thread overview]
Message-ID: <0c4c6f79-62d1-4ccd-b5e3-f76c9000ff3d@amd.com> (raw)
In-Reply-To: <vhwle6fj3ifmcouppec5adegqludggsxcsxxveqa43hugtsdgy@pb7vd5cqjmx3>

On 3/28/2025 1:58 PM, Kirill A. Shutemov wrote:
> On Thu, Mar 27, 2025 at 07:39:22PM +0200, Kirill A. Shutemov wrote:
>> On Thu, Mar 27, 2025 at 11:02:24AM -0400, Steven Rostedt wrote:
>>> On Thu, 27 Mar 2025 16:43:43 +0200
>>> "Kirill A. Shutemov" <kirill.shutemov@linux.intel.com> wrote:
>>>
>>>>>> The only option I see so far is to drop static branch from this path.
>>>>>>
>>>>>> But I am not sure if it the only case were we use static branch from CPU
>>>>>> hotplug callbacks.
>>>>>>
>>>>>> Any other ideas?
>>>>>
>>>>>
>>>>> Hmmm, didn't take too close a look here, but there is the
>>>>> static_key_slow_dec_cpuslocked() variant, would that work here? Is the issue
>>>>> the caller may or may not have the cpu_hotplug lock?
>>>>
>>>> Yes. This is generic page alloc path and it can be called with and without
>>>> the lock.
>>>
>>> Note, it's not the static_branch that is an issue, it's enabling/disabling
>>> the static branch that is. Changing a static branch takes a bit of work as
>>> it does modify the kernel text.
>>>
>>> Is it possible to delay the update via a workqueue?
>>
>> Ah. Good point. Should work. I'll give it try.
> 
> The patch below fixes problem for me.
> 
> It is silly to add work_struct to zone for one-time cleanup, but I guess
> not a big deal.
> 
> Tom, Srikanth, could you please test it?
> 
> diff --git a/include/linux/mmzone.h b/include/linux/mmzone.h
> index 9540b41894da..ea5f7e0b675d 100644
> --- a/include/linux/mmzone.h
> +++ b/include/linux/mmzone.h
> @@ -964,6 +964,9 @@ struct zone {
>   #ifdef CONFIG_UNACCEPTED_MEMORY
>   	/* Pages to be accepted. All pages on the list are MAX_PAGE_ORDER */
>   	struct list_head	unaccepted_pages;
> +
> +	/* To be called once last page in the zone is accepted */
> +	struct work_struct	unaccepted_cleanup;
>   #endif
>   
>   	/* zone flags, see below */
> diff --git a/mm/internal.h b/mm/internal.h
> index 109ef30fee11..f2e6d42af6eb 100644
> --- a/mm/internal.h
> +++ b/mm/internal.h
> @@ -1516,6 +1516,7 @@ unsigned long move_page_tables(struct vm_area_struct *vma,
>   
>   #ifdef CONFIG_UNACCEPTED_MEMORY
>   void accept_page(struct page *page);
> +void unaccepted_cleanup_work(struct work_struct *work);
>   #else /* CONFIG_UNACCEPTED_MEMORY */
>   static inline void accept_page(struct page *page)
>   {
> diff --git a/mm/mm_init.c b/mm/mm_init.c
> index 2630cc30147e..d5a51f65dc4d 100644
> --- a/mm/mm_init.c
> +++ b/mm/mm_init.c
> @@ -1404,6 +1404,7 @@ static void __meminit zone_init_free_lists(struct zone *zone)
>   
>   #ifdef CONFIG_UNACCEPTED_MEMORY
>   	INIT_LIST_HEAD(&zone->unaccepted_pages);
> +	INIT_WORK(&zone->unaccepted_cleanup, unaccepted_cleanup_work);
>   #endif
>   }
>   
> diff --git a/mm/page_alloc.c b/mm/page_alloc.c
> index 4fe93029bcb6..e5f16fdb7eeb 100644
> --- a/mm/page_alloc.c
> +++ b/mm/page_alloc.c
> @@ -6921,6 +6921,11 @@ static DEFINE_STATIC_KEY_FALSE(zones_with_unaccepted_pages);
>   
>   static bool lazy_accept = true;
>   
> +void unaccepted_cleanup_work(struct work_struct *work)
> +{
> +	static_branch_dec(&zones_with_unaccepted_pages);
> +}
> +
>   static int __init accept_memory_parse(char *p)
>   {
>   	if (!strcmp(p, "lazy")) {
> @@ -6960,7 +6965,7 @@ static void __accept_page(struct zone *zone, unsigned long *flags,
>   	__free_pages_ok(page, MAX_PAGE_ORDER, FPI_TO_TAIL);
>   
>   	if (last)
> -		static_branch_dec(&zones_with_unaccepted_pages);
> +		schedule_work(&zone->unaccepted_cleanup);
>   }
>   
>   void accept_page(struct page *page)


Tested this patch ontop of next-20250328, it resolves the issue.



  reply	other threads:[~2025-03-28  8:39 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-03-25  9:10 Aithal, Srikanth
2025-03-25 13:33 ` Kirill A. Shutemov
2025-03-26 14:17   ` Aithal, Srikanth
2025-03-26 22:30   ` Tom Lendacky
2025-03-27 12:58     ` Kirill A. Shutemov
2025-03-27 14:25       ` Kirill A. Shutemov
2025-03-27 14:35         ` Jason Baron
2025-03-27 14:43           ` Kirill A. Shutemov
2025-03-27 15:02             ` Steven Rostedt
2025-03-27 17:39               ` Kirill A. Shutemov
2025-03-28  8:28                 ` Kirill A. Shutemov
2025-03-28  8:39                   ` Aithal, Srikanth [this message]
2025-03-28  9:09                   ` Kirill A. Shutemov
2025-03-28  9:17                     ` Ard Biesheuvel
2025-03-28  9:26                       ` Kirill A. Shutemov
2025-03-28  9:33                         ` Ard Biesheuvel
2025-03-28 10:54                           ` Kirill A. Shutemov
2025-03-28 16:18                             ` Ard Biesheuvel
2025-03-28  9:19                     ` Aithal, Srikanth
2025-03-28  9:25                       ` Kirill A. Shutemov

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=0c4c6f79-62d1-4ccd-b5e3-f76c9000ff3d@amd.com \
    --to=sraithal@amd.com \
    --cc=Michael.Roth@amd.com \
    --cc=ardb@kernel.org \
    --cc=jbaron@akamai.com \
    --cc=jpoimboe@kernel.org \
    --cc=kirill.shutemov@linux.intel.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-next@vger.kernel.org \
    --cc=peterz@infradead.org \
    --cc=rostedt@goodmis.org \
    --cc=thomas.lendacky@amd.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

all inboxes | Powered by JetHome®