This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
Home Products Support Community News


[Xen-devel] [PATCH] Only include online cpus in cpu_mask_to_apicid_flat

To: Keir Fraser <keir.fraser@xxxxxxxxxxxxx>
Subject: [Xen-devel] [PATCH] Only include online cpus in cpu_mask_to_apicid_flat
From: "Yang, Sheng" <sheng.yang@xxxxxxxxx>
Date: Tue, 31 Aug 2010 15:19:01 +0800
Cc: "xen-devel@xxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxx>
Delivery-date: Tue, 31 Aug 2010 00:19:56 -0700
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
List-help: <mailto:xen-devel-request@lists.xensource.com?subject=help>
List-id: Xen developer discussion <xen-devel.lists.xensource.com>
List-post: <mailto:xen-devel@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=unsubscribe>
Organization: Intel Opensource Technology Center
Sender: xen-devel-bounces@xxxxxxxxxxxxxxxxxxx
User-agent: KMail/1.13.2 (Linux/2.6.32-24-generic; KDE/4.4.2; x86_64; ; )
The former fix of __bind_irq_vector() can ensure the destination field in 
redirection table is valid by limiting the cpu_mask to the online cpus. But 
is another issue that some interrupts(timer and serial) would like to be 
delivered to all online cpus with LPR delivery mode. But at the time of 
bind_irq_vector() called, there were only one cpu(BSP) was online, so the 
interrupts would always be delivered to BSP. This method can work but not the 

In fact, setup_ioapic_dest() would be called to reprogram the IOAPIC 
table to follow "irq_cfg->cpu_mask", after SMP initialization work was 
done. So I think the better choice is to keep the original value in irq_cfg-
>cpu_mask, and just make sure the value we wrote to the IOAPIC redirection 
is valid. Then modifying cpu_mask_to_apicid_flat() seems like a better idea.

This patch would revert the fix of __bind_irq_vector(), and modify 
cpu_mask_to_apicid_flat() to contain only online CPUs.

Yang, Sheng

diff --git a/xen/arch/x86/genapic/delivery.c b/xen/arch/x86/genapic/delivery.c
--- a/xen/arch/x86/genapic/delivery.c
+++ b/xen/arch/x86/genapic/delivery.c
@@ -36,9 +36,10 @@
        return cpu_online_map;

+/* Cover only online cpus */
 unsigned int cpu_mask_to_apicid_flat(cpumask_t cpumask)
-       return cpus_addr(cpumask)[0]&0xFF;
+       return cpus_addr(cpumask)[0] & cpus_addr(cpu_online_map)[0] & 0xFF;

diff --git a/xen/arch/x86/irq.c b/xen/arch/x86/irq.c
--- a/xen/arch/x86/irq.c
+++ b/xen/arch/x86/irq.c
@@ -86,14 +86,14 @@
     cpus_and(online_mask, cpu_mask, cpu_online_map);
     if (cpus_empty(online_mask))
         return -EINVAL;
-    if ((cfg->vector == vector) && cpus_equal(cfg->cpu_mask, online_mask))
+    if ((cfg->vector == vector) && cpus_equal(cfg->cpu_mask, cpu_mask))
         return 0;
     if (cfg->vector != IRQ_VECTOR_UNASSIGNED)
         return -EBUSY;
     for_each_cpu_mask(cpu, online_mask)
         per_cpu(vector_irq, cpu)[vector] = irq;
     cfg->vector = vector;
-    cfg->cpu_mask = online_mask;
+    cfg->cpu_mask = cpu_mask;
     irq_status[irq] = IRQ_USED;
     if (IO_APIC_IRQ(irq))
         irq_vector[irq] = vector;

Attachment: dest_fix.patch
Description: Text Data

Xen-devel mailing list
<Prev in Thread] Current Thread [Next in Thread>