[PATCH 1/2] xen/arm: Defer request_irq on secondary CPUs after local_irq_enable

Henry Wang posted 2 patches 3 years, 9 months ago
There is a newer version of this series
[PATCH 1/2] xen/arm: Defer request_irq on secondary CPUs after local_irq_enable
Posted by Henry Wang 3 years, 9 months ago
With the enhanced ASSERT_ALLOC_CONTEXT, calling request_irq before
local_irq_enable on secondary cores will lead to

(XEN) Xen call trace:
(XEN) [<000000000021d86c>] alloc_xenheap_pages+0x74/0x194 (PC)
(XEN) [<000000000021d864>] alloc_xenheap_pages+0x6c/0x194 (LR)
(XEN) [<0000000000229e90>] xmalloc_tlsf.c#xmalloc_pool_get+0x1c/0x28
(XEN) [<000000000022a270>] xmem_pool_alloc+0x21c/0x448
(XEN) [<000000000022a8dc>] _xmalloc+0x8c/0x290
(XEN) [<000000000026b57c>] request_irq+0x40/0xb8
(XEN) [<0000000000272780>] init_timer_interrupt+0x74/0xcc
(XEN) [<000000000027212c>] start_secondary+0x1b4/0x238
(XEN) [<0000000084000200>] 0000000084000200
(XEN)
(XEN)
(XEN) ****************************************
(XEN) Panic on CPU 4:
(XEN) Assertion '!in_irq() && (local_irq_is_enabled() ||
num_online_cpus() <= 1)' failed at common/page_alloc.c:2212
(XEN) ****************************************

on systems without a big enough pool for xmalloc() to cater the
requested size.

Reported-by: Wei Chen <Wei.Chen@arm.com>
Suggested-by: Julien Grall <jgrall@amazon.com>
Signed-off-by: Henry Wang <Henry.Wang@arm.com>
Change-Id: Iebdde81f52785b0c6e037c981ff68922db016d08
---
 xen/arch/arm/smpboot.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/xen/arch/arm/smpboot.c b/xen/arch/arm/smpboot.c
index 7bfd0a73a7..a057e85ac1 100644
--- a/xen/arch/arm/smpboot.c
+++ b/xen/arch/arm/smpboot.c
@@ -361,9 +361,6 @@ void start_secondary(void)
 
     init_secondary_IRQ();
 
-    init_maintenance_interrupt();
-    init_timer_interrupt();
-
     set_current(idle_vcpu[cpuid]);
 
     setup_cpu_sibling_map(cpuid);
@@ -380,6 +377,10 @@ void start_secondary(void)
     cpumask_set_cpu(cpuid, &cpu_online_map);
 
     local_irq_enable();
+
+    init_maintenance_interrupt();
+    init_timer_interrupt();
+
     local_abort_enable();
 
     check_local_cpu_errata();
-- 
2.25.1
Re: [PATCH 1/2] xen/arm: Defer request_irq on secondary CPUs after local_irq_enable
Posted by Julien Grall 3 years, 9 months ago
Hi Henry,

The CC list doesn't seem to contain the other maintainers. Please use 
the scripts provided in the repo (such scripts/add_maintainers.pl) to 
generate the CC.

On 05/05/2022 03:54, Henry Wang wrote:
> With the enhanced ASSERT_ALLOC_CONTEXT, calling request_irq before
> local_irq_enable on secondary cores will lead to
> 
> (XEN) Xen call trace:
> (XEN) [<000000000021d86c>] alloc_xenheap_pages+0x74/0x194 (PC)
> (XEN) [<000000000021d864>] alloc_xenheap_pages+0x6c/0x194 (LR)
> (XEN) [<0000000000229e90>] xmalloc_tlsf.c#xmalloc_pool_get+0x1c/0x28
> (XEN) [<000000000022a270>] xmem_pool_alloc+0x21c/0x448
> (XEN) [<000000000022a8dc>] _xmalloc+0x8c/0x290
> (XEN) [<000000000026b57c>] request_irq+0x40/0xb8
> (XEN) [<0000000000272780>] init_timer_interrupt+0x74/0xcc
> (XEN) [<000000000027212c>] start_secondary+0x1b4/0x238
> (XEN) [<0000000084000200>] 0000000084000200
> (XEN)
> (XEN)
> (XEN) ****************************************
> (XEN) Panic on CPU 4:
> (XEN) Assertion '!in_irq() && (local_irq_is_enabled() ||
> num_online_cpus() <= 1)' failed at common/page_alloc.c:2212
> (XEN) ****************************************
> 
> on systems without a big enough pool for xmalloc() to cater the
> requested size.

Can you explain in the commit message, why this is OK to move the code 
after enabling interrupts?

> 
> Reported-by: Wei Chen <Wei.Chen@arm.com>
> Suggested-by: Julien Grall <jgrall@amazon.com>
> Signed-off-by: Henry Wang <Henry.Wang@arm.com>
> Change-Id: Iebdde81f52785b0c6e037c981ff68922db016d08
> ---
>   xen/arch/arm/smpboot.c | 7 ++++---
>   1 file changed, 4 insertions(+), 3 deletions(-)
> 
> diff --git a/xen/arch/arm/smpboot.c b/xen/arch/arm/smpboot.c
> index 7bfd0a73a7..a057e85ac1 100644
> --- a/xen/arch/arm/smpboot.c
> +++ b/xen/arch/arm/smpboot.c
> @@ -361,9 +361,6 @@ void start_secondary(void)
>   
>       init_secondary_IRQ();
>   
> -    init_maintenance_interrupt();
> -    init_timer_interrupt();
> -
>       set_current(idle_vcpu[cpuid]);
>   
>       setup_cpu_sibling_map(cpuid);
> @@ -380,6 +377,10 @@ void start_secondary(void)
>       cpumask_set_cpu(cpuid, &cpu_online_map);
>   
>       local_irq_enable();
> +
> +    init_maintenance_interrupt();
> +    init_timer_interrupt();
> +
>       local_abort_enable();
>   
>       check_local_cpu_errata();

Cheers,

-- 
Julien Grall
RE: [PATCH 1/2] xen/arm: Defer request_irq on secondary CPUs after local_irq_enable
Posted by Henry Wang 3 years, 9 months ago
Hi Julien,

> -----Original Message-----
> From: Julien Grall <julien@xen.org>
> Hi Henry,
> 
> The CC list doesn't seem to contain the other maintainers. Please use
> the scripts provided in the repo (such scripts/add_maintainers.pl) to
> generate the CC.
> 
> On 05/05/2022 03:54, Henry Wang wrote:
> > With the enhanced ASSERT_ALLOC_CONTEXT, calling request_irq before
> > local_irq_enable on secondary cores will lead to
> >
> > (XEN) Xen call trace:
> > (XEN) [<000000000021d86c>] alloc_xenheap_pages+0x74/0x194 (PC)
> > (XEN) [<000000000021d864>] alloc_xenheap_pages+0x6c/0x194 (LR)
> > (XEN) [<0000000000229e90>] xmalloc_tlsf.c#xmalloc_pool_get+0x1c/0x28
> > (XEN) [<000000000022a270>] xmem_pool_alloc+0x21c/0x448
> > (XEN) [<000000000022a8dc>] _xmalloc+0x8c/0x290
> > (XEN) [<000000000026b57c>] request_irq+0x40/0xb8
> > (XEN) [<0000000000272780>] init_timer_interrupt+0x74/0xcc
> > (XEN) [<000000000027212c>] start_secondary+0x1b4/0x238
> > (XEN) [<0000000084000200>] 0000000084000200
> > (XEN)
> > (XEN)
> > (XEN) ****************************************
> > (XEN) Panic on CPU 4:
> > (XEN) Assertion '!in_irq() && (local_irq_is_enabled() ||
> > num_online_cpus() <= 1)' failed at common/page_alloc.c:2212
> > (XEN) ****************************************
> >
> > on systems without a big enough pool for xmalloc() to cater the
> > requested size.
> 
> Can you explain in the commit message, why this is OK to move the code
> after enabling interrupts?

