diff options
author | Tuukka Tikkanen <tuukka.tikkanen@linaro.org> | 2014-12-04 11:09:22 +0200 |
---|---|---|
committer | Tuukka Tikkanen <tuukka.tikkanen@linaro.org> | 2014-12-10 09:47:29 +0200 |
commit | 00431be8d73acdeb6e4938de584607384cd2aa59 (patch) | |
tree | 49eecea6d6fa9f365841e882f0230227b15ea8ba | |
parent | 6b7a59e14e5b116959ae3eb264b42ed700e20d1a (diff) |
energy_model: Fix make_energy_model_template
make_energy_model_template() first calls read_sysfs_cpu_topo()
followed by idlestat_load(). The former will generate topology
based on the host idlestat is being run on. The latter will
merge topology from trace file host. In particular, if these
two hosts have different topologies, the result is unlikely to
be what the user expects.
The call to make_energy_model_template occurs before the main
code has processed --trace or --import. If template creation
is tried in --trace mode, the operation will either fail (if
the trace file does not exist) or it uses existing trace file
contents without running a new trace (if the trace file does
exist). In other words, the behavior is essentially equal to
the --import mode. Since topology of the old trace file could
arguably be different from the current configuration, the
result may be unlike what the user expects.
To fix these problems, prevent generation of energy model
template in --trace mode and construct topology for template
purposes exlusively from trace file without using any other
sources of information.
Signed-off-by: Tuukka Tikkanen <tuukka.tikkanen@linaro.org>
Reviewed-by: Larry Bassel <larry.bassel@linaro.org>
-rw-r--r-- | energy_model.c | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/energy_model.c b/energy_model.c index 4b6cfc7..26422a5 100644 --- a/energy_model.c +++ b/energy_model.c @@ -33,7 +33,6 @@ static int make_energy_model_template(struct program_options *options) fprintf(f, "# Replace ? with correct values\n"); init_cpu_topo_info(); - read_sysfs_cpu_topo(); datas = idlestat_load(options->filename); if (!datas) { fclose(f); @@ -103,6 +102,16 @@ int parse_energy_model(struct program_options *options) f = fopen(path, "r"); if (!f) { if (errno == ENOENT) { + if (options->mode == TRACE) { + fprintf(stderr, + "Energy model file %s does not " + "exist.\nIdlestat was started in " + "trace mode. If you wish to " + "generate energy model\ntemplate, " + "run idlestat in import mode.\n", + path); + return -1; + } ret = make_energy_model_template(options); exit(ret); } |