From: Masaki Kanno Subject: [PATCH] Fix showing of CPU Affinity by xm vcpu-list Date: Mon, 19 May 2008 16:54:37 +0900 Message-ID: <6BC8B985961590kanno.masaki@jp.fujitsu.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="Boundary-1ZCmhCEs5RuD7SFgMcTdk" Return-path: List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xensource.com Errors-To: xen-devel-bounces@lists.xensource.com To: xen-devel@lists.xensource.com List-Id: xen-devel@lists.xenproject.org --Boundary-1ZCmhCEs5RuD7SFgMcTdk Content-Type: text/plain; charset=iso-2022-jp Content-Transfer-Encoding: 7bit Content-Description: Mail message body 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 Best regards, Kan --Boundary-1ZCmhCEs5RuD7SFgMcTdk Content-Type: application/octet-stream; name="xm_vcpu_list.patch" Content-Disposition: attachment; filename="xm_vcpu_list.patch" Content-Transfer-Encoding: base64 ZGlmZiAtciBkMDgxN2YwODU5OWEgdG9vbHMvcHl0aG9uL3hlbi94bS9tYWluLnB5Ci0tLSBh L3Rvb2xzL3B5dGhvbi94ZW4veG0vbWFpbi5weQlGcmkgTWF5IDE2IDA5OjM3OjE5IDIwMDgg KzAxMDAKKysrIGIvdG9vbHMvcHl0aG9uL3hlbi94bS9tYWluLnB5CU1vbiBNYXkgMTkgMTA6 MDM6MzcgMjAwOCArMDkwMApAQCAtMTA5Niw3ICsxMDk2LDcgQEAgZGVmIHhtX3ZjcHVfbGlz dChhcmdzKToKIAogICAgICAgICAgICAgIyBub3JtYWxpemUgY3B1bWFwIGJ5IG1vZHVsdXMg bnJfY3B1cywgYW5kIGRyb3AgZHVwbGljYXRlcwogICAgICAgICAgICAgY3B1bWFwID0gZGlj dC5mcm9ta2V5cygKLSAgICAgICAgICAgICAgICAgICAgICAgbWFwKGxhbWJkYSB4OiB4ICUg bnJfY3B1cywgY3B1bWFwKSkua2V5cygpCisgICAgICAgICAgICAgICAgICAgICAgIGZpbHRl cihsYW1iZGEgeDogeCA8IG5yX2NwdXMsIGNwdW1hcCkpLmtleXMoKQogICAgICAgICAgICAg aWYgbGVuKGNwdW1hcCkgPT0gbnJfY3B1czoKICAgICAgICAgICAgICAgICByZXR1cm4gImFu eSBjcHUiCiAK --Boundary-1ZCmhCEs5RuD7SFgMcTdk Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel --Boundary-1ZCmhCEs5RuD7SFgMcTdk--