History log of /system/core/logd/LogBuffer.cpp
Revision Date Author Comments (<<< Hide modified files) (Show modified files >>>)
8fa8896d2ed97eb274c62f0e386dabf2e2a82a45 26-Jan-2016 Mark Salyzyn <salyzyn@google.com> logd: security buffer only AID_SYSTEM reader

- limit AID_SYSTEM uid or gid to read security buffer messages
- adjust liblog tests to reflect the reality of this adjustment

To fully test all security buffer paths and modes

$ su 0,0,0 /data/nativetest/liblog-unit-tests/liblog-unit-tests --gtest_filter=liblog.__security*
$ su 1000,1000,1000 /data/nativetest/liblog-unit-tests/liblog-unit-tests --gtest_filter=liblog.__security*
$ su 2000,2000,2000 /data/nativetest/liblog-unit-tests/liblog-unit-tests --gtest_filter=liblog.__security*

ToDo: Integrate the above individually into the gTest Q/A testing

Bug: 26029733
Change-Id: Idcf5492db78fa6934ef6fb43f3ef861052675651
/system/core/logd/LogBuffer.cpp
7fd6c5c6f5f55e680a67cd9ca949f9c85b0ac0d0 20-Jan-2016 Mark Salyzyn <salyzyn@google.com> logd: prune maintain per-id watermark (part deux)

iterator corruption as we allow mLast to slip through the FIFO

Bug: 23685592
Bug: 26646087
Change-Id: Ifcbaecf390ee47b195c3d823d080c66c15db4530
/system/core/logd/LogBuffer.cpp
507eb9fec2b062e02cac0b76e35fb435cc9bf3d7 11-Jan-2016 Mark Salyzyn <salyzyn@google.com> logd: prune maintain per-id watermark

Without this change LogBuffer::prune and LogBuffer::erase
contributes 16.7% and 1.79% respectively. With this change,
they contributes 3.06 and 2.33% respectively. Pruning is
performed roughly 1 in every 255 log entries, a periodic
tamer latency spike.

Bug: 23685592
Change-Id: I6ae1cf9f3559bca4cf448efe8bcb2b96a1914c54
/system/core/logd/LogBuffer.cpp
1a5bac2069c3b8a0f4b5ede91ec4f83be5509827 06-Jan-2016 Mark Salyzyn <salyzyn@google.com> Merge "Revert "logd: liblog: whitelist "snet_event_log"""
0ee8de3c2df48c579a12e60299ff820ebf3db12a 06-Jan-2016 Mark Salyzyn <salyzyn@google.com> Revert "logd: liblog: whitelist "snet_event_log""

Callers will not guarantee that they can or will ratelimit, we need to
retain the ability to blacklist snet_event_log as a result.

This reverts commit 6aa21b225dd1600473388bd640443653d649420a.

Bug: 26178938
Change-Id: Ibf47d2e23a84c56f5f72d02312c698df7ff2b601
/system/core/logd/LogBuffer.cpp
66607ebc0e451d239b7b15a8794cfd7bec992e6c 05-Jan-2016 Mark Salyzyn <salyzyn@google.com> logd: document ro.logd.size

Bad comment advise in LogBuffer.cpp results in partners failing to
considering using ro.logd.size to set the platform buffer size
default.

NB: It is not good practice to increase the log buffer size to deal
with logspam, as increases will result in logd scale issues getting
closer to hitting the background cgroup cpu cap. Once we hit that
cap, logd spirals, pruning old entries slower than the incoming log
entries. logd.writer will take 100% cpu.

Change-Id: If4a7a74f300d078eeaed0ffd3eb3fd77d1f9fe90
/system/core/logd/LogBuffer.cpp
6aa21b225dd1600473388bd640443653d649420a 23-Dec-2015 Mark Salyzyn <salyzyn@google.com> logd: liblog: whitelist "snet_event_log"

Dangerous bridge to cross to whitelist, who is special, who is not?
Rationalized as these events are used to catch exploits on platform.
As it stands no one should be allowed to block any messages in the
security context, not even for development purposes.

Bug: 26178938
Change-Id: Ibdc76bc0fe29ba05be168b623af1c9f41d7edbd2
/system/core/logd/LogBuffer.cpp
bec3c3def945576d59d3344c16e149e6d9154e15 28-Aug-2015 Mark Salyzyn <salyzyn@google.com> logd: Add worst pid of system filter

- Add a new statistic that reports per pid and log_id for AID_SYSTEM
- Add a new pruning filter ~1000/! boolean
- Use this new statistic to prune on worst pid within AID_SYSTEM

Bug: 26029733
Bug: 21615139
Bug: 22855208
Change-Id: Iab5dd28f807dcf03d276372853883f3b6afa8294
/system/core/logd/LogBuffer.cpp
9c66a58f216e88e46f4ceacbd54599c28a20a729 15-Dec-2015 Mark Salyzyn <salyzyn@google.com> logd: Allow flags "eng" and "svelte" in boolean

