def _taskset_cmd(self, cmd, num_cpus): """ modify cmd to be via taskset """ cpu_a = cpu_lib.CPUAllocator() assert num_cpus # use high numbered cpus cpu_list = cpu_a.get_n_cpus(num_cpus, low=False) new_cmd = "taskset -c {} {}".format(",".join(map(str, cpu_list)), cmd) return new_cmd
def _get_single_numa_cpu_list(self): cpu_a = cpu_lib.CPUAllocator() # get the highest number numa node numa_id = cpu_a.get_numa_ids()[-1] numa_obj = cpu_a.get_numa_by_id(numa_id) cpu_obj_list = numa_obj.get_cpu_list() cpu_id_list = [] for cpu in cpu_obj_list: if not cpu.is_free(): continue cpu_id_list.append(cpu.get_cpu_id()) return cpu_id_list