Exemplo n.º 1
0
    def __init__(self, cpu_nodes=4, cpu_sockets=1, cpu_cores=1, cpu_threads=2,
                 kb_mem=1048576, mempages=None, **kwargs):

        super(NUMATopology, self).__init__(**kwargs)

        cpu_count = 0
        for cell_count in range(cpu_nodes):
            cell = vconfig.LibvirtConfigCapsNUMACell()
            cell.id = cell_count
            cell.memory = kb_mem // cpu_nodes
            for socket_count in range(cpu_sockets):
                for cpu_num in range(cpu_cores * cpu_threads):
                    cpu = vconfig.LibvirtConfigCapsNUMACPU()
                    cpu.id = cpu_count
                    cpu.socket_id = cell_count
                    cpu.core_id = cpu_num // cpu_threads
                    cpu.siblings = set([cpu_threads *
                                       (cpu_count // cpu_threads) + thread
                                        for thread in range(cpu_threads)])
                    cell.cpus.append(cpu)

                    cpu_count += 1

            # If no mempages are provided, use only the default 4K pages
            if mempages:
                cell.mempages = mempages[cell_count]
            else:
                cell.mempages = create_mempages([(4, cell.memory // 4)])

            self.cells.append(cell)
Exemplo n.º 2
0
    def _gen_numa_topology(cls, cpu_nodes, cpu_sockets, cpu_cores,
                           cpu_threads, kb_mem, numa_mempages_list=None):

        topology = vconfig.LibvirtConfigCapsNUMATopology()

        cpu_count = 0
        for cell_count in range(cpu_nodes):
            cell = vconfig.LibvirtConfigCapsNUMACell()
            cell.id = cell_count
            cell.memory = kb_mem // cpu_nodes
            for socket_count in range(cpu_sockets):
                for cpu_num in range(cpu_cores * cpu_threads):
                    cpu = vconfig.LibvirtConfigCapsNUMACPU()
                    cpu.id = cpu_count
                    cpu.socket_id = cell_count
                    cpu.core_id = cpu_num // cpu_threads
                    cpu.siblings = set([cpu_threads *
                                       (cpu_count // cpu_threads) + thread
                                        for thread in range(cpu_threads)])
                    cell.cpus.append(cpu)

                    cpu_count += 1
            # Set mempages per numa cell. if numa_mempages_list is empty
            # we will set only the default 4K pages.
            if numa_mempages_list:
                mempages = numa_mempages_list[cell_count]
            else:
                mempages = vconfig.LibvirtConfigCapsNUMAPages()
                mempages.size = 4
                mempages.total = cell.memory // mempages.size
                mempages = [mempages]
            cell.mempages = mempages
            topology.cells.append(cell)

        return topology