- enhance property_get_bool, drop property_get_bool_svelte
- enhance base properties with ro and persist variants
- update and fortify README.property
- primarily move auditd and kernel logger into a realm where
they can be controlled by build properties.
- Move logd.klogd to logd.kernel, and add ro.logd.kernel
and persist.logd.kernel.
- Add ro.logd.auditd and persist.logd.auditd.
- Document persist.logd.security
- Document log.tag and persist.logd.tag properties.
- Document ro.logd.size, persist.logd.size and logd.size
properties.

Bug: 26178938
Bug: 26029733
Bug: 17760225
Change-Id: Ibc1a497e45d69db5cf52133937f7ba6fb1d6cd21
/system/core/logd/LogBuffer.cpp
ee3b838e13dc2140ac2051c1012d471effd0fd5f 17-Dec-2015 Mark Salyzyn <salyzyn@google.com> logd: statistics per-pid filter

Primarily gives access to the Chattiest TIDs and TAGs
associated with a pid.

Has a secondary effect of allowing us to pull out the
command line, comm and in some cases the associated
PACKAGE for a specific pid while the logs are still
present even if the executable is gone.

Bug: 26029733
Bug: 21615139
Change-Id: I1ea63165a680a9318360579b70b1512078ed5682
/system/core/logd/LogBuffer.cpp
cdda62b2c1178eca8cb9f5d8c775190736a98e3b 14-Dec-2015 Mark Salyzyn <salyzyn@google.com> logd: ro.config.low_ram set buffer size to 64K

Bug: 25792367
Change-Id: Icae85a7de70b3a71f89b2bf8c80866649f727177
/system/core/logd/LogBuffer.cpp
86052a5d4f217a73c769c77f7ac0904b65e67942 11-Dec-2015 Mark Salyzyn <salyzyn@google.com> Merge "logd: liblog: logcat: Add LOG_ID_SECURITY"
7b87365ecf8c08307173537645b85708f59aab78 04-Dec-2015 Mark Salyzyn <salyzyn@google.com> logd: readlog apps get logger_entry_v4

Adds the uid field to outgoing content for readlog applications.
AID_LOG, AID_ROOT and AID_SYSTEM gain access to the information.

Bug: 25996918
Change-Id: I0254303c19d174cbf5e722c38844be5c54410c85
/system/core/logd/LogBuffer.cpp
083b037c0740ca00f72429e4457bfdd4b4d4dfa7 04-Dec-2015 Mark Salyzyn <salyzyn@google.com> logd: liblog: logcat: Add LOG_ID_SECURITY

- Largish commit, buffer and access controls done together
- Add LOG_ID_SECURITY binary content log
- Add "default" meta buffer
- allow LOG_ID_SECURITY only from AID_SYSTEM and AID_ROOT UID & GID
- Use __android_log_security() to gate logging
- Add __android_log_security_bwrite() native access to security
logging.
- Add liblog.__security_buffer end-to-end gTest

Bug: 26029733
Change-Id: Ibcf5b4660c17c1aa6902c0d93f8ffd29c93d9a93
/system/core/logd/LogBuffer.cpp
b75cce0389748bea111ca62af623645117e12d9d 30-Nov-2015 Mark Salyzyn <salyzyn@google.com> logd: wakeup on wrap or timeout

If a timeout is specified for the reader, then go to sleep
with the socket open. If the start time is about to get
pruned in the specified log buffers, then wakeup and dump
the logs; or wakeup on timeout, whichever comes first.

Bug: 25929746
Change-Id: I7d2421c2c5083b33747b84f74d9a560d3ba645df
/system/core/logd/LogBuffer.cpp
ba7a9a016bf011fdf45b6736d4c6d6795faba9d3 02-Dec-2015 Mark Salyzyn <salyzyn@google.com> logd: liblog: logcat: switch to android_log_clockid() (2)

android_log_timestamp returns the property leading letter,
it is better to return a clockid_t with android_log_clockid()

Bug: 23668800
Change-Id: I38dee773bf3844177826b03a26b03215c79a5359
/system/core/logd/LogBuffer.cpp
9e18cdcebd893fbbb2369d893be219a7d832865f 07-Dec-2015 Mark Salyzyn <salyzyn@google.com> Revert "logd: liblog: logcat: switch to android_log_clockid()"

This reverts commit 77b5696b1dea6f7afed89e113e479f4a131c14fc.

Change-Id: I7711bf1a7e3f72ed29a2498d7287b725a0e624bd
/system/core/logd/LogBuffer.cpp
77b5696b1dea6f7afed89e113e479f4a131c14fc 02-Dec-2015 Mark Salyzyn <salyzyn@google.com> logd: liblog: logcat: switch to android_log_clockid()

