Skip to contentSkip to conversation

libvirt/libxl implemetation of get_online_cpu / virNodeGetCPUMap?

libvirt Daniel P. Berrange 5 participants 13 messages Feb 24, 2015 – Mar 24, 2015 6 messages not in the archive

lore
Share & tools
lore
#1 lore raw
In reply to a message not in the archive
Quoted 9 lines · Anthony PERARD

Hi,

A recent OpenStack nova commit make use of virNodeGetCPUMap to get the list of online cpu of a host. But this API is not implemented for the libvirt xen driver.

The commit:
Add handling for offlined CPUs to the nova libvirt driver.
https://review.openstack.org/gitweb?p=openstack/nova.git;a=commitdiff;h=0696a5cd5f0fdc08951a074961bb8ce0c3310086

FWIW, this should not impact Xen based on my understanding. The code path in question should only be used when Nova is setup todo NUMA pinning support, and that is not supported with Xen in OpenStack, only KVM. Did it actually cause failures for you, or are you simply keeping track of all used APIs in Nova as a sanity check ?

Quoted 6 lines

Is there a need to use this under Xen? (Is it possible to have offline CPU?).
What libxl API those provide this information, if it exist?

I found libxl_get_online_cpus() but that not enough. They want a bitmap.

Regards,
Daniel

Signature · 4 lines
|: http://berrange.com      -o-    http://www.flickr.com/photos/dberrange/ :|
|: http://libvirt.org              -o-             http://virt-manager.org :|
|: http://autobuild.org       -o-         http://search.cpan.org/~danberr/ :|
|: http://entangle-photo.org       -o-       http://live.gnome.org/gtk-vnc :|
#2 lore raw
In reply to a message not in the archive
Quoted 6 lines · Anthony PERARD

Hi,

A recent OpenStack nova commit make use of virNodeGetCPUMap to get the list of online cpu of a host. But this API is not implemented for the libvirt xen driver.

Quoted 6 lines

The commit:
Add handling for offlined CPUs to the nova libvirt driver.
https://review.openstack.org/gitweb?p=openstack/nova.git;a=commitdiff;h=0696a5cd5f0fdc08951a074961bb8ce0c3310086

Is there a need to use this under Xen? (Is it possible to have offline CPU?).

Yes, I think so. No idea how you use it though.

Quoted 4 lines

What libxl API those provide this information, if it exist?

I found libxl_get_online_cpus() but that not enough. They want a bitmap.

I think that is all which currently exists, at least at the libxl level, you may need to add a new interface.

It'd be worth looking into the various host numa interfaces -- perhaps one of them indirectly exposes what you want?

Ian.

#4 lore raw
In reply to a message not in the archive
Quoted 11 lines · Daniel P. Berrange
Quoted 9 lines · Anthony PERARD

Hi,

A recent OpenStack nova commit make use of virNodeGetCPUMap to get the list of online cpu of a host. But this API is not implemented for the libvirt xen driver.

The commit:
Add handling for offlined CPUs to the nova libvirt driver.
https://review.openstack.org/gitweb?p=openstack/nova.git;a=commitdiff;h=0696a5cd5f0fdc08951a074961bb8ce0c3310086

Quoted 5 lines

FWIW, this should not impact Xen based on my understanding. The code path in question should only be used when Nova is setup todo NUMA pinning support, and that is not supported with Xen in OpenStack, only KVM. Did it actually cause failures for you, or are you simply keeping track of all used APIs in Nova as a sanity check ?

It prevent nova from starting. I do the setup with DevStack.

The error:
libvirtError: this function is not supported by the connection driver: virNodeGetCPUMap

And a part of the traceback:
File "/opt/stack/nova/nova/openstack/common/service.py", line 491, in run_service
service.start()
File "/opt/stack/nova/nova/service.py", line 181, in start
self.manager.pre_start_hook()
File "/opt/stack/nova/nova/compute/manager.py", line 1188, in pre_start_hook
self.update_available_resource(nova.context.get_admin_context())
File "/opt/stack/nova/nova/compute/manager.py", line 6062, in update_available_resource
rt.update_available_resource(context)
File "/opt/stack/nova/nova/compute/resource_tracker.py", line 315, in update_available_resource
resources = self.driver.get_available_resource(self.nodename)
File "/opt/stack/nova/nova/virt/libvirt/driver.py", line 4896, in get_available_resource
numa_topology = self._get_host_numa_topology()
File "/opt/stack/nova/nova/virt/libvirt/driver.py", line 4749, in _get_host_numa_topology
online_cpus = self._host.get_online_cpus()
File "/opt/stack/nova/nova/virt/libvirt/host.py", line 599, in get_online_cpus
(cpus, cpu_map, online) = self.get_connection().getCPUMap()

