Пример #1
0
    def testResetAffinityWhenConfigured(self):
        taskset.set(os.getpid(), self.CPU_SET)
        self.assertEqual(taskset.get(os.getpid()), self.CPU_SET)

        proc = commands.start((EXT_SLEEP, '30s'))
        try:
            self.assertEqual(taskset.get(proc.pid), online_cpus())
        finally:
            proc.kill()
Пример #2
0
    def testKeepAffinity(self):
        taskset.set(os.getpid(), self.CPU_SET)
        self.assertEqual(taskset.get(os.getpid()), self.CPU_SET)

        proc = commands.start((EXT_SLEEP, '30s'), reset_cpu_affinity=False)
        try:
            self.assertEqual(taskset.get(proc.pid), self.CPU_SET)
        finally:
            proc.kill()
Пример #3
0
    def testResetAffinityWhenConfigured(self):
        taskset.set(os.getpid(), self.CPU_SET)
        self.assertEquals(taskset.get(os.getpid()), self.CPU_SET)

        try:
            proc = commands.execCmd((EXT_SLEEP, '30s'), sync=False)

            self.assertEquals(taskset.get(proc.pid), online_cpus())
        finally:
            proc.kill()
Пример #4
0
    def testResetAffinityWhenConfigured(self):
        taskset.set(os.getpid(), self.CPU_SET)
        self.assertEquals(taskset.get(os.getpid()), self.CPU_SET)

        try:
            proc = utils.execCmd((EXT_SLEEP, '30s'), sync=False)

            self.assertEquals(taskset.get(proc.pid), online_cpus())
        finally:
            proc.kill()
Пример #5
0
    def test_set_from_parent(self, cpu_set):

        validate_running_with_enough_cpus(cpu_set)

        self.proc = multiprocessing.Process(target=self._run_child)
        self.proc.start()
        if not self.running.wait(0.5):
            raise RuntimeError("helper child process not running!")

        taskset.set(self.proc.pid, cpu_set)
        self.assertEqual(taskset.get(self.proc.pid), cpu_set)
Пример #6
0
    def test_set_from_parent(self, cpu_set):

        validate_running_with_enough_cpus(cpu_set)

        self.proc = multiprocessing.Process(target=self._run_child)
        self.proc.start()
        if not self.running.wait(0.5):
            raise RuntimeError("helper child process not running!")

        taskset.set(self.proc.pid, cpu_set)
        self.assertEqual(taskset.get(self.proc.pid), cpu_set)
Пример #7
0
    def testKeepAffinity(self):
        taskset.set(os.getpid(), self.CPU_SET)
        self.assertEquals(taskset.get(os.getpid()), self.CPU_SET)

        try:
            proc = commands.execCmd((EXT_SLEEP, '30s'),
                                    sync=False,
                                    resetCpuAffinity=False)

            self.assertEquals(taskset.get(proc.pid), self.CPU_SET)
        finally:
            proc.kill()
Пример #8
0
    def testKeepAffinity(self):
        taskset.set(os.getpid(), self.CPU_SET)
        self.assertEquals(taskset.get(os.getpid()), self.CPU_SET)

        try:
            proc = utils.execCmd((EXT_SLEEP, '30s'),
                                 sync=False,
                                 resetCpuAffinity=False)

            self.assertEquals(taskset.get(proc.pid), self.CPU_SET)
        finally:
            proc.kill()
Пример #9
0
def __set_cpu_affinity():
    cpu_affinity = config.get('vars', 'cpu_affinity')
    if cpu_affinity == "":
        return

    online_cpus = taskset.online_cpus()

    log = logging.getLogger('vds')

    if len(online_cpus) == 1:
        log.debug('Only one cpu detected: affinity disabled')
        return

    if cpu_affinity.lower() == taskset.AUTOMATIC:
        cpu_set = frozenset((taskset.pick_cpu(online_cpus), ))
    else:
        cpu_set = frozenset(
            int(cpu.strip()) for cpu in cpu_affinity.split(","))

    log.info('VDSM will run with cpu affinity: %s', cpu_set)
    taskset.set(os.getpid(), cpu_set, all_tasks=True)
Пример #10
0
Файл: vdsmd.py Проект: nirs/vdsm
def __set_cpu_affinity():
    cpu_affinity = config.get('vars', 'cpu_affinity')
    if cpu_affinity == "":
        return

    online_cpus = taskset.online_cpus()

    log = logging.getLogger('vds')

    if len(online_cpus) == 1:
        log.debug('Only one cpu detected: affinity disabled')
        return

    if cpu_affinity.lower() == taskset.AUTOMATIC:
        cpu_set = frozenset((taskset.pick_cpu(online_cpus),))
    else:
        cpu_set = frozenset(int(cpu.strip())
                            for cpu in cpu_affinity.split(","))

    log.info('VDSM will run with cpu affinity: %s', cpu_set)
    taskset.set(os.getpid(), cpu_set, all_tasks=True)
Пример #11
0
 def _run_child(self, cpu_set=None):
     if cpu_set:
         taskset.set(os.getpid(), cpu_set)
     self.running.set()
     self.stop.wait()
Пример #12
0
 def _run_child(self, cpu_set=None):
     if cpu_set:
         taskset.set(os.getpid(), cpu_set)
     self.running.set()
     self.stop.wait()