android_log_timestamp returns the property leading letter,
it is better to return a clockid_t with android_log_clockid()

Bug: 23668800
Change-Id: I3c4e3e6b87f6676950797f1f0e203b44c542ed43
/system/core/logd/LogBuffer.cpp
c2e7d4965f86dbe90cece6d25e91d934a698d195 16-Nov-2015 Mark Salyzyn <salyzyn@google.com> Revert "liblog: resolve deadlocks"

This reverts commit 7a2a3071921b11d7e476862e7f9cbe72be43d0f7.

Bug: 25693940
Change-Id: I9a7c926289e972f80c03c92e33535e1dedaa7381
/system/core/logd/LogBuffer.cpp
7a2a3071921b11d7e476862e7f9cbe72be43d0f7 06-Nov-2015 Mark Salyzyn <salyzyn@google.com> liblog: resolve deadlocks

Although ever present, an increased regression introduced with
commit b6bee33182cedea49199eb2252b3f3b442899c6d (liblog: logd:
support logd.timestamp = monotonic).

A signal handler can interrupt in locked context, if log is written
in the signal handler, we are in deadlock. Block signals while we
are locked. Separate out timestamp lock from is loggable lock to
reduce contention situations. Provide a best-guess response if
lock would fail in timestamp path.

Bug: 25563384
Change-Id: I6dccd6b99ebace1c473c03a785a35c63ed5c6a8a
/system/core/logd/LogBuffer.cpp
8897a3fffd28c779dcfd8e5988ae90f5da7b5a88 04-Nov-2015 Mark Salyzyn <salyzyn@google.com> Merge "liblog: logd: support logd.timestamp = monotonic"
50122695d218232d88ffde5c3fc3e93021971080 12-Oct-2015 Mark Salyzyn <salyzyn@google.com> logd: pruning time horizon

Estimate a time horizon of ten fold for worst UID pruning

Bug: 24782000
Change-Id: I7118deb6d42531c68ed2ac2a59c57b0580b942cc
/system/core/logd/LogBuffer.cpp
b6bee33182cedea49199eb2252b3f3b442899c6d 08-Sep-2015 Mark Salyzyn <salyzyn@google.com> liblog: logd: support logd.timestamp = monotonic

if ro.logd.timestamp or persist.logd.timestamp are set to the value
monotonic then liblog writer, liblog printing and logd all switch to
recording/printing monotonic time rather than realtime. If reinit
detects a change for presist.logd.timestamp, correct the older entry
timestamps in place.

ToDo: A corner case condition where new log entries in monotonic time
occur before logd reinit detects persist.logd.timestamp, there
will be a few out-of-order entries, but with accurate
timestamps. This problem does not happen for ro.logd.timestamp
as it is set before logd starts.

NB: This offers a nano second time accuracy on all log entries
that may be more suitable for merging with other system
activities, such as systrace, that also use monotonic time. This
feature is for debugging.

Bug: 23668800
Change-Id: Iee6dab7140061b1a6627254921411f61b01aa5c2
/system/core/logd/LogBuffer.cpp
58b8be8906f903ac3d83c41bcb0fb9c7841945f0 30-Sep-2015 Mark Salyzyn <salyzyn@google.com> logd: correct for number of elements in prune

Chatty logs would distort the average log size by elevating the
elements, but not the size. Add statistical collection for the
number of elements that report chatty, and subtract that from
the number of elements to improve the pruning estimate. Pick
minElements as 1% rather than 10% of the total with this more
accurate number of elements, to a minumum of 4.

Bug: 24511000
Change-Id: I3f36558138aa0b2a50e4fac6440c3a8505d95276
/system/core/logd/LogBuffer.cpp
aaad42f47c7363d68ddfb9ef8f1b51972c4d429d 30-Sep-2015 Mark Salyzyn <salyzyn@google.com> logd: use coalesce instead of merge (cleanup)

- switch to coalesce instead of merge in naming of functions
and variables. Confusing since we also to merge-sorts and
other activities in the logger.
- define maxPrune rather than using a number in the code path.

Bug: 24511000
/system/core/logd/LogBuffer.cpp
2b25c66070f73413013caa48e1c171cb895869b5 17-Sep-2015 Mark Salyzyn <salyzyn@google.com> logd: clearAll by UID speedup

- If doing a clear, skip accounting
- Ensure for busy checking, behind a region lock for instance, only
break out if there was something to do. Basically move the filter
actions first, and defer checking the region lock to the ends of
the loops.

Bug: 23711431
Change-Id: Icc984f406880633516fb17dda84188a30d092e01
/system/core/logd/LogBuffer.cpp
c5dc970edc202f89ecdd0c2fe988c7e2b8408bef 17-Sep-2015 Mark Salyzyn <salyzyn@google.com> logd: clear return and deal with busy if readers locked

