summaryrefslogtreecommitdiffstats
path: root/logd
Commit message (Collapse)AuthorAgeFilesLines
* Merge tag 'android-6.0.1_r3' of ↵Steve Kondik2015-12-071-1/+4
|\ | | | | | | | | | | | | | | https://android.googlesource.com/platform/system/core into HEAD Android 6.0.1 release 3 Change-Id: I8b65c0223e3444360432abd871a9d8f007831ba0
| * logd: pruning time horizonMark Salyzyn2015-11-041-1/+4
| | | | | | | | | | | | | | | | Estimate a time horizon of ten fold for worst UID pruning Bug: 25453210 Bug: 24782000 Change-Id: I7118deb6d42531c68ed2ac2a59c57b0580b942cc
* | Merge tag 'android-6.0.0_r26' into cm-13.0Ricardo Cerqueira2015-11-056-55/+134
|\ \ | |/ | | | | | | | | Android 6.0.0 release 26 Change-Id: I93d1e3767cbacab2b18cff360065c91b9eaf1d96
| * Merge "logd: worst uid record watermark part five" into mnc-dr-devMark Salyzyn2015-09-141-4/+56
| |\
| | * logd: worst uid record watermark part fiveMark Salyzyn2015-09-101-4/+56
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | (cherry pick from commit 5bb2972dce918b60f1ed9ddc6fe0636e97679187) A regression that resulted in increased memory consumption for some logging patterns because we rarely did merge or leading checks, and age-out checking. On the last prune cycle, we reset for a full scan. Add some comments describing the pruning processes. Bug: 23327476 Bug: 23681639 Bug: 23685592 Change-Id: I22b0f339c9269b006831fda9cefe295a263ebb92
| * | logd: klogd and MediatekMark Salyzyn2015-09-112-16/+50
| |/ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | (cherry pick from commit 46d159d4626ca5d5667b739792840c3178a1457b) - sniff for PID in kernel log messages if available - properly deal with klogd watermark in face of modified output - deal more stringently with priority tag, must have [ following - suppress process-name stutter in tag that can happen - do not use : to demark tag if within [ ] Mediatek-special change that adds <printk_state>(<cpu>)[<pid>:<comm>] as a prefix to the printk messages. Along the lines of (simplified for entertainment purposes, YMMV): char tbuf[50]; /* printk prefix */ int this_cpu = smp_processor_id(); char state = __raw_get_cpu_var(printk_state); unsigned tlen = snprintf(tbuf, sizeof(tbuf), "%c(%x)[%d:%s]", state, this_cpu, current->pid, current->comm); Bug: 23517551 Change-Id: I568e25c5aa6d8474835454a0e83b19c2921b7985
| * logd: worst uid record watermark part fourMark Salyzyn2015-09-042-9/+11
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | (cherry pick from commit 831aa297307a038705bc771281ffd53266484b4a) With part deux we caused an apparent regression by not checking for stale recorded iterators. This checking was on-purpose bypassesed when leading prune entries were to be deleted without touching the statistics engine due to an in-place merge. Part deux had us leaving iterators we were not focussed on untouched which in turn because they were left behind, had a much higher likelihood of being deleted without touching the statistics engine. Perform the check every delete. Bug: 23789348 Bug: 23490267 Change-Id: Idc6cc23d1f9e3b6cd9a083139a0de59479fbfe08
| * Merge "logd: worst uid record watermark part three" into mnc-dr-devMark Salyzyn2015-09-011-12/+11
| |\
| | * logd: worst uid record watermark part threeMark Salyzyn2015-08-311-12/+11
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | (cherry pick from commit ccfe8446a19c1c0c9e55133fde84dedb2b9f5d4f) Regression that cause records to be preserved for more than a day. Bug: 23681639 Bug: 23685592 Change-Id: I5e4393c8e3ed935790994c77ec51dc6512a6daa6
| * | Merge "logd: worst uid record watermark part deux" into mnc-dr-devMark Salyzyn2015-09-011-1/+5
| |\ \ | | |/
| | * logd: worst uid record watermark part deuxMark Salyzyn2015-08-311-1/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | (cherry pick from commit 49afe0d00fdc163e5b8a1ab2f859c4688613d5b8) Only record watermark if not known, or represents the worst UID currently under focus. This has resulted in a halving of the average prune time in the face of heavy spam because we get less processing spikes. Bug: 23327476 Bug: 23681639 Bug: 23685592 Change-Id: I19f297042b9fc2c98d902695c1c36df1bf5cd6f6
| * | healthd: logd: add timestamp to kernel logged battery messagesMark Salyzyn2015-08-271-0/+10
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | (cherry pick from commit acb1ddf56c98a75a49b263f99ef07ce361dc4323) Aid monotonic to realtime logging synchronization correction in the Android ecosystem by providing a periodic notification. We now have the following messages in the kernel logs: - PM: suspend entry %Y-%m-%d %H:%M:%S.%09q UTC - PM: suspend exit %Y-%m-%d %H:%M:%S.%09q UTC - Suspended for %s.%03q seconds - healthd: battery l=100 ... %Y-%m-%d %H:%M:%S.%09q UTC Alter klogd to resynchronize on healthd messages as well. NB: Time using strftime format, %q is a reference to fractional second as introduced into log_time strptime method. Bug: 21868540 Change-Id: I854afc0a07dff9c7f26d2b2f68990e52bf90e300
| * | logd: refine is_prioMark Salyzyn2015-08-271-9/+15
| |/ | | | | | | | | | | | | | | | | | | | | | | | | (cherry pick from commit 618d0dec5037df0fad1ce5cc90da2b7fc2c88b0c) - Heuristics associated with translation of kernel messages to Android user space logs. - Limit is_prio to 4 characters, we got false positives on hex values like <register contents> with no alpha chars. - x11 and other register definitions are not valid tags, en0 is - fix some Android coding standard issues Change-Id: Idc3dcc53a2cb75ac38628c8ef7a5d5b53f12587a
| * logd: worst uid record watermarkMark Salyzyn2015-08-202-1/+23
| | | | | | | | | | | | | | | | | | | | (cherry pick from commit c892ea3fa80dfd3d35c5a3b8bfdc73e7b85eaede) Hold on to last worst uid watermark and bypass a spike to O(n*n*x) (n=samples, x=number of spammers) wrt chatty trimming. Bug: 23327476 Change-Id: I9f21ce95e969b67e576417a760f75c4d86acf364
| * logd: log buffer switch to std::listMark Salyzyn2015-08-201-2/+3
| | | | | | | | | | | | | | | | (cherry pick from commit 94a89c42fe9521f5ac2d382a172c082ca421d6c3) Bug: 23350706 Bug: 23327476 Change-Id: Ib0530b9dd5842c6d05c84d7a66f2531c97461067
| * logd: white and black switch to std::listMark Salyzyn2015-08-202-19/+13
| | | | | | | | | | | | | | (cherry pick from commit e0ed16c6db5c443ecb5f9f7daca95a111fd1f582) Bug: 23350706 Change-Id: I981d9fa63a0d87eb309485cca93cfc44fc0506cc
| * logd: logtimes switch to std::listMark Salyzyn2015-08-202-4/+6
| | | | | | | | | | | | | | (cherry pick from commit 98dca2d0b15f9a579efae8592dbb45059aad082e) Bug: 23350706 Change-Id: Icc60dd06119ea20a22610644ff880d5135363aba
| * logd: prune 10% or 256 entries maxMark Salyzyn2015-08-201-11/+7
| | | | | | | | | | | | | | | | (cherry pick from commit b39ed0c9925356c74a6347630b04d875288d803b) Bug: 22351810 Bug: 23327476 Change-Id: I902ba6b431d8b7cee2d65ee2f76e9f7c4f30b152
| * logd: sizes > 1M prune in smaller batchesMark Salyzyn2015-08-201-8/+15
| | | | | | | | | | | | | | | | | | (cherry pick from commit 62ab0fd4efeed313adf2fdf84167d754620c0ad1) Switch to 1% batch sizes from 10% when individual buffer size > 1M Bug: 22351810 Change-Id: Ifee570a54643ceb0ba767e1787e937f70cc90b72
* | logd: optimize code hotspotsMark Salyzyn2015-11-018-50/+72
| | | | | | | | | | | | | | | | | | | | | | Discovered that we had a few libc hotspots. Adjust code to generally reduce or nullify the number of calls to malloc, free, strlen, strcmp, strncmp, memcmp & strncasecmp. Total gain looks to be about 3% of logd's processing time. malloc still contributes to 3%, but all others are now total 0.5%. Bug: 23685592 Change-Id: Ife721121667969260cdb8b055524ae90f5911278
* | logd: log_strtok_r deal with nulsMark Salyzyn2015-11-013-32/+67
| | | | | | | | | | | | | | | | Rename to log_strntok_r and change from dealing with strings to dealing with a string and an associated length. Bug: 23517551 Change-Id: Ia72f1305a53f55eeef9861ac378fb8205fd2378e
* | logd: Add LogUtils.hMark Salyzyn2015-11-015-22/+48
| | | | | | | | | | | | Move prototypes from LogBufferElement.h to LogUtils.h Change-Id: I55e42e17e6c997e35b2b78b87fd2f84f8f393282
* | logd: klogd deal with nuls in dmesgMark Salyzyn2015-11-015-94/+147
| | | | | | | | | | | | | | | | | | | | Switch to using string and length in all transactions, treating trailing nuls the same as spaces. ToDo: change dumpstate (bugreport) to use logcat -b printable _regardless_ Bug: 23517551 Change-Id: I42162365e6bf8ed79d356e7b689a673902116fdb
* | logd: klogd: sniff for time correction on MediatekMark Salyzyn2015-11-011-39/+65
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Need some more flexibility when parsing kernel messages cluttered with extra fluff. This is the minimal relaxation we can do to the rules to ensure that we work on all possible devices and kernels when sniffing for time correction information. We want to minimize any future maintenance, keep in mind klogd is a "userdebug" or "eng" feature and is disabled in "user" builds. Manage expectations. Bug: 23517551 Change-Id: I026d074e14fb2550e728683e85a973bd87e78a9c
* | logd: klogd and Mediatek part deuxMark Salyzyn2015-11-011-7/+21
| | | | | | | | | | | | | | | | - switch to an open coded strnrchr - validity checking on n, taglen and b values. Bug: 23517551 Change-Id: I568e25c5aa6d8474835454a0e83b19c2921b7986
* | logd: klogd and MediatekMark Salyzyn2015-11-012-16/+50
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | - sniff for PID in kernel log messages if available - properly deal with klogd watermark in face of modified output - deal more stringently with priority tag, must have [ following - suppress process-name stutter in tag that can happen - do not use : to demark tag if within [ ] Mediatek-special change that adds <printk_state>(<cpu>)[<pid>:<comm>] as a prefix to the printk messages. Along the lines of (simplified for entertainment purposes, YMMV): char tbuf[50]; /* printk prefix */ int this_cpu = smp_processor_id(); char state = __raw_get_cpu_var(printk_state); unsigned tlen = snprintf(tbuf, sizeof(tbuf), "%c(%x)[%d:%s]", state, this_cpu, current->pid, current->comm); Bug: 23517551 Change-Id: I568e25c5aa6d8474835454a0e83b19c2921b7985
* | healthd: logd: add timestamp to kernel logged battery messagesMark Salyzyn2015-11-011-0/+10
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Aid monotonic to realtime logging synchronization correction in the Android ecosystem by providing a periodic notification. We now have the following messages in the kernel logs: - PM: suspend entry %Y-%m-%d %H:%M:%S.%09q UTC - PM: suspend exit %Y-%m-%d %H:%M:%S.%09q UTC - Suspended for %s.%03q seconds - healthd: battery l=100 ... %Y-%m-%d %H:%M:%S.%09q UTC Alter klogd to resynchronize on healthd messages as well. NB: Time using strftime format, %q is a reference to fractional second as introduced into log_time strptime method. Bug: 21868540 Change-Id: I854afc0a07dff9c7f26d2b2f68990e52bf90e300
* | Logd: Handle unused variable and fieldsAndreas Gampe2015-11-014-12/+3
| | | | | | | | | | | | | | For build-system CFLAGS clean-up. Bug: 18632512 Change-Id: If81d6705b44e9a29f64c44c56ea633c031e831b7
* | logd: refine is_prioMark Salyzyn2015-11-011-9/+15
|/ | | | | | | | | | | - Heuristics associated with translation of kernel messages to Android user space logs. - Limit is_prio to 4 characters, we got false positives on hex values like <register contents> with no alpha chars. - x11 and other register definitions are not valid tags, en0 is - fix some Android coding standard issues Change-Id: Idc3dcc53a2cb75ac38628c8ef7a5d5b53f12587a
* logd: allow logd to write to /dev/cpuset filesJeff Vander Stoep2015-07-241-0/+4
| | | | | | | | | | | | Required by logd on devices with USE_CPUSETS defined. Make /dev/cpuset/background, /dev/cpuset/foreground and /dev/cpuset/task writeable by system gid. Add logd to system group for writing to cpuset files and to root group to avoid regressions. When dropping privs, also drop supplementary groups. Bug: 22699101 Change-Id: Icc01769b18b5e1f1649623da8325a8bfabc3a3f0
* logd: serialize accesses to stats helpersMark Salyzyn2015-06-254-4/+19
| | | | | | | | | | | | | (cherry pick from commit ed777e9eece54bf899f1a77a83f8b702970de686) Quick low-risk to resolve possible hash table corruption. Resolved an unlikely path memory leak. ToDo: replace lock with nested lock so no lock helpers are required. Bug: 22068332 Change-Id: I303ab06608502c7d61d42f111a9c43366f184d0c
* logd: missing klogd contentMark Salyzyn2015-06-153-42/+68
| | | | | | | | | | | | | | | | | | | | | | | (cherry pick from commit ee49c6a670a54e0636f81f39ddc93c87c9a4d766) - regression in log_strtok_r (part deux) In commit 'logd: fix kernel logline stutter' 2c3b300fd8307e8da13608197d0a89bc613de5fb we introduced log_strtok_r. as a replacement for strtok_r that dealt with a problem with some kernel log messages. Fix is to refine definition of is_timestamp to not match on patterns like [0], requiring a single period. Another fix is to refine definition of is_prio to properly escape non-digit content. - Missing content because SYSLOG_ACTION_SIZE_BUFFER with added logging is too short for full read of SYSLOG_ACTION_READ_ALL dropping initial content. Add a margin for additional 1024 bytes. - Absolute _first_ log entry has sequence number of 1, which is specifically dropped, start sequence count at 1 rather than 0. - Remove trailing space for efficiency. - If tag exists but no content, trick into kernel logging. Bug: 21851884 Change-Id: I0867a555a3bca09bbf18d18e75e41dffffe57a23
* logd: filter on __android_log_is_loggableMark Salyzyn2015-06-152-1/+23
| | | | | | | | | | | | (cherry pick from commit e59c469fa89d438d2d7150b7d8cd6b401900709b) - Default level when not specified is ANDROID_LOG_VERBOSE which is inert. Bug: 20416721 Bug: 19544788 Bug: 17760225 Change-Id: Icc098e53dc47ceaaeb24ec42eb6f61d6430ec2f6
* Merge "Lower the priority of the threads in logd/logcat." into mnc-devMark Salyzyn2015-06-091-0/+7
|\
| * Lower the priority of the threads in logd/logcat.Riley Andrews2015-06-091-0/+7
| | | | | | | | | | | | | | | | | | sched_batch implies only a penalty to latency in scheduling, but does not imply that the process will be given less cpu time. Increase the nice level to 10 to prioritize it below ui threads. Bug: 21696721 Change-Id: I075af059dc755402f7df9b0d7a66cca921ff04b2
* | logd: build breakageMark Salyzyn2015-06-081-1/+1
| | | | | | | | | | | | | | | | (cherry pick from 3e21de2915a44d9f6d6a9e8610a2fc5feb33d107) OPEN_BRACKET_SPACE comparison always false Change-Id: I1ff4288b4b79a49702727d3a8b8c8f179f500951
* | logd: fix kernel logline stutterMark Salyzyn2015-06-083-4/+140
| | | | | | | | | | | | | | | | | | | | | | | | | | (cherry pick from commit 2c3b300fd8307e8da13608197d0a89bc613de5fb) - look for cases where one log line contains two without a newline. - rare condition, occurs when a printk does not have a terminating newline under certain race conditions. - the newline may be performed broken up as a second call - the timestamps can be reversed (showing the race effects). - driver(s) should really have the newline in their log messages. Change-Id: Ibfb56b32047da3d6513db059ca6edad0f0105168
* | logd: filters remove leading expire messages and rateMark Salyzyn2015-06-055-11/+39
|/ | | | | | | | | | | | | | | | | | | (cherry pick from commit 047cc0729fd837a03b99db901941c1421ef15f96) - Cleanup resulting from experience and feedback - When filtering inside logd, drop any leading expire messages, they are cluttering up leading edge of tombstones (which filter by pid) - Increase and introduce EXPIRE_RATELIMIT from 1 to 10 seconds - Increase EXPIRE_THRESHOLD from 4 to 10 count - Improve the expire messages from: logd : uid=1000(system) too chatty comm=com.google.android.phone, expire 2800 lines change tag to be more descriptive, and reduce accusatory tone to: chatty : uid=1000(system) com.google.android.phone expire 2800 lines - if the UID name forms a prefix for comm name, then drop UID name Change-Id: Ied7cc04c0ab3ae02167649a0b97378e44ef7b588
* logd: switch to unordered_map from BasicHashtableMark Salyzyn2015-06-043-63/+56
| | | | | | | | | | | | (charry pick from commit 511338dd575572d567c04d69eaea60627b6c3452) BasicHashtable is relatively untested, move over to a C++ template library that has more bake time. Bug: 20419786 Bug: 21590652 Bug: 20500228 Change-Id: I926aaecdc8345eca75c08fdd561b0473504c5d95
* init.rc: logd: Add logpersistd (nee logcatd)Mark Salyzyn2015-06-023-0/+49
| | | | | | | | | | | | | | | | | | | (cherry pick from commit 100658c303919d8f69c76f6f25eac376795712f0) - logpersistd is defined as a thread or process in the context of the logd domain. Here we define logpersistd as logcat -f in logd domain and call it logcatd to represent its service mechanics. - Use logcatd to manage content in /data/misc/logd/ directory. - Only turn on for persist.logd.logpersistd = logcatd. - Add logpersist.start, logpersist.stop and logpersist.cat debug class executables, thus only in the eng and userdebug builds. ToDo: Wish to add Developer Options menu to turn this feature on or off, complicated by the fact that user builds have no tools with access rights to /data/misc/logd. Bug: 19608716 Change-Id: I57ad757f121c473d04f9fabe9d4820a0eca06f31
* logd: test modernizationMark Salyzyn2015-06-011-47/+35
| | | | | | | (cherry pick from commit 62d6a2a921d5ee5cc455e6ae5e62d4ad2474fd25) Bug: 19603976 Change-Id: Ie920c128e7e6a436fea7a96c7d68bc39e13a2ad4
* logd: whitelist should not preserve expire messagesMark Salyzyn2015-06-011-1/+1
| | | | | | (cherry pick from commit c5bf3b830472bca677407833018f20b7643953fe) Change-Id: I56275c73191b96aa21e7b4049d401e1f44211f9b
* logd: KISS & fix preserve a dayMark Salyzyn2015-06-011-16/+9
| | | | | | | | | | | | | | | (cherry pick from commit 5921276a16528bf79292e828080bf0ec984cbb23) Code in 833a9b1e38ce65f2cdf3ebd095aaa99a92eb9467 was borken, simpler approach is to simply check last entry (to save a syscall) minus EXPIRE_HOUR_THRESHOLD. This does make longer logs less likely to call upon the spam detection than the algorithm being replaced, but sadly we ended up with a log entry in the future at the beginning of the logs confounding the previous algorithm. Bug: 21555259 Change-Id: I04fad67e95c8496521dbabb73b5f32c19d6a16c2
* logd: deal with sloppy leading expire messagesMark Salyzyn2015-06-011-10/+15
| | | | | | | | | | | | | | | | | | | | | | (cherry pick from commit 5392aac95d279a7ffc91d8fbcd074307186ca36c) The odds of chatty content also leading the logs is pretty high eg: 1799 12017 I logd: uid=10007 chatty comm=Binder_B, expire 4 lines 1799 1829 I logd: uid=10007 chatty comm=Binder_2, expire 4 lines 1919 20637 I logd: uid=10007 chatty comm=m.sersistent, expire 1 line 1919 20638 I logd: uid=10007 chatty comm=s.persistent, expire 1 line 1919 2316 I logd: uid=10007 chatty comm=UlrDispatch, expire 4 lines 19379 20634 I logd: uid=10045 chatty, expire 14 lines 19379 19388 I logd: uid=10045 chatty comm=lizerDaemon, expire 4 lines 591 4396 I logd: uid=1000 chatty comm=Thread-220, expire 5 lines 591 1377 I logd: uid=1000 chatty comm=Thread-92, expire 4 lines 1919 2267 I logd: uid=10007 chatty comm=WifiScanner, expire 4 lines 591 4397 I logd: uid=1000 chatty comm=DhcpClient, expire 4 lines 591 4398 I logd: uid=1000 chatty comm=Thread-222, expire 4 lines 226 580 D CommandListener: Setting iface cfg Change-Id: I5ab24bc7bf5d2690bae7e789831b07f23ff8bcc6
* logd: worst-UID only to preserve a dayMark Salyzyn2015-05-202-1/+26
| | | | | | | | | | (cherry pick from commit 833a9b1e38ce65f2cdf3ebd095aaa99a92eb9467) Do not invoke worst-UID pruning in the face of other UIDs logs that are more than a day old, switch to pruning oldest only. Change-Id: Icf988b8d5458400a660d0f8e9d2df3f9d9a4c2d9
* logd: Add TID statisticsMark Salyzyn2015-05-134-3/+120
| | | | | | | (cherry pick from commit 17ed6797df722464eb5cc6dfc3e1e32aec284b70) Bug: 19608965 Change-Id: Ifbf0b00c48ef12b5970b9f9f217bd1dd8f587f2c
* logd: CleanupMark Salyzyn2015-05-1312-119/+111
| | | | | | | | | (cherry pick from commit 7718778793b106498b931dd708a466cf3a6f6a0f) - Android Coding Standard for Constructors - Side effects NONE Change-Id: I2cda9dd73f3ac3ab58f394015cb810820093d47b
* logd: Add klogdMark Salyzyn2015-05-139-24/+587
| | | | | | | | | | | | | | | | | | (cherry pick from commit ae4d928d816e30dbe57c2c321b0f0759d0567b3f) - Add a klogd to collect the kernel logs and place them into a new kernel log buffer - Parse priority, tag and message from the kernel log messages. - Turn off pruning for worst UID for the kernel log buffer - Sniff for 'PM: suspend exit', 'PM: suspend enter' and 'Suspended for' messages and correct the internal definition time correction against monotonic dynamically. - Discern if we have monotonic or real time (delineation 1980) in audit messages. - perform appropriate math to correct the timestamp to be real time - filter out any external sources of kernel logging Change-Id: I8d4c7c5ac19f1f3218079ee3a05a50e2ca55f60d
* logd: Add Tag statisticsMark Salyzyn2015-05-125-2/+110
| | | | | | | | | | | | | (cherry pick from commit 344bff4391dd434dda501e812f18f524290c5a7c) - Optional class of statistics for events Tags - export tagToName from LogBuffer (located in main.cp to address https://android-review.googlesource.com/#/c/110204) - Can not handle dropped because getTag() can not work, will need to be fixed if we start filtering. Bug: 19608965 Change-Id: I7b90607ca588bf37bab71f19b1570a290e772776
* logd: pidToName deficiencyMark Salyzyn2015-05-121-0/+4
| | | | | | | | (Cherry pick from commit aa43ae2268076227e8b72ea095f8aeac439b3168) any logging in zygote permanently sets the pidToName Change-Id: I0b8fdc96fb5965a04d4dc4293c39815beef5eb8e