History log of /system/core/liblog/logd_writer.c
Revision Date Author Comments (<<< Hide modified files) (Show modified files >>>)
2ed51d708eda64516ec79ac6397f690de38f0075 09-Mar-2017 Mark Salyzyn <salyzyn@google.com> liblog: specify clang format

Switch coding style to match

SideEffects: None
Test: compile
Bug: 27405083
Change-Id: Id426d5c5e3b18f2ceec22b31bbc9781aabf6bcca
/system/core/liblog/logd_writer.c
d69e801fe890d1732906aaadb8aa06244bb4ac52 14-Feb-2017 Mark Salyzyn <salyzyn@google.com> liblog: Harden log_id check.

Logd currently checks against LOG_ID_MAX and LOG_ID_KERNEL to
determine if a given log_id is available. liblog uses only
LOG_ID_KERNEL. While this matches with the comments in log/log_id.h
to always keep LOG_ID_KERNEL at the end it does not match with other
checks that logd makes, causing inconsistent behavior. This
inconsistency is noticable on devices that errantly rewrite
LOG_ID_MAX to not equal LOG_ID_KERNEL + 1. For log buffers with
id's greater than LOG_ID_KERNEL, liblog reports that logd is
unavailable while logd would accept the request.

The guideline is to not use buffer ids above LOG_ID_KERNEL.
This hardening change prevents an inconsistency that results if these
guidelines are not followed. Partners are urged instead to increase
LOG_ID_KERNEL locally to match their LOG_ID_MAX - 1 when they add new
local log buffers in their private builds.

Signed-off-by: Evan Ralston <eralston@amazon.com>
Signed-off-by: Mark Salyzyn <salyzyn@google.com>
Test: compiles. no functional change
Change-Id: Icd4b12ac79c1e5cd1d8a32f67a9795797580aad5
/system/core/liblog/logd_writer.c
65e1e6284c0d604f27510aba6788541f4a492164 03-Jan-2017 Mark Salyzyn <salyzyn@google.com> liblog: retry -ENOTCONN | -ECONNREFUSED | -ENOENT indefinitely

Deal with recovering after transitory failures surrounding logd
crash or recovery. Improve the chances that the logging functions
can work in a signal handler, not officially supported, but making
sure logging is not blamed for system lockups when misused.

Reorder gTests so that setuid(AID_SYSTEM) is performed after
liblog.enoent test, and that this occurs after other tests that
like to see buffers with content in them as we stop logd.

Test: gTest liblog-unit-tests --gtest_filter=liblog.enoent
Bug: 33755074
Change-Id: I66f88599534614b7b61da6b2ae5fe099ebaced3a
/system/core/liblog/logd_writer.c
cfd5b080af8de527d768f0ff7902c26af8d49307 17-Oct-2016 Mark Salyzyn <salyzyn@google.com> system/core: preparation to pull back interfaces from android/log.h

Point to log/log.h where necessary, define LOG_TAG where necessary.
Accept that private/android_logger.h is suitable replacement for
log/logger.h and android/log.h.

Correct liblog/README

Effectively a cleanup and controlled select revert of
'system/core: drop or replace log/logger.h' and
'system/core: Replace log/log.h with android/log.h'.

Test: compile
Bug: 30465923
Change-Id: Ic2ad157bad6f5efe2c6af293a73bb753300b17a2
/system/core/liblog/logd_writer.c
db8a266aea6c12b0fb8ee3587d72333662b05266 10-Oct-2016 Mark Salyzyn <salyzyn@google.com> liblog: __android_log_pmsg_file_write() cleanup

__android_log_pmsg_file_write() will open /dev/pmsg0 if not
already, and will close it if we opened it.

Added atomic access to the android_log_context as insurance.

Fortify and correct pmsg tests.

Test: gTest liblog-unit-tests --gtest_filter=liblog.__android_log_pmsg_file_*
Bug: 31958686
Change-Id: I2cf6f971b6968938f471fda67367efe20dae3004
/system/core/liblog/logd_writer.c
807e40ecc9786755e2f74a7a6a9b20c812588119 22-Sep-2016 Mark Salyzyn <salyzyn@google.com> liblog: logd: Add android_lookupEventTag_len()

Allows us to mitigate the impact of MAP_PRIVATE and copy on write by
calling android_lookupEventTag_len instead of android_lookupEventTag,
and delaying the copy on write impact to the later. We return a
string length in a supplied location along with the string pointer
with android_lookupEventTag_len(const EventTagMap* map, size_t* len,
int tag). The string is not guaranteed to be nul terminated. Since
android_lookupEventTag() called even once can cause the memory
impact, we will mark it as deprecated, but we currently have no
timeframe for removal since this is a very old interface.

Add an API for __android_log_is_loggable_len() that accepts the non
null terminated content and fixup callers that would gain because the
length is known prior to the call either in the compiler or at
runtime. Tackle transition to android_lookupEventTag_len() and
fixup callers.

On any application that performs logging (eg: com.android.phone)

/proc/<pid>/smaps before:

xxxxxxxxxx-xxxxxxxxxx rw-p 00000000 fd:00 463 /system/etc/event-log-tags
Size: 20 kB
Rss: 20 kB
Pss: 1 kB
Shared_Clean: 0 kB
Shared_Dirty: 20 kB
Private_Clean: 0 kB
Private_Dirty: 0 kB
Referenced: 0 kB
Anonymous: 20 kB
AnonHugePages: 0 kB
Swap: 0 kB
SwapPss: 0 kB
KernelPageSize: 4 kB
MMUPageSize: 4 kB
Locked: 0 kB
VmFlags: rd wr mr mw me ac

/proc/<pid>/smaps after:

xxxxxxxxxx-xxxxxxxxxx rw-p 00000000 fd:00 1773 /system/etc/event-log-tags
Size: 20 kB
Rss: 20 kB
Pss: 1 kB
Shared_Clean: 20 kB (was 0kB)
Shared_Dirty: 0 kB (was 20kB)
Private_Clean: 0 kB
Private_Dirty: 0 kB
Referenced: 20 kB (was 0kB)
Anonymous: 0 kB (was 20kB)
AnonHugePages: 0 kB
Swap: 0 kB
SwapPss: 0 kB
KernelPageSize: 4 kB
MMUPageSize: 4 kB
Locked: 0 kB
VmFlags: rd wr mr mw me ac

Added liblog-unit-tests --gtest_filter=liblog.event_log_tags to
check for Shared_Clean: to not be 0 and Anonymous: to be 0 for
all processes referencing event-log-tags. Which can include multiple
references to /system/etc/event-log-tags and future possible refs to
/data/misc/logd/event-log-tags and /dev/event-log-tags. We want
failure messages to help point to errant code using the deprecated
interface.

This change saves 1/4MB of memory or more on a typical system.

Test: gTest liblog-unit-tests
Bug: 31456426
Change-Id: I9e08e44d9092bd96fe704b5709242e7195281d33
/system/core/liblog/logd_writer.c
6584d0a35ab7722bdc6590525dee29f72f0ec576 28-Sep-2016 Mark Salyzyn <salyzyn@google.com> liblog: Replace log/log.h with android/log.h

Move all liblog related content into android/log.h, and make
log/log.h points to android/log.h.

Test: Compile
Bug: 26552300
Bug: 31289077
Change-Id: I858e0ebe047b86f2a8530a99bc9c380d3d58edbb
/system/core/liblog/logd_writer.c
a166708d1541007ab5502040051e31863a29edce 28-Sep-2016 Mark Salyzyn <salyzyn@google.com> liblog: logcat: Replace log/logd.h with log/log.h

Should use log/log.h and in some cases android/log.h instead. Can
not remove file because still in use by partners, so log/logd.h
points to log/log.h.

Test: Compile
Bug: 26552300
Bug: 31289077
Change-Id: I3580d46154617abb7231027a44f4ab9ee023febf
/system/core/liblog/logd_writer.c
004cd3c55def10a92888295a9bad5fd0a18b725e 28-Sep-2016 Mark Salyzyn <salyzyn@google.com> liblog: logd: logcat: deprecate log/log_read.h

Always used in combination with log/logger.h except in log_time.cpp,
and not used externally. As a result liblog has to support stl, a
small price to pay since goal is to convert liblog to C++ internally.

Test: compile
Bug: 31456426
Bug: 26552300
Bug: 31289077
Change-Id: I72828ec807d0a2c8e40bbdebd7a69f147a7ca5a9
/system/core/liblog/logd_writer.c
5ba300346706e79cb7afcbe5f6b498df5d696d5c 22-Aug-2016 Elliott Hughes <enh@google.com> liblog: use SOCK_NONBLOCK directly.

No need to have a race, even if it doesn't matter.

Change-Id: Ia79f2633643bc63618de0fd85953b3226415484f
/system/core/liblog/logd_writer.c
c33103c440517ae8fa5589c22eef795627adf793 29-Mar-2016 Mark Salyzyn <salyzyn@google.com> liblog: gate write on log id available

- Secure LOG_ID_KERNEL in writer
- Secure LOG_ID_SECURITY in reader and writer
- if writer transport says not available, do not write to that log id

Bug: 27566046
Bug: 27896341
Change-Id: If63a78a56fb94adfbf9979454c4cadb81af45c19
/system/core/liblog/logd_writer.c
018a96d03f0d452bf078084eedcd5693da42308d 01-Mar-2016 Mark Salyzyn <salyzyn@google.com> liblog: split out transports into separate files

Create config_logger, logger and logger_read to house the log
interfaces. Add fake_logger, logd_logger and pmsg_logger to
house the write and read transports. Allows for an easier and
direct path to add new transports to the library.

SideEffects: None, logger benchmark performance unaffected

Bug: 27176738
Bug: 27405083
Change-Id: I01b38637334a5242905c8c89f6ab0a92e2540008
/system/core/liblog/logd_writer.c