Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 2ddc5a19 authored by Florian Mayer's avatar Florian Mayer Committed by Gerrit Code Review
Browse files

Merge "Always use shared memory for atrace."

parents f2e5b4ba fc0adaf8
Loading
Loading
Loading
Loading
+4 −34
Original line number Diff line number Diff line
@@ -88,12 +88,6 @@ __BEGIN_DECLS
#error ATRACE_TAG must be defined to be one of the tags defined in cutils/trace.h
#endif

// Set this to 0 to revert to the old Binder-based atrace implementation.
// This is only here in case rollbacks do not apply cleanly.
// TODO(fmayer): Remove this once we are confident this won't need to be
// rolled back, no later than 2020-03-01.
#define ATRACE_SHMEM 1

/**
 * Opens the trace file for writing and reads the property for initial tags.
 * The atrace.tags.enableflags property sets the tags to trace.
@@ -121,12 +115,8 @@ void atrace_set_debuggable(bool debuggable);
 * prevent tracing within the Zygote process.
 */
void atrace_set_tracing_enabled(bool enabled);

/**
 * If !ATRACE_SHMEM:
 *   Flag indicating whether setup has been completed, initialized to 0.
 *   Nonzero indicates setup has completed.
 *   Note: This does NOT indicate whether or not setup was successful.
 * If ATRACE_SHMEM:
 * This is always set to false. This forces code that uses an old version
 * of this header to always call into atrace_setup, in which we call
 * atrace_init unconditionally.
@@ -154,28 +144,8 @@ extern int atrace_marker_fd;
#define ATRACE_INIT() atrace_init()
#define ATRACE_GET_ENABLED_TAGS() atrace_get_enabled_tags()

#if ATRACE_SHMEM
void atrace_init();
uint64_t atrace_get_enabled_tags();
#else
static inline void atrace_init()
{
    if (CC_UNLIKELY(!atomic_load_explicit(&atrace_is_ready, memory_order_acquire))) {
        atrace_setup();
    }
}

/**
 * Get the mask of all tags currently enabled.
 * It can be used as a guard condition around more expensive trace calculations.
 * Every trace function calls this, which ensures atrace_init is run.
 */
static inline uint64_t atrace_get_enabled_tags()
{
    atrace_init();
    return atrace_enabled_tags;
}
#endif

/**
 * Test if a given tag is currently enabled.
+0 −7
Original line number Diff line number Diff line
@@ -41,9 +41,6 @@ static void atrace_init_once()
    } else {
      atrace_enabled_tags = atrace_get_property();
    }
#if !ATRACE_SHMEM
    atomic_store_explicit(&atrace_is_ready, true, memory_order_release);
#endif
}

static void atrace_seq_number_changed(uint32_t prev_seq_no, uint32_t seq_no) {
@@ -69,11 +66,7 @@ static void atrace_seq_number_changed(uint32_t prev_seq_no, uint32_t seq_no) {

void atrace_setup()
{
#if ATRACE_SHMEM
    atrace_init();
#else
    pthread_once(&atrace_once_control, atrace_init_once);
#endif
}

void atrace_begin_body(const char* name)
+11 −16
Original line number Diff line number Diff line
@@ -71,8 +71,6 @@ alignas(uint64_t) static char empty_pi[96];
static const prop_info* atrace_property_info = reinterpret_cast<const prop_info*>(empty_pi);
#endif

#if ATRACE_SHMEM

/**
 * This is called when the sequence number of debug.atrace.tags.enableflags
 * changes and we need to reload the enabled tags.
@@ -96,7 +94,6 @@ uint64_t atrace_get_enabled_tags()
    atrace_init();
    return atrace_enabled_tags;
}
#endif

// Set whether this process is debuggable, which determines whether
// application-level tracing is allowed when the ro.debuggable system property
@@ -186,7 +183,6 @@ static uint64_t atrace_get_property()
void atrace_update_tags()
{
    uint64_t tags;
    if (ATRACE_SHMEM || 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);
@@ -200,7 +196,6 @@ void atrace_update_tags()
        pthread_mutex_unlock(&atrace_tags_mutex);
    }
}
}

#define WRITE_MSG(format_begin, format_end, name, value) { \
    char buf[ATRACE_MESSAGE_LENGTH]; \
+0 −2
Original line number Diff line number Diff line
@@ -30,10 +30,8 @@ void atrace_async_begin_body(const char* /*name*/, int32_t /*cookie*/) {}
void atrace_async_end_body(const char* /*name*/, int32_t /*cookie*/) {}
void atrace_int_body(const char* /*name*/, int32_t /*value*/) {}
void atrace_int64_body(const char* /*name*/, int64_t /*value*/) {}
#if ATRACE_SHMEM
void atrace_init() {}
uint64_t atrace_get_enabled_tags()
{
    return ATRACE_TAG_NOT_READY;
}
#endif