I'll look into why nova is going through NUMA code paths then.

Thanks for your information,

Signature · 1 line
Anthony PERARD
#5 lore raw
Quoted 41 lines · Anthony PERARD
Quoted 11 lines · Daniel P. Berrange
Quoted 9 lines · Anthony PERARD

Hi,

A recent OpenStack nova commit make use of virNodeGetCPUMap to get the list of online cpu of a host. But this API is not implemented for the libvirt xen driver.

The commit:
Add handling for offlined CPUs to the nova libvirt driver.
https://review.openstack.org/gitweb?p=openstack/nova.git;a=commitdiff;h=0696a5cd5f0fdc08951a074961bb8ce0c3310086

Quoted 5 lines

FWIW, this should not impact Xen based on my understanding. The code path in question should only be used when Nova is setup todo NUMA pinning support, and that is not supported with Xen in OpenStack, only KVM. Did it actually cause failures for you, or are you simply keeping track of all used APIs in Nova as a sanity check ?

It prevent nova from starting. I do the setup with DevStack.

The error:
libvirtError: this function is not supported by the connection driver: virNodeGetCPUMap

And a part of the traceback:
File "/opt/stack/nova/nova/openstack/common/service.py", line 491, in run_service
service.start()
File "/opt/stack/nova/nova/service.py", line 181, in start
self.manager.pre_start_hook()
File "/opt/stack/nova/nova/compute/manager.py", line 1188, in pre_start_hook
self.update_available_resource(nova.context.get_admin_context())
File "/opt/stack/nova/nova/compute/manager.py", line 6062, in update_available_resource
rt.update_available_resource(context)
File "/opt/stack/nova/nova/compute/resource_tracker.py", line 315, in update_available_resource
resources = self.driver.get_available_resource(self.nodename)
File "/opt/stack/nova/nova/virt/libvirt/driver.py", line 4896, in get_available_resource
numa_topology = self._get_host_numa_topology()
File "/opt/stack/nova/nova/virt/libvirt/driver.py", line 4749, in _get_host_numa_topology
online_cpus = self._host.get_online_cpus()
File "/opt/stack/nova/nova/virt/libvirt/host.py", line 599, in get_online_cpus
(cpus, cpu_map, online) = self.get_connection().getCPUMap()

Quoted 1 line

I'll look into why nova is going through NUMA code paths then.

Oh damn, yes, I understand why now. Please file a bug against Nova for this, as we must fix it as a high pripority. It was certainly not my intention to break Xen when I approved this change

Regards,
Daniel

Signature · 4 lines
|: http://berrange.com      -o-    http://www.flickr.com/photos/dberrange/ :|
|: http://libvirt.org              -o-             http://virt-manager.org :|
|: http://autobuild.org       -o-         http://search.cpan.org/~danberr/ :|
|: http://entangle-photo.org       -o-       http://live.gnome.org/gtk-vnc :|
#7 lore raw
In reply to a message not in the archive
Quoted 42 lines · Daniel P. Berrange
Quoted 41 lines · Anthony PERARD
Quoted 11 lines · Daniel P. Berrange
Quoted 9 lines · Anthony PERARD

Hi,

A recent OpenStack nova commit make use of virNodeGetCPUMap to get the list of online cpu of a host. But this API is not implemented for the libvirt xen driver.

The commit:
Add handling for offlined CPUs to the nova libvirt driver.
https://review.openstack.org/gitweb?p=openstack/nova.git;a=commitdiff;h=0696a5cd5f0fdc08951a074961bb8ce0c3310086

Quoted 5 lines

FWIW, this should not impact Xen based on my understanding. The code path in question should only be used when Nova is setup todo NUMA pinning support, and that is not supported with Xen in OpenStack, only KVM. Did it actually cause failures for you, or are you simply keeping track of all used APIs in Nova as a sanity check ?

It prevent nova from starting. I do the setup with DevStack.

The error:
libvirtError: this function is not supported by the connection driver: virNodeGetCPUMap

And a part of the traceback:
File "/opt/stack/nova/nova/openstack/common/service.py", line 491, in run_service
service.start()
File "/opt/stack/nova/nova/service.py", line 181, in start
self.manager.pre_start_hook()
File "/opt/stack/nova/nova/compute/manager.py", line 1188, in pre_start_hook
self.update_available_resource(nova.context.get_admin_context())
File "/opt/stack/nova/nova/compute/manager.py", line 6062, in update_available_resource
rt.update_available_resource(context)
File "/opt/stack/nova/nova/compute/resource_tracker.py", line 315, in update_available_resource
resources = self.driver.get_available_resource(self.nodename)
File "/opt/stack/nova/nova/virt/libvirt/driver.py", line 4896, in get_available_resource
numa_topology = self._get_host_numa_topology()
File "/opt/stack/nova/nova/virt/libvirt/driver.py", line 4749, in _get_host_numa_topology
online_cpus = self._host.get_online_cpus()
File "/opt/stack/nova/nova/virt/libvirt/host.py", line 599, in get_online_cpus
(cpus, cpu_map, online) = self.get_connection().getCPUMap()

Quoted 5 lines
Quoted 1 line

I'll look into why nova is going through NUMA code paths then.

Oh damn, yes, I understand why now. Please file a bug against Nova for this, as we must fix it as a high pripority. It was certainly not my intention to break Xen when I approved this change

Here is the bug report: https://bugs.launchpad.net/nova/+bug/1425115

Regards,

Signature · 1 line
Anthony PERARD
#11 lore raw
In reply to a message not in the archive
Quoted 4 lines · Ian Campbell
Quoted 2 lines · Anthony PERARD

What libxl API those provide this information, if it exist?

Quoted 9 lines
Quoted 2 lines

I found libxl_get_online_cpus() but that not enough. They want a bitmap.

I think that is all which currently exists, at least at the libxl level, you may need to add a new interface.

It'd be worth looking into the various host numa interfaces -- perhaps one of them indirectly exposes what you want?

Given Daniel's latest emails, I'm not sure this is useful but libxl_get_cpu_topology() should put LIBXL_CPUTOPOLOGY_INVALID_ENTRY in all the fields of the i-eth element of the array it returns, if the i-eth pcpu is offline (see the implementation of XEN_SYSCTL_topologyinfo in xen/common/sysctl.c).

So, scanning that array and constructing the bitmap according to whether or not we find that marker on the various elements would be the way to go, I would say.

I've actually never tested this, i.e., I've never tried offlining a pcpu on the host. I'll give it a go as soon as I find 5 minutes, and let know if it works.

Regards,
Dario

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

#12 lore raw
Quoted 20 lines · Dario Faggioli
Quoted 4 lines · Ian Campbell
Quoted 2 lines · Anthony PERARD

What libxl API those provide this information, if it exist?

Quoted 9 lines
Quoted 2 lines

I found libxl_get_online_cpus() but that not enough. They want a bitmap.

I think that is all which currently exists, at least at the libxl level, you may need to add a new interface.

It'd be worth looking into the various host numa interfaces -- perhaps one of them indirectly exposes what you want?

Given Daniel's latest emails, I'm not sure this is useful but libxl_get_cpu_topology() should put LIBXL_CPUTOPOLOGY_INVALID_ENTRY in all the fields of the i-eth element of the array it returns, if the i-eth pcpu is offline (see the implementation of XEN_SYSCTL_topologyinfo in xen/common/sysctl.c).

Quoted 3 lines

So, scanning that array and constructing the bitmap according to whether or not we find that marker on the various elements would be the way to go, I would say.

It could work, yes, although if there were other reasons for INVALID entry it would fall down.

Thinking about it, it might be a better idea long term to expose a some specific interfaces for managing or interrogating host CPU status rather than inferring it through other means, it's not like the hypercall would be very hard to setup and plumb through.

But as you say, Daniel's response might have made this all moot anyway, or at least deferrable.

Ian.

Quoted 6 lines

I've actually never tested this, i.e., I've never tried offlining a pcpu on the host. I'll give it a go as soon as I find 5 minutes, and let know if it works.

Regards,
Dario

#8 lore raw
In reply to Anthony PERARD
Quoted 43 lines · Anthony PERARD
Quoted 42 lines · Daniel P. Berrange
Quoted 41 lines · Anthony PERARD
Quoted 11 lines · Daniel P. Berrange
Quoted 9 lines · Anthony PERARD

Hi,

A recent OpenStack nova commit make use of virNodeGetCPUMap to get the list of online cpu of a host. But this API is not implemented for the libvirt xen driver.

The commit:
Add handling for offlined CPUs to the nova libvirt driver.
https://review.openstack.org/gitweb?p=openstack/nova.git;a=commitdiff;h=0696a5cd5f0fdc08951a074961bb8ce0c3310086

Quoted 5 lines

FWIW, this should not impact Xen based on my understanding. The code path in question should only be used when Nova is setup todo NUMA pinning support, and that is not supported with Xen in OpenStack, only KVM. Did it actually cause failures for you, or are you simply keeping track of all used APIs in Nova as a sanity check ?

It prevent nova from starting. I do the setup with DevStack.

The error:
libvirtError: this function is not supported by the connection driver: virNodeGetCPUMap

And a part of the traceback:
File "/opt/stack/nova/nova/openstack/common/service.py", line 491, in run_service
service.start()
File "/opt/stack/nova/nova/service.py", line 181, in start
self.manager.pre_start_hook()
File "/opt/stack/nova/nova/compute/manager.py", line 1188, in pre_start_hook
self.update_available_resource(nova.context.get_admin_context())
File "/opt/stack/nova/nova/compute/manager.py", line 6062, in update_available_resource
rt.update_available_resource(context)
File "/opt/stack/nova/nova/compute/resource_tracker.py", line 315, in update_available_resource
resources = self.driver.get_available_resource(self.nodename)
File "/opt/stack/nova/nova/virt/libvirt/driver.py", line 4896, in get_available_resource
numa_topology = self._get_host_numa_topology()
File "/opt/stack/nova/nova/virt/libvirt/driver.py", line 4749, in _get_host_numa_topology
online_cpus = self._host.get_online_cpus()
File "/opt/stack/nova/nova/virt/libvirt/host.py", line 599, in get_online_cpus
(cpus, cpu_map, online) = self.get_connection().getCPUMap()

Quoted 7 lines
Quoted 5 lines
Quoted 1 line

I'll look into why nova is going through NUMA code paths then.

Oh damn, yes, I understand why now. Please file a bug against Nova for this, as we must fix it as a high pripority. It was certainly not my intention to break Xen when I approved this change

Here is the bug report: https://bugs.launchpad.net/nova/+bug/1425115

If you are able to test a fix easily then try the patch here:

https://review.openstack.org/#/c/159106/

If you're able to add a comment to the review indicating that you've confirmed it fixes Xen, that'd be useful, since there's no automated testing of Xen that reports on reviews.

Regards,
Daniel

Signature · 4 lines
|: http://berrange.com      -o-    http://www.flickr.com/photos/dberrange/ :|
|: http://libvirt.org              -o-             http://virt-manager.org :|
|: http://autobuild.org       -o-         http://search.cpan.org/~danberr/ :|
|: http://entangle-photo.org       -o-       http://live.gnome.org/gtk-vnc :|
#13 lore raw
In reply to Dario Faggioli
Quoted 20 lines · Dario Faggioli
Quoted 4 lines · Ian Campbell
Quoted 2 lines · Anthony PERARD

What libxl API those provide this information, if it exist?

Quoted 9 lines
Quoted 2 lines

I found libxl_get_online_cpus() but that not enough. They want a bitmap.

I think that is all which currently exists, at least at the libxl level, you may need to add a new interface.

It'd be worth looking into the various host numa interfaces -- perhaps one of them indirectly exposes what you want?

Given Daniel's latest emails, I'm not sure this is useful but libxl_get_cpu_topology() should put LIBXL_CPUTOPOLOGY_INVALID_ENTRY in all the fields of the i-eth element of the array it returns, if the i-eth pcpu is offline (see the implementation of XEN_SYSCTL_topologyinfo in xen/common/sysctl.c).

Quoted 7 lines

So, scanning that array and constructing the bitmap according to whether or not we find that marker on the various elements would be the way to go, I would say.

I've actually never tested this, i.e., I've never tried offlining a pcpu on the host. I'll give it a go as soon as I find 5 minutes, and let know if it works.

FWIW, this code in openstack was only added for benefit of s390 architecture where apparently it is common to have hosts with CPUs offlined. Presumably you have to pay IBM for each extra CPU you turn online :)

Regards,
Daniel

Signature · 4 lines
|: http://berrange.com      -o-    http://www.flickr.com/photos/dberrange/ :|
|: http://libvirt.org              -o-             http://virt-manager.org :|
|: http://autobuild.org       -o-         http://search.cpan.org/~danberr/ :|
|: http://entangle-photo.org       -o-       http://live.gnome.org/gtk-vnc :|
#14 lore raw
Quoted 4 lines · Daniel P. Berrange

FWIW, this code in openstack was only added for benefit of s390 architecture where apparently it is common to have hosts with CPUs offlined. Presumably you have to pay IBM for each extra CPU you turn online :)

Presumably :-)

OOI, why does the code care which CPUs are online rather than just the total number (IOW why a bitmap)?

Ian.

#16 lore raw
In reply to a message not in the archive
Quoted 10 lines · Ian Campbell
Quoted 4 lines · Daniel P. Berrange

FWIW, this code in openstack was only added for benefit of s390 architecture where apparently it is common to have hosts with CPUs offlined. Presumably you have to pay IBM for each extra CPU you turn online :)

