summaryrefslogtreecommitdiffstats
path: root/base/debug
diff options
context:
space:
mode:
authorrnk@chromium.org <rnk@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-02-21 21:39:35 +0000
committerrnk@chromium.org <rnk@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-02-21 21:39:35 +0000
commit42c6abd826b941d38ddba38c25b12ec86ef972d6 (patch)
treebc2474c237fb4b03e23fd236cbda48c4583135a1 /base/debug
parentbc75dd58a48aeb3877ea1d9ef9c703d9fbb39c24 (diff)
downloadchromium_src-42c6abd826b941d38ddba38c25b12ec86ef972d6.zip
chromium_src-42c6abd826b941d38ddba38c25b12ec86ef972d6.tar.gz
chromium_src-42c6abd826b941d38ddba38c25b12ec86ef972d6.tar.bz2
Revert r122552: "Implement proper atomic code for trace macros."
The tsan bots have been red since this change, and crashing on WorkerPoolTest.PostTask in base. I've been unable to reproduce the failure from the bots locally, so I'm reverting this and we'll see what happens on the bots. Unfortunately we don't have a win_tsan try bot, or I'd say reapply once you get a green run from that. TBR=jbates@chromium.org BUG=115107 TEST=base_unittests.exe Review URL: https://chromiumcodereview.appspot.com/9430018 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@122881 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base/debug')
-rw-r--r--base/debug/trace_event.h25
-rw-r--r--base/debug/trace_event_impl.cc11
-rw-r--r--base/debug/trace_event_impl.h1
3 files changed, 15 insertions, 22 deletions
diff --git a/base/debug/trace_event.h b/base/debug/trace_event.h
index 5860f8d..2298b03 100644
--- a/base/debug/trace_event.h
+++ b/base/debug/trace_event.h
@@ -145,6 +145,9 @@
// Without the use of these static category pointers and enabled flags all
// trace points would carry a significant performance cost of aquiring a lock
// and resolving the category.
+//
+// ANNOTATE_BENIGN_RACE is used to suppress the warning on the static category
+// pointers.
#ifndef BASE_DEBUG_TRACE_EVENT_H_
@@ -153,9 +156,8 @@
#include <string>
-#include "base/atomicops.h"
-#include "base/debug/trace_event_impl.h"
#include "build/build_config.h"
+#include "base/debug/trace_event_impl.h"
// By default, const char* argument values are assumed to have long-lived scope
// and will not be copied. Use this macro to force a const char* to be copied.
@@ -483,21 +485,14 @@
INTERNAL_TRACE_EVENT_UID2(name_prefix, __LINE__)
// Implementation detail: internal macro to create static category.
-// No barriers are needed, because this code is designed to operate safely
-// even when the unsigned char* points to garbage data (which may be the case
-// on processors without cache coherency).
+// - ANNOTATE_BENIGN_RACE, see Thread Safety above.
#define INTERNAL_TRACE_EVENT_GET_CATEGORY_INFO(category) \
- static base::subtle::AtomicWord INTERNAL_TRACE_EVENT_UID(atomic) = 0; \
- const uint8* INTERNAL_TRACE_EVENT_UID(catstatic) = \
- reinterpret_cast<const uint8*>( \
- base::subtle::NoBarrier_Load(&INTERNAL_TRACE_EVENT_UID(atomic))); \
- if (!INTERNAL_TRACE_EVENT_UID(catstatic)) { \
+ static const unsigned char* INTERNAL_TRACE_EVENT_UID(catstatic) = NULL; \
+ ANNOTATE_BENIGN_RACE(&INTERNAL_TRACE_EVENT_UID(catstatic), \
+ "trace_event category"); \
+ if (!INTERNAL_TRACE_EVENT_UID(catstatic)) \
INTERNAL_TRACE_EVENT_UID(catstatic) = \
- TRACE_EVENT_API_GET_CATEGORY_ENABLED(category); \
- base::subtle::NoBarrier_Store(&INTERNAL_TRACE_EVENT_UID(atomic), \
- reinterpret_cast<base::subtle::AtomicWord>( \
- INTERNAL_TRACE_EVENT_UID(catstatic))); \
- }
+ TRACE_EVENT_API_GET_CATEGORY_ENABLED(category);
// Implementation detail: internal macro to create static category and add
// event if the category is enabled.
diff --git a/base/debug/trace_event_impl.cc b/base/debug/trace_event_impl.cc
index b81e32a..f1c80bd 100644
--- a/base/debug/trace_event_impl.cc
+++ b/base/debug/trace_event_impl.cc
@@ -20,7 +20,6 @@
#include "base/utf_string_conversions.h"
#include "base/stl_util.h"
#include "base/sys_info.h"
-#include "base/third_party/dynamic_annotations/dynamic_annotations.h"
#include "base/time.h"
#if defined(OS_WIN)
@@ -325,12 +324,6 @@ TraceLog::TraceLog()
: enabled_(false)
, dispatching_to_observer_list_(false) {
SetProcessID(static_cast<int>(base::GetCurrentProcId()));
- // Trace is enabled or disabled on one thread while other threads are
- // accessing the enabled flag. We don't care whether edge-case events are
- // traced or not, so we allow races on the enabled flag to keep the trace
- // macros fast.
- ANNOTATE_BENIGN_RACE_SIZED(g_category_enabled, sizeof(g_category_enabled),
- "trace_event category enabled");
}
TraceLog::~TraceLog() {
@@ -369,6 +362,8 @@ static void EnableMatchingCategory(int category_index,
if (is_match)
break;
}
+ ANNOTATE_BENIGN_RACE(&g_category_enabled[category_index],
+ "trace_event category enabled");
g_category_enabled[category_index] = is_match ?
is_included : (is_included ^ 1);
}
@@ -407,6 +402,8 @@ const unsigned char* TraceLog::GetCategoryEnabledInternal(const char* name) {
else
EnableMatchingCategory(new_index, excluded_categories_, 0);
} else {
+ ANNOTATE_BENIGN_RACE(&g_category_enabled[new_index],
+ "trace_event category enabled");
g_category_enabled[new_index] = 0;
}
return &g_category_enabled[new_index];
diff --git a/base/debug/trace_event_impl.h b/base/debug/trace_event_impl.h
index 1806f893..c1d98b8 100644
--- a/base/debug/trace_event_impl.h
+++ b/base/debug/trace_event_impl.h
@@ -18,6 +18,7 @@
#include "base/observer_list.h"
#include "base/string_util.h"
#include "base/synchronization/lock.h"
+#include "base/third_party/dynamic_annotations/dynamic_annotations.h"
#include "base/timer.h"
// Older style trace macros with explicit id and extra data