Commit f9bc310e authored by jie.pan's avatar jie.pan Committed by Commit bot

Add support for PERF_RECORD_MMAP2 record type

Newer perf.data contains both MMAP and MMAP2 record type,
but MMAP2 record type is not supported in previous ll_prof,
MMAP2 record information will be lost.

BUG=v8:4569
LOG=n

Review URL: https://codereview.chromium.org/1469153004

Cr-Commit-Position: refs/heads/master@{#32319}
parent 45c52ddf
...@@ -568,7 +568,7 @@ PERF_EVENT_HEADER_DESC = Descriptor([ ...@@ -568,7 +568,7 @@ PERF_EVENT_HEADER_DESC = Descriptor([
]) ])
# Reference: kernel/events/core.c # Reference: kernel/tools/perf/util/event.h
PERF_MMAP_EVENT_BODY_DESC = Descriptor([ PERF_MMAP_EVENT_BODY_DESC = Descriptor([
("pid", "u32"), ("pid", "u32"),
("tid", "u32"), ("tid", "u32"),
...@@ -577,6 +577,20 @@ PERF_MMAP_EVENT_BODY_DESC = Descriptor([ ...@@ -577,6 +577,20 @@ PERF_MMAP_EVENT_BODY_DESC = Descriptor([
("pgoff", "u64") ("pgoff", "u64")
]) ])
# Reference: kernel/tools/perf/util/event.h
PERF_MMAP2_EVENT_BODY_DESC = Descriptor([
("pid", "u32"),
("tid", "u32"),
("addr", "u64"),
("len", "u64"),
("pgoff", "u64"),
("maj", "u32"),
("min", "u32"),
("ino", "u64"),
("ino_generation", "u64"),
("prot", "u32"),
("flags","u32")
])
# perf_event_attr.sample_type bits control the set of # perf_event_attr.sample_type bits control the set of
# perf_sample_event fields. # perf_sample_event fields.
...@@ -616,6 +630,7 @@ PERF_SAMPLE_EVENT_IP_FORMAT = "u64" ...@@ -616,6 +630,7 @@ PERF_SAMPLE_EVENT_IP_FORMAT = "u64"
PERF_RECORD_MMAP = 1 PERF_RECORD_MMAP = 1
PERF_RECORD_MMAP2 = 10
PERF_RECORD_SAMPLE = 9 PERF_RECORD_SAMPLE = 9
...@@ -664,6 +679,15 @@ class TraceReader(object): ...@@ -664,6 +679,15 @@ class TraceReader(object):
mmap_info.filename = HOST_ROOT + filename[:filename.find(chr(0))] mmap_info.filename = HOST_ROOT + filename[:filename.find(chr(0))]
return mmap_info return mmap_info
def ReadMmap2(self, header, offset):
mmap_info = PERF_MMAP2_EVENT_BODY_DESC.Read(self.trace,
offset + self.header_size)
# Read null-terminated filename.
filename = self.trace[offset + self.header_size + ctypes.sizeof(mmap_info):
offset + header.size]
mmap_info.filename = HOST_ROOT + filename[:filename.find(chr(0))]
return mmap_info
def ReadSample(self, header, offset): def ReadSample(self, header, offset):
sample = self.sample_event_body_desc.Read(self.trace, sample = self.sample_event_body_desc.Read(self.trace,
offset + self.header_size) offset + self.header_size)
...@@ -973,6 +997,14 @@ if __name__ == "__main__": ...@@ -973,6 +997,14 @@ if __name__ == "__main__":
else: else:
library_repo.Load(mmap_info, code_map, options) library_repo.Load(mmap_info, code_map, options)
mmap_time += time.time() - start mmap_time += time.time() - start
elif header.type == PERF_RECORD_MMAP2:
start = time.time()
mmap_info = trace_reader.ReadMmap2(header, offset)
if mmap_info.filename == HOST_ROOT + V8_GC_FAKE_MMAP:
log_reader.ReadUpToGC()
else:
library_repo.Load(mmap_info, code_map, options)
mmap_time += time.time() - start
elif header.type == PERF_RECORD_SAMPLE: elif header.type == PERF_RECORD_SAMPLE:
ticks += 1 ticks += 1
start = time.time() start = time.time()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment