Skip to content

scripts: add sleep-accuracy measurement tool#580

Open
askervin wants to merge 1 commit intocontainers:mainfrom
askervin:5dO_scripts_sleep_accuracy
Open

scripts: add sleep-accuracy measurement tool#580
askervin wants to merge 1 commit intocontainers:mainfrom
askervin:5dO_scripts_sleep_accuracy

Conversation

@askervin
Copy link
Collaborator

@askervin askervin commented Oct 3, 2025

No description provided.

@askervin askervin force-pushed the 5dO_scripts_sleep_accuracy branch from f179393 to 9d19fb5 Compare October 3, 2025 13:25
Signed-off-by: Antti Kervinen <antti.kervinen@intel.com>
@klihub
Copy link
Collaborator

klihub commented Feb 2, 2026

@askervin Shouldn't we just review this and get it merged ?

@askervin askervin marked this pull request as ready for review February 2, 2026 15:16
@askervin
Copy link
Collaborator Author

askervin commented Feb 2, 2026

@klihub, I think you're right. Marked this now ready for review. Merging it will simplify getting numbers from #618, and help others to do the same.

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");
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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");
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: ditto here... we could avoid buffered I/O with _GNU_SOURCE.

Comment on lines +461 to +465
// 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);
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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) {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If there is no slash, the option is silenty ignored?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants