Re: [Xen-devel] [PATCH for-next 1/3] x86/smp: Rework cpu_smpboot_alloc() to cope with more than just -ENOMEM

2017-10-16 Thread Wei Liu
On Mon, Oct 02, 2017 at 05:13:47PM +0100, Andrew Cooper wrote:
> No functional change.
> 
> Signed-off-by: Andrew Cooper 

Reviewed-by: Wei Liu 

___
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel


Re: [Xen-devel] [PATCH for-next 1/3] x86/smp: Rework cpu_smpboot_alloc() to cope with more than just -ENOMEM

2017-10-12 Thread Jan Beulich
>>> On 02.10.17 at 18:13,  wrote:
> No functional change.
> 
> Signed-off-by: Andrew Cooper 

Reviewed-by: Jan Beulich 



___
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel


[Xen-devel] [PATCH for-next 1/3] x86/smp: Rework cpu_smpboot_alloc() to cope with more than just -ENOMEM

2017-10-02 Thread Andrew Cooper
No functional change.

Signed-off-by: Andrew Cooper 
---
CC: Jan Beulich 
CC: Wei Liu 
CC: George Dunlap 
---
 xen/arch/x86/smpboot.c | 31 ++-
 1 file changed, 18 insertions(+), 13 deletions(-)

diff --git a/xen/arch/x86/smpboot.c b/xen/arch/x86/smpboot.c
index 3ca716c..a3c42ea 100644
--- a/xen/arch/x86/smpboot.c
+++ b/xen/arch/x86/smpboot.c
@@ -696,33 +696,34 @@ static int cpu_smpboot_alloc(unsigned int cpu)
 nodeid_t node = cpu_to_node(cpu);
 struct desc_struct *gdt;
 unsigned long stub_page;
+int rc = -ENOMEM;
 
 if ( node != NUMA_NO_NODE )
 memflags = MEMF_node(node);
 
 stack_base[cpu] = alloc_xenheap_pages(STACK_ORDER, memflags);
 if ( stack_base[cpu] == NULL )
-goto oom;
+goto out;
 memguard_guard_stack(stack_base[cpu]);
 
 order = get_order_from_pages(NR_RESERVED_GDT_PAGES);
 per_cpu(gdt_table, cpu) = gdt = alloc_xenheap_pages(order, memflags);
 if ( gdt == NULL )
-goto oom;
+goto out;
 memcpy(gdt, boot_cpu_gdt_table, NR_RESERVED_GDT_PAGES * PAGE_SIZE);
 BUILD_BUG_ON(NR_CPUS > 0x1);
 gdt[PER_CPU_GDT_ENTRY - FIRST_RESERVED_GDT_ENTRY].a = cpu;
 
 per_cpu(compat_gdt_table, cpu) = gdt = alloc_xenheap_pages(order, 
memflags);
 if ( gdt == NULL )
-goto oom;
+goto out;
 memcpy(gdt, boot_cpu_compat_gdt_table, NR_RESERVED_GDT_PAGES * PAGE_SIZE);
 gdt[PER_CPU_GDT_ENTRY - FIRST_RESERVED_GDT_ENTRY].a = cpu;
 
 order = get_order_from_bytes(IDT_ENTRIES * sizeof(idt_entry_t));
 idt_tables[cpu] = alloc_xenheap_pages(order, memflags);
 if ( idt_tables[cpu] == NULL )
-goto oom;
+goto out;
 memcpy(idt_tables[cpu], idt_table, IDT_ENTRIES * sizeof(idt_entry_t));
 
 for ( stub_page = 0, i = cpu & ~(STUBS_PER_PAGE - 1);
@@ -735,21 +736,25 @@ static int cpu_smpboot_alloc(unsigned int cpu)
 BUG_ON(i == cpu);
 stub_page = alloc_stub_page(cpu, _cpu(stubs.mfn, cpu));
 if ( !stub_page )
-goto oom;
+goto out;
 per_cpu(stubs.addr, cpu) = stub_page + STUB_BUF_CPU_OFFS(cpu);
 
 if ( secondary_socket_cpumask == NULL &&
  (secondary_socket_cpumask = xzalloc(cpumask_t)) == NULL )
-goto oom;
+goto out;
 
-if ( zalloc_cpumask_var(_cpu(cpu_sibling_mask, cpu)) &&
- zalloc_cpumask_var(_cpu(cpu_core_mask, cpu)) &&
- alloc_cpumask_var(_cpu(scratch_cpumask, cpu)) )
-return 0;
+if ( !(zalloc_cpumask_var(_cpu(cpu_sibling_mask, cpu)) &&
+   zalloc_cpumask_var(_cpu(cpu_core_mask, cpu)) &&
+   alloc_cpumask_var(_cpu(scratch_cpumask, cpu))) )
+goto out;
+
+rc = 0;
+
+ out:
+if ( rc )
+cpu_smpboot_free(cpu);
 
- oom:
-cpu_smpboot_free(cpu);
-return -ENOMEM;
+return rc;
 }
 
 static int cpu_smpboot_callback(
-- 
2.1.4


___
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel