WARNING - OLD ARCHIVES

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/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-devel

[Xen-devel] [PATCH] Fix showing of CPU Affinity by xm vcpu-list

To: xen-devel@xxxxxxxxxxxxxxxxxxx
Subject: [Xen-devel] [PATCH] Fix showing of CPU Affinity by xm vcpu-list
From: Masaki Kanno <kanno.masaki@xxxxxxxxxxxxxx>
Date: Mon, 19 May 2008 16:54:37 +0900
Delivery-date: Mon, 19 May 2008 00:55:33 -0700
Envelope-to: www-data@xxxxxxxxxxxxxxxxxx
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/cgi-bin/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=unsubscribe>
Sender: xen-devel-bounces@xxxxxxxxxxxxxxxxxxx
Hi,

I saw strange information about CPU Affinity as follows.
My machine has two physical CPUs.  When I set CPU Affinity with both 
existing physical CPU numbers and non-existing physical CPU numbers, 
the information of CPU Affinity occasionally was "any cpu".

# xm info | grep nr_cpus
nr_cpus                : 2
# xm vcpu-pin vm1 0 1
# xm vcpu-list vm1
Name                                ID  VCPU   CPU State   Time(s) CPU Affinity
vm1                                  6     0     1   -b-      33.6 1
# xm vcpu-pin vm1 0 1-2
# xm vcpu-list vm1
Name                                ID  VCPU   CPU State   Time(s) CPU Affinity
vm1                                  6     0     1   -b-      33.6 any cpu  <-- 
Why?
# xm debug-key q
# xm dmesg
(snip)
(XEN) VCPU information and callbacks for domain 6:
(XEN)     VCPU0: CPU1 [has=F] flags=1 upcall_pend = 00, upcall_mask = 00 
dirty_cpus={} cpu_affinity={1-2}
(XEN)     100 Hz periodic timer (period 10 ms)
(XEN)     Notifying guest (virq 1, port 0, stat 0/-1/0)
# xm vcpu-pin vm1 0 1,3
# xm vcpu-list vm1
Name                                ID  VCPU   CPU State   Time(s) CPU Affinity
vm1                                  6     0     1   -b-      33.6 1
# xm debug-key q
# xm dmesg
(snip)
(XEN) VCPU information and callbacks for domain 6:
(XEN)     VCPU0: CPU1 [has=T] flags=0 upcall_pend = 00, upcall_mask = 00 
dirty_cpus={1} cpu_affinity={1,3}
(XEN)     100 Hz periodic timer (period 10 ms)
(XEN)     Notifying guest (virq 1, port 0, stat 0/-1/0)
# xm vcpu-pin vm1 0 1,4
# xm vcpu-list vm1
Name                                ID  VCPU   CPU State   Time(s) CPU Affinity
vm1                                  6     0     1   -b-      33.6 any cpu  <-- 
Why?
# xm debug-key q
# xm dmesg
(snip)
(XEN) VCPU information and callbacks for domain 6:
(XEN)     VCPU0: CPU1 [has=T] flags=0 upcall_pend = 00, upcall_mask = 00 
dirty_cpus={1} cpu_affinity={1,4}
(XEN)     100 Hz periodic timer (period 10 ms)
(XEN)     Notifying guest (virq 1, port 0, stat 0/-1/0)


I investigated a cause why strange information was shown.  The following 
line had the cause. 

diff -r d0817f08599a tools/python/xen/xm/main.py
--- a/tools/python/xen/xm/main.py       Fri May 16 09:37:19 2008 +0100
+++ b/tools/python/xen/xm/main.py       Mon May 19 10:03:37 2008 +0900
@@ -1096,7 +1096,7 @@ def xm_vcpu_list(args):
 
             # normalize cpumap by modulus nr_cpus, and drop duplicates
             cpumap = dict.fromkeys(
-                       map(lambda x: x % nr_cpus, cpumap)).keys()
+                       filter(lambda x: x < nr_cpus, cpumap)).keys()
             if len(cpumap) == nr_cpus:
                 return "any cpu"
 
Because the line makes cpumap by using results of "x % nr_cpus", 
non-existing physical CPU numbers are handled as existing physical CPU 
numbers. 

  - 1 % 2 --> Physical CPU number 1
  - 2 % 2 --> Physical CPU number 0
  - 3 % 2 --> Physical CPU number 1
  - 4 % 2 --> Physical CPU number 0

This patch removes non-existing physical CPU numbers from cpumap by 
filter(), then this problem is solved. 

Signed-off-by: Masaki Kanno <kanno.masaki@xxxxxxxxxxxxxx>

Best regards,
 Kan

Attachment: xm_vcpu_list.patch
Description: Binary data

_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-devel
<Prev in Thread] Current Thread [Next in Thread>
  • [Xen-devel] [PATCH] Fix showing of CPU Affinity by xm vcpu-list, Masaki Kanno <=