Exemplo n.º 1
0
    def test_can_fit_hugepages(self):
        cell = objects.NUMACell(
            id=0, cpuset=set([1, 2]), memory=1024,
            siblings=[], pinned_cpus=set([]),
            mempages=[
                objects.NUMAPagesTopology(
                    size_kb=4, total=1548736, used=0),
                objects.NUMAPagesTopology(
                    size_kb=2048, total=513, used=0),
                objects.NUMAPagesTopology(
                    size_kb=1048576, total=4, used=1, reserved=1)])

        pagesize = 2048
        self.assertTrue(cell.can_fit_hugepages(pagesize, 2 ** 20))
        self.assertFalse(cell.can_fit_hugepages(pagesize, 2 ** 21))
        self.assertFalse(cell.can_fit_hugepages(pagesize, 2 ** 19 + 1))

        pagesize = 1048576
        self.assertTrue(cell.can_fit_hugepages(pagesize, 2 ** 20))
        self.assertTrue(cell.can_fit_hugepages(pagesize, 2 ** 20 * 2))
        self.assertFalse(cell.can_fit_hugepages(pagesize, 2 ** 20 * 3))

        self.assertRaises(
            exception.MemoryPageSizeNotSupported,
            cell.can_fit_hugepages, 12345, 2 ** 20)
Exemplo n.º 2
0
    def test_can_fit_pagesize(self):
        # NOTE(stephenfin): '**' is Python's "power of" symbol
        cell = objects.NUMACell(id=0,
                                cpuset=set([1, 2]),
                                pcpuset=set(),
                                memory=1024,
                                siblings=[set([1]), set([2])],
                                pinned_cpus=set(),
                                mempages=[
                                    objects.NUMAPagesTopology(size_kb=4,
                                                              total=1548736,
                                                              used=0),
                                    objects.NUMAPagesTopology(size_kb=2048,
                                                              total=513,
                                                              used=0),
                                    objects.NUMAPagesTopology(size_kb=1048576,
                                                              total=4,
                                                              used=1,
                                                              reserved=1)
                                ])

        pagesize = 2048
        self.assertTrue(cell.can_fit_pagesize(pagesize, 2**20))
        self.assertFalse(cell.can_fit_pagesize(pagesize, 2**21))
        self.assertFalse(cell.can_fit_pagesize(pagesize, 2**19 + 1))

        pagesize = 1048576
        self.assertTrue(cell.can_fit_pagesize(pagesize, 2**20))
        self.assertTrue(cell.can_fit_pagesize(pagesize, 2**20 * 2))
        self.assertFalse(cell.can_fit_pagesize(pagesize, 2**20 * 3))

        self.assertRaises(exception.MemoryPageSizeNotSupported,
                          cell.can_fit_pagesize, 12345, 2**20)
Exemplo n.º 3
0
 def test_numa_cell_not_equivalent_different_pages(self):
     pt1 = objects.NUMAPagesTopology(size_kb=1024, total=32, used=0)
     pt2 = objects.NUMAPagesTopology(size_kb=1024, total=32, used=1)
     cell1 = objects.NUMACell(id=1, cpuset=set([1, 2]), memory=32,
                              cpu_usage=10, pinned_cpus=set([3, 4]),
                              siblings=[set([5, 6])],
                              mempages=[pt1])
     cell2 = objects.NUMACell(id=1, cpuset=set([1, 2]), memory=32,
                              cpu_usage=10, pinned_cpus=set([3, 4]),
                              siblings=[set([5, 6])],
                              mempages=[pt2])
     self.assertNotEqual(cell1, cell2)
Exemplo n.º 4
0
    def test_can_fit_pagesize_oversubscription(self):
        """Validate behavior when using page oversubscription.

        While hugepages aren't themselves oversubscribable, we also track small
        pages which are.
        """
        # NOTE(stephenfin): '**' is Python's "power of" symbol
        cell = objects.NUMACell(
            id=0,
            cpuset=set([1, 2]),
            pcpuset=set(),
            memory=1024,
            siblings=[set([1]), set([2])],
            pinned_cpus=set(),
            mempages=[
                # 1 GiB total, all used
                objects.NUMAPagesTopology(size_kb=4, total=2**18, used=2**18),
            ])

        pagesize = 4
        # request 2^20 KiB (so 1 GiB)
        self.assertTrue(cell.can_fit_pagesize(pagesize, 2**20, use_free=False))
        # request 2^20 + 1 KiB (so # > 1 GiB)
        self.assertFalse(
            cell.can_fit_pagesize(pagesize, 2**20 + 1, use_free=False))
