Skip to contentSkip to conversation

xl: expose max_cpu_id from `xl info`

PATCH Andrew Cooper 3 participants 7 messages Mar 13, 2012 – Mar 14, 2012

lore
Share & tools
lore
#0 lore raw

This will allow userspace to reason with the total number of CPUs, not just the current number of online CPUs.

Signature · 2 lines
Andrew Cooper - Dom0 Kernel Engineer, Citrix XenServer
T: +44 (0)1223 225 900, http://www.citrix.com

# HG changeset patch
# Parent 5d20d2f6ffed0a49f030f04a8870f1926babbcbf
xl: display max_cpu_ids for xl info

Expose "max_cpu_id" in stdout from xl info

tools/libxl/xl_cmdimpl.c +1 -0
diff -r 5d20d2f6ffed tools/libxl/xl_cmdimpl.c
@@ -3734,6 +3734,7 @@ static void output_physinfo(void)
     }
 
     printf("nr_cpus                : %d\n", info.nr_cpus);
+    printf("max_cpu_id             : %d\n", info.max_cpu_id);
     printf("nr_nodes               : %d\n", info.nr_nodes);
     printf("cores_per_socket       : %d\n", info.cores_per_socket);
     printf("threads_per_core       : %d\n", info.threads_per_core);

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel

#1 lore raw
Quoted 21 lines · Andrew Cooper

This will allow userspace to reason with the total number of CPUs, not just the current number of online CPUs.

-- Andrew Cooper - Dom0 Kernel Engineer, Citrix XenServer T: +44 (0)1223 225 900, http://www.citrix.com

xl-info-max_cpu_id.patch

# HG changeset patch
# Parent 5d20d2f6ffed0a49f030f04a8870f1926babbcbf
xl: display max_cpu_ids for xl info

Expose "max_cpu_id" in stdout from xl info

diff -r 5d20d2f6ffed tools/libxl/xl_cmdimpl.c

tools/libxl/xl_cmdimpl.c static void output_physinfo(void) · line 3737

Quoted 4 lines
tools/libxl/xl_cmdimpl.c +1 -0
@@ -3734,6 +3734,7 @@ static void output_physinfo(void)
     }
 
     printf("nr_cpus                : %d\n", info.nr_cpus);
+    printf("max_cpu_id             : %d\n", info.max_cpu_id);

Is this true: nr_cpus = max_cpu_id + 1 ?

Zhigang

Quoted 9 lines
tools/libxl/xl_cmdimpl.c +0 -0
     printf("nr_nodes               : %d\n", info.nr_nodes);
     printf("cores_per_socket       : %d\n", info.cores_per_socket);
     printf("threads_per_core       : %d\n", info.threads_per_core);

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel

#2 lore raw
Quoted 24 lines · Zhigang Wang
Quoted 23 lines · Andrew Cooper

This will allow userspace to reason with the total number of CPUs, not just the current number of online CPUs.

-- Andrew Cooper - Dom0 Kernel Engineer, Citrix XenServer T: +44 (0)1223 225 900, http://www.citrix.com

xl-info-max_cpu_id.patch

# HG changeset patch
# Parent 5d20d2f6ffed0a49f030f04a8870f1926babbcbf
xl: display max_cpu_ids for xl info

Expose "max_cpu_id" in stdout from xl info

diff -r 5d20d2f6ffed tools/libxl/xl_cmdimpl.c

tools/libxl/xl_cmdimpl.c +0 -0
@@ -3734,6 +3734,7 @@ static void output_physinfo(void)
     }
 
Quoted 6 lines

tools/libxl/xl_cmdimpl.c static void output_physinfo(void) · line 3737

Quoted 2 lines
tools/libxl/xl_cmdimpl.c +1 -0
     printf("nr_cpus                : %d\n", info.nr_cpus);
+    printf("max_cpu_id             : %d\n", info.max_cpu_id);

Is this true: nr_cpus = max_cpu_id + 1 ?

Zhigang

if and only if all cpus are online.

nr_cpus is set to nr_online_cpus() in the hypercall, while max_cpu_id is set to nr_cpu_ids-1.

nr_cpus is liable to change during runtime, while max_cpu_id is not.

~Andrew

Quoted 11 lines
Quoted 10 lines
tools/libxl/xl_cmdimpl.c +0 -0
     printf("nr_nodes               : %d\n", info.nr_nodes);
     printf("cores_per_socket       : %d\n", info.cores_per_socket);
     printf("threads_per_core       : %d\n", info.threads_per_core);

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel

Signature · 2 lines
Andrew Cooper - Dom0 Kernel Engineer, Citrix XenServer
T: +44 (0)1223 225 900, http://www.citrix.com

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel

#3 lore raw
Quoted 32 lines · Andrew Cooper
Quoted 24 lines · Zhigang Wang
Quoted 23 lines · Andrew Cooper

This will allow userspace to reason with the total number of CPUs, not just the current number of online CPUs.

-- Andrew Cooper - Dom0 Kernel Engineer, Citrix XenServer T: +44 (0)1223 225 900, http://www.citrix.com

xl-info-max_cpu_id.patch

# HG changeset patch
# Parent 5d20d2f6ffed0a49f030f04a8870f1926babbcbf
xl: display max_cpu_ids for xl info

Expose "max_cpu_id" in stdout from xl info

diff -r 5d20d2f6ffed tools/libxl/xl_cmdimpl.c

tools/libxl/xl_cmdimpl.c +0 -0
@@ -3734,6 +3734,7 @@ static void output_physinfo(void)
     }
 
Quoted 6 lines

tools/libxl/xl_cmdimpl.c static void output_physinfo(void) · line 3737

Quoted 2 lines
tools/libxl/xl_cmdimpl.c +1 -0
     printf("nr_cpus                : %d\n", info.nr_cpus);
+    printf("max_cpu_id             : %d\n", info.max_cpu_id);

Is this true: nr_cpus = max_cpu_id + 1 ?

Zhigang

Quoted 8 lines

if and only if all cpus are online.

nr_cpus is set to nr_online_cpus() in the hypercall, while max_cpu_id is set to nr_cpu_ids-1.

nr_cpus is liable to change during runtime, while max_cpu_id is not.

~Andrew

If this is the case, I think nr_cpus is a bit confusing. Can we make it always representing the number of physical cpus (from hypervisor's viewpoint, not dom0)?

Zhigang

Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
tools/libxl/xl_cmdimpl.c +0 -0
     printf("nr_nodes               : %d\n", info.nr_nodes);
     printf("cores_per_socket       : %d\n", info.cores_per_socket);
     printf("threads_per_core       : %d\n", info.threads_per_core);
Quoted 9 lines
Quoted 5 lines
Quoted 4 lines

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel

Signature · 2 lines
Andrew Cooper - Dom0 Kernel Engineer, Citrix XenServer
T: +44 (0)1223 225 900, http://www.citrix.com

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel

#4 lore raw

<snip>

Quoted 11 lines
Quoted 11 lines
Quoted 3 lines

Is this true: nr_cpus = max_cpu_id + 1 ?

Zhigang

if and only if all cpus are online.

nr_cpus is set to nr_online_cpus() in the hypercall, while max_cpu_id is set to nr_cpu_ids-1.

nr_cpus is liable to change during runtime, while max_cpu_id is not.

Quoted 9 lines
Quoted 1 line

~Andrew

If this is the case, I think nr_cpus is a bit confusing. Can we make it always representing the number of physical cpus (from hypervisor's viewpoint, not dom0)?

Zhigang

No. The names here reflect the hypercall name parameters. The hypercall cant be changed because it is an ABI, and the "name : value" pairs here cant be changed because of backward compatibility with the previous toolstack.

Signature · 2 lines
Andrew Cooper - Dom0 Kernel Engineer, Citrix XenServer
T: +44 (0)1223 225 900, http://www.citrix.com
#5 lore raw
Quoted 16 lines · Andrew Cooper

<snip>

Quoted 15 lines
Quoted 11 lines
Quoted 3 lines

Is this true: nr_cpus = max_cpu_id + 1 ?

Zhigang

if and only if all cpus are online.

nr_cpus is set to nr_online_cpus() in the hypercall, while max_cpu_id is set to nr_cpu_ids-1.

nr_cpus is liable to change during runtime, while max_cpu_id is not.

~Andrew

If this is the case, I think nr_cpus is a bit confusing. Can we make it always representing the number of physical cpus (from hypervisor's viewpoint, not dom0)?

Quoted 8 lines
Quoted 3 lines

Zhigang

No. The names here reflect the hypercall name parameters. The hypercall cant be changed because it is an ABI, and the "name : value" pairs here cant be changed because of backward compatibility with the previous toolstack.

Ok. Thanks for you info. I think nr_online_cpus() is the right thing here: it represents online physical cpus from hypervisor's viewpoint.

It's fine to add this output here if you need it. But for most of the xen users, the current nr_cpus should be what they want (for how many pcpus they can use).

Other ways to get full hardware info could be BIOS/SMBIOS/DMI, and I think it's better than xl info.

Thanks,

Zhigang