- Propagate to caller the clearing errors, busy blocked by reader.
- For clear, perform retries within logd with a one second lul each,
telling readers to skip, but on final retry to kill all readers if
problem still persists due to block reader (or high volume logspammer).

Bug: 23711431
Change-Id: Ie4c46bc9480a7f49b96a81fae25a95c603270c33
/system/core/logd/LogBuffer.cpp
5bb2972dce918b60f1ed9ddc6fe0636e97679187 08-Sep-2015 Mark Salyzyn <salyzyn@google.com> logd: worst uid record watermark part five

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
/system/core/logd/LogBuffer.cpp
831aa297307a038705bc771281ffd53266484b4a 04-Sep-2015 Mark Salyzyn <salyzyn@google.com> logd: worst uid record watermark part four

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
Change-Id: Idc6cc23d1f9e3b6cd9a083139a0de59479fbfe08
/system/core/logd/LogBuffer.cpp
ccfe8446a19c1c0c9e55133fde84dedb2b9f5d4f 24-Aug-2015 Mark Salyzyn <salyzyn@google.com> logd: worst uid record watermark part three

Regression that cause records to be preserved for more than a day.

Bug: 23681639
Bug: 23685592
Change-Id: I5e4393c8e3ed935790994c77ec51dc6512a6daa6
/system/core/logd/LogBuffer.cpp
49afe0d00fdc163e5b8a1ab2f859c4688613d5b8 24-Aug-2015 Mark Salyzyn <salyzyn@google.com> logd: worst uid record watermark part deux

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
Change-Id: I19f297042b9fc2c98d902695c1c36df1bf5cd6f6
/system/core/logd/LogBuffer.cpp
73160acc5cb5236b30327569e6b51dbfe73e4a0f 20-Aug-2015 Mark Salyzyn <salyzyn@google.com> logd: switch asprintf to std::string

Bug: 23350706
Change-Id: I715cdd4563a09de3680081947a3439f0cac623be
/system/core/logd/LogBuffer.cpp
c892ea3fa80dfd3d35c5a3b8bfdc73e7b85eaede 20-Aug-2015 Mark Salyzyn <salyzyn@google.com> logd: worst uid record watermark

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
/system/core/logd/LogBuffer.cpp
b39ed0c9925356c74a6347630b04d875288d803b 19-Aug-2015 Mark Salyzyn <salyzyn@google.com> logd: prune 10% or 256 entries max

Bug: 22351810
Bug: 23327476
Change-Id: I902ba6b431d8b7cee2d65ee2f76e9f7c4f30b152
/system/core/logd/LogBuffer.cpp
62ab0fd4efeed313adf2fdf84167d754620c0ad1 10-Aug-2015 Mark Salyzyn <salyzyn@google.com> logd: sizes > 1M prune in smaller batches

Switch to 1% batch sizes from 10% when individual buffer size > 1M

Bug: 22351810
Change-Id: Ifee570a54643ceb0ba767e1787e937f70cc90b72
/system/core/logd/LogBuffer.cpp
e59c469fa89d438d2d7150b7d8cd6b401900709b 02-Oct-2014 Mark Salyzyn <salyzyn@google.com> logd: filter on __android_log_is_loggable

- Default level when not specified is ANDROID_LOG_VERBOSE
which is inert.

Bug: 20416721
Bug: 19544788
Bug: 17760225
Change-Id: Icc098e53dc47ceaaeb24ec42eb6f61d6430ec2f6
/system/core/logd/LogBuffer.cpp
047cc0729fd837a03b99db901941c1421ef15f96 04-Jun-2015 Mark Salyzyn <salyzyn@google.com> logd: filters remove leading expire messages and rate

- 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
/system/core/logd/LogBuffer.cpp
511338dd575572d567c04d69eaea60627b6c3452 19-May-2015 Mark Salyzyn <salyzyn@google.com> logd: switch to unordered_map from BasicHashtable

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
/system/core/logd/LogBuffer.cpp
10a124d342530b4c366f08d3a899474c4e5eb7fc 01-Jun-2015 Mark Salyzyn <salyzyn@google.com> Merge "logd: whitelist should not preserve expire messages"
5921276a16528bf79292e828080bf0ec984cbb23 01-Jun-2015 Mark Salyzyn <salyzyn@google.com> logd: KISS & fix preserve a day

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
/system/core/logd/LogBuffer.cpp
5392aac95d279a7ffc91d8fbcd074307186ca36c 22-May-2015 Mark Salyzyn <salyzyn@google.com> logd: deal with sloppy leading expire messages

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
/system/core/logd/LogBuffer.cpp
c5bf3b830472bca677407833018f20b7643953fe 21-May-2015 Mark Salyzyn <salyzyn@google.com> logd: whitelist should not preserve expire messages

