def plot_cpu_cooling_states(self, cpu, axis, local_fig): """ Plot the state evolution of a cpufreq cooling device :param cpu: The CPU. Whole clusters can be controlled as a single cooling device, they will be plotted as long this CPU belongs to the cluster. :type cpu: int """ start = self.trace.start end = self.trace.end df = self.df_cpufreq_cooling_state([cpu]) df = df_refit_index(df, start, end) cdev_name = "CPUs {}".format(mask_to_list(df.cpus.unique()[0])) df.cdev_state.plot(drawstyle="steps-post", ax=axis, label="\"{}\"".format(cdev_name)) axis.legend() if local_fig: axis.grid(True) axis.set_title("cpufreq cooling devices status") axis.yaxis.set_major_locator(MaxNLocator(integer=True)) axis.grid(axis='y') axis.set_xlim(start, end)
def cpufreq_cdevs(self): """ Get cpufreq cooling devices that appear in the trace """ df = self.df_cpufreq_cooling_state() res = df['cpus'].unique().tolist() return [mask_to_list(mask) for mask in res]
def cpufreq_cdevs(self): """ Get cpufreq cooling devices that appear in the trace """ df = self._dfg_trace_event('thermal_power_cpu_limit') res = df['cpus'].unique().tolist() return [mask_to_list(mask) for mask in res]
def cpufreq_cdevs(self): """ Get cpufreq cooling devices that appear in the trace """ df = self._dfg_trace_event('thermal_power_cpu_limit') res = df['cpus'].unique().tolist() return [mask_to_list(mask) for mask in res]
def _find_core_groups(cls, target): """ Read the core_siblings masks for each CPU from sysfs :param target: Devlib Target object to read masks from :returns: A list of tuples of ints, representing the partition of core siblings """ cpus = range(target.number_of_cpus) topology_base = '/sys/devices/system/cpu/' # We only care about core_siblings, but let's check *_siblings, so we # can throw an error if a CPU's thread_siblings isn't just itself, or if # there's a topology level we don't understand. # Since we might have to read a lot of files, read everything we need in # one go to avoid taking too long. mask_glob = topology_base + 'cpu**/topology/*_siblings' file_values = read_multiple_oneline_files(target, [mask_glob]) regex = re.compile(topology_base + r'cpu([0-9]+)/topology/([a-z]+)_siblings') ret = set() for path, mask_str in file_values.iteritems(): match = regex.match(path) cpu = int(match.groups()[0]) level = match.groups()[1] # mask_to_list returns the values in descending order, so we'll sort # them ascending. This isn't strictly necessary but it's nicer. siblings = tuple(sorted(mask_to_list(int(mask_str, 16)))) if level == 'thread': if siblings != (cpu, ): # SMT systems aren't supported raise RuntimeError('CPU{} thread_siblings is {}. ' 'expected {}'.format( cpu, siblings, [cpu])) continue if level != 'core': # The only other levels we should expect to find are 'book' and # 'shelf', which are not used by architectures we support. raise RuntimeError( 'Unrecognised topology level "{}"'.format(level)) ret.add(siblings) # Sort core groups so that the lowest-numbered cores are first # Again, not strictly necessary, just more pleasant. return sorted(ret, key=lambda x: x[0])
def _find_core_groups(cls, target): """ Read the core_siblings masks for each CPU from sysfs :param target: Devlib Target object to read masks from :returns: A list of tuples of ints, representing the partition of core siblings """ cpus = range(target.number_of_cpus) topology_base = '/sys/devices/system/cpu/' # We only care about core_siblings, but let's check *_siblings, so we # can throw an error if a CPU's thread_siblings isn't just itself, or if # there's a topology level we don't understand. # Since we might have to read a lot of files, read everything we need in # one go to avoid taking too long. mask_glob = topology_base + 'cpu**/topology/*_siblings' file_values = read_multiple_oneline_files(target, [mask_glob]) regex = re.compile( topology_base + r'cpu([0-9]+)/topology/([a-z]+)_siblings') ret = set() for path, mask_str in file_values.iteritems(): match = regex.match(path) cpu = int(match.groups()[0]) level = match.groups()[1] # mask_to_list returns the values in descending order, so we'll sort # them ascending. This isn't strictly necessary but it's nicer. siblings = tuple(sorted(mask_to_list(int(mask_str, 16)))) if level == 'thread': if siblings != (cpu,): # SMT systems aren't supported raise RuntimeError('CPU{} thread_siblings is {}. ' 'expected {}'.format(cpu, siblings, [cpu])) continue if level != 'core': # The only other levels we should expect to find are 'book' and # 'shelf', which are not used by architectures we support. raise RuntimeError( 'Unrecognised topology level "{}"'.format(level)) ret.add(siblings) # Sort core groups so that the lowest-numbered cores are first # Again, not strictly necessary, just more pleasant. return sorted(ret, key=lambda x: x[0])
def stringify_mask(mask): return 'CPUs {}'.format(mask_to_list(mask))
def stringify_mask(mask): return 'CPUs {}'.format(mask_to_list(mask))