summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJohn Kacur <jkacur@redhat.com>2014-08-14 17:24:31 +0200
committerJohn Kacur <jkacur@redhat.com>2014-08-14 17:24:31 +0200
commitdd01e7dab9a4eb7adf752d6fc7706b7ebe2b2f2c (patch)
treef0e168f59c8abe11872f594127143772651c2e62
parent72ce09a0fa3c7b2b8c55d1f54749acc4274d2693 (diff)
downloadrt-tests-dd01e7dab9a4eb7adf752d6fc7706b7ebe2b2f2c.tar.gz
cyclictest: Add long option --laptop to preserve battery power
Some people running cyclictest on laptops don't want to automatically take advantage of the trick that prevents the power management to transistion to high cstates, since it eats up their battery power. Allow them to suppress this feature with --laptop This will result in power latency results of course. Feature-requested-by: Joakim Hernberg <jhernberg@alchemy.lu> Signed-off-by: John Kacur <jkacur@redhat.com>
-rw-r--r--src/cyclictest/cyclictest.c14
1 files changed, 13 insertions, 1 deletions
diff --git a/src/cyclictest/cyclictest.c b/src/cyclictest/cyclictest.c
index b45041e..a3e7b1d 100644
--- a/src/cyclictest/cyclictest.c
+++ b/src/cyclictest/cyclictest.c
@@ -186,6 +186,7 @@ static int use_fifo = 0;
static pthread_t fifo_threadid;
static int aligned = 0;
static int offset = 0;
+static int laptop = 0;
static pthread_cond_t refresh_on_max_cond = PTHREAD_COND_INITIALIZER;
static pthread_mutex_t refresh_on_max_lock = PTHREAD_MUTEX_INITIALIZER;
@@ -235,6 +236,11 @@ static void set_latency_target(void)
struct stat s;
int err;
+ if (laptop) {
+ warn("not setting cpu_dma_latency to save battery power\n");
+ return;
+ }
+
errno = 0;
err = stat("/dev/cpu_dma_latency", &s);
if (err == -1) {
@@ -1020,6 +1026,9 @@ static void display_help(int error)
"-i INTV --interval=INTV base interval of thread in us default=1000\n"
"-I --irqsoff Irqsoff tracing (used with -b)\n"
"-l LOOPS --loops=LOOPS number of loops: default=0(endless)\n"
+ " --laptop Save battery when running cyclictest\n"
+ " This will give you poorer realtime results\n"
+ " but will not drain your battery so quickly\n"
"-m --mlockall lock current and future memory allocations\n"
"-M --refresh_on_max delay updating the screen until a new max latency is hit\n"
"-n --nanosleep use clock_nanosleep\n"
@@ -1183,7 +1192,7 @@ enum option_values {
OPT_QUIET, OPT_PRIOSPREAD, OPT_RELATIVE, OPT_RESOLUTION, OPT_SYSTEM,
OPT_SMP, OPT_THREADS, OPT_TRACER, OPT_UNBUFFERED, OPT_NUMA, OPT_VERBOSE,
OPT_WAKEUP, OPT_WAKEUPRT, OPT_DBGCYCLIC, OPT_POLICY, OPT_HELP, OPT_NUMOPTS,
- OPT_ALIGNED,
+ OPT_ALIGNED, OPT_LAPTOP,
};
/* Process commandline options */
@@ -1216,6 +1225,7 @@ static void process_options (int argc, char *argv[], int max_cpus)
{"histofall", required_argument, NULL, OPT_HISTOFALL },
{"interval", required_argument, NULL, OPT_INTERVAL },
{"irqsoff", no_argument, NULL, OPT_IRQSOFF },
+ {"laptop", no_argument, NULL, OPT_LAPTOP },
{"loops", required_argument, NULL, OPT_LOOPS },
{"mlockall", no_argument, NULL, OPT_MLOCKALL },
{"refresh_on_max", no_argument, NULL, OPT_REFRESH },
@@ -1445,6 +1455,8 @@ static void process_options (int argc, char *argv[], int max_cpus)
handlepolicy(optarg); break;
case OPT_DBGCYCLIC:
ct_debug = 1; break;
+ case OPT_LAPTOP:
+ laptop = 1; break;
}
}