lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <0c4c6f79-62d1-4ccd-b5e3-f76c9000ff3d@amd.com>
Date: Fri, 28 Mar 2025 14:09:18 +0530
From: "Aithal, Srikanth" <sraithal@....com>
To: "Kirill A. Shutemov" <kirill.shutemov@...ux.intel.com>,
 Tom Lendacky <thomas.lendacky@....com>
Cc: Steven Rostedt <rostedt@...dmis.org>, Jason Baron <jbaron@...mai.com>,
 Peter Zijlstra <peterz@...radead.org>, Josh Poimboeuf <jpoimboe@...nel.org>,
 Ard Biesheuvel <ardb@...nel.org>,
 Linux-Next Mailing List <linux-next@...r.kernel.org>,
 open list <linux-kernel@...r.kernel.org>,
 "Roth, Michael" <Michael.Roth@....com>
Subject: Re: linux-next regression: SNP Guest boot hangs with certain cpu/mem
 config combination

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@...ux.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.



Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