static void atrace_init_once() { atrace_marker_fd = open("/sys/kernel/debug/tracing/trace_marker", O_WRONLY | O_CLOEXEC); if (atrace_marker_fd == -1) { ALOGE("Error opening trace file: %s (%d)", strerror(errno), errno); atrace_enabled_tags = 0; goto done; } atrace_enabled_tags = atrace_get_property(); done: atomic_store_explicit(&atrace_is_ready, true, memory_order_release); }
static void atrace_init_once() { atrace_marker_fd = open("/sys/kernel/debug/tracing/trace_marker", O_WRONLY); if (atrace_marker_fd == -1) { ALOGE("Error opening trace file: %s (%d)", strerror(errno), errno); atrace_enabled_tags = 0; goto done; } atrace_enabled_tags = atrace_get_property(); done: android_atomic_release_store(1, &atrace_is_ready); }
// Update tags if tracing is ready. Useful as a sysprop change callback. void atrace_update_tags() { uint64_t tags; if (CC_UNLIKELY(atomic_load_explicit(&atrace_is_ready, memory_order_acquire))) { if (atomic_load_explicit(&atrace_is_enabled, memory_order_acquire)) { tags = atrace_get_property(); pthread_mutex_lock(&atrace_tags_mutex); atrace_enabled_tags = tags; pthread_mutex_unlock(&atrace_tags_mutex); } else { // Tracing is disabled for this process, so we simply don't // initialize the tags. pthread_mutex_lock(&atrace_tags_mutex); atrace_enabled_tags = ATRACE_TAG_NOT_READY; pthread_mutex_unlock(&atrace_tags_mutex); } } }