Age | Commit message (Collapse) | Author |
|
Currently the a -ve failure value is being handled as an error
for the number of CPUs. Also check for zero cpus as this should
be considered as invalid. This also stops a zero sized calloc
based on zero cpus being reported as an error by static analysis.
Signed-off-by: Colin Ian King <colin.king@canonical.com>
Reviewed-by: Amit Kucheria <amit.kucheria@linaro.org>
Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
|
|
Currently using a negative -t value will run forever because duration
is an unsigned int and the check to see if it is negative is always
true because an unsigned int can never be negative. Make duration
a signed int to fix this.
Signed-off-by: Colin Ian King <colin.king@canonical.com>
Reviewed-by: Amit Kucheria <amit.kucheria@linaro.org>
Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
|
|
Signed-off-by: Colin Ian King <colin.king@canonical.com>
Reviewed-by: Amit Kucheria <amit.kucheria@linaro.org>
Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
|
|
Signed-off-by: Colin Ian King <colin.king@canonical.com>
Reviewed-by: Amit Kucheria <amit.kucheria@linaro.org>
Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
|
|
Currently the late_wakings calculation is always zero because
of a typo, fix this.
Signed-off-by: Colin Ian King <colin.king@canonical.com>
Reviewed-by: Amit Kucheria <amit.kucheria@linaro.org>
Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
|
|
Signed-off-by: Lisa Nguyen <lisa.nguyen@linaro.org>
|
|
Coverity Scan detected a resource leak in energy_model.c. Refer
to defect #84132.
To fix the defect, change the way memory is allocated for the
cluster_energy_table static variable.
Signed-off-by: Lisa Nguyen <lisa.nguyen@linaro.org>
|
|
Coverity Scan detected a resource leak in build_cstate_info() and
output_cstate_info() functions. Refer to defect #84131.
Valgrind confirms the memory leak as well:
==41915== 4,768 bytes in 1 blocks are definitely lost in loss record 6 of 8
==41915== at 0x4C2F948: calloc (vg_replace_malloc.c:711)
==41915== by 0x40232B: build_cstate_info (idlestat.c:318)
==41915== by 0x403DD1: output_cstate_info (idlestat.c:937)
==41915== by 0x404D53: idlestat_store (idlestat.c:1286)
==41915== by 0x4055A8: main (idlestat.c:1532)
Fix this issue by rewritting the syntax for the calloc function inside
build_cstate_info(), so the pointer can be easily deferenced later. Also,
deallocate any memory that was created locally inside output_cstate_info().
Signed-off-by: Lisa Nguyen <lisa.nguyen@linaro.org>
|
|
Add a BUILD file with instructions on how to cross-compile for
arm and arm64. Also update the README file to inform users where
they can submit feedback and patches to and fix trivial spelling
errors.
[Daniel Lezcano] : Reformated the text for better readability.
Signed-off-by: Lisa Nguyen <lisa.nguyen@linaro.org>
Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
|
|
Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
|
|
Signed-off-by: Colin Ian King <colin.king@canonical.com>
Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
|
|
cppcheck detected a potential buffer overflow with a %s scanf width format
specifier being larger than the destination buffer. Reduce the scan size to
match the expected buffer size.
Fixes error:
[idlestat.c:974]: (error) Width 32 given in format string (no. 2) is larger
than destination buffer 'irqname[17]', use %16s to prevent overflowing it.
Signed-off-by: Colin Ian King <colin.king@canonical.com>
Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
|
|
fpath is not being free'd causing a small memory leak, free it.
Signed-off-by: Colin Ian King <colin.king@canonical.com>
Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
|
|
This breaks on recent kernels because the cpu enumation from /sys may not
be in numerical order. Remove it for now.
Signed-off-by: Colin Ian King <colin.king@canonical.com>
Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
|
|
readdir_r is deprecated and should be replaced with readdir. readdir_r
is considered unsafe on systems where NAME_MAX is undefined and on
some systems it cannot read directory entries with very long names.
Fixes build warning:
topology.c:357:2: warning: ‘readdir_r’ is deprecated
[-Wdeprecated-declarations]
while (!readdir_r(dir, &dirent, &direntp)) {
^~~~~
In file included from topology.c:35:0:
/usr/include/dirent.h:183:12: note: declared here
extern int readdir_r (DIR *__restrict __dirp,
Signed-off-by: Colin Ian King <colin.king@canonical.com>
Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
|
|
clang's scan-build detected the following error "Undefined or
garbage value returned to caller" because ret is not intialised.
Signed-off-by: Colin Ian King <colin.king@canonical.com>
Signed-off-by: Amit Kucheria <amit.kucheria@linaro.org>
|
|
There was no manual page. For the convience of users who do not
compile idlestat from the source code, here comes the man page.
Also add 'install' target in Makefile for installing idlestat and
idlestat.1 to /usr/local/bin and /usr/local/man/man1 respectively.
Signed-off-by: Koan-Sin Tan <freedom.tan@linaro.org>
[cleaned-up whitespace before applying]
Signed-off-by: Amit Kucheria <amit.kucheria@linaro.org>
|
|
The function merge_pstates did not work as advertised. This patch fixes
the implementation.
Signed-off-by: Tuukka Tikkanen <idlestat@tic0.net>
Signed-off-by: Amit Kucheria <amit.kucheria@linaro.org>
|
|
Several parts of idlestat code did not cope with some cpu(s)
being offline. This patch adds information to cpu topology
data structure to record online status. Online-sensitive
parts of the code may query the status using is_cpu_online()
and skip performing activities related to offline cpus.
The following activities are skipped of cpu is offline:
- Trace: Obtaining initial frequency
- Trace: Storing initial frequency
- Trace: Adding pseudo pstate transition 0 Hz to end of trace
- Trace: Storing cpu C-state information
- Tracefile_idlestat: Reading cpu C-state information
- Topology: Mapping "datas" to "topology"
Signed-off-by: Tuukka Tikkanen <idlestat@tic0.net>
Signed-off-by: Amit Kucheria <amit.kucheria@linaro.org>
|
|
The structure member cpu_topology.physical_num is not used for
anything and can be removed.
Signed-off-by: Tuukka Tikkanen <idlestat@tic0.net>
Signed-off-by: Amit Kucheria <amit.kucheria@linaro.org>
|
|
The function read_cpu_topo_info ignores several return values,
doesn't skip comment lines and contains redundant innermost loop.
This patch fixes these issues.
Signed-off-by: Tuukka Tikkanen <idlestat@tic0.net>
Signed-off-by: Amit Kucheria <amit.kucheria@linaro.org>
|
|
Previously any directory entry in /sys/devices/system/cpu/ with
the substring "cpu" within the name would be considered to be
a subdirectory for a cpu. The substring should begin the name,
not just appear within the name.
Signed-off-by: Tuukka Tikkanen <idlestat@tic0.net>
Signed-off-by: Amit Kucheria <amit.kucheria@linaro.org>
|
|
The number of cap and C states displayed for a cluster
in a generated energy model template file was not correct, as
these values weren't compatible with the list of cap and C
states later in the file.
Signed-off-by: Larry Bassel <larry.bassel@linaro.org>
Signed-off-by: Amit Kucheria <amit.kucheria@linaro.org>
|
|
The 2 functions using variable argument interface used
va_start() but did not do the balancing va_end().
Signed-off-by: Tuukka Tikkanen <tuukka.tikkanen@linaro.org>
|
|
Make it possible to compile with either AOSP and NDK without
warnings. For AOSP, putting the idlestat to AOSP_ROOT/external
works fine. For NDK, the following command works fine.
ndk-build NDK_PROJECT_PATH=`pwd` \
APP_BUILD_SCRIPT=`pwd`/Android.mk \
APP_PLATFORM=19 APP_ABI=armeabi-v7a
1. Most code modifications to eliminate warnings
2. Both AOSP and NDK use -Wl,--gc-sections, which will remove code
compiled from tracefile_*.c and *_report.c, so we need
-Wl,--no-gc-sections
3. Android basename() is declared in <libgen.h>
4. Android doesn't have old <values.h>, use <floats.h> instead
Signed-off-by: Koan-Sin Tan <freedom.tan@linaro.org>
Reviewed-by: Tuukka Tikkanen <tuukka.tikkanen@linaro.org>
|
|
Android complation checks that all parameters are used. Add
check for this condition to default compilation as well. For
cases where the parameter is legitimately not used, add a
macro UNUSED to flag such cases for the compiler. This macro
is defined in a new header file. Currently this macro is
defined functional if the preprocessor macro __GNUC__ is
defined, otherwise the macro expands to an empty comment.
Signed-off-by: Tuukka Tikkanen <tuukka.tikkanen@linaro.org>
|
|
load_text_data_line() has been split out of the original trace
file loading loop. The original code incremented event count
at the points of code that had successfully completed importing
a single event. As the new function additionally now returns
a return code indicating success, this incrementation can be
done at the call site. This removes the need to pass a pointer
to the count variable and allows further cleanup of the code.
Signed-off-by: Tuukka Tikkanen <tuukka.tikkanen@linaro.org>
|
|
The parameter cpu is not used in write_cstate_info.
Note: The function is intended as an abstraction for writing
cstate information to trace file. As the trace file format
may change in future or multiple output formats may be
forthcoming, this function is an abstraction for storing
the state. Some future format may require the cpu number,
so this parameter may be reintroduced later. However, as
we currently do not know whether it is needed or not, it
can be removed.
Signed-off-by: Tuukka Tikkanen <tuukka.tikkanen@linaro.org>
|
|
Function calculate_energy_model (no longer) uses the program
options structure. It may have been used earlier for the
verbosity control in some messages, but that system has been
reworked. Remove the unused paramter.
Signed-off-by: Tuukka Tikkanen <tuukka.tikkanen@linaro.org>
|
|
alloc_pstate() searched the array of existing frequencies as if
the frequencies were in descending order (by frequency) but
then inserted the new frequency as if the frequencies were
to be sorted into ascending order. The search order was changed
to ascending order.
cluster_get_highest_freq() actually returned the lowest active
frequency in the cluster. core_get_highest_freq() acted in the
similar way. These have been fixed.
Signed-off-by: Tuukka Tikkanen <tuukka.tikkanen@linaro.org>
|
|
Some energy model detail lines did not have their columns
align properly. In addition, since idlestat really has no
idea how P-state numbers and frequencies align, do not
print P-state number guesses.
Signed-off-by: Tuukka Tikkanen <tuukka.tikkanen@linaro.org>
|
|
Signed-off-by: Dietmar Eggemann <dietmar.eggemann@arm.com>
|
|
Signed-off-by: Dietmar Eggemann <dietmar.eggemann@arm.com>
Signed-off-by: Tuukka Tikkanen <tuukka.tikkanen@linaro.org>
|
|
Signed-off-by: Dietmar Eggemann <dietmar.eggemann@arm.com>
Signed-off-by: Tuukka Tikkanen <tuukka.tikkanen@linaro.org>
|
|
Earlier cluster P-state calculation for energy model was based
on a very simple guess (longest duration of any contained CPU).
This patch changes the calculation to be based on actual core
or cluster residency at the frequency in question.
Signed-off-by: Tuukka Tikkanen <tuukka.tikkanen@linaro.org>
|
|
Idlestat adds phony frequency entries to the end of trace file
to ensure all the last running state is accounted for. This
phony frequency was unsigned int "-1" (aka 2^32-1 or 2^64-1),
which was then listed in any energy model template generated
from the trace file.
This patch changes the phony frequency to 0 and makes the
energy model template generation ignore 0 frequency.
Signed-off-by: Tuukka Tikkanen <tuukka.tikkanen@linaro.org>
|
|
The P-state (frequency) for cores and clusters was not calculated.
This patch adds recording of core/cluster frequency as the
highest frequency of all non-idle cpus contained within the core/
cluster.
Signed-off-by: Tuukka Tikkanen <tuukka.tikkanen@linaro.org>
|
|
As the kernel trace buffer is a finite resource, the default
trace buffer size idlestat sets may either be impossibly
large or insufficient to hold the data. This patch adds two
new command line options to control buffer size and whether
or not it will be polled during the trace period.
The polling functionality while tracing is not yet implemented.
Signed-off-by: Tuukka Tikkanen <tuukka.tikkanen@linaro.org>
|
|
Calls to core_get_least_cstate and cluster_get_least_cstate
were not included in the patch that intended to add them. This
caused all core/cluster c-states to be recorded as if the
core/cluster entered exactly the same state as what was
entered by any cpu in the core/cluster that changed its state.
Signed-off-by: Tuukka Tikkanen <tuukka.tikkanen@linaro.org>
|
|
The return value from call to fscanf was previously ignored.
Now the function cpuidle_get_target_residency will return -1
if fscanf fails to parse the value.
Signed-off-by: Tuukka Tikkanen <tuukka.tikkanen@linaro.org>
|
|
The report_ops and trace_ops arrays are created by the linker.
Static analysis tool has no idea of this and make a false positive
detection for the loops that access the arrays. This patch
introduces comments that suppress the detection for the
lines in question.
Signed-off-by: Tuukka Tikkanen <tuukka.tikkanen@linaro.org>
|
|
Both verbose_printf and verbose_fprintf were missing va_start
macro, required before passing the varargs to v(f)printf.
Signed-off-by: Tuukka Tikkanen <tuukka.tikkanen@linaro.org>
|
|
Process status codes are positive integers. Parse_energy_model()
would use the return value of make_energy_model_template()
directly as a parameter to call to exit(). In case of an error,
this would translate to exit(-1), which is incorrect. This
patch makes all non-zero return value from energy model
template creation get traslated to 1.
Signed-off-by: Tuukka Tikkanen <tuukka.tikkanen@linaro.org>
|
|
Idlestat_load() returns ptr_error() rather than a NULL pointer
in case of failure. The function make_energy_model_template
checked for NULL instead of using the is_err() macro. This
patch corrects the behavior.
Signed-off-by: Tuukka Tikkanen <tuukka.tikkanen@linaro.org>
|
|
The c-state information copy loop in create_states() should iterate
from 0 to MAXCSTATE-1 instead of 0 to MAXCSTATE. This patch replaces
the upper bound comparison operator <= with < to fix this.
Reported-by: Coverity Scan <scan-admin@coverity.com>
Signed-off-by: Tuukka Tikkanen <tuukka.tikkanen@linaro.org>
|
|
Signed-off-by: Amit Kucheria <amit.kucheria@linaro.org>
Reviewed-by: Tuukka Tikkanen <tuukka.tikkanen@linaro.org>
|
|
Makes it easier to add/remove options and keep them sync'ed.
Signed-off-by: Amit Kucheria <amit.kucheria@linaro.org>
Reviewed-by: Tuukka Tikkanen <tuukka.tikkanen@linaro.org>
|
|
It should've been part of dd89f9215bf7c2e345716eb09dfa975f1f1d15dc "idlestat:
Add support for baseline datas".
While we're at it, remove the '-d' option which is not used anymore.
Signed-off-by: Amit Kucheria <amit.kucheria@linaro.org>
Reviewed-by: Tuukka Tikkanen <tuukka.tikkanen@linaro.org>
|
|
Many of the source files were missing copyright headers. Headers have been
added to all .c and .h files and existing headers were updates with
contributor information.
The version number was bumped up to 0.5 due to having many new features
since last version number update.
Signed-off-by: Tuukka Tikkanen <tuukka.tikkanen@linaro.org>
|
|
The functions used to calculate core/cluster c-state statistics from
individual cpu statistics are no longer used and can be removed.
Signed-off-by: Tuukka Tikkanen <tuukka.tikkanen@linaro.org>
|