Age | Commit message (Collapse) | Author |
|
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>
|
|
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>
|
|
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>
|
|
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>
|
|
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>
|
|
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>
|
|
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>
|
|
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>
|
|
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 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>
|
|
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>
|
|
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>
|
|
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>
|
|
If some cpus are offline, the 'topology' directory is deleted in the sysfs.
With the current code, the topology is partially built, thus giving partial
results.
Fix this by continuing the parsing.
Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
|
|
The display functions are tied together in the code. Split this, so we can
choose each subsystem to display separately.
Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
Acked-by: Larry Bassel <larry.bassel@linaro.org>
Tested-by: Larry Bassel <larry.bassel@linaro.org>
|
|
The output is now in the form of:
----------------------------------------------------------------
| P-state | min | max | avg | total | hits |
----------------------------------------------------------------
| cpu0 |
----------------------------------------------------------------
| 2.90GHz | 0us | 37.93ms | 383us | 163.89ms | 428 |
| 2.20GHz | 11us | 1.69ms | 160us | 3.83ms | 24 |
| 1.80GHz | 8us | 2.72ms | 106us | 6.37ms | 60 |
| 1.30GHz | 1us | 4.51ms | 1.13ms | 5.65ms | 5 |
| 1.20GHz | 0us | 17.75ms | 292us | 3.55s | 12148 |
----------------------------------------------------------------
| cpu1 |
----------------------------------------------------------------
| 2.90GHz | 0us | 5.59ms | 447us | 118.06ms | 264 |
| 1.20GHz | 0us | 13.83ms | 656us | 3.05s | 4649 |
----------------------------------------------------------------
| cpu2 |
----------------------------------------------------------------
| 2.90GHz | 1us | 118.77ms | 1.45ms | 326.93ms | 225 |
| 2.80GHz | 24us | 1.34ms | 263us | 5.26ms | 20 |
| 2.50GHz | 11us | 2.49ms | 327us | 9.49ms | 29 |
| 1.20GHz | 1us | 21.24ms | 404us | 3.99s | 9891 |
----------------------------------------------------------------
| cpu3 |
----------------------------------------------------------------
| 2.90GHz | 3us | 21.07ms | 720us | 127.51ms | 177 |
| 1.60GHz | 3us | 5.14ms | 120us | 12.03ms | 100 |
| 1.20GHz | 1us | 18.07ms | 660us | 2.76s | 4190 |
----------------------------------------------------------------
--------------------------------------------------------------------------------
| C-state | min | max | avg | total | hits | over | under |
--------------------------------------------------------------------------------
| clusterA |
--------------------------------------------------------------------------------
| C1-IVB | 0us | 1.24ms | 1.24ms | 1.24ms | 1 | 0 | 0 |
| C7-IVB | 0us | 10.07ms | 1.78ms | 19.10s | 10739 | 0 | 0 |
--------------------------------------------------------------------------------
| core0 |
--------------------------------------------------------------------------------
| C1-IVB | 0us | 2.02ms | 262us | 3.14ms | 12 | 0 | 0 |
| C7-IVB | 0us | 15.92ms | 2.09ms | 23.30s | 11163 | 0 | 0 |
--------------------------------------------------------------------------------
| cpu0 |
--------------------------------------------------------------------------------
| POLL | 3us | 3us | 3us | 3us | 1 | 0 | 0 |
| C1-IVB | 0us | 2.95ms | 179us | 162.03ms | 905 | 0 | 0 |
| C3-IVB | 1us | 9.07ms | 555us | 192.47ms | 347 | 0 | 0 |
| C6-IVB | 6us | 3.84ms | 1.18ms | 40.13ms | 34 | 0 | 0 |
| C7-IVB | 1us | 16.35ms | 2.27ms | 25.83s | 11396 | 0 | 0 |
--------------------------------------------------------------------------------
| cpu1 |
--------------------------------------------------------------------------------
| C1-IVB | 1us | 11.12ms | 173us | 54.09ms | 313 | 0 | 0 |
| C3-IVB | 2us | 1.39ms | 399us | 55.81ms | 140 | 0 | 0 |
| C6-IVB | 20us | 1.04ms | 517us | 2.07ms | 4 | 0 | 0 |
| C7-IVB | 1us | 41.48ms | 5.93ms | 26.67s | 4495 | 0 | 0 |
--------------------------------------------------------------------------------
| core1 |
--------------------------------------------------------------------------------
| C1-IVB | 0us | 1.25ms | 116us | 4.04ms | 35 | 0 | 0 |
| C7-IVB | 0us | 22.25ms | 2.17ms | 22.97s | 10605 | 0 | 0 |
--------------------------------------------------------------------------------
| cpu2 |
--------------------------------------------------------------------------------
| POLL | 3us | 3us | 3us | 3us | 1 | 0 | 0 |
| C1-IVB | 1us | 9.65ms | 265us | 133.88ms | 505 | 0 | 0 |
| C3-IVB | 1us | 3.74ms | 440us | 127.48ms | 290 | 0 | 0 |
| C6-IVB | 24us | 2.34ms | 1.01ms | 32.32ms | 32 | 0 | 0 |
| C7-IVB | 1us | 31.43ms | 2.70ms | 25.33s | 9369 | 0 | 0 |
--------------------------------------------------------------------------------
| cpu3 |
--------------------------------------------------------------------------------
| POLL | 11us | 11us | 11us | 11us | 1 | 0 | 0 |
| C1-IVB | 1us | 4.80ms | 94us | 42.66ms | 455 | 0 | 0 |
| C3-IVB | 1us | 2.00ms | 420us | 28.59ms | 68 | 0 | 0 |
| C6-IVB | 31us | 1.42ms | 800us | 8.00ms | 10 | 0 | 0 |
| C7-IVB | 0us | 98.04ms | 6.92ms | 26.99s | 3899 | 0 | 0 |
--------------------------------------------------------------------------------
Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
Acked-by: Larry Bassel <larry.bassel@linaro.org>
Tested-by: Larry Bassel <larry.bassel@linaro.org>
|
|
These options are pointless and not interesting. Removing them.
Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
Acked-by: Larry Bassel <larry.bassel@linaro.org>
Tested-by: Larry Bassel <larry.bassel@linaro.org>
|
|
dir needs closing on return exit path. Found by Coverity Scan.
Signed-off-by: Colin Ian King <colin.king@canonical.com>
Signed-off-by: Amit Kucheria <amit.kucheria@linaro.org>
|
|
Valgrind found the following leak:
==8065== 131,264 bytes in 4 blocks are definitely lost in loss record 11 of 11
==8065== at 0x4C2AB80: malloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==8065== by 0x4EF4C10: __alloc_dir (opendir.c:207)
==8065== by 0x4053D2: topo_folder_scan (topology.c:308)
==8065== by 0x405510: read_sysfs_cpu_topo (topology.c:344)
==8065== by 0x404630: main (idlestat.c:1250)
dir_topology should be closed to stop this leak.
Signed-off-by: Colin Ian King <colin.king@canonical.com>
Signed-off-by: Amit Kucheria <amit.kucheria@linaro.org>
|
|
Several sscanf format specifiers are using %u for
cpu_info.core_id but should be using %d as the
argument type is an int *
Signed-off-by: Colin Ian King <colin.king@canonical.com>
Signed-off-by: Amit Kucheria <amit.kucheria@linaro.org>
|
|
|
|
|
|
|
|
|
|
s_cpu is not being checked for a memory allocation failure, instead
s_core is being checked. Fix this cut-n-paste error.
Signed-off-by: Colin Ian King <colin.king@canonical.com>
Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
|
|
Added GPLv2 copyright headers.
|
|
We read cpu top[ology info from /sys/devices/system/cpuX/topology.
Packed them into cpu_topology struct. And print in next format.
clusterA:
coreX
cpuA
cpuB
coreY
cpuC
cpuD
clusterB:
coreS
cpuE
cpuF
coreT
cpuG
cpuH
...
When cpu topology info could be read, CPU idle state is shown
ordered by topology.
When cpu topology info could not be read, CPU idle state is shown
in old order.
Signed-off-by: Shaojie Sun <shaojie.sun@linaro.com>
Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
|