Commit graph

46 commits

Author SHA1 Message Date
Mike Frysinger
3e8a851625 use IGNORE_EINTR w/close
HANDLE_EINTR is both not safe and not useful on Linux systems.
Switch to IGNORE_EINTR like Chromium has done everywhere.

See http://crbug.com/269623 for details.

BUG=chromium:373154
TEST=`cbuildbot {arm,amd64,x86}-generic-full` passes

Change-Id: I3d99bb2376cb7961ac31ba0fa82bafc1b4c14bd9
Reviewed-on: https://chromium-review.googlesource.com/199821
Reviewed-by: Daniel Erat <derat@chromium.org>
Reviewed-by: Luigi Semenzato <semenzato@chromium.org>
Commit-Queue: Mike Frysinger <vapier@chromium.org>
Tested-by: Mike Frysinger <vapier@chromium.org>
2014-05-15 07:41:00 +00:00
Luigi Semenzato
e5883fadd9 metrics_daemon: restore correct meaning of Logging.DailyUse.
Maintain separate persistent values for DailyActiveUse and
CumulativeActiveUse.  The latter is used to compute crash rates
relative to active use.

BUG=chromium:364746
TEST=manual

Change-Id: I4d0485016eb49b30a77169ba1cedc1ffbff8810e
Reviewed-on: https://chromium-review.googlesource.com/195698
Reviewed-by: Daniel Erat <derat@chromium.org>
Reviewed-by: Luigi Semenzato <semenzato@chromium.org>
Tested-by: Luigi Semenzato <semenzato@chromium.org>
Commit-Queue: Luigi Semenzato <semenzato@chromium.org>
2014-05-13 00:08:39 +00:00
Luigi Semenzato
254d22e5fd metrics_daemon: log to syslog
Also log to stderr when not running as daemon.

BUG=chromium:364700
TEST=manually verified in both daemon and non-daemon modes

Change-Id: If62f70c1d327a5ecaf3075b6689b83a1494c09d5
Reviewed-on: https://chromium-review.googlesource.com/199380
Tested-by: Luigi Semenzato <semenzato@chromium.org>
Reviewed-by: Daniel Erat <derat@chromium.org>
Commit-Queue: Luigi Semenzato <semenzato@chromium.org>
2014-05-13 00:08:13 +00:00
Daniel Erat
c83975ab1e metrics: Clean up user-active code.
Stop listening for the soon-to-deleted PowerStateChanged
D-Bus signal from powerd; the code that was listening for
it had some issues (there was no guarantee that it'd run
before the system suspended, and resumes weren't handled at
all).