Presumably :-)

OOI, why does the code care which CPUs are online rather than just the total number (IOW why a bitmap)?

When doing strict CPU pinning,the openstack scheduler needs to have the list of all pCPUs available in the host. It then tries to place guests on pCPUs such that the guest does not span across NUMA nodes. To do this it needs to know which particular pCPUs in the host are available. So we need the full bitmap rather than just a total count.

Regards,
Daniel

Signature · 4 lines
|: http://berrange.com      -o-    http://www.flickr.com/photos/dberrange/ :|
|: http://libvirt.org              -o-             http://virt-manager.org :|
|: http://autobuild.org       -o-         http://search.cpan.org/~danberr/ :|
|: http://entangle-photo.org       -o-       http://live.gnome.org/gtk-vnc :|
#18 lore raw
In reply to a message not in the archive
Quoted 9 lines · Daniel P. Berrange
Quoted 8 lines · Ian Campbell
Quoted 4 lines · Daniel P. Berrange

FWIW, this code in openstack was only added for benefit of s390 architecture where apparently it is common to have hosts with CPUs offlined. Presumably you have to pay IBM for each extra CPU you turn online :)

Presumably :-)

Quoted 8 lines
Quoted 2 lines

OOI, why does the code care which CPUs are online rather than just the total number (IOW why a bitmap)?

When doing strict CPU pinning,the openstack scheduler needs to have the list of all pCPUs available in the host. It then tries to place guests on pCPUs such that the guest does not span across NUMA nodes. To do this it needs to know which particular pCPUs in the host are available. So we need the full bitmap rather than just a total count.

Makes perfect sense, thanks.

Ian.

#9 lore raw
In reply to Anthony PERARD
Quoted 41 lines · Anthony PERARD
Quoted 40 lines · Daniel P. Berrange
Quoted 39 lines · Anthony PERARD
Quoted 7 lines · Daniel P. Berrange
Quoted 6 lines · Anthony PERARD

Hi,

A recent OpenStack nova commit make use of virNodeGetCPUMap to get the list of online cpu of a host. But this API is not implemented for the libvirt xen driver.

Quoted 8 lines
Quoted 3 lines

The commit:
Add handling for offlined CPUs to the nova libvirt driver.
https://review.openstack.org/gitweb?p=openstack/nova.git;a=commitdiff;h=0696a5cd5f0fdc08951a074961bb8ce0c3310086

FWIW, this should not impact Xen based on my understanding. The code path in question should only be used when Nova is setup todo NUMA pinning support, and that is not supported with Xen in OpenStack, only KVM. Did it actually cause failures for you, or are you simply keeping track of all used APIs in Nova as a sanity check ?

It prevent nova from starting. I do the setup with DevStack.

The error:
libvirtError: this function is not supported by the connection driver: virNodeGetCPUMap

And a part of the traceback:
File "/opt/stack/nova/nova/openstack/common/service.py", line 491, in run_service
service.start()
File "/opt/stack/nova/nova/service.py", line 181, in start
self.manager.pre_start_hook()
File "/opt/stack/nova/nova/compute/manager.py", line 1188, in pre_start_hook
self.update_available_resource(nova.context.get_admin_context())
File "/opt/stack/nova/nova/compute/manager.py", line 6062, in update_available_resource
rt.update_available_resource(context)
File "/opt/stack/nova/nova/compute/resource_tracker.py", line 315, in update_available_resource
resources = self.driver.get_available_resource(self.nodename)
File "/opt/stack/nova/nova/virt/libvirt/driver.py", line 4896, in get_available_resource
numa_topology = self._get_host_numa_topology()
File "/opt/stack/nova/nova/virt/libvirt/driver.py", line 4749, in _get_host_numa_topology
online_cpus = self._host.get_online_cpus()
File "/opt/stack/nova/nova/virt/libvirt/host.py", line 599, in get_online_cpus
(cpus, cpu_map, online) = self.get_connection().getCPUMap()

Quoted 4 lines
Quoted 4 lines
Quoted 1 line

I'll look into why nova is going through NUMA code paths then.

Oh damn, yes, I understand why now. Please file a bug against Nova for this, as we must fix it as a high pripority. It was certainly not my intention to break Xen when I approved this change

I applied the patch, not getting this python libvirtError, but libvirt deamon is throwing error.

2015-03-24 08:46:31.169+0000: 1030: error : virNodeGetCPUMap:1342 : this function is not supported by the connection driver: virNodeGetCPUMap
Quoted 4 lines

Here is the bug report: https://bugs.launchpad.net/nova/+bug/1425115

Regards,