Merge "boottime/init: Report ro.boottime.init* properties in milliseconds."
This commit is contained in:
commit
7dde4fa4e2
4 changed files with 10 additions and 11 deletions
|
|
@ -212,10 +212,8 @@ void RecordInitBootTimeProp(
|
||||||
BootEventRecordStore* boot_event_store, const char* property) {
|
BootEventRecordStore* boot_event_store, const char* property) {
|
||||||
std::string value = GetProperty(property);
|
std::string value = GetProperty(property);
|
||||||
|
|
||||||
int32_t time_in_ns;
|
int32_t time_in_ms;
|
||||||
if (android::base::ParseInt(value, &time_in_ns)) {
|
if (android::base::ParseInt(value, &time_in_ms)) {
|
||||||
static constexpr int32_t kNanosecondsPerMillisecond = 1e6;
|
|
||||||
int32_t time_in_ms = static_cast<int32_t>(time_in_ns / kNanosecondsPerMillisecond);
|
|
||||||
boot_event_store->AddBootEventWithValue(property, time_in_ms);
|
boot_event_store->AddBootEventWithValue(property, time_in_ms);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -178,7 +178,7 @@ static int wait_for_coldboot_done_action(const std::vector<std::string>& args) {
|
||||||
panic();
|
panic();
|
||||||
}
|
}
|
||||||
|
|
||||||
property_set("ro.boottime.init.cold_boot_wait", std::to_string(t.duration_ns()).c_str());
|
property_set("ro.boottime.init.cold_boot_wait", std::to_string(t.duration_ms()).c_str());
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -576,7 +576,7 @@ static void selinux_initialize(bool in_kernel_domain) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// init's first stage can't set properties, so pass the time to the second stage.
|
// init's first stage can't set properties, so pass the time to the second stage.
|
||||||
setenv("INIT_SELINUX_TOOK", std::to_string(t.duration_ns()).c_str(), 1);
|
setenv("INIT_SELINUX_TOOK", std::to_string(t.duration_ms()).c_str(), 1);
|
||||||
} else {
|
} else {
|
||||||
selinux_init_all_handles();
|
selinux_init_all_handles();
|
||||||
}
|
}
|
||||||
|
|
@ -757,8 +757,9 @@ int main(int argc, char** argv) {
|
||||||
|
|
||||||
setenv("INIT_SECOND_STAGE", "true", 1);
|
setenv("INIT_SECOND_STAGE", "true", 1);
|
||||||
|
|
||||||
uint64_t start_ns = start_time.time_since_epoch().count();
|
static constexpr uint32_t kNanosecondsPerMillisecond = 1e6;
|
||||||
setenv("INIT_STARTED_AT", StringPrintf("%" PRIu64, start_ns).c_str(), 1);
|
uint64_t start_ms = start_time.time_since_epoch().count() / kNanosecondsPerMillisecond;
|
||||||
|
setenv("INIT_STARTED_AT", StringPrintf("%" PRIu64, start_ms).c_str(), 1);
|
||||||
|
|
||||||
char* path = argv[0];
|
char* path = argv[0];
|
||||||
char* args[] = { path, nullptr };
|
char* args[] = { path, nullptr };
|
||||||
|
|
|
||||||
|
|
@ -276,7 +276,7 @@ class SocketConnection {
|
||||||
while (*timeout_ms > 0) {
|
while (*timeout_ms > 0) {
|
||||||
Timer timer;
|
Timer timer;
|
||||||
int nr = poll(ufds, 1, *timeout_ms);
|
int nr = poll(ufds, 1, *timeout_ms);
|
||||||
uint64_t millis = timer.duration_ns()/1000000;
|
uint64_t millis = timer.duration_ms();
|
||||||
*timeout_ms = (millis > *timeout_ms) ? 0 : *timeout_ms - millis;
|
*timeout_ms = (millis > *timeout_ms) ? 0 : *timeout_ms - millis;
|
||||||
|
|
||||||
if (nr > 0) {
|
if (nr > 0) {
|
||||||
|
|
|
||||||
|
|
@ -55,8 +55,8 @@ class Timer {
|
||||||
return std::chrono::duration_cast<double_duration>(boot_clock::now() - start_).count();
|
return std::chrono::duration_cast<double_duration>(boot_clock::now() - start_).count();
|
||||||
}
|
}
|
||||||
|
|
||||||
int64_t duration_ns() const {
|
int64_t duration_ms() const {
|
||||||
return (boot_clock::now() - start_).count();
|
return std::chrono::duration_cast<std::chrono::milliseconds>(boot_clock::now() - start_).count();
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue