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

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

Issue 9474023: Sync trace time on Chrome OS (just like Android) (Closed) Base URL: http://git.chromium.org/git/chromium/src@master
Patch Set: fixup comments Created 8 years, 10 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
« 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 665 matching lines...) Expand 10 before | Expand all | Expand 10 after
676 const std::string& extra) 676 const std::string& extra)
677 { 677 {
678 #if defined(OS_WIN) 678 #if defined(OS_WIN)
679 TraceEventETWProvider::Trace(name, phase, id, extra); 679 TraceEventETWProvider::Trace(name, phase, id, extra);
680 #endif 680 #endif
681 INTERNAL_TRACE_EVENT_ADD(phase, "ETW Trace Event", name, 681 INTERNAL_TRACE_EVENT_ADD(phase, "ETW Trace Event", name,
682 TRACE_EVENT_FLAG_COPY, "id", id, "extra", extra); 682 TRACE_EVENT_FLAG_COPY, "id", id, "extra", extra);
683 } 683 }
684 684
685 void TraceLog::AddClockSyncMetadataEvents() { 685 void TraceLog::AddClockSyncMetadataEvents() {
686 #if defined(OS_ANDROID) 686 #if defined(OS_ANDROID) || defined(OS_CHROMEOS)
687 // Since Android does not support sched_setaffinity, we cannot establish clock 687 // Since Android/ChromeOS do not support sched_setaffinity, we cannot
688 // sync unless the scheduler clock is set to global. If the trace_clock file 688 // establish clock sync unless the scheduler clock is set to global.
689 // can't be read, we will assume the kernel doesn't support tracing and do 689 // If the trace_clock file can't be read, we will assume the kernel
690 // nothing. 690 // doesn't support tracing and do nothing.
691 std::string clock_mode; 691 std::string clock_mode;
692 if (!file_util::ReadFileToString( 692 if (!file_util::ReadFileToString(
693 FilePath("/sys/kernel/debug/tracing/trace_clock"), 693 FilePath("/sys/kernel/debug/tracing/trace_clock"),
694 &clock_mode)) 694 &clock_mode))
695 return; 695 return;
696 696
697 if (clock_mode != "local [global]\n") { 697 if (clock_mode != "local [global]\n") {
698 DLOG(WARNING) << 698 DLOG(WARNING) <<
699 "The kernel's tracing clock must be set to global in order for " << 699 "The kernel's tracing clock must be set to global in order for " <<
700 "trace_event to be synchronized with . Do this by\n" << 700 "trace_event to be synchronized with . Do this by\n" <<
701 " echo global > /sys/kerel/debug/tracing/trace_clock"; 701 " echo global > /sys/kerel/debug/tracing/trace_clock";
702 return; 702 return;
703 } 703 }
704 704
705 // Android's kernel trace system has a trace_marker feature: this is a file on 705 // Linux's kernel trace system has a trace_marker feature: this is a file on
706 // debugfs that takes the written data and pushes it onto the trace 706 // debugfs that takes the written data and pushes it onto the trace
707 // buffer. So, to establish clock sync, we write our monotonic clock into that 707 // buffer. So, to establish clock sync, we write our monotonic clock into that
708 // trace buffer. 708 // trace buffer.
709 TimeTicks now = TimeTicks::HighResNow(); 709 TimeTicks now = TimeTicks::HighResNow();
710 710
711 double now_in_seconds = now.ToInternalValue() / 1000000.0; 711 double now_in_seconds = now.ToInternalValue() / 1000000.0;
712 std::string marker = 712 std::string marker =
713 StringPrintf("trace_event_clock_sync: parent_ts=%f\n", 713 StringPrintf("trace_event_clock_sync: parent_ts=%f\n",
714 now_in_seconds); 714 now_in_seconds);
715 if (file_util::WriteFile( 715 if (file_util::WriteFile(
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
756 // Create a FNV hash from the process ID for XORing. 756 // Create a FNV hash from the process ID for XORing.
757 // See http://isthe.com/chongo/tech/comp/fnv/ for algorithm details. 757 // See http://isthe.com/chongo/tech/comp/fnv/ for algorithm details.
758 unsigned long long offset_basis = 14695981039346656037ull; 758 unsigned long long offset_basis = 14695981039346656037ull;
759 unsigned long long fnv_prime = 1099511628211ull; 759 unsigned long long fnv_prime = 1099511628211ull;
760 unsigned long long pid = static_cast<unsigned long long>(process_id_); 760 unsigned long long pid = static_cast<unsigned long long>(process_id_);
761 process_id_hash_ = (offset_basis ^ pid) * fnv_prime; 761 process_id_hash_ = (offset_basis ^ pid) * fnv_prime;
762 } 762 }
763 763
764 } // namespace debug 764 } // namespace debug
765 } // namespace base 765 } // 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