Exemplo n.º 5
0
 def test_reserved_property_not_set(self):
     p = objects.NUMAPagesTopology(
         # To have reserved not set is similar than to have receive
         # a NUMAPageTopology version 1.0
         size_kb=1024,
         total=64,
         used=32)
     self.assertEqual(32, p.free)
Exemplo n.º 6
0
    def test_can_fit_hugepages(self):
        cell = objects.NUMACell(
            id=0, cpuset=set([1, 2]), memory=1024,
            mempages=[
                objects.NUMAPagesTopology(
                    size_kb=4, total=1548736, used=0),
                objects.NUMAPagesTopology(
                    size_kb=2048, total=513, used=0)])  # 1,002G

        pagesize = 2048

        self.assertTrue(cell.can_fit_hugepages(pagesize, 2 ** 20))
        self.assertFalse(cell.can_fit_hugepages(pagesize, 2 ** 21))
        self.assertFalse(cell.can_fit_hugepages(pagesize, 2 ** 19 + 1))
        self.assertRaises(
            exception.MemoryPageSizeNotSupported,
            cell.can_fit_hugepages, 12345, 2 ** 20)
Exemplo n.º 7
0
    def test_pages_topology_wipe(self):
        pages_topology = objects.NUMAPagesTopology(
            size_kb=2048, total=1024, used=512)

        self.assertEqual(2048, pages_topology.size_kb)
        self.assertEqual(1024, pages_topology.total)
        self.assertEqual(512, pages_topology.used)
        self.assertEqual(512, pages_topology.free)
        self.assertEqual(1048576, pages_topology.free_kb)
Exemplo n.º 8
0
def _numa_pagesize_usage_from_cell(hostcell, instancecell, sign):
    topo = []
    for pages in hostcell.mempages:
        if pages.size_kb == instancecell.pagesize:
            topo.append(objects.NUMAPagesTopology(
                size_kb=pages.size_kb,
                total=pages.total,
                used=max(0, pages.used +
                         instancecell.memory * units.Ki /
                         pages.size_kb * sign)))
        else:
            topo.append(pages)
    return topo
Exemplo n.º 9
0
import datetime

from nova import objects
from nova.scheduler import driver
from nova.scheduler import host_manager
from nova.tests import uuidsentinel

NUMA_TOPOLOGY = objects.NUMATopology(cells=[
    objects.NUMACell(
        id=0,
        cpuset=set([1, 2]),
        memory=512,
        cpu_usage=0,
        memory_usage=0,
        mempages=[
            objects.NUMAPagesTopology(size_kb=16, total=387184, used=0),
            objects.NUMAPagesTopology(size_kb=2048, total=512, used=0)
        ],
        siblings=[],
        pinned_cpus=set([])),
    objects.NUMACell(
        id=1,
        cpuset=set([3, 4]),
        memory=512,
        cpu_usage=0,
        memory_usage=0,
        mempages=[
            objects.NUMAPagesTopology(size_kb=4, total=1548736, used=0),
            objects.NUMAPagesTopology(size_kb=2048, total=512, used=0)
        ],
        siblings=[],
Exemplo n.º 10
0
 def test_numa_pages_not_equivalent_missing_b(self):
     pt1 = objects.NUMAPagesTopology(size_kb=1024, total=32, used=0)
     pt2 = objects.NUMAPagesTopology(size_kb=1024, used=0)
     self.assertNotEqual(pt1, pt2)
Exemplo n.º 11
0
 def test_equivalent(self):
     pt1 = objects.NUMAPagesTopology(size_kb=1024, total=32, used=0)
     pt2 = objects.NUMAPagesTopology(size_kb=1024, total=32, used=0)
     self.assertEqual(pt1, pt2)
Exemplo n.º 12
0
        objects.InstanceNUMACell(
            id=0, cpuset=set([1]), memory=_2MB, pagesize=0),
        objects.InstanceNUMACell(
            id=1, cpuset=set([3]), memory=_2MB, pagesize=0)
    ]),
}

_NUMA_LIMIT_TOPOLOGIES = {
    '2mb':
    objects.NUMATopologyLimits(id=0,
                               cpu_allocation_ratio=1.0,
                               ram_allocation_ratio=1.0),
}

_NUMA_PAGE_TOPOLOGIES = {
    '2kb*8': objects.NUMAPagesTopology(size_kb=2, total=8, used=0)
}

_NUMA_HOST_TOPOLOGIES = {
    '2mb':
    objects.NUMATopology(cells=[
        objects.NUMACell(id=0,
                         cpuset=set([1, 2]),
                         memory=_2MB,
                         cpu_usage=0,
                         memory_usage=0,
                         mempages=[_NUMA_PAGE_TOPOLOGIES['2kb*8']],
                         siblings=[],
                         pinned_cpus=set([])),
        objects.NUMACell(id=1,
                         cpuset=set([3, 4]),