trace_processor: fix parsing of kernel LMK events
Bug: 122721587
Change-Id: I610ecacf31b1df34930c48e4a170be5c89b2f422
diff --git a/src/trace_processor/instants_table.cc b/src/trace_processor/instants_table.cc
index 592c5c8..b5707e4 100644
--- a/src/trace_processor/instants_table.cc
+++ b/src/trace_processor/instants_table.cc
@@ -37,6 +37,7 @@
StorageSchema InstantsTable::CreateStorageSchema() {
const auto& instants = storage_->instants();
return StorageSchema::Builder()
+ .AddColumn<IdColumn>("id", TableId::kInstants)
.AddOrderedNumericColumn("ts", &instants.timestamps())
.AddStringColumn("name", &instants.name_ids(), &storage_->string_pool())
.AddNumericColumn("value", &instants.values())
diff --git a/src/trace_processor/proto_trace_parser.cc b/src/trace_processor/proto_trace_parser.cc
index dfa6379..125086f 100644
--- a/src/trace_processor/proto_trace_parser.cc
+++ b/src/trace_processor/proto_trace_parser.cc
@@ -114,6 +114,7 @@
utid_name_id_(context->storage->InternString("utid")),
cpu_freq_name_id_(context->storage->InternString("cpufreq")),
cpu_idle_name_id_(context->storage->InternString("cpuidle")),
+ comm_name_id_(context->storage->InternString("comm")),
num_forks_name_id_(context->storage->InternString("num_forks")),
num_irq_total_name_id_(context->storage->InternString("num_irq_total")),
num_softirq_total_name_id_(
@@ -140,6 +141,7 @@
batt_current_id_(context->storage->InternString("batt.current_ua")),
batt_current_avg_id_(
context->storage->InternString("batt.current.avg_ua")),
+ lmk_id_(context->storage->InternString("mem.lmk")),
oom_score_adj_id_(context->storage->InternString("oom_score_adj")),
ion_total_unknown_id_(context->storage->InternString("mem.ion.unknown")),
ion_change_unknown_id_(
@@ -622,6 +624,10 @@
ParseSignalDeliver(timestamp, pid, ftrace.slice(fld_off, fld.size()));
break;
}
+ case protos::FtraceEvent::kLowmemoryKill: {
+ ParseLowmemoryKill(timestamp, ftrace.slice(fld_off, fld.size()));
+ break;
+ }
case protos::FtraceEvent::kOomScoreAdjUpdate: {
ParseOOMScoreAdjUpdate(timestamp, ftrace.slice(fld_off, fld.size()));
break;
@@ -691,13 +697,18 @@
break;
}
}
- // TODO(taylori): Move the comm to the args table once it exists.
- StringId name = context_->storage->InternString(
- base::StringView("mem.lmk." + comm.ToStdString()));
- auto* instants = context_->storage->mutable_instants();
+
// Storing the pid of the event that is lmk-ed.
+ auto* instants = context_->storage->mutable_instants();
UniqueTid utid = context_->process_tracker->UpdateThread(timestamp, pid, 0);
- instants->AddInstantEvent(timestamp, 0, name, utid, RefType::kRefUtid);
+ uint32_t row =
+ instants->AddInstantEvent(timestamp, 0, lmk_id_, utid, RefType::kRefUtid);
+
+ // Store the comm as an arg.
+ RowId row_id = TraceStorage::CreateRowId(TableId::kInstants, row);
+ auto comm_id = context_->storage->InternString(comm);
+ context_->storage->mutable_args()->AddArg(
+ row_id, comm_name_id_, comm_name_id_, Variadic::String(comm_id));
}
void ProtoTraceParser::ParseRssStat(int64_t timestamp,
diff --git a/src/trace_processor/proto_trace_parser.h b/src/trace_processor/proto_trace_parser.h
index d52c1e0..c6bde9f 100644
--- a/src/trace_processor/proto_trace_parser.h
+++ b/src/trace_processor/proto_trace_parser.h
@@ -108,6 +108,7 @@
const StringId utid_name_id_;
const StringId cpu_freq_name_id_;
const StringId cpu_idle_name_id_;
+ const StringId comm_name_id_;
const StringId num_forks_name_id_;
const StringId num_irq_total_name_id_;
const StringId num_softirq_total_name_id_;
@@ -126,6 +127,7 @@
const StringId batt_capacity_id_;
const StringId batt_current_id_;
const StringId batt_current_avg_id_;
+ const StringId lmk_id_;
const StringId oom_score_adj_id_;
const StringId ion_total_unknown_id_;
const StringId ion_change_unknown_id_;
diff --git a/src/trace_processor/trace_storage.h b/src/trace_processor/trace_storage.h
index e98a285..c022806 100644
--- a/src/trace_processor/trace_storage.h
+++ b/src/trace_processor/trace_storage.h
@@ -51,6 +51,7 @@
// invalid row id.
kCounters = 1,
kRawEvents = 2,
+ kInstants = 3,
};
// The top 8 bits are set to the TableId and the bottom 32 to the row of the
@@ -317,17 +318,17 @@
class Instants {
public:
- inline size_t AddInstantEvent(int64_t timestamp,
- StringId name_id,
- double value,
- int64_t ref,
- RefType type) {
+ inline uint32_t AddInstantEvent(int64_t timestamp,
+ StringId name_id,
+ double value,
+ int64_t ref,
+ RefType type) {
timestamps_.emplace_back(timestamp);
name_ids_.emplace_back(name_id);
values_.emplace_back(value);
refs_.emplace_back(ref);
types_.emplace_back(type);
- return instant_count() - 1;
+ return static_cast<uint32_t>(instant_count() - 1);
}
size_t instant_count() const { return timestamps_.size(); }