From 624345b4962ca96dc0a009397bcee14b0e4fbf6b Mon Sep 17 00:00:00 2001 From: Nikola Dipanov Date: Thu, 4 Jun 2015 17:09:13 +0100 Subject: libvirt: Don't try to confine a non-NUMA instance Even though it seemed like a good idea at the time, it turns out that choosing a NUMA node at random can lead to placements that are suboptimal. Since the benefit of the current approach is unclear, and the downside is actually hurting users - it is best to remove it (we would be no worse off than before Nova was even NUMA aware), and think about optimizitaions going forward, if any. Change-Id: Idd4d5c236067fc40ed3a5049f3c1a58b75f9b5e5 Closes-bug: #1461777 (cherry picked from commit eb253255d74cbe6e630225080c463f1eb16b9932) Conflicts: nova/tests/unit/virt/libvirt/test_driver.py nova/virt/libvirt/driver.py --- nova/tests/virt/libvirt/test_driver.py | 13 ++++--------- nova/virt/libvirt/driver.py | 30 ++++++------------------------ 2 files changed, 10 insertions(+), 33 deletions(-) diff --git a/nova/tests/virt/libvirt/test_driver.py b/nova/tests/virt/libvirt/test_driver.py index 60acd651a2..571bc1be5d 100644 --- a/nova/tests/virt/libvirt/test_driver.py +++ b/nova/tests/virt/libvirt/test_driver.py @@ -1209,11 +1209,9 @@ class LibvirtConnTestCase(test.TestCase): objects.Flavor, "get_by_id", return_value=flavor), mock.patch.object(conn, '_has_min_version', return_value=True), mock.patch.object( - conn, "_get_host_capabilities", return_value=caps), - mock.patch.object( - random, 'choice', side_effect=lambda cells: cells[0])): + conn, "_get_host_capabilities", return_value=caps)): cfg = conn._get_guest_config(instance_ref, [], {}, disk_info) - self.assertEqual(set([0, 1]), cfg.cpuset) + self.assertIsNone(cfg.cpuset) self.assertIsNone(cfg.cputune) self.assertIsNone(cfg.cpu.numa) @@ -1272,15 +1270,12 @@ class LibvirtConnTestCase(test.TestCase): mock.patch.object( conn, "_get_host_capabilities", return_value=caps), mock.patch.object( - hardware, 'get_vcpu_pin_set', return_value=set([2, 3])), - mock.patch.object( - random, 'choice', side_effect=lambda cells: cells[0]) + hardware, 'get_vcpu_pin_set', return_value=set([2, 3])) ) as (get_by_id_mock, has_min_version_mock, get_host_cap_mock, - get_vcpu_pin_set_mock, choice_mock): + get_vcpu_pin_set_mock): cfg = conn._get_guest_config(instance_ref, [], {}, disk_info) # NOTE(ndipanov): we make sure that pin_set was taken into account # when choosing viable cells - choice_mock.assert_called_once_with([set([2, 3])]) self.assertEqual(set([2, 3]), cfg.cpuset) self.assertIsNone(cfg.cputune) self.assertIsNone(cfg.cpu.numa) diff --git a/nova/virt/libvirt/driver.py b/nova/virt/libvirt/driver.py index 9c67f3515a..c26546b264 100644 --- a/nova/virt/libvirt/driver.py +++ b/nova/virt/libvirt/driver.py @@ -31,7 +31,6 @@ import functools import glob import mmap import os -import random import shutil import socket import sys @@ -3753,29 +3752,12 @@ class LibvirtDriver(driver.ComputeDriver): context, instance) if not guest_cpu_numa: - # No NUMA topology defined for instance - vcpus = flavor.vcpus - memory = flavor.memory_mb - if topology: - # Host is NUMA capable so try to keep the instance in a cell - viable_cells_cpus = [] - for cell in topology.cells: - if vcpus <= len(cell.cpuset) and memory <= cell.memory: - viable_cells_cpus.append(cell.cpuset) - - if not viable_cells_cpus: - # We can't contain the instance in a cell - do nothing for - # now. - # TODO(ndipanov): Attempt to spread the instance accross - # NUMA nodes and expose the topology to the instance as an - # optimisation - return allowed_cpus, None, None - else: - pin_cpuset = random.choice(viable_cells_cpus) - return pin_cpuset, None, None - else: - # We have no NUMA topology in the host either - return allowed_cpus, None, None + # No NUMA topology defined for instance - let the host kernel deal + # with the NUMA effects. + # TODO(ndipanov): Attempt to spread the instance + # across NUMA nodes and expose the topology to the + # instance as an optimisation + return allowed_cpus, None, None else: if topology: # Now get the CpuTune configuration from the numa_topology -- cgit v1.2.1