Also remove the session-state- and screen-lock-handling
code; it provided an inaccurate view of user activity (what
if the user is listening to music with the screen locked or
if they don't have screen-locking enabled?).

Track uptime instead via a timer that fires every five
minutes.

BUG=chromium:359619
TEST=manual: ran metrics_daemon --nodaemon and watched the
     logs

Change-Id: I4ad74773daefa01afdea080d20001ff1944c2eee
Reviewed-on: https://chromium-review.googlesource.com/195491
Reviewed-by: Daniel Erat <derat@chromium.org>
Commit-Queue: Daniel Erat <derat@chromium.org>
Tested-by: Daniel Erat <derat@chromium.org>
2014-04-18 09:23:59 +00:00
Luigi Semenzato
5ef2e39119 metrics_daemon: report cumulative daily use.
This had been lost in the previous changes.  Also, the meaning
of DailyUse changes: it is now cumulative daily use.  But we should
revise these stats so I think it's OK for now.

BUG=chromium:339588
TEST=unit tests

Change-Id: I4894fef0ffb237633abcf949c01dd7ea5f5e5d6e
Reviewed-on: https://chromium-review.googlesource.com/195005
Reviewed-by: Daniel Erat <derat@chromium.org>
Tested-by: Luigi Semenzato <semenzato@chromium.org>
Commit-Queue: Luigi Semenzato <semenzato@chromium.org>
2014-04-16 17:14:51 +00:00
Luigi Semenzato
ba0c65d098 metrics: add per-version daily stats reporting
Adds a few kernel crash stats which are reported daily but
are accumulated from beginning to end of a Chrome OS version.

BUG=chromium:339588
TEST=ran and checked histograms on device
BRANCH=none

Change-Id: I630c673156c28dc90ffe0c9c2df58caaada082dc
Reviewed-on: https://chromium-review.googlesource.com/190404
Reviewed-by: Luigi Semenzato <semenzato@chromium.org>
Commit-Queue: Luigi Semenzato <semenzato@chromium.org>
Tested-by: Luigi Semenzato <semenzato@chromium.org>
2014-03-22 13:29:45 +00:00
Luigi Semenzato
2fd51cc42d metrics: refactor counters
The metrics daemon had counter classes that represented
persistent, tagged values, and UMA stats.  To create some
derived UMA stats we need to separate persistency and UMA stats,
and the tagging doesn't help either.

This rewrite is supposed to keep the same functionality.

BUG=chromium:339588
TEST=ran and checked a few histograms
BRANCH=none

Change-Id: Ia1121ab2db391d71edffab9f52afe29ce17686ba
Reviewed-on: https://chromium-review.googlesource.com/188082
Tested-by: Luigi Semenzato <semenzato@chromium.org>
Reviewed-by: Luigi Semenzato <semenzato@chromium.org>
Commit-Queue: Luigi Semenzato <semenzato@chromium.org>
2014-03-14 19:42:50 +00:00
Luigi Semenzato
859b3f0ad3 metrics: add per-version cumulative counters
This adds counters that accumulate some measurement across an OS version;
they are reset at version updates, but reported more frequently (for instance,
daily).

Such counts could be obtained by pseudonymous dremel queries, but this is
more convenient.

The code replaces the "tag" datum in the counters with two tags: a
"report tag" and a "reset tag".  When the report
tag changes, the count is reported but not reset.  When the reset tag
changes, the count is both reported and reset.

This also adds one usage of the new counter which tracks the total
number of kernel crashes since the most recent OS version update.

The state machine in counter.cc changes a bit because it's no longer
true that a counter is reset after reporting it.  That logic is
still rather confusing, and could use a rewrite.

BUG=chromium:339588
TEST=ran on target under various situations
BRANCH=none

Change-Id: I5f83731e1a3d6e055b6d0f89111c9ffc60ccfcb9
Reviewed-on: https://chromium-review.googlesource.com/185081
Reviewed-by: Daniel Erat <derat@chromium.org>
Commit-Queue: Luigi Semenzato <semenzato@chromium.org>
Tested-by: Luigi Semenzato <semenzato@chromium.org>
2014-02-22 03:10:10 +00:00
Luigi Semenzato
c5a92347a5 metrics daemon: change location of flag files
For security reasons, we changed the location of some flag
files to /var/run from /tmp, but we didn't update this
program to look for the files in their new location.
This corrects the problem.

BUG=chromium:200181
TEST=manually verified that kernel crash counters increase
BRANCH=none

Change-Id: I03efe6179a1ad8dfd4c8cbb1eccf24c7a8494058
Reviewed-on: https://chromium-review.googlesource.com/186692
Reviewed-by: Chris Masone <cmasone@chromium.org>
Commit-Queue: Luigi Semenzato <semenzato@chromium.org>
Tested-by: Luigi Semenzato <semenzato@chromium.org>
2014-02-15 04:22:12 +00:00
Ben Chan
2e6543ddad Update to build against libchrome-242728.
This CL updates metrics to build against libchrome-242728 and also converts
libmetrics into slotted libraries (libmetrics-180609 and libmetrics-242728).

BUG=chromium:341521
BUG=chromium:342866
CQ-DEPEND=CL:186027
CQ-DEPEND=CL:186026
CQ-DEPEND=CL:186037
CQ-DEPEND=CL:186092
CQ-DEPEND=CL:186028
CQ-DEPEND=CL:186029
CQ-DEPEND=CL:186038
CQ-DEPEND=CL:186093
CQ-DEPEND=CL:186100
CQ-DEPEND=CL:186039
TEST=Trybot run on paladin, release, and chromiumos-sdk builders.

Change-Id: I09dc3d47cfe24a22864abf217658c63493b35cba
Reviewed-on: https://chromium-review.googlesource.com/185187
Reviewed-by: Ben Chan <benchan@chromium.org>
Tested-by: Ben Chan <benchan@chromium.org>
Commit-Queue: Ben Chan <benchan@chromium.org>
2014-02-12 19:39:45 +00:00
Luigi Semenzato
0d9a9c961e Fix out-of-bound index and clean up code.
There was an out-of-bound index after something like 7.5 hours of
active use.  This probably caused the metrics daemon to restart
and pollute some of the memuse statistics, the very ones
responsible for the overflow.

BUG=chromium:326824
TEST=ran manually and verified memuse is still reported

Change-Id: I70709f8cbba63ea1ca5e277b2ab58729e072e127
Reviewed-on: https://chromium-review.googlesource.com/178976
Reviewed-by: Luigi Semenzato <semenzato@chromium.org>
Commit-Queue: Luigi Semenzato <semenzato@chromium.org>
Tested-by: Luigi Semenzato <semenzato@chromium.org>
2013-12-06 22:44:22 +00:00
Yunlian Jiang
d399bed72c metrics: fix global-buffer-overflow
This fix the problem that the subscript of a global
array overflows in some cases.

BUG=chromium:326284
TEST=Unittest and suite:smoke passes.

Change-Id: I6a19d3bb18a886ee8a29b9a4df5f2b136ce57c5c
Reviewed-on: https://chromium-review.googlesource.com/178973
Reviewed-by: Mike Frysinger <vapier@chromium.org>
Commit-Queue: Yunlian Jiang <yunlian@chromium.org>
Tested-by: Yunlian Jiang <yunlian@chromium.org>
2013-12-06 00:52:31 +00:00
Sonny Rao
4b8aebb0f4 Add additional stats for swapping from /proc/vmstat
This adds swap-in and swap-out rate calculation on the same intervals
as major page fault collection.

BUG=chromium:261965
TEST=observe Platform.SwapIn{Long,Short} and
Platform.SwapOut{Long,Short} appear in histograms

Change-Id: Ifcdba1088cdff355b8e132145ac79635b185663b
Reviewed-on: https://gerrit.chromium.org/gerrit/64162
Reviewed-by: Luigi Semenzato <semenzato@chromium.org>
Commit-Queue: Sonny Rao <sonnyrao@chromium.org>
Tested-by: Sonny Rao <sonnyrao@chromium.org>
2013-08-01 18:15:49 -07:00
Ben Chan
6f59842fb1 Remove unnecessary call to the deprecated g_thread_init().
g_thread_init() has been deprecated since glib 2.32. This CL removes the
unnecessary call to g_thread_init(), so that we can later migrate to
glib 2.34. It also replaces dbus_g_thread_init(), which calls the
deprecated g_thread_supported(), with dbus_threads_init_default()
directly.

BUG=chromium:253025
TEST=Tested the following:
1. Build and run unit tests.
2. chrome://histograms shows that CrOS metrics are being collected.

Change-Id: I9c191d1926928caa8a704db03024f48f6c1cb383
Reviewed-on: https://gerrit.chromium.org/gerrit/59683
Reviewed-by: Mike Frysinger <vapier@chromium.org>
Tested-by: Ben Chan <benchan@chromium.org>
Commit-Queue: Ben Chan <benchan@chromium.org>
2013-06-24 13:08:13 -07:00
Luigi Semenzato
d92d18c935 Fix wrong sysfs pathname.
This bug was introduced while adding test code
which was supposed to improve the reliability
of this program.

BUG=chromium:238890
TEST=verified that about:histograms contains samples

Change-Id: I66323292f9261f5715760d7c884f91aca1f7e453
Reviewed-on: https://gerrit.chromium.org/gerrit/57501
Reviewed-by: Sonny Rao <sonnyrao@chromium.org>
Tested-by: Luigi Semenzato <semenzato@chromium.org>
Commit-Queue: Luigi Semenzato <semenzato@chromium.org>
2013-06-05 09:44:27 -07:00
Luigi Semenzato
fb3a8211b5 Collect CPU frequency thermal throttling stats
This collects the max frequency every 30s and reports
it as a percentage of the unthrottled frequency.
The special value of 101% indicates that the CPU is
using turbo.

BUG=chromium:238890
TEST=ran manually, checked about:histograms

Change-Id: Ia1c8a2344b81b8274f9045b854d2e6d35cf49339
Reviewed-on: https://gerrit.chromium.org/gerrit/50387
Reviewed-by: Darin Petkov <petkov@chromium.org>
Commit-Queue: Luigi Semenzato <semenzato@chromium.org>
Tested-by: Luigi Semenzato <semenzato@chromium.org>
2013-05-10 14:55:31 -07:00
Darin Petkov
40f2573a7b metrics: Listen to session manager for screen lock/unlock signals.
This should fix a pretty broken DailyUseTime metric. Also, use
contstants from service_constants.h where available.

BUG=chromium:216382,chromium:234799
TEST=unit tests; stop metrics_daemon on the device, then ran metrics_daemon
--nodaemon and inspected console log output while logging in/out as well as on
suspend/resume.
CQ-DEPEND=Ibfcc54c8dbf145cccd5ef871c7c9701b8312eb9e

Change-Id: I69ca0ea9594a496453f0933147ec66b0fa334718
Reviewed-on: https://gerrit.chromium.org/gerrit/49468
Tested-by: Darin Petkov <petkov@chromium.org>
Reviewed-by: Chris Masone <cmasone@chromium.org>
Commit-Queue: Darin Petkov <petkov@chromium.org>
2013-04-30 06:01:10 -07:00
Luigi Semenzato
942cbabb1c Modify swap metrics to be more useful.
We need to record the amount of swap used, and correlate it
with the total amount of swap.

The metrics added are Platform.MeminfoSwapUsed and
Platform.MeminfoSwapUsedPercent.

BUG=chromium-os:38583
TEST=not really
BRANCH=none

Change-Id: Iaf26c917e3c4d23f3f58f436047f8dd165177960
Reviewed-on: https://gerrit.chromium.org/gerrit/43123
Tested-by: Luigi Semenzato <semenzato@chromium.org>
Reviewed-by: Sonny Rao <sonnyrao@chromium.org>
Commit-Queue: Luigi Semenzato <semenzato@chromium.org>
2013-02-13 13:00:49 -08:00
Luigi Semenzato
3ccca065fd Add meminfo swap metrics.
The current metrics don't show how much swap we're using at a given
time.  We only have indirect measures (page faults rate for instance).

We also need to add one type of histogram scale, since compressed swap
can exceed total RAM, and all current histograms are on a scale from
zero to total RAM.

BUG=chromium-os:38583
TEST=stared at the code really hard and compiled it
BRANCH=none

Change-Id: Icb9dce5efe5dbd78123aad51ffd369cb46721096
Reviewed-on: https://gerrit.chromium.org/gerrit/42598
Reviewed-by: Sonny Rao <sonnyrao@chromium.org>
Commit-Queue: Luigi Semenzato <semenzato@chromium.org>
Tested-by: Luigi Semenzato <semenzato@chromium.org>
2013-02-05 16:08:33 -08:00
Mike Frysinger
71ebf98645 include base/stringprintf.h directly
This code uses StringPrintf, but doesn't include the header.  Older
versions of libbase would implicitly include it, but newer ones do
not.  So include it ourselves to fix building with newer versions.

BUG=chromium-os:25872
TEST=`emerge-x86-alex metrics` works (with newer and older libbase)

Change-Id: I7859f67767958f70853a40e8df4a33a64b36d010
Reviewed-on: https://gerrit.chromium.org/gerrit/17487
Reviewed-by: Darin Petkov <petkov@chromium.org>
Tested-by: Mike Frysinger <vapier@chromium.org>
Commit-Ready: Mike Frysinger <vapier@chromium.org>
2012-03-07 17:12:08 -08:00
Luigi Semenzato
5bd764faf3 Add page fault statistics.
BUG=chromium-os:20624
TEST=observe that Platform.PageFaultXXX appear in about:histograms.

Change-Id: Ifc281d31e05102dc4133d133f732b737e19891f1
Reviewed-on: http://gerrit.chromium.org/gerrit/10143
Commit-Ready: Luigi Semenzato <semenzato@chromium.org>
Tested-by: Luigi Semenzato <semenzato@chromium.org>
Reviewed-by: Darin Petkov <petkov@chromium.org>
2011-10-18 12:12:16 -07:00
Luigi Semenzato
8accd33d92 Add memuse stats and fix disk I/O computations.
This changes adds memory usage stats after 1  5, 30, 150, and 750
minutes of active use (approximated by wall
clock time minus sleep time).  We log only the anonymous memory
usage (active + inactive) as we expect that other types of
allocations would not convey much additional information.

This also fixes the disk I/O computation to use actual active
time elapsed between callbacks, instead of assuming the expected
interval has elapsed.  The existing code causes errors in
both directions when a suspend/resume cycle occurs between callbacks.

BUG=14209
TEST=verify that about:histograms page contains Platform.MemuseAnon1 after 1 minute and Platform.MemuseAnon2 after 5 minutes.

Change-Id: Ib32d915fac7766a9fca7125105224889ea93050e
Reviewed-on: http://gerrit.chromium.org/gerrit/1132
Reviewed-by: Darin Petkov <petkov@chromium.org>
Tested-by: Luigi Semenzato <semenzato@chromium.org>
2011-05-23 15:06:49 -07:00
Darin Petkov
8032dd0c6f metrics: Fixed compile-time warnings due to unused variables.
BUG=chromium-os:15040
TEST=built with gcc-4.6

Change-Id: Idf95c986e1eda79be735eeb4ff7c79e9a7eede60
Reviewed-on: http://gerrit.chromium.org/gerrit/569
Tested-by: Darin Petkov <petkov@chromium.org>
Reviewed-by: Chris Sosa <sosa@chromium.org>
2011-05-10 10:19:45 -07:00
Luigi Semenzato
29c7ef9e6a Add meminfo UMA collection.
Change-Id: Ief779a5bdc68b8e5bf2f1ed979bf30b50aca8e0f

BUG=chromium-os:13747
TEST=verify that Platform.Meminfo* entries are in about:histograms.

Review URL: http://codereview.chromium.org/6804014
2011-04-12 14:12:35 -07:00
Luigi Semenzato
0f132bba6f Find device-dependent disk stats file, and skip disk stats if not available.
Change-Id: I03afb85e3357dd4c2cf5effd98b194c71d77c71d

BUG=12171
TEST=unit tested

Review URL: http://codereview.chromium.org/6541007
2011-02-28 11:17:43 -08:00
Luigi Semenzato
c88e42dea9 Collect some disk statistics.
Change-Id: Id30f4b7e5d121f2632592ebacf47a18ea1d89fec

BUG=chromium-os:12171
TEST=ran on target and observed that stats are generated

Review URL: http://codereview.chromium.org/6486021
2011-02-17 10:21:16 -08:00
Ken Mixter
eafbbdf3df metrics: Add guest mode detection to metrics library and client
Change-Id: I2c27bd999330395ba3568820ea76198b202bd7f4

BUG=7203
TEST=Verify metrics_client -c and -g toggling consent and guest mode.

Review URL: http://codereview.chromium.org/3571009
2010-10-01 15:38:42 -07:00
Sam Leffler
239b826808 remove TimeToDrop support
Now that flimflam has native support this can be purged.

TEST=run FEATURES=test emerge-x86-generic metrics; verify TimeToDrop is still being recorded w/ about:histograms/Network

Review URL: http://codereview.chromium.org/3233004
2010-08-30 08:56:58 -07:00
Ken Mixter
4c5daa4794 Add weekly crash counters, refactor metrics_daemon, respect opt-in in library.
BUG=5340,5814

Change-Id: I2c207055f1ebe48051193395e2dbe38d9140b025

Review URL: http://codereview.chromium.org/3171023
2010-08-26 18:35:06 -07:00
Ken Mixter
ccd84c03d2 Add # daily crashes metrics and separate kernel crashes out.
BUG=5340

Review URL: http://codereview.chromium.org/3181015
2010-08-16 19:57:13 -07:00
Darin Petkov
38d5cb09ef Log active use time between kernel crashes.
Also, initialize the network state from flimflam, just in case -- now
that the metrics daemon process starts a bit late,

BUG=none
TEST=unit tests, ran on the device, emerged arm-generic

Review URL: http://codereview.chromium.org/2864009
2010-06-24 12:10:26 -07:00
Darin Petkov
1bb904ed4d Measure and report time between user-space process crashes.
BUG=none
TEST=unit tests, gmerged on the device and inspected
logs, about:histograms,etc.

Review URL: http://codereview.chromium.org/2736008
2010-06-16 15:58:06 -07:00
Darin Petkov
f1e85e49b3 Implement a persistent storage aggregation counter class.
This class is currently used to aggregate the active daily use time
but can also be used to aggregate other data (e.g., active use time
between crashes) before sending to UMA. Abstracting this in a separate
class also simplifies the daemon unit tests.

An alternative design would store the data on shutdown (but may slow
down shutdown a little). This should do it for now.

BUG=none
TEST=gmerged on device,inspected logs,about:histograms,etc.

Review URL: http://codereview.chromium.org/2731008
2010-06-10 15:59:53 -07:00
Benson Leung
53faeb0d6c Fixed KDBusMatches bug.
Missing comma in array definition caused metrics_daemon to fail.
Metrics_daemon would use a lot of CPU when broken.

Review URL: http://codereview.chromium.org/2767003
2010-06-08 15:59:13 -07:00
David James
6bf6e2530d Update metrics daemon to use new power manager signals for locking (4 of 7).
Co-dependent with the following change:
 - Issue 2685003: Update XScreenSaver to use new power manager signals for
   locking (3 of 7).

TEST=Ran test suite.
BUG=chromium-os:3694

Review URL: http://codereview.chromium.org/2698002
2010-06-06 18:52:40 -07:00
David James
3b3add5ad2 Cleanup style nits in metrics daemon.
- Remove trailing spaces.
- Convert 'char *' to 'char*'
- Fix other minor style nits
- Many of these issues were pointed out by tfarina.

BUG=none
TEST=Checked that it compiles and passes tests.

Review URL: http://codereview.chromium.org/2693001
2010-06-04 15:01:19 -07:00
Darin Petkov
e334840fb3 s/org.moblin.connman/org.chromium.flimflam/
Review URL: http://codereview.chromium.org/2664003
2010-06-04 14:07:41 -07:00
Darin Petkov
f27f036d31 Update metrics_daemon to use base/time.h instead of time_t directly.
Also, guard against time jumps in the active daily use metric collection.

BUG=none
TEST=unit tests; gmerge'd on the target device and inspected the logs.

Review URL: http://codereview.chromium.org/2576005
2010-06-04 13:14:19 -07:00
Darin Petkov
11b8eb3cf1 Add metrics library tests. Some metrics daemon API cleanup.
Refactor the metrics daemon API a little so that we don't need
to link in libmetrics into the daemon test binary.

Review URL: http://codereview.chromium.org/2079007
2010-05-18 11:00:59 -07:00
Darin Petkov
fc91b42a5e Start transition the metrics library to non-static API. Use gmock in tests.
Review URL: http://codereview.chromium.org/2049007
2010-05-12 13:05:45 -07:00
Darin Petkov
2ccef01626 Add some basic tests for metrics_daemon.
A separate CL adds a test stanza to the metrics ebuild. More tests
(specifically, for the D-Bus MessageFilter) will also come in a
separate CL.

Review URL: http://codereview.chromium.org/1919005
2010-05-05 16:06:37 -07:00
Darin Petkov
41e0623cab ... will look into some unit and integration testing for all metrics code next in a separate CL.
Review URL: http://codereview.chromium.org/1863002
2010-05-03 16:45:37 -07:00
Darin Petkov
703ec97bdf Log time between network drops -- from online to offline.
Rewrite most of metrics_daemon. Convert to low-level D-Bus API -- this
simplifies the code a little and also allows us to catch the power
state signal. I still suspect we may be abusing D-Bus a little but it
seems to work.

snanda@ -- please review the power state code specifically.

BUG=none
TEST=tested on target platform and arm-generic builds

Review URL: http://codereview.chromium.org/1799001
2010-04-27 11:02:18 -07:00
Darin Petkov
c2526a1265 Update the libmetrics API to match the new Chrome interface.
Review URL: http://codereview.chromium.org/1642018
2010-04-21 14:24:04 -07:00
Darin Petkov
4fcb2ac28f metrics cleanup and fixes.
- value is int now.
- add seconds to milliseconds option to metrics_client and use it
- chmod chronos/root fix
- style fixes

Review URL: http://codereview.chromium.org/1649007
2010-04-15 16:40:23 -07:00
Darin Petkov
65b0146839 Unify metrics_collection and metrics_daemon into metrics.
Tested new binaries on the target.
Tested incremental build.
Tested arm-generic build.

Review URL: http://codereview.chromium.org/1650006
2010-04-14 13:32:20 -07:00