scripts: add sleep-accuracy measurement tool#580
scripts: add sleep-accuracy measurement tool#580askervin wants to merge 1 commit intocontainers:mainfrom
Conversation
f179393 to
9d19fb5
Compare
Signed-off-by: Antti Kervinen <antti.kervinen@intel.com>
|
@askervin Shouldn't we just review this and get it merged ? |
| FILE *f = NULL; | ||
| while (1) { | ||
| sprintf(disable_filename, "/sys/devices/system/cpu/cpu%d/cpuidle/state%d/disable", cpu, state); | ||
| FILE *f = fopen(disable_filename, "w"); |
There was a problem hiding this comment.
nit: Since we're _GNU_SOURCE, I think we could avoid buffered I/O altogether and just use open and dprintf here.
| FILE *f = NULL; | ||
|
|
||
| sprintf(freq_filename, "/sys/devices/system/cpu/cpu%d/cpufreq/scaling_max_freq", cpu); | ||
| f = fopen(freq_filename, "w"); |
There was a problem hiding this comment.
nit: ditto here... we could avoid buffered I/O with _GNU_SOURCE.
| // Wait until there is more than single CPU to toggle again. | ||
| // This prevents keep setting main thread's CPU affinity to same CPU in a loop. | ||
| while (toggle_cpu0 != -1) { | ||
| delay(toggle_cpu_interval_ns); | ||
| } |
There was a problem hiding this comment.
Is the idea here that if we only have a single CPU (cpu0) then at the end of the first iteration, we stay looping here forever. So basically doing the same as we would do without having this extra while, but avoiding the now unnecessary set_cpu_affinity() ?
| options.cpus[options.cpu_count++][1] = atoi(slash + 1); | ||
| } else { | ||
| options.cpus[options.cpu_count++][0] = atoi(token); | ||
| options.cpus[options.cpu_count - 1][1] = -1; // indicate single CPU pinning |
There was a problem hiding this comment.
This looks a bit confusing. Isn't the intention to set cpus[options.cpu_count][0] to the first part to value A and cpus[options.cpu_count][1] to either the value following '/' or -1 if none? So the latter could also be [options.cpu_count][0] = atoi(token) and [options.cpu_count++][1] = -1? BTW, should it also be checked that atoi() returns useful values and not perhaps -42, and would strtoul() be a better choice?
| char *token = strtok(argv[++i], ","); | ||
| while (token && options.polprio_count < MAX_COMB) { | ||
| char *slash = strchr(token, '/'); | ||
| if (slash) { |
There was a problem hiding this comment.
If there is no slash, the option is silenty ignored?
No description provided.