aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--README.html3
-rw-r--r--argparse.c12
-rw-r--r--cputemp2maxfreq.c27
-rw-r--r--cputemp2maxfreq.h1
4 files changed, 40 insertions, 3 deletions
diff --git a/README.html b/README.html
index 312f4c6..5ed6157 100644
--- a/README.html
+++ b/README.html
@@ -30,6 +30,9 @@
</p>
<p><strong>Scaling options:</strong></p>
<ul>
+ <li><strong>-d</strong> sets the transition latency (the time it takes the
+ CPU to apply a new frequency). This is a value in microseconds or the
+ keyword &quot;auto&quot; for autodetection.</li>
<li><strong>-f</strong> sets the fallback frequency. In case something goes
wrong the program sets the CPU frequency to it's minimum. In case that
fails too it will try the fallback frequency</li>
diff --git a/argparse.c b/argparse.c
index 37d9176..124f3bc 100644
--- a/argparse.c
+++ b/argparse.c
@@ -14,6 +14,8 @@ void printhelp()
"Usage: %s <options>\n"
"\n"
"Scaling options:\n"
+ "-d <delay> Transition latency in us or \"auto\" for autodetect\n"
+ " Default: auto\n"
"-f <frequency> Fallback frequency in KHz, used when everything fails\n"
" Default: %ld\n"
"-g <governor> cpufreq governor to use, use \"keep\" to keep current governor\n"
@@ -65,7 +67,7 @@ void argparse(int argc, char **argv)
memcpy(&userconfig,&config,sizeof(struct s_config));
// Parse options
- while((opt=getopt(argc,argv,"c:C:f:g:hi:l:mp:s:t:u"))!=-1)
+ while((opt=getopt(argc,argv,"c:C:d:f:g:hi:l:mp:s:t:u"))!=-1)
{
DEBUG1_ARGPARSE("Argument: %c Value: %s\n",opt,optarg);
switch(opt)
@@ -78,6 +80,14 @@ void argparse(int argc, char **argv)
strncpy(userconfig.csvlog,optarg,sizeof(userconfig.csvlog));
userconfig.csvoverwrite=1;
break;
+ case 'd':
+ if (strcmp("auto",optarg)==0)
+ {
+ userconfig.transition_latency=-1;
+ } else {
+ userconfig.transition_latency=strtoll(optarg,NULL,10);
+ }
+ break;
case 'f':
userconfig.fallback_freq=strtoll(optarg,NULL,10);
break;
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) ||
diff --git a/cputemp2maxfreq.h b/cputemp2maxfreq.h
index afce5ca..ade4d58 100644
--- a/cputemp2maxfreq.h
+++ b/cputemp2maxfreq.h
@@ -45,6 +45,7 @@ struct s_config {
char csvoverwrite; // Overwrite CSV file if it already exists
FILE *csvfile; // File handle for CSV file
char use_unixtime; // Use unixtime timestamps in logs and CSV
+ long int transition_latency; // User configurable transition latency, <0 for autodetect
};
#endif