Age | Commit message (Collapse) | Author |
|
Current implementation for core/cluster data calculation is to look
for intersections of same state residency in cpu data after loading
all of the data. This fails to correctly record core/cluster data
for cases where all the contained cpus are in a low power state, but
are not using the exact same state.
To resolve this, core/cluster state needs to be evaluated at the
same time as the cpu events are being processes. The store_data()
function is modified to record not only the affected cpu changes,
but also the affected core and cluster. Supporting changes are added
throughout the source tree.
Signed-off-by: Tuukka Tikkanen <tuukka.tikkanen@linaro.org>
|
|
Current implementation for core/cluster data calculation is to look
for intersections of same state residency in cpu data after loading
all of the data. This fails to correctly record core/cluster data
for cases where all the contained cpus are in a low power state, but
are not using the exact same state.
To resolve this, core/cluster state needs to be evaluated at the
same time as the cpu events are being processes. This patch adds
functions for allocating and initializing memory for core/cluster
statistics.
Signed-off-by: Tuukka Tikkanen <tuukka.tikkanen@linaro.org>
|
|
This patch adds the following functions/macros:
cpu_to_cluster(cpuid, topo) maps cpu index into containing cluster,
cpu_to_core(cpuid, topo) maps cpu index into containing core,
core_for_each_cpu(cpu, core) iterates all cpus in a core,
cluster_for_each_core(core, clust) iterates all cores in a cluster,
cluster_for_each_cpu(cpu, clust) iterates all cpus in a cluster and
topo_for_each_clister(clust, topo) iterates all clusters in a topology.
core_get_least_cstate(core) returns the smallest cstate index of all
cpus in a core.
core_get_highest_freq(core) returns the highest known frequency of
all cpus in a core. C-states are ignored. If the frequency is not
known for any of the cpus, the function returns 0.
get_affected_core_least_cstate(cpuid, topo) and
get_affected_core_highest_freq(cpuid, topo) return similar to the
two functions just above. The only difference is that they first
map the cpuid into the containing core.
For the above 4 functions/macros, there are cluster variants:
cluster_get_least_cstate(clust),
cluster_get_highest_freq(clust),
get_affected_cluster_least_cstate(cpuid, topo) and
get_affected_cluster_highest_freq(cpuid, topo).
Signed-off-by: Tuukka Tikkanen <tuukka.tikkanen@linaro.org>
|
|
The function store_data() does not use the parameter count for any
purpose. This patch removes the parameter.
Signed-off-by: Tuukka Tikkanen <tuukka.tikkanen@linaro.org>
|
|
This patch changes list_add(node, pos->prev) into
list_add_tail(node, pos). This can be done as the
linked lists are cyclic. In terms of expanded macros the change is
from __list_add(node, pos->prev, pos->prev->next) into
__list_add(node, pos->prev, pos).
Signed-off-by: Tuukka Tikkanen <tuukka.tikkanen@linaro.org>
|
|
The function cluster_data() has no callers, remove it.
Signed-off-by: Tuukka Tikkanen <tuukka.tikkanen@linaro.org>
|
|
trace-cmd(1) related tools are convenient for getting and
processing traces using Ftrace Linux kernel internal tracer.
Usually, trace-cmd-report(1) is used to convert files from
trace-cmd's trace-cmd.dat(5) binary format to human readable
text files.
Signed-off-by: Koan-Sin Tan <freedom.tan@linaro.org>
Reviewed-by: Tuukka Tikkanen <tuukka.tikkanen@linaro.org>
|
|
The format of the energy model file should be described.
Signed-off-by: Larry Bassel <larry.bassel@linaro.org>
|
|
Idlestat modifies the kernel trace options via sysfs interface every
time a trace is created. The user may have prefer to have the original
trace options restored once idlestat is finished with the task. This
patch adds code to save and restore the trace options that might be
modified by idlestat.
idlestore_store_trace_options(): Saves the options by 1) record the
original trace buffer size and 2) scan the whole ftrace event
hierarchy, storing the paths of enabled event types into a list.
idlestat_restore_trace_options(): Restores the options including
buffer size and enabled events. Disables all other events.
Signed-off-by: Koan-Sin Tan <freedom.tan@linaro.org>
Signed-off-by: Tuukka Tikkanen <tuukka.tikkanen@linaro.org>
|
|
This patch adds comparison report style. It is similar to default
report style, except that it displays changes in active trace
compared to the baseline trace.
It becomes active by providing a baseline trace (--baseline)
and specifying the comparison report style with "-r comparison".
Signed-off-by: Tuukka Tikkanen <tuukka.tikkanen@linaro.org>
|
|
As pstates are allocated in the pstate arrays only when seen in
traces and each trace has its own private arrays, main trace
and baseline may end up having different sets of pstates in
their arrays. This patch iterates through the pstate arrays
and inserts pstate entries into the arrays so that both traces
have the same pstates in same order. This allows easy comparison
between the two traces.
Signed-off-by: Tuukka Tikkanen <tuukka.tikkanen@linaro.org>
|
|
Some report types may wish to manipulate their operation pointers
before they are taken into use by the main program. Add a mechanism
for implementing this.
Signed-off-by: Tuukka Tikkanen <tuukka.tikkanen@linaro.org>
|
|
While passing around the per report data pointer has been previously
implemented, there was no mechanism for the report ops to allocate
or release the data as needed. This patch moves allocation of
report_data pointer from struct options to main() and adds calls
necessary for allocating (and initializing) and releasing the data.
Signed-off-by: Tuukka Tikkanen <tuukka.tikkanen@linaro.org>
|
|
The functions display_cstates and display_pstates are in control of
dumping c/p state information for each cpu. This patch adds handling
of baseline states to both functions. If the selected report mode
does not provide baseline handling function(s), the operation is
silently skipped.
Signed-off-by: Tuukka Tikkanen <tuukka.tikkanen@linaro.org>
|
|
pstate_single_state and wakeup_single_state have had most of
their names copied from the cstate variant. As the items
displayed by these functions are frequencies and interrupt
sources, rename the functions to pstate_single_freq and
wakeup_single_irq.
Signed-off-by: Tuukka Tikkanen <tuukka.tikkanen@linaro.org>
|
|
This patch adds relay of baseline data for per-cpu entries when
composing the report.
Signed-off-by: Tuukka Tikkanen <tuukka.tikkanen@linaro.org>
|
|
The existing version of alloc_pstate() can create duplicate
entries for the same pstate if called with a frequency
value that already exists. Change the semantics so that
in case the frequency already exists in the array, the
index returned is for the existing frequency.
This change allows removal of (now) obsolete function
get_current_pstate and merging of pstate entries between
main trace and baseline trace for comparison report purposes.
Signed-off-by: Tuukka Tikkanen <tuukka.tikkanen@linaro.org>
|
|
The establish_idledata_to_topo copies addresses of cstate and pstate
data from a struct cpuidle_datas to struct cpu_cpu's that are used
by the topology code. This patch adds support for copying addresses
of baseline data pointed to by baseline member of the datas structure.
Signed-off-by: Tuukka Tikkanen <tuukka.tikkanen@linaro.org>
|
|
This patch adds command line option for specifying a baseline
trace file. If specified, the trace is loaded using idlestat_load
and the baseline member in the main datas structure points to
the loaded baseline datas structure. As such, this adds no new
features itself, but allows implementing a comparison feature.
Signed-off-by: Tuukka Tikkanen <tuukka.tikkanen@linaro.org>
|
|
The initial implementation of default, boxless and csv report formats
required making the report format ops structures global. Getoptions()
referred directly to these structures when assigning the active ops
pointer.
This patch adds a name field to the structures and places pointers
to the structures in a special segment so that the list of ops
structures can be iterated like an array without having to create
such an array explicitly. Getoptions() is modified to record only
the name and main() will then obtain the actual structure pointer
by name.
The ops array head and sentinel is combined into the same source
files that have been used for trace file ops arrays. The files
are renamed to ops_head.c and ops_tail.c.
Command line options parsing now checks that there is only one
specification of report format. Usage function lists the available
formats. -C and -B are retained as shortcuts for -r csv and
-r boxless, respectively.
Signed-off-by: Tuukka Tikkanen <tuukka.tikkanen@linaro.org>
|
|
Some reports may require some program options to be set, but other
reports may not require the same options. To keep details of these
checks out of main() and getoptions(), this patch adds a new
operation to report_ops for doing these checks when necessary.
Pointer to struct program_options is passed to the op. If the
options are not suitable for operation, the op must print an error
message for the user and return -1. Otherwise the op should
return 0.
Signed-off-by: Tuukka Tikkanen <tuukka.tikkanen@linaro.org>
|
|
print_vrb (print verbose) is a preprocessor macro defined in utils.h.
It behaves like fprintf(stderr, ...) if the level argument is greater
than or equal to current options->verbose value (incremented by one
for each -v parameter on command line). Unfortunately the macro does
depend on variable "options" being visible in the scope it is used in,
which prevents using it in any function that does not have that
variable declared in it or passed to it.
This patch makes the macro a real function and disconnects the
dependency of having options visible at call site. Instead while the
options are passed, a call to set_verbose_level() is make whenever
the value of options->verbose changes.
The name and call semantics are adjusted to increase versatility of
the function. Two variants are created:
verbose_printf(int min_level, const char *fmt, ...)
verbose_fprintf(FILE *f, int min_level, const char *fmt, ...)
These two behave like printf and fprintf if level >= current verbose
level, otherwise they do nothing and return 0.
Signed-off-by: Tuukka Tikkanen <tuukka.tikkanen@linaro.org>
|
|
Struct report_ops is defined in idlestat.h. Having the definition
in report_ops.h keeps the definition grouped with the declarations
of different report types.
Signed-off-by: Tuukka Tikkanen <tuukka.tikkanen@linaro.org>
|
|
Enum formats is no longer used and the definition in idlestat.h
can be dropped.
Signed-off-by: Tuukka Tikkanen <tuukka.tikkanen@linaro.org>
|
|
This patch separates loading of different trace file formats to
independent functions. In order to call the correct function for
each trace file processed, each load function comes with a match
function. Pointers to these functions are stored in a new
struct trace_ops.
In order to avoid static lists of trace file formats (e.g.
implemented as static arrays or a number of registration
function calls in main), pointers to all trace_ops structures
are collected by the linker into a private segment. This creates
an implicit array of the pointers, which may then be enumerated
starting right after a globally linked element trace_ops_head.
A sentinel NULL pointer trails the array. A helper macro
EXPORT_TRACE_OPS is added for creating the special pointers.
Signed-off-by: Tuukka Tikkanen <tuukka.tikkanen@linaro.org>
Reviewed-by: Koan-Sin Tan <freedom.tan@linaro.org>
|
|
Pre-patch the topology is rooted to a global variable g_cpu_topo_list.
This prevents loading multiple traces for comparison. This patch
makes the allocation dynamic. The root pointer is stored within
struct cpuidle_datas, allowing the idlestat_load() to retain its
prototype, but most of the functions defined in topology.c have
a new parameter for passing the topology root pointer.
Signed-off-by: Tuukka Tikkanen <tuukka.tikkanen@linaro.org>
Reviewed-by: Koan-Sin Tan <freedom.tan@linaro.org>
|
|
Return values from programs are unsigned. Replace return -1 with
return 1 in main().
Signed-off-by: Tuukka Tikkanen <tuukka.tikkanen@linaro.org>
|
|
The header file topology.h could not be included as the first header
file due to using the type "bool" without first including stdbool.h.
This patch adds directive to include stdbool and removes directive to
include idlestat.h to reduce risk of cyclic dependecy forming later
during development. The two required structure declarations from the
omitted header are added as explicit forward declarations.
Signed-off-by: Tuukka Tikkanen <tuukka.tikkanen@linaro.org>
Reviewed-by: Koan-Sin Tan <freedom.tan@linaro.org>
|
|
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>
|
|
Function inter() may return newly allocated structures or one of the
parameters (if the other parameter is NULL). This function is called
in a loop from cluster_data(), core_cluster_data() and
physical_cluster_data() with one of the parameters often being an
earlier return value from inter(). This causes a great number of
structure allocations without matching memory releases.
Code in topology.c takes the result from *_cluster_data(), but it
only releases the top-level structure, without releasing the
data pointed to by top-level structure members.
This patch plugs both types of leaks. Since the memory pointed to
by inter() may or may not be allocated by that call, a new member
has been added to struct cpuidle_cstate to indicate the origin
of the structure.
This patch also adds detection for data aliasing related to inter(),
but does not remove the bug.
Signed-off-by: Tuukka Tikkanen <tuukka.tikkanen@linaro.org>
|
|
This patch changes the return value of inter() and intersection()
on allocation fail to ptrerror(). Previously the return value was
NULL, which under normal conditions indicates no overlap between
the two sets. Further cascading changes are made to callers of
these functions and the callers of callers etc.
Signed-off-by: Tuukka Tikkanen <tuukka.tikkanen@linaro.org>
|
|
This patch modifies malloc/calloc/realloc calls in idlestat.c to
conform to following rules:
1. Newly allocated memory is zeroed by using calloc instead of malloc
or by calling memset after realloc. The only exception is when the newly
allocated memory is storage for a string or always completely overwritten
with a call to memcpy or a single assignment statement.
2. Calls to memset(ptr, 0, size) that followed calloc have been removed.
3. perror() message body after allocation failure is uniformly __func__,
resulting in "func_name: Out of memory".
Signed-off-by: Tuukka Tikkanen <tuukka.tikkanen@linaro.org>
|
|
The element count has already been incremented by the time of
calling realloc in inter(), so adding +1 to the element
count is unnecessary.
Signed-off-by: Tuukka Tikkanen <tuukka.tikkanen@linaro.org>
|
|
Some functions such as inter() and intersection() use NULL return
value to indicate both errors (e.g. out of memory) and a result
(empty intersection). Make ptrerror() return a unique non-NULL
pointer value so that the error and NULL result can be told apart.
Previously the parameter to ptrerror() was unconditionally
interpreted as a pointer to string to be passed to perror(). Now
the function checks the value and calls perror only if the
parameter value is not NULL.
A new function, is_err(), has been added to check if any pointer
value is equal to ptrerror() return value.
error(), ptrerror() and is_err() have been moved to utils.c.
The functions that used ptrerror() before this patch have been
modified to consistently return ptrerror() instead of NULL in
cases of errors (affects the return statements where no call to
perror() is desired). Likewise the callers now use is_err()
instead of checking for NULL pointer.
Signed-off-by: Tuukka Tikkanen <tuukka.tikkanen@linaro.org>
|
|
The function intersection() uses pointer parameters without checking
the validity. Add assert() statements making sure the pointers are
not NULL.
Signed-off-by: Tuukka Tikkanen <tuukka.tikkanen@linaro.org>
Reviewed-by: Amit Kucheria <amit.kucheria@linaro.org>
|
|
The initial and final pstates were stored only if the display
options at the time of creating the trace file included display
of P-states. Since the trace may later be imported with the
P-state display on, add the pseudo P-state changes to the trace
unconditionally.
In addition, the return value of get_trace_ts was never checked
for error. The error checking has been added. Since floating
point comparison for equality is unreliable, the function now
returns only status and the actual data is relayed by modifying
memory pointed to by a function parameter. Error messages have
been added to the get_trace_ts function.
Signed-off-by: Tuukka Tikkanen <tuukka.tikkanen@linaro.org>
Reviewed-by: Amit Kucheria <amit.kucheria@linaro.org>
|
|
Functions build_cstate_info and load_and_build_cstate_info
previously handled errors by returning an error code without
printing an error message. This was a problem because the error
could be caused by something which does not set errno, but
the caller assumed this was always the case and called perror()
to report the error to user.
This patch adds reporting of errors directly from these
functions and changes the caller error propagation to be silent.
Signed-off-by: Tuukka Tikkanen <tuukka.tikkanen@linaro.org>
Reviewed-by: Amit Kucheria <amit.kucheria@linaro.org>
|
|
An earlier patch introduced generating P-state changes into
beginning and end of the trace file. This was done to account
P-state residencies that extended outside of the trace period
correctly. These P-state changes reliably trigger warning
messages about changing a P-state for an idle CPU. (These could
also be triggered by P-state changes that occur naturally.)
This patch suppresses warnings about P-state changes for "an idle
CPU" when the actual idle state of the CPU is not known.
Signed-off-by: Tuukka Tikkanen <tuukka.tikkanen@linaro.org>
Reviewed-by: Amit Kucheria <amit.kucheria@linaro.org>
|
|
This patch adds closing the the input file stream after being
done parsing it to parse_energy_model().
Signed-off-by: Tuukka Tikkanen <tuukka.tikkanen@linaro.org>
Reviewed-by: Larry Bassel <larry.bassel@linaro.org>
|
|
make_energy_model_template() did not close the output stream, this
has been fixed. In addition, the (partial) output file is now deleted
in case of a failure.
Signed-off-by: Tuukka Tikkanen <tuukka.tikkanen@linaro.org>
Reviewed-by: Larry Bassel <larry.bassel@linaro.org>
|
|
As the only field of the options structure used by idlestat_load() is
the trace file path, pass the path and not the options structure. This
also allows loading different traces, such as baseline trace for
comparison, during single invocation of idlestat.
Signed-off-by: Tuukka Tikkanen <tuukka.tikkanen@linaro.org>
Reviewed-by: Amit Kucheria <amit.kucheria@linaro.org>
|
|
Currently the options->format field is not used outside of the
idlestat_load() function. Make the variable local, as the usage
is local. This makes it easier load multiple traces during single
invocation of idlestat.
Signed-off-by: Tuukka Tikkanen <tuukka.tikkanen@linaro.org>
Reviewed-by: Amit Kucheria <amit.kucheria@linaro.org>
|
|
Before this patch,
read_int() ignores the return value of fscanf(), file_read_value()
checks for only EOF instead of all failures of a fscanf call and
check_window_size() ignores the return value of an ioctl call.
This patch fixes the error checking for all of the above.
Signed-off-by: Tuukka Tikkanen <tuukka.tikkanen@linaro.org>
Reviewed-by: Amit Kucheria <amit.kucheria@linaro.org>
|
|
The error message printed out by bad_filename() contains the illegal
character detected. In case the character is not printable,
display the hexadecimal code for it instead of writing out the literal
character as is.
Signed-off-by: Tuukka Tikkanen <tuukka.tikkanen@linaro.org>
Reviewed-by: Amit Kucheria <amit.kucheria@linaro.org>
|
|
The boxless format is more Braille terminal friendly.
It's default one without | and - for box boundaries.
Trailing spaces have been removed where such would appear
after removal of right edge of the box. This report
format can be invoked with the -B option.
Implementation shares some functions with default report
format and is added to default_report.c.
Signed-off-by: Koan-Sin Tan <freedom.tan@linaro.org>
Signed-off-by: Tuukka Tikkanen <tuukka.tikkanen@linaro.org>
|
|
1. add csv report ops in csv_report.c
2. add -C option
3. add simple description in csv-format.txt
Signed-off-by: Koan-Sin Tan <freedom.tan@linaro.org>
Signed-off-by: Tuukka Tikkanen <tuukka.tikkanen@linaro.org>
|
|
The goals of this patch are
1) to support different report formats (e.g., text, csv, gnuplot
commands),
2) to support different report modes (e.g., single run stats,
histograms, comparison), and
3) without cluttering the main program code with vast amounts of
conditional output code in primary processing loop.
This patch implements report output via an "report operations
structure" (struct output_ops) pointed to from options structure.
Clutter in main source file has been reduced by moving the default
report generation functions to separate report format specific source
file and utils.c.
Signed-off-by: Koan-Sin Tan <freedom.tan@linaro.org>
Signed-off-by: Tuukka Tikkanen <tuukka.tikkanen@linaro.org>
|
|
Some parts of the code use asserts as a way to terminate execution
in case input data processing fails. This leaves the user in the black
regarding the reason why the tool terminated (and possibly dumped a
core file).
Replace the abnormal termination with displaying error message and
terminating the application in a controlled fashion.
Replace asserts with displaying error messages and/or terminating
program in a controlled manner. Also refine some error handling paths.
Leave asserts that are triggered by program internal behavior intact.
Signed-off-by: Pi-Cheng Chen <pi-cheng.chen@linaro.org>
Signed-off-by: Tuukka Tikkanen <tuukka.tikkanen@linaro.org>
|
|
This patch plugs a leak that occurs when cstate data is not
what we expect.
Signed-off-by: Tuukka Tikkanen <tuukka.tikkanen@linaro.org>
|
|
Add output_cstate_info() to store c-state information
into idlestat trace file.
Add load_and_build_cstate_info() to read/import trace
with c-state information.
For idlestat log, c-state information are stored after
topology information. For ftrace and 'trace-cmd report'
formats, since there is no topology and c-state
information stored, read them from sysfs on the
current running machine for now (which means you
still have to process them on the same machine).
Signed-off-by: Koan-Sin Tan <freedom.tan@linaro.org>
Reviewed-by: Tuukka Tikkanen <tuukka.tikkanen@linaro.org>
|