Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(55)

Side by Side Diff: base/debug/trace_event_impl.cc

Issue 9581019: Revert 124144 - Sync trace time on Chrome OS (just like Android) (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "base/debug/trace_event_impl.h" 5 #include "base/debug/trace_event_impl.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/debug/trace_event.h" 10 #include "base/debug/trace_event.h"
(...skipping 669 matching lines...) Expand 10 before | Expand all | Expand 10 after
680 const std::string& extra) 680 const std::string& extra)
681 { 681 {
682 #if defined(OS_WIN) 682 #if defined(OS_WIN)
683 TraceEventETWProvider::Trace(name, phase, id, extra); 683 TraceEventETWProvider::Trace(name, phase, id, extra);
684 #endif 684 #endif
685 INTERNAL_TRACE_EVENT_ADD(phase, "ETW Trace Event", name, 685 INTERNAL_TRACE_EVENT_ADD(phase, "ETW Trace Event", name,
686 TRACE_EVENT_FLAG_COPY, "id", id, "extra", extra); 686 TRACE_EVENT_FLAG_COPY, "id", id, "extra", extra);
687 } 687 }
688 688
689 void TraceLog::AddClockSyncMetadataEvents() { 689 void TraceLog::AddClockSyncMetadataEvents() {
690 #if defined(OS_ANDROID) || defined(OS_CHROMEOS) 690 #if defined(OS_ANDROID)
691 // Since Android/ChromeOS do not support sched_setaffinity, we cannot 691 // Since Android does not support sched_setaffinity, we cannot establish clock
692 // establish clock sync unless the scheduler clock is set to global. 692 // sync unless the scheduler clock is set to global. If the trace_clock file
693 // If the trace_clock file can't be read, we will assume the kernel 693 // can't be read, we will assume the kernel doesn't support tracing and do
694 // doesn't support tracing and do nothing. 694 // nothing.
695 std::string clock_mode; 695 std::string clock_mode;
696 if (!file_util::ReadFileToString( 696 if (!file_util::ReadFileToString(
697 FilePath("/sys/kernel/debug/tracing/trace_clock"), 697 FilePath("/sys/kernel/debug/tracing/trace_clock"),
698 &clock_mode)) 698 &clock_mode))
699 return; 699 return;
700 700
701 if (clock_mode != "local [global]\n") { 701 if (clock_mode != "local [global]\n") {
702 DLOG(WARNING) << 702 DLOG(WARNING) <<
703 "The kernel's tracing clock must be set to global in order for " << 703 "The kernel's tracing clock must be set to global in order for " <<
704 "trace_event to be synchronized with . Do this by\n" << 704 "trace_event to be synchronized with . Do this by\n" <<
705 " echo global > /sys/kerel/debug/tracing/trace_clock"; 705 " echo global > /sys/kerel/debug/tracing/trace_clock";
706 return; 706 return;
707 } 707 }
708 708
709 // Linux's kernel trace system has a trace_marker feature: this is a file on 709 // Android's kernel trace system has a trace_marker feature: this is a file on
710 // debugfs that takes the written data and pushes it onto the trace 710 // debugfs that takes the written data and pushes it onto the trace
711 // buffer. So, to establish clock sync, we write our monotonic clock into that 711 // buffer. So, to establish clock sync, we write our monotonic clock into that
712 // trace buffer. 712 // trace buffer.
713 TimeTicks now = TimeTicks::HighResNow(); 713 TimeTicks now = TimeTicks::HighResNow();
714 714
715 double now_in_seconds = now.ToInternalValue() / 1000000.0; 715 double now_in_seconds = now.ToInternalValue() / 1000000.0;
716 std::string marker = 716 std::string marker =
717 StringPrintf("trace_event_clock_sync: parent_ts=%f\n", 717 StringPrintf("trace_event_clock_sync: parent_ts=%f\n",
718 now_in_seconds); 718 now_in_seconds);
719 if (file_util::WriteFile( 719 if (file_util::WriteFile(
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
760 // Create a FNV hash from the process ID for XORing. 760 // Create a FNV hash from the process ID for XORing.
761 // See http://isthe.com/chongo/tech/comp/fnv/ for algorithm details. 761 // See http://isthe.com/chongo/tech/comp/fnv/ for algorithm details.
762 unsigned long long offset_basis = 14695981039346656037ull; 762 unsigned long long offset_basis = 14695981039346656037ull;
763 unsigned long long fnv_prime = 1099511628211ull; 763 unsigned long long fnv_prime = 1099511628211ull;
764 unsigned long long pid = static_cast<unsigned long long>(process_id_); 764 unsigned long long pid = static_cast<unsigned long long>(process_id_);
765 process_id_hash_ = (offset_basis ^ pid) * fnv_prime; 765 process_id_hash_ = (offset_basis ^ pid) * fnv_prime;
766 } 766 }
767 767
768 } // namespace debug 768 } // namespace debug
769 } // namespace base 769 } // namespace base
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698