From 0bcd97a7485d971c5276e19b1a6c2672539dc38d Mon Sep 17 00:00:00 2001 From: Martijn Coenen Date: Wed, 15 Jul 2015 14:25:23 +0200 Subject: Map realtime to clock_monotonic. This maps a monotonic timestamp to the corresponding real-time timestamp, which can be used to match up the traces with other logs that use real-time. Also write clock_sync records first instead of at the end, to avoid not being to write it due to the buffer being full. Bug: 23668823 Change-Id: I644aeea496197e194ec30f808f754e3e043d905f --- cmds/atrace/atrace.cpp | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) (limited to 'cmds') diff --git a/cmds/atrace/atrace.cpp b/cmds/atrace/atrace.cpp index 9def406..26c5b4a 100644 --- a/cmds/atrace/atrace.cpp +++ b/cmds/atrace/atrace.cpp @@ -264,9 +264,27 @@ static bool appendStr(const char* filename, const char* str) static void writeClockSyncMarker() { char buffer[128]; + int len = 0; + int fd = open(k_traceMarkerPath, O_WRONLY); + if (fd == -1) { + fprintf(stderr, "error opening %s: %s (%d)\n", k_traceMarkerPath, + strerror(errno), errno); + return; + } float now_in_seconds = systemTime(CLOCK_MONOTONIC) / 1000000000.0f; - snprintf(buffer, 128, "trace_event_clock_sync: parent_ts=%f\n", now_in_seconds); - writeStr(k_traceMarkerPath, buffer); + + len = snprintf(buffer, 128, "trace_event_clock_sync: parent_ts=%f\n", now_in_seconds); + if (write(fd, buffer, len) != len) { + fprintf(stderr, "error writing clock sync marker %s (%d)\n", strerror(errno), errno); + } + + int64_t realtime_in_ms = systemTime(CLOCK_REALTIME) / 1000000; + len = snprintf(buffer, 128, "trace_event_clock_sync: realtime_ts=%" PRId64 "\n", realtime_in_ms); + if (write(fd, buffer, len) != len) { + fprintf(stderr, "error writing clock sync marker %s (%d)\n", strerror(errno), errno); + } + + close(fd); } // Enable or disable a kernel option by writing a "1" or a "0" into a /sys @@ -646,7 +664,6 @@ static bool startTrace() // Disable tracing in the kernel. static void stopTrace() { - writeClockSyncMarker(); setTracingEnabled(false); } @@ -940,6 +957,7 @@ int main(int argc, char **argv) // another. ok = clearTrace(); + writeClockSyncMarker(); if (ok && !async) { // Sleep to allow the trace to be captured. struct timespec timeLeft; -- cgit v1.1 From 6afc38c45af45eb8f64793bca2903b3f4c55579b Mon Sep 17 00:00:00 2001 From: Lorenzo Colitti Date: Wed, 9 Sep 2015 22:59:25 +0900 Subject: Dump the ND offload status and address table in bugreports. Also, move NetworkDiagnostics between the two runs of getting the wifi counters, so we can see the effect on the counters of sending our probe packets. Bug: 23661687 Change-Id: I3f81c003a35f50ac1cb8e77d0a8c73dae4fd91f3 --- cmds/dumpstate/dumpstate.c | 28 +++++++++++++++------------- 1 file changed, 15 insertions(+), 13 deletions(-) (limited to 'cmds') diff --git a/cmds/dumpstate/dumpstate.c b/cmds/dumpstate/dumpstate.c index ef8db06..792f015 100644 --- a/cmds/dumpstate/dumpstate.c +++ b/cmds/dumpstate/dumpstate.c @@ -434,8 +434,6 @@ static void dumpstate() { run_command("ARP CACHE", 10, "ip", "-4", "neigh", "show", NULL); run_command("IPv6 ND CACHE", 10, "ip", "-6", "neigh", "show", NULL); - run_command("NETWORK DIAGNOSTICS", 10, "dumpsys", "connectivity", "--diag", NULL); - run_command("IPTABLES", 10, SU_PATH, "root", "iptables", "-L", "-nvx", NULL); run_command("IP6TABLES", 10, SU_PATH, "root", "ip6tables", "-L", "-nvx", NULL); run_command("IPTABLE NAT", 10, SU_PATH, "root", "iptables", "-t", "nat", "-L", "-nvx", NULL); @@ -447,25 +445,29 @@ static void dumpstate() { SU_PATH, "root", "wpa_cli", "IFNAME=wlan0", "list_networks", NULL); #ifdef FWDUMP_bcmdhd - run_command("DUMP WIFI INTERNAL COUNTERS", 20, + run_command("ND OFFLOAD TABLE", 5, + SU_PATH, "root", "wlutil", "nd_hostip", NULL); + + run_command("DUMP WIFI INTERNAL COUNTERS (1)", 20, SU_PATH, "root", "wlutil", "counters", NULL); + + run_command("ND OFFLOAD STATUS (1)", 5, + SU_PATH, "root", "wlutil", "nd_status", NULL); + #endif dump_file("INTERRUPTS (1)", "/proc/interrupts"); - property_get("dhcp.wlan0.gateway", network, ""); - if (network[0]) - run_command("PING GATEWAY", 10, "ping", "-c", "3", "-i", ".5", network, NULL); - property_get("dhcp.wlan0.dns1", network, ""); - if (network[0]) - run_command("PING DNS1", 10, "ping", "-c", "3", "-i", ".5", network, NULL); - property_get("dhcp.wlan0.dns2", network, ""); - if (network[0]) - run_command("PING DNS2", 10, "ping", "-c", "3", "-i", ".5", network, NULL); + run_command("NETWORK DIAGNOSTICS", 10, "dumpsys", "connectivity", "--diag", NULL); + #ifdef FWDUMP_bcmdhd run_command("DUMP WIFI STATUS", 20, SU_PATH, "root", "dhdutil", "-i", "wlan0", "dump", NULL); - run_command("DUMP WIFI INTERNAL COUNTERS", 20, + + run_command("DUMP WIFI INTERNAL COUNTERS (2)", 20, SU_PATH, "root", "wlutil", "counters", NULL); + + run_command("ND OFFLOAD STATUS (2)", 5, + SU_PATH, "root", "wlutil", "nd_status", NULL); #endif dump_file("INTERRUPTS (2)", "/proc/interrupts"); -- cgit v1.1 From 21948005f0294a64a42932b21a33ae75295dc3d9 Mon Sep 17 00:00:00 2001 From: Andreas Gampe Date: Mon, 14 Sep 2015 16:33:11 -0700 Subject: Installd: Allow different behavior before bootcomplete Check dev.bootcomplete in dex2oat(). Use the information for two changes. Only switch to the background when we're post bootcomplete. This will ensure better utilization after upgrades. Add a second dex2oat-threads property that is used pre bootcomplete. A separation of these phases allows using less cores when the device is up, freeing up resources for other purposes, e.g., avoid jank. The precedence during boot is the boot property, or the image property if the former doesn't exist, or the default property as a fallback. Bug: 23898216 Bug: 24004256 Change-Id: I5063f3fc4b437cbe88c4e94584e01c1c78eccc4d --- cmds/installd/commands.cpp | 55 ++++++++++++++++++++++++++++++++++++---------- 1 file changed, 43 insertions(+), 12 deletions(-) (limited to 'cmds') diff --git a/cmds/installd/commands.cpp b/cmds/installd/commands.cpp index 7090b36..769cd34 100644 --- a/cmds/installd/commands.cpp +++ b/cmds/installd/commands.cpp @@ -746,7 +746,7 @@ static bool check_boolean_property(const char* property_name, bool default_value static void run_dex2oat(int zip_fd, int oat_fd, const char* input_file_name, const char* output_file_name, int swap_fd, const char *pkgname, const char *instruction_set, - bool vm_safe_mode, bool debuggable) + bool vm_safe_mode, bool debuggable, bool post_bootcomplete) { static const unsigned int MAX_INSTRUCTION_SET_LEN = 7; @@ -770,8 +770,24 @@ static void run_dex2oat(int zip_fd, int oat_fd, const char* input_file_name, dex2oat_compiler_filter_flag, NULL) > 0; char dex2oat_threads_buf[PROPERTY_VALUE_MAX]; - bool have_dex2oat_threads_flag = property_get("dalvik.vm.dex2oat-threads", dex2oat_threads_buf, - NULL) > 0; + bool have_dex2oat_threads_flag = false; + if (!post_bootcomplete) { + have_dex2oat_threads_flag = property_get("dalvik.vm.boot-dex2oat-threads", + dex2oat_threads_buf, + NULL) > 0; + // If there's no boot property, fall back to the image property. + if (!have_dex2oat_threads_flag) { + have_dex2oat_threads_flag = property_get("dalvik.vm.image-dex2oat-threads", + dex2oat_threads_buf, + NULL) > 0; + } + // If there's neither, fall back to the default property. + } + if (!have_dex2oat_threads_flag) { + have_dex2oat_threads_flag = property_get("dalvik.vm.dex2oat-threads", + dex2oat_threads_buf, + NULL) > 0; + } char dex2oat_threads_arg[PROPERTY_VALUE_MAX + 2]; if (have_dex2oat_threads_flag) { sprintf(dex2oat_threads_arg, "-j%s", dex2oat_threads_buf); @@ -1065,6 +1081,27 @@ static bool calculate_odex_file_path(char path[PKG_PATH_MAX], return true; } +static bool IsPostBootComplete() { + char dev_bootcomplete_prop_buf[PROPERTY_VALUE_MAX]; + if (property_get("dev.bootcomplete", dev_bootcomplete_prop_buf, "0") > 0) { + return (strcmp(dev_bootcomplete_prop_buf, "1") == 0); + } + return false; +} + +static void SetDex2OatAndPatchOatScheduling(bool set_to_bg) { + if (set_to_bg) { + if (set_sched_policy(0, SP_BACKGROUND) < 0) { + ALOGE("set_sched_policy failed: %s\n", strerror(errno)); + exit(70); + } + if (setpriority(PRIO_PROCESS, 0, ANDROID_PRIORITY_BACKGROUND) < 0) { + ALOGE("setpriority failed: %s\n", strerror(errno)); + exit(71); + } + } +} + int dexopt(const char *apk_path, uid_t uid, bool is_public, const char *pkgname, const char *instruction_set, int dexopt_needed, bool vm_safe_mode, bool debuggable, const char* oat_dir) @@ -1076,6 +1113,7 @@ int dexopt(const char *apk_path, uid_t uid, bool is_public, const char *input_file; char in_odex_path[PKG_PATH_MAX]; int res, input_fd=-1, out_fd=-1, swap_fd=-1; + bool post_bootcomplete = IsPostBootComplete(); // Early best-effort check whether we can fit the the path into our buffers. // Note: the cache path will require an additional 5 bytes for ".swap", but we'll try to run @@ -1198,14 +1236,7 @@ int dexopt(const char *apk_path, uid_t uid, bool is_public, ALOGE("capset failed: %s\n", strerror(errno)); exit(66); } - if (set_sched_policy(0, SP_BACKGROUND) < 0) { - ALOGE("set_sched_policy failed: %s\n", strerror(errno)); - exit(70); - } - if (setpriority(PRIO_PROCESS, 0, ANDROID_PRIORITY_BACKGROUND) < 0) { - ALOGE("setpriority failed: %s\n", strerror(errno)); - exit(71); - } + SetDex2OatAndPatchOatScheduling(post_bootcomplete); if (flock(out_fd, LOCK_EX | LOCK_NB) != 0) { ALOGE("flock(%s) failed: %s\n", out_path, strerror(errno)); exit(67); @@ -1222,7 +1253,7 @@ int dexopt(const char *apk_path, uid_t uid, bool is_public, input_file_name++; } run_dex2oat(input_fd, out_fd, input_file_name, out_path, swap_fd, pkgname, - instruction_set, vm_safe_mode, debuggable); + instruction_set, vm_safe_mode, debuggable, post_bootcomplete); } else { ALOGE("Invalid dexopt needed: %d\n", dexopt_needed); exit(73); -- cgit v1.1 From 72ebebed876a62e719b098e43d9d516361bde029 Mon Sep 17 00:00:00 2001 From: Andreas Gampe Date: Mon, 21 Sep 2015 13:21:30 -0700 Subject: Installd: Take boot status as dexopt parameter Expect the boot status explicitly as a parameter so that we do not have to rely on dev.bootcomplete, which isn't meaningfully set when the device needs the decryption screen on boot. Bug: 23898216 Change-Id: I9b34298caf70b1e5d40970cc0d04c469016a80a7 --- cmds/installd/commands.cpp | 15 +++------------ cmds/installd/installd.cpp | 6 +++--- cmds/installd/installd.h | 2 +- 3 files changed, 7 insertions(+), 16 deletions(-) (limited to 'cmds') diff --git a/cmds/installd/commands.cpp b/cmds/installd/commands.cpp index 769cd34..d4aa7d3 100644 --- a/cmds/installd/commands.cpp +++ b/cmds/installd/commands.cpp @@ -1081,14 +1081,6 @@ static bool calculate_odex_file_path(char path[PKG_PATH_MAX], return true; } -static bool IsPostBootComplete() { - char dev_bootcomplete_prop_buf[PROPERTY_VALUE_MAX]; - if (property_get("dev.bootcomplete", dev_bootcomplete_prop_buf, "0") > 0) { - return (strcmp(dev_bootcomplete_prop_buf, "1") == 0); - } - return false; -} - static void SetDex2OatAndPatchOatScheduling(bool set_to_bg) { if (set_to_bg) { if (set_sched_policy(0, SP_BACKGROUND) < 0) { @@ -1104,7 +1096,7 @@ static void SetDex2OatAndPatchOatScheduling(bool set_to_bg) { int dexopt(const char *apk_path, uid_t uid, bool is_public, const char *pkgname, const char *instruction_set, int dexopt_needed, - bool vm_safe_mode, bool debuggable, const char* oat_dir) + bool vm_safe_mode, bool debuggable, const char* oat_dir, bool boot_complete) { struct utimbuf ut; struct stat input_stat; @@ -1113,7 +1105,6 @@ int dexopt(const char *apk_path, uid_t uid, bool is_public, const char *input_file; char in_odex_path[PKG_PATH_MAX]; int res, input_fd=-1, out_fd=-1, swap_fd=-1; - bool post_bootcomplete = IsPostBootComplete(); // Early best-effort check whether we can fit the the path into our buffers. // Note: the cache path will require an additional 5 bytes for ".swap", but we'll try to run @@ -1236,7 +1227,7 @@ int dexopt(const char *apk_path, uid_t uid, bool is_public, ALOGE("capset failed: %s\n", strerror(errno)); exit(66); } - SetDex2OatAndPatchOatScheduling(post_bootcomplete); + SetDex2OatAndPatchOatScheduling(boot_complete); if (flock(out_fd, LOCK_EX | LOCK_NB) != 0) { ALOGE("flock(%s) failed: %s\n", out_path, strerror(errno)); exit(67); @@ -1253,7 +1244,7 @@ int dexopt(const char *apk_path, uid_t uid, bool is_public, input_file_name++; } run_dex2oat(input_fd, out_fd, input_file_name, out_path, swap_fd, pkgname, - instruction_set, vm_safe_mode, debuggable, post_bootcomplete); + instruction_set, vm_safe_mode, debuggable, boot_complete); } else { ALOGE("Invalid dexopt needed: %d\n", dexopt_needed); exit(73); diff --git a/cmds/installd/installd.cpp b/cmds/installd/installd.cpp index 13e3168..f67e838 100644 --- a/cmds/installd/installd.cpp +++ b/cmds/installd/installd.cpp @@ -48,9 +48,9 @@ static int do_install(char **arg, char reply[REPLY_MAX] __unused) static int do_dexopt(char **arg, char reply[REPLY_MAX] __unused) { /* apk_path, uid, is_public, pkgname, instruction_set, - * dexopt_needed, vm_safe_mode, debuggable, oat_dir */ + * dexopt_needed, vm_safe_mode, debuggable, oat_dir, boot_complete */ return dexopt(arg[0], atoi(arg[1]), atoi(arg[2]), arg[3], arg[4], atoi(arg[5]), - atoi(arg[6]), atoi(arg[7]), arg[8]); + atoi(arg[6]), atoi(arg[7]), arg[8], atoi(arg[9])); } static int do_mark_boot_complete(char **arg, char reply[REPLY_MAX] __unused) @@ -194,7 +194,7 @@ struct cmdinfo { struct cmdinfo cmds[] = { { "ping", 0, do_ping }, { "install", 5, do_install }, - { "dexopt", 9, do_dexopt }, + { "dexopt", 10, do_dexopt }, { "markbootcomplete", 1, do_mark_boot_complete }, { "movedex", 3, do_move_dex }, { "rmdex", 2, do_rm_dex }, diff --git a/cmds/installd/installd.h b/cmds/installd/installd.h index 7ec5793..24b9084 100644 --- a/cmds/installd/installd.h +++ b/cmds/installd/installd.h @@ -243,7 +243,7 @@ int get_size(const char *uuid, const char *pkgname, int userid, int free_cache(const char *uuid, int64_t free_size); int dexopt(const char *apk_path, uid_t uid, bool is_public, const char *pkgName, const char *instruction_set, int dexopt_needed, bool vm_safe_mode, - bool debuggable, const char* oat_dir); + bool debuggable, const char* oat_dir, bool boot_complete); int mark_boot_complete(const char *instruction_set); int movefiles(); int linklib(const char* uuid, const char* pkgname, const char* asecLibDir, int userId); -- cgit v1.1