From 0cd3cee7284718a0e8fb0a4e70693d0f08f66ac9 Mon Sep 17 00:00:00 2001 From: Sahid Orentino Ferdjaoui Date: Mon, 3 Dec 2018 16:23:30 +0100 Subject: [PATCH] adding compute/cpu_shared_set option For Rocky, Nova introduced compute/cpu_shared_set and libvirt driver uses that option to specify set of pCPUs which will be used to put emulator threads on. So guest vCPUs can be pinned on pCPUs which will be entirely dedicated for them. Change-Id: I88b2afda67a91266f21d2c870a76646262488db2 Closes-Bug: 1806434 Signed-off-by: Sahid Orentino Ferdjaoui --- config.yaml | 8 ++++++++ hooks/nova_compute_context.py | 3 +++ templates/rocky/nova.conf | 6 ++++++ unit_tests/test_nova_compute_contexts.py | 4 +++- 4 files changed, 20 insertions(+), 1 deletion(-) diff --git a/config.yaml b/config.yaml index 991411ee..ee54cc80 100644 --- a/config.yaml +++ b/config.yaml @@ -187,6 +187,14 @@ options: Sets vcpu_pin_set option in nova.conf which defines which pcpus that instance vcpus can or cannot use. For example '^0,^2' to reserve two cpus for the host. + cpu-shared-set: + type: string + default: + description: | + Sets compute/cpu_shared_set option in nova.conf defines which + physical CPUs will be used for best-effort guest vCPU resources. + Currently only used by libvirt driver to place guest emulator threads + when hw:emulator_threads_policy:share is set. virtio-net-tx-queue-size: type: int default: diff --git a/hooks/nova_compute_context.py b/hooks/nova_compute_context.py index 979c0bd9..fd5e6770 100644 --- a/hooks/nova_compute_context.py +++ b/hooks/nova_compute_context.py @@ -247,6 +247,9 @@ class NovaComputeLibvirtContext(context.OSContextGenerator): if config('vcpu-pin-set'): ctxt['vcpu_pin_set'] = config('vcpu-pin-set') + if config('cpu-shared-set'): + ctxt['cpu_shared_set'] = config('cpu-shared-set') + if config('virtio-net-tx-queue-size'): ctxt['virtio_net_tx_queue_size'] = ( config('virtio-net-tx-queue-size')) diff --git a/templates/rocky/nova.conf b/templates/rocky/nova.conf index c6a184f0..8aaf719f 100644 --- a/templates/rocky/nova.conf +++ b/templates/rocky/nova.conf @@ -264,3 +264,9 @@ disable_libvirt_livesnapshot = False {% include "parts/section-serial-console" %} {% include "parts/section-placement" %} + +[compute] +{% if cpu_shared_set -%} +cpu_shared_set = {{ cpu_shared_set }} +{% endif -%} + diff --git a/unit_tests/test_nova_compute_contexts.py b/unit_tests/test_nova_compute_contexts.py index a25faaa3..a84d9e53 100644 --- a/unit_tests/test_nova_compute_contexts.py +++ b/unit_tests/test_nova_compute_contexts.py @@ -398,6 +398,7 @@ class NovaComputeContextTests(CharmTestCase): self.test_config.set('pci-passthrough-whitelist', 'mypcidevices') self.test_config.set('virtio-net-tx-queue-size', 512) self.test_config.set('virtio-net-rx-queue-size', 1024) + self.test_config.set('cpu-shared-set', "4-12,^8,15") libvirt = context.NovaComputeLibvirtContext() self.assertEqual( @@ -414,7 +415,8 @@ class NovaComputeContextTests(CharmTestCase): 'force_raw_images': True, 'pci_passthrough_whitelist': 'mypcidevices', 'virtio_net_tx_queue_size': 512, - 'virtio_net_rx_queue_size': 1024}, libvirt()) + 'virtio_net_rx_queue_size': 1024, + 'cpu_shared_set': "4-12,^8,15"}, libvirt()) def test_ksm_configs(self): self.lsb_release.return_value = {'DISTRIB_CODENAME': 'lucid'}