Change-Id: I56275c73191b96aa21e7b4049d401e1f44211f9b
/system/core/logd/LogBuffer.cpp
833a9b1e38ce65f2cdf3ebd095aaa99a92eb9467 16-May-2015 Mark Salyzyn <salyzyn@google.com> logd: worst-UID only to preserve a day

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
/system/core/logd/LogBuffer.cpp
7718778793b106498b931dd708a466cf3a6f6a0f 13-May-2015 Mark Salyzyn <salyzyn@google.com> logd: Cleanup

- Android Coding Standard for Constructors
- Side effects NONE

Change-Id: I2cda9dd73f3ac3ab58f394015cb810820093d47b
/system/core/logd/LogBuffer.cpp
21fb7e0b753b2251369bfaa1c6f6a09e58e64437 20-Apr-2015 Mark Salyzyn <salyzyn@google.com> logd: improve details on chatty records

- Report applications UID, TID/PID by name.
- change wording to have an accurate connotation
- drop privilege check since filtered upstream

Bug: 19608965
Bug: 20334069
Bug: 20370119
Change-Id: I2b1c26580b4c2de293874214ff5ae745546f3cca
/system/core/logd/LogBuffer.cpp
35173a9ac5bd1f4702ccfda3df02ec47ecb57949 23-Apr-2015 Mark Salyzyn <salyzyn@google.com> logd: reduce chance of dropped 1 messages

- do not time out at 1 second if drop has count of less than 4

Bug: 20334069
Bug: 20370119
Change-Id: I787cb553dfab5ed71abd6ed72b63de675f834e0c
/system/core/logd/LogBuffer.cpp
653f9581bf32cc2532c2b1d442d7bb2bbf0c173e 23-Apr-2015 Mark Salyzyn <salyzyn@google.com> Merge "logd: per UID less aggressive 12.5% threshold"
e06a6e0f26f51a8f1aab84076d5241ae820069b7 20-Apr-2015 Mark Salyzyn <salyzyn@google.com> logd: ratelimit drop messages to 1/sec

Bug: 20334069
Bug: 20370119
Change-Id: I6f850aec46c4df1c99a5b1f28db75d071e134ad5
/system/core/logd/LogBuffer.cpp
d717d805d4d636a837ccfba87c78b0dc89cb8fd9 21-Apr-2015 Mark Salyzyn <salyzyn@google.com> logd: per UID less aggressive 12.5% threshold

Per-UID quota has a threshold of 12.5% of the total log size.
If less than that space is taken by the UID, then we
will not engage the pruning based on worst UID.

Change-Id: I9f15c9a26938f1115eb75e9c28ddb073e7680e06
/system/core/logd/LogBuffer.cpp
2c9d909a00a6b0dd7f17402f3f0d94d5fd76c8c3 18-Apr-2015 Mark Salyzyn <salyzyn@google.com> logd: better drop message merging

- Former algorithm anlo coalesced adjacent records
- New algorithm maintains a hash list of all drop
records and coalesces them all.

Bug: 20334069
Bug: 20370119
Change-Id: Idc15ce31fc1087c2cfa39da60c62feade8b88761
/system/core/logd/LogBuffer.cpp
202e153f94a0957185ae4b4bed4c5356513e4322 09-Feb-2015 Mark Salyzyn <salyzyn@google.com> logd: propagate ::log status

Add a return value for the ::log() methods, this allows
us to optimize the wakeup for the readers to only occur
when the log message is actually placed.

This is for a future where we may dedupe identical log
messages, filter out log messages, and certainly if we
filter the messages out with an internal logd check of
__android_log_is_loggable().

Change-Id: I763b2a7c29502ab7fa0a5d5022c7b60244fcfde4
/system/core/logd/LogBuffer.cpp
ae769238391f7f9fa5c03a436d5f1fd73130e6bd 18-Mar-2015 Mark Salyzyn <salyzyn@google.com> logd: disable worst uid prune for events buffer

There is some usage statistics that would be hurt by pruning by UID,
since _all_ usage statistics come from system_server. In other words
we expect it to be chatty. Until we formulate and evaluate a better
(eg: per-tag?) filtration mechanism, lets hold off pruning by UID.

Bug: 19608965
Change-Id: Iddd45a671e13bdcf3394c20919ad1f2e4ef36616
/system/core/logd/LogBuffer.cpp
ab0dcf682867bd7e1fdebfd8d8f9fafaccfad7f6 16-Mar-2015 Mark Salyzyn <salyzyn@google.com> logd: annotate worst-UID pruned entries

- internal dropped entries are associated by prune by worst UID
and are applied by UID and by PID
- track dropped entries by rewriting them in place
- merge similar dropped entries together for same UID(implied),
PID and TID so that blame can more clearly be placed
- allow aging of dropped entries by the general backgound pruning
- report individual dropped entries formatted to reader
- add statistics to track dropped entries by UID, the combination
of statistics and dropped logging can track over-the-top Chattiest
clients.

Bug: 19608965
Change-Id: Ibc68480df0c69c55703270cd70c6b26aea165853
/system/core/logd/LogBuffer.cpp
720f6d1d55d936d98cc9752e96f479e03e6d5009 16-Mar-2015 Mark Salyzyn <salyzyn@google.com> logd: Add Pid statistics

- Optional class of statistics for PID
- Enhance pidToName
- Enhanced uidToName
- Enhance pidToUid
- template sort and iteration

Bug: 19608965
Change-Id: I04a1f02e9851b62987f9b176908134e455f22d1d
/system/core/logd/LogBuffer.cpp
97c1c2beee2cbd8c67c1cd507367e5b084d853c8 10-Mar-2015 Mark Salyzyn <salyzyn@google.com> logd: optimize statistics

- Go back to basic requirements
- Simplify
- use hash tables to minimize memory impact

Bug: 19608965
Change-Id: If7becb34354d6415e5c387ecea7d4109a15259c8
/system/core/logd/LogBuffer.cpp
f7c0f75275d0fde2d8b7614f1501f0ad0cd3a01c 03-Mar-2015 Mark Salyzyn <salyzyn@google.com> logd: replace internal CLOCK_MONOTONIC use with sequence numbers

- switch to simpler and faster internal sequence number, drops
a syscall overhead on 32-bit platforms.
- add ability to break-out of flushTo loop with filter return -1
allowing in reduction in reader overhead.

Change-Id: Ic5cb2b9afa4d9470153971fc9197b07279e2b79d
/system/core/logd/LogBuffer.cpp
11e55cb9c1e5efe553e36f1b5c04ab21883f66e1 11-Mar-2015 Mark Salyzyn <salyzyn@google.com> logd: add reinit command

- respond to SIGHUP
- respond to logd command "reinit"
- respond to logd --reinit
- reopens files on /data, eg: re-read of persistent properties

Bug: 19681572
Change-Id: Iadac58e6653f027cb7355497bd675eef376ce0a8
/system/core/logd/LogBuffer.cpp
4ed16b4381e6723670575ff8da3cfe12fe74998a 03-Mar-2015 Mark Salyzyn <salyzyn@google.com> Revert "logd: Add minimum time bucket statistics"

This forward port reverts
commit e457b74ce6ee6d799812dc2ec5e4b8b18bcd3e91

No longer as necessary once we add
liblog: Instrument logging of logd write drops
Although this provided an indication of how close statistically we
were to overloading logd it is simpler to understand fails thus to
hunt and peck a corrected value for /proc/sys/net/unix/max_dgram_qlen

Change-Id: I2b30e0fc30625a48fd11a12c2d2cc6a41f26226f
/system/core/logd/LogBuffer.cpp
8e8e8db549ffa6e692246abce6f5560c3a1e93c2 15-Jan-2015 Dragoslav Mitrinovic <drago@motorola.com> logd: fix persistent blocking reader performance

logd suffers major performance degradation when persistent (blocking)
client reader connects to it (e.g. logcat). The root cause of the
degradation is that each time when reader is notified of the arrival
of new log entries, the reader commences its search for the new entries
from the beginning of the linked list (oldest entries first).

This commit alters the search to start from the end of the linked list
and work backwards. This dramatically decreases logd CPU consumption
when blocking reader is connected, and increases the maximum logging
throughput (before the logs start getting lost) by a factor ~ 20.

Change-Id: Ib60955ce05544e52a8b24acc3dcf5863e1e39c5c
/system/core/logd/LogBuffer.cpp
da6495d06f1798ea81cebbfbdd44f16135e1a3cd 17-Dec-2014 TraianX Schiau <traianx.schiau@intel.com> logd: Fix pruning

In a scenario in which an on-line (blocking) client is running and
a clean is attempted (logcat -c), the following can be observed:

1) the on-line logger seems to freeze
2) any other clear attempt will have no effect

What is actually happening:

In this case prune function will "instruct" the oldest timeEntry
to skip a huge number (very close to ULONG_MAX) of messages, this
being the cause of 1.

Since the consumer thread will skip all the log entries, mStart
updating will also be skipped. So a new cleaning attempt will have
the same oldest entry, nothing will be done.

Fix description:
a. keep a separated skipAhead count for individual log buffers (log_id_t)
LogTimeEntry::LogTimeEntry
LogTimeEntry::FilterSecondPass
LogTimeEntry::skipAhead
LogTimeEntry::riggerSkip_Locked

b. update LogTimeEntry::mStart even if the current message is skipped
LogTimeEntry::FilterSecondPass

c. while pruning, only take into account the LogTimeEntrys that are monitoring
the log_id in question, and provide a public method of checking this.
LogTimeEntry::isWatching
LogTimeEntry::FilterFirstPass
LogTimeEntry::FilterSecondPass

d. Reset the skip cont befor the client thtread starts to sleep, at this point
we should be up to date.
LogTimeEntry::cleanSkip_Locked
LogTimeEntry::threadStart

Change-Id: I1b369dc5b02476e633e52578266a644e37e188a5
Signed-off-by: TraianX Schiau <traianx.schiau@intel.com>
/system/core/logd/LogBuffer.cpp
eae155e1ce9c496c2af71a5e56cb182484f10531 14-Oct-2014 Mark Salyzyn <salyzyn@google.com> logd: insert order for first entry

Change-Id: I39e8e6d32407a1796a0c3a121f9dc4dc5402c3df
/system/core/logd/LogBuffer.cpp
e72c6e43668c8c6e1af77e2e5038557581cbf148 21-Sep-2014 Mark Salyzyn <salyzyn@google.com> logd: cleanup

- simplify access and control exposure to class list
- indent
- compile warning
- Follow standard naming convention for variables and methods
- merge common fragments
- Side Effects: none

Change-Id: I74796043ac34753c6dd10018719ebc0bcd94e010
/system/core/logd/LogBuffer.cpp
1a240b47903c0dc3d7f23b609b6520f17f11b953 12-Jun-2014 Mark Salyzyn <salyzyn@google.com> logd: Allow apps to clear their UID-specific data

Bug: 13501501
Change-Id: Ia72e25fc19430ce63fb359cd9b3f0523d41f5aa8
/system/core/logd/LogBuffer.cpp
ab4b7308ecd8a425cdeb3e289fcfeda0e08085be 23-May-2014 Mark Salyzyn <salyzyn@google.com> logd: used before set warning

Change-Id: I30c078f8b22ebe4dcb48d57adf88b3e51b4fa202
/system/core/logd/LogBuffer.cpp
57a0af93133ad0d190a79372b702653f96b99fe8 10-May-2014 Mark Salyzyn <salyzyn@google.com> init: logd: Allow Developer settings to adjust logd size

- AID_SYSTEM can set persist.logd.size
- AID_SYSTEM can issue command to /dev/socket/logd to
change the runtime global log sizes.
- Add support for ro.logd.size.* as populated by BoardConfig.mk
- Limit size to maximum ~3% of physical memory.

Bug: 14563261
Bug: 14627052
Change-Id: I606420db2e9d9d032296e71149e4a5b20cbd1137
/system/core/logd/LogBuffer.cpp
671e343c7d9c832eca093325c0b8b934c47a83b4 06-May-2014 Mark Salyzyn <salyzyn@google.com> logd: logcat: Add persist.logd.size group of properties

- logd Add persist.logd.size (global), persist.logd.size.<logid>
- logcat report a more flexible multiplier in -g command.

Bug: 14563261
Bug: 14469172
Change-Id: Ie389caa14ad3ae3d4a3a3cc463425bb9dbc5e483
/system/core/logd/LogBuffer.cpp
c8a576c637ae00577273b778498019dd609fcd15 05-Apr-2014 Mark Salyzyn <salyzyn@google.com> logd: Statistics improvements

- Drop in-place sorting.
- Add fast-track for uid sizes and elements.
- Add sort() for per-uid and per-pid statistics.

Change-Id: Ib8655d4cc0b3bd4e87534522987bcc7fc7a5251a
/system/core/logd/LogBuffer.cpp
99f47a9e7c4374f2bbfc18e4a97aa7848245ea33 07-Apr-2014 Mark Salyzyn <salyzyn@google.com> logd: liblog: logcat: debuggerd: Add LOG_ID_CRASH

Change-Id: Iea453764a1a4fc1661f461f10c641c30150e4d20
/system/core/logd/LogBuffer.cpp
1c950479393d42d18829d4009dbdb3a7f03acbb7 02-Apr-2014 Mark Salyzyn <salyzyn@google.com> logd: liblog: logcat: enable prune features for user

- Enable whitelist, blacklist and logsize tuneables for user

Change-Id: Id0c283844c71c5263a8cfbebf2e550f7ac415858
/system/core/logd/LogBuffer.cpp
ca4c63d7994e66b45e9ebeb62e417b7da904b87c 02-Apr-2014 Mark Salyzyn <salyzyn@google.com> logd: build breakage in user

build breakage in branch: git_klp-dev-gpl @ 1101951

Change-Id: I4c9681bf4c97368ec19f5a79fef134aba937f337
/system/core/logd/LogBuffer.cpp
e457b74ce6ee6d799812dc2ec5e4b8b18bcd3e91 20-Feb-2014 Mark Salyzyn <salyzyn@google.com> logd: Add minimum time bucket statistics

* Only enabled for dev builds because halves performance.
- Used to establish if /proc/sys/net/unix/max_dgram_qlen
is appropriate for the platform
(see logd/LogStatistics.cpp comments)
- enabled if logd.dgram_qlen.statistics is not zero/empty

Change-Id: Ib8ecfeb75b6f0f954c099a6b1032b8afb5efcbd4
/system/core/logd/LogBuffer.cpp
b992d0d7d34bed62fd16151a68d60d58cc8003ef 21-Mar-2014 Mark Salyzyn <salyzyn@google.com> logd: liblog: Thread IDs missing from logcat -v thread

- stuff caller's thread id into the packet.

Bug: 13568206
Change-Id: I02d0cdf9b1d9e839ff8969f591db42dfe6e4cc95
/system/core/logd/LogBuffer.cpp
dfa7a07f5be656cfafdb4e75916bc9dcd9e592e7 11-Feb-2014 Mark Salyzyn <salyzyn@google.com> logd: liblog: logcat: Add LogWhiteBlackList

- liblog android_logger_get_log_size and android_logger_get_readable_size
adjusted to return long instead of int because of -G flag extending range

NB: ifdef'd only for userdebug and eng builds

- liblog Add android_logger_[sg]et_prune_list and android_logger_set_log_size
- logcat Add -P, -p and -G flags
- logd Add LogWhiteBlackList and configurable log size

(cherry picked from commit 18a5432158ad43b8faefe4950b30e760200ce0b4)

Change-Id: I1572338c1b34bd968ad7867857ef708156ec3b6a
/system/core/logd/LogBuffer.cpp
64d6fe936253b336049c285369a56cf139bd002f 07-Feb-2014 Mark Salyzyn <salyzyn@google.com> logd: prune by worst offending UID

(cherry picked from commit 3c4919e4748d32d7f3e147ab57f4fafee28c7447)

Change-Id: I39965007569123ff5eebe01b5bfa555bbcb2dfe7
/system/core/logd/LogBuffer.cpp
34facab86b0fe7ec613de92b46b637f864fb0682 06-Feb-2014 Mark Salyzyn <salyzyn@google.com> logd: liblog: logcat: Add Statistics

- logd add statistical collection and formatting
- liblog add android_logger_get_statistics call
- logcat add -S flag
- logcat add -b all

(cherry picked from commit 51a29c8dc445e4fb89860561933e54a231e6ffb4)

Change-Id: I521753b1969ecd4590c956aeeb1557d101059d67
/system/core/logd/LogBuffer.cpp
7e2f83c0bcc3ad8a2840a48be14d302ed79d671c 05-Mar-2014 Mark Salyzyn <salyzyn@google.com> logd: liblog: 64-bit issues

- structure packing
- move towards log_time from struct timespec
- extend log_time to cover differences between
log_time and struct timespec

Change-Id: I106ed0b609917306d170044054b5b32645f2a295
/system/core/logd/LogBuffer.cpp
c03e72cc1c155ff668df8df1caec363b07347d0d 18-Feb-2014 Mark Salyzyn <salyzyn@google.com> logd: Adjust to match defacto coding style

(cherry picked from commit c46f77bd2ad01f3a695416c4cf22d6a9738bb7b8)

Change-Id: I80685cdc7116e10c5a5a77abe856fd96804f9117
/system/core/logd/LogBuffer.cpp
740f9b4f97d6311b29fa885e86413d51d8c92d53 14-Jan-2014 Mark Salyzyn <salyzyn@google.com> logd: prune more aggressively when over the top

(cherry picked from commit 63c15d50615a4c9e9ad25f601ef9dcb1161d8990)

Change-Id: I929dddc7da048c032fb791c7af23f215f8856bf3
/system/core/logd/LogBuffer.cpp
0175b0747a1f55329109e84c9a1322dcb95e2848 26-Feb-2014 Mark Salyzyn <salyzyn@google.com> logd: initial checkin.

* Create a new userspace log daemon for handling logging messages.

Original-Change-Id: I75267df16359684490121e6c31cca48614d79856
Signed-off-by: Nick Kralevich <nnk@google.com>

* Merge conflicts
* rename new syslog daemon to logd to prevent confusion with bionic syslog
* replace racy getGroups call with KISS call to client->getGid()
* Timestamps are filed at logging source
* insert entries into list in timestamp order
* Added LogTimeEntry tail filtration handling
* Added region locking around LogWriter list
* separate threads for each writer
* /dev/socket/logd* permissions

Signed-off-by: Mark Salyzyn <salyzyn@google.com>

(cherry picked from commit 3e76e0a49760c4970b7cda6153e51026af98e4f3)

Author: Nick Kralevich <nnk@google.com>
Change-Id: Ice88b1412d8f9daa7f9119b2b5aaf684a5e28098
/system/core/logd/LogBuffer.cpp