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()
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()
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()
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()
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)
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()
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()
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)
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)
def _run_child(self, cpu_set=None): if cpu_set: taskset.set(os.getpid(), cpu_set) self.running.set() self.stop.wait()