Lines Matching defs:cpu

57 static long unsigned get_cpu_total_time(struct cpu_info *cpu);
58 static int get_freq_scales_count(int cpu);
64 static void read_freq_stats(int cpu);
121 // Read stats without aggregating freq stats in the total cpu
132 // Read stats again with aggregating freq stats in the total cpu
137 // Swap new and old cpu buffers;
169 * Uses the two files /sys/devices/system/cpu/present and
170 * /sys/devices/system/cpu/online to determine the number of CPUs. Expects the
176 int cpu_count = get_cpu_count_from_file("/sys/devices/system/cpu/present");
177 if (cpu_count != get_cpu_count_from_file("/sys/devices/system/cpu/online")) {
211 static int get_freq_scales_count(int cpu) {
217 sprintf(filename, "/sys/devices/system/cpu/cpu%d/cpufreq/stats/time_in_state", cpu);
240 fscanf(file, "cpu %lu %lu %lu %lu %lu %lu %lu %*d %*d %*d\n",
250 sprintf(scanline, "cpu%d %%lu %%lu %%lu %%lu %%lu %%lu %%lu %%*d %%*d %%*d\n", i);
260 * Read the frequency stats for a given cpu.
262 static void read_freq_stats(int cpu) {
267 sprintf(filename, "/sys/devices/system/cpu/cpu%d/cpufreq/stats/time_in_state", cpu);
270 for (i = 0; i < new_cpus[cpu].freq_count; i++) {
271 fscanf(file, "%u %lu\n", &new_cpus[cpu].freqs[i].freq,
272 &new_cpus[cpu].freqs[i].time);
274 new_total_cpu.freqs[i].freq = new_cpus[cpu].freqs[i].freq;
275 new_total_cpu.freqs[i].time += new_cpus[cpu].freqs[i].time;
282 * Get the sum of the cpu time from all categories.
284 static long unsigned get_cpu_total_time(struct cpu_info *cpu) {
285 return (cpu->utime + cpu->ntime + cpu->stime + cpu->itime + cpu->iowtime + cpu->irqtime +
286 cpu->sirqtime);
301 sprintf(label, "cpu%d", i);
398 * Only aggregate the frequency stats in the total cpu stats if the frequencies
423 fprintf(stderr, "Usage %s [ -n iterations ] [ -d delay ] [ -c cpu ] [ -m ] [ -h ]\n"