Sure, will correct both issues in v2.

Kind regards,
Henry

> 
> >
> > Reported-by: Wei Chen <Wei.Chen@arm.com>
> > Suggested-by: Julien Grall <jgrall@amazon.com>
> > Signed-off-by: Henry Wang <Henry.Wang@arm.com>
> > Change-Id: Iebdde81f52785b0c6e037c981ff68922db016d08
> > ---
> >   xen/arch/arm/smpboot.c | 7 ++++---
> >   1 file changed, 4 insertions(+), 3 deletions(-)
> >
> > diff --git a/xen/arch/arm/smpboot.c b/xen/arch/arm/smpboot.c
> > index 7bfd0a73a7..a057e85ac1 100644
> > --- a/xen/arch/arm/smpboot.c
> > +++ b/xen/arch/arm/smpboot.c
> > @@ -361,9 +361,6 @@ void start_secondary(void)
> >
> >       init_secondary_IRQ();
> >
> > -    init_maintenance_interrupt();
> > -    init_timer_interrupt();
> > -
> >       set_current(idle_vcpu[cpuid]);
> >
> >       setup_cpu_sibling_map(cpuid);
> > @@ -380,6 +377,10 @@ void start_secondary(void)
> >       cpumask_set_cpu(cpuid, &cpu_online_map);
> >
> >       local_irq_enable();
> > +
> > +    init_maintenance_interrupt();
> > +    init_timer_interrupt();
> > +
> >       local_abort_enable();
> >
> >       check_local_cpu_errata();
> 
> Cheers,
> 
> --
> Julien Grall
RE: [PATCH 1/2] xen/arm: Defer request_irq on secondary CPUs after local_irq_enable
Posted by Henry Wang 3 years, 9 months ago
Hi, 

> -----Original Message-----
> Subject: [PATCH 1/2] xen/arm: Defer request_irq on secondary CPUs after
> local_irq_enable
> 
> With the enhanced ASSERT_ALLOC_CONTEXT, calling request_irq before
> local_irq_enable on secondary cores will lead to
> 
> (XEN) Xen call trace:
> (XEN) [<000000000021d86c>] alloc_xenheap_pages+0x74/0x194 (PC)
> (XEN) [<000000000021d864>] alloc_xenheap_pages+0x6c/0x194 (LR)
> (XEN) [<0000000000229e90>] xmalloc_tlsf.c#xmalloc_pool_get+0x1c/0x28
> (XEN) [<000000000022a270>] xmem_pool_alloc+0x21c/0x448
> (XEN) [<000000000022a8dc>] _xmalloc+0x8c/0x290
> (XEN) [<000000000026b57c>] request_irq+0x40/0xb8
> (XEN) [<0000000000272780>] init_timer_interrupt+0x74/0xcc
> (XEN) [<000000000027212c>] start_secondary+0x1b4/0x238
> (XEN) [<0000000084000200>] 0000000084000200
> (XEN)
> (XEN)
> (XEN) ****************************************
> (XEN) Panic on CPU 4:
> (XEN) Assertion '!in_irq() && (local_irq_is_enabled() ||
> num_online_cpus() <= 1)' failed at common/page_alloc.c:2212
> (XEN) ****************************************
> 
> on systems without a big enough pool for xmalloc() to cater the
> requested size.
> 
> Reported-by: Wei Chen <Wei.Chen@arm.com>
> Suggested-by: Julien Grall <jgrall@amazon.com>
> Signed-off-by: Henry Wang <Henry.Wang@arm.com>
> Change-Id: Iebdde81f52785b0c6e037c981ff68922db016d08

Sorry about the Change-Id, forgot to remove it before sending the mail to ML,
will remove it in V2. Same for PATCH 2/2.

Kind regards,
Henry

> ---
>  xen/arch/arm/smpboot.c | 7 ++++---
>  1 file changed, 4 insertions(+), 3 deletions(-)