diff options
author | PA4WDH | 2024-07-25 17:27:28 +0200 |
---|---|---|
committer | PA4WDH | 2024-07-25 17:27:28 +0200 |
commit | 5a33d25886af8f0996d901fcfc66674a3dc625db (patch) | |
tree | 8ad1db0da5a5aa39348d96d71cbea38e3b740c05 /cputemp2maxfreq.c | |
parent | Fix typos (diff) | |
download | cputemp2maxfreq-5a33d25886af8f0996d901fcfc66674a3dc625db.tar.gz cputemp2maxfreq-5a33d25886af8f0996d901fcfc66674a3dc625db.tar.bz2 cputemp2maxfreq-5a33d25886af8f0996d901fcfc66674a3dc625db.zip |
Add commandline parameter to set transition latency0.4
Diffstat (limited to 'cputemp2maxfreq.c')
-rw-r--r-- | cputemp2maxfreq.c | 27 |
1 files changed, 25 insertions, 2 deletions
diff --git a/cputemp2maxfreq.c b/cputemp2maxfreq.c index 597f1e8..ad27062 100644 --- a/cputemp2maxfreq.c +++ b/cputemp2maxfreq.c @@ -29,6 +29,7 @@ struct s_config config={ 0, // Don't overwrite CSV logfile NULL, // File handler for CSV file 0, // Don't use unix timestamps in log outputs + -1, // Transition latency, default to autodetect }; struct s_cpudata cpudata; @@ -38,11 +39,19 @@ void signal_handler(int signum) failsafe(0); } +char *transition_latency_remarks[] = { + "Autodetected", + "Set via commandline", + "This seems low, consider setting it via -d" +}; + int main(int argc,char **argv) { long int diff; long int newfreq; + char *transition_latency_remark; + argparse(argc,argv); config.logger("%s version %s, buildtime %s %s",config.name,version(),__DATE__,__TIME__); @@ -64,6 +73,12 @@ int main(int argc,char **argv) config.logger("Overwrite CSV log: %d",config.csvoverwrite); } config.logger("Use unix timestamps: %d",config.use_unixtime); + if (config.transition_latency<0) + { + config.logger("Transition latency: Autodetect"); + } else { + config.logger("Transition latency: %d",config.transition_latency); + } if ((config.max_temp<VALID_TEMP_MIN) || (config.max_temp>VALID_TEMP_MAX)) { @@ -87,13 +102,21 @@ int main(int argc,char **argv) cpudata.min_freq=sysfs_read_long_int("/sys/devices/system/cpu/cpufreq/policy0/cpuinfo_min_freq"); cpudata.max_freq=sysfs_read_long_int("/sys/devices/system/cpu/cpufreq/policy0/cpuinfo_max_freq"); cpudata.scale_max=sysfs_read_long_int("/sys/devices/system/cpu/cpufreq/policy0/scaling_max_freq"); - cpudata.transition_latency=sysfs_read_long_int("/sys/devices/system/cpu/cpufreq/policy0/cpuinfo_transition_latency"); + if (config.transition_latency<0) + { + transition_latency_remark=transition_latency_remarks[0]; + cpudata.transition_latency=sysfs_read_long_int("/sys/devices/system/cpu/cpufreq/policy0/cpuinfo_transition_latency"); + if (cpudata.transition_latency<1000) transition_latency_remark=transition_latency_remarks[2]; + } else { + transition_latency_remark=transition_latency_remarks[1]; + cpudata.transition_latency=config.transition_latency; + } config.logger("CPU data:"); config.logger("Minimum frequency: %ld",cpudata.min_freq); config.logger("Maximum frequency: %ld",cpudata.max_freq); config.logger("Scaling maximum frequency: %ld",cpudata.scale_max); - config.logger("Transition Latency: %ld",cpudata.transition_latency); + config.logger("Transition Latency: %ld (%s)",cpudata.transition_latency,transition_latency_remark); if ((cpudata.min_freq<VALID_FREQ_MIN) || (cpudata.min_freq>VALID_FREQ_MAX) || (cpudata.max_freq<VALID_FREQ_MIN) || (cpudata.max_freq>VALID_FREQ_MAX) || |