Merge "Do not set properties in bionic_systrace"
This commit is contained in:
commit
e46ded5ce1
@ -34,27 +34,25 @@ constexpr char SYSTRACE_PROPERTY_NAME[] = "debug.atrace.tags.enableflags";
|
|||||||
|
|
||||||
static Lock g_lock;
|
static Lock g_lock;
|
||||||
static const prop_info* g_pinfo;
|
static const prop_info* g_pinfo;
|
||||||
static uint32_t g_serial = -1;
|
static uint32_t g_property_serial = -1;
|
||||||
|
static uint32_t g_property_area_serial = -1;
|
||||||
static uint64_t g_tags;
|
static uint64_t g_tags;
|
||||||
static int g_trace_marker_fd = -1;
|
static int g_trace_marker_fd = -1;
|
||||||
|
|
||||||
static bool should_trace() {
|
static bool should_trace() {
|
||||||
bool result = false;
|
bool result = false;
|
||||||
g_lock.lock();
|
g_lock.lock();
|
||||||
// If g_pinfo is null, this means that systrace hasn't been run and it's safe to
|
// debug.atrace.tags.enableflags is set to a safe non-tracing value during property
|
||||||
// assume that no trace writing will need to take place. However, to avoid running
|
// space initialization, so it should only be null in two cases, if there are
|
||||||
// this costly find check each time, we set it to a non-tracing value so that next
|
// insufficient permissions for this process to access the property, in which
|
||||||
// time, it will just check the serial to see if the value has been changed.
|
// case an audit will be logged, and during boot before the property server has
|
||||||
// this function also deals with the bootup case, during which the call to property
|
// been started, in which case we store the global property_area serial to prevent
|
||||||
// set will fail if the property server hasn't yet started.
|
// the costly find operation until we see a changed property_area.
|
||||||
if (g_pinfo == NULL) {
|
if (!g_pinfo && g_property_area_serial != __system_property_area_serial()) {
|
||||||
|
g_property_area_serial = __system_property_area_serial();
|
||||||
g_pinfo = __system_property_find(SYSTRACE_PROPERTY_NAME);
|
g_pinfo = __system_property_find(SYSTRACE_PROPERTY_NAME);
|
||||||
if (g_pinfo == NULL) {
|
|
||||||
__system_property_set(SYSTRACE_PROPERTY_NAME, "0");
|
|
||||||
g_pinfo = __system_property_find(SYSTRACE_PROPERTY_NAME);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
if (g_pinfo != NULL) {
|
if (g_pinfo) {
|
||||||
// Find out which tags have been enabled on the command line and set
|
// Find out which tags have been enabled on the command line and set
|
||||||
// the value of tags accordingly. If the value of the property changes,
|
// the value of tags accordingly. If the value of the property changes,
|
||||||
// the serial will also change, so the costly system_property_read function
|
// the serial will also change, so the costly system_property_read function
|
||||||
@ -62,11 +60,11 @@ static bool should_trace() {
|
|||||||
// first. The values within pinfo may change, but its location is guaranteed
|
// first. The values within pinfo may change, but its location is guaranteed
|
||||||
// not to move.
|
// not to move.
|
||||||
uint32_t cur_serial = __system_property_serial(g_pinfo);
|
uint32_t cur_serial = __system_property_serial(g_pinfo);
|
||||||
if (cur_serial != g_serial) {
|
if (cur_serial != g_property_serial) {
|
||||||
g_serial = cur_serial;
|
g_property_serial = cur_serial;
|
||||||
char value[PROP_VALUE_MAX];
|
char value[PROP_VALUE_MAX];
|
||||||
__system_property_read(g_pinfo, 0, value);
|
__system_property_read(g_pinfo, 0, value);
|
||||||
g_tags = strtoull(value, NULL, 0);
|
g_tags = strtoull(value, nullptr, 0);
|
||||||
}
|
}
|
||||||
result = ((g_tags & ATRACE_TAG_BIONIC) != 0);
|
result = ((g_tags & ATRACE_TAG_BIONIC) != 0);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user