Merge "fiemap_writer: Add a progress notification." am: dec436438a
am: 3b7f64d323
Change-Id: Ia827d8dc68460779ad4e0946aa5d7b67043ef7ed
diff --git a/libcutils/include/cutils/native_handle.h b/libcutils/include/cutils/native_handle.h
index 10f5bc0..f6cae36 100644
--- a/libcutils/include/cutils/native_handle.h
+++ b/libcutils/include/cutils/native_handle.h
@@ -23,6 +23,9 @@
extern "C" {
#endif
+#define NATIVE_HANDLE_MAX_FDS 1024
+#define NATIVE_HANDLE_MAX_INTS 1024
+
/* Declare a char array for use with native_handle_init */
#define NATIVE_HANDLE_DECLARE_STORAGE(name, maxFds, maxInts) \
alignas(native_handle_t) char (name)[ \
diff --git a/libcutils/native_handle.cpp b/libcutils/native_handle.cpp
index 66f7a3d..b409e5b 100644
--- a/libcutils/native_handle.cpp
+++ b/libcutils/native_handle.cpp
@@ -22,9 +22,6 @@
#include <string.h>
#include <unistd.h>
-static const int kMaxNativeFds = 1024;
-static const int kMaxNativeInts = 1024;
-
native_handle_t* native_handle_init(char* storage, int numFds, int numInts) {
if ((uintptr_t) storage % alignof(native_handle_t)) {
errno = EINVAL;
@@ -39,7 +36,8 @@
}
native_handle_t* native_handle_create(int numFds, int numInts) {
- if (numFds < 0 || numInts < 0 || numFds > kMaxNativeFds || numInts > kMaxNativeInts) {
+ if (numFds < 0 || numInts < 0 || numFds > NATIVE_HANDLE_MAX_FDS ||
+ numInts > NATIVE_HANDLE_MAX_INTS) {
errno = EINVAL;
return NULL;
}
diff --git a/lmkd/lmkd.c b/lmkd/lmkd.c
index ca78c38..da2d15a 100644
--- a/lmkd/lmkd.c
+++ b/lmkd/lmkd.c
@@ -959,7 +959,7 @@
}
#ifdef LMKD_LOG_STATS
-static void memory_stat_parse_line(char* line, struct memory_stat* mem_st) {
+static void memory_stat_parse_line(char *line, struct memory_stat *mem_st) {
char key[LINE_MAX + 1];
int64_t value;
@@ -981,63 +981,25 @@
mem_st->swap_in_bytes = value;
}
-static int memory_stat_from_cgroup(struct memory_stat* mem_st, int pid, uid_t uid) {
- FILE *fp;
- char buf[PATH_MAX];
+static int memory_stat_parse(struct memory_stat *mem_st, int pid, uid_t uid) {
+ FILE *fp;
+ char buf[PATH_MAX];
- snprintf(buf, sizeof(buf), MEMCG_PROCESS_MEMORY_STAT_PATH, uid, pid);
+ snprintf(buf, sizeof(buf), MEMCG_PROCESS_MEMORY_STAT_PATH, uid, pid);
- fp = fopen(buf, "r");
+ fp = fopen(buf, "r");
- if (fp == NULL) {
- ALOGE("%s open failed: %s", buf, strerror(errno));
- return -1;
- }
+ if (fp == NULL) {
+ ALOGE("%s open failed: %s", buf, strerror(errno));
+ return -1;
+ }
- while (fgets(buf, PAGE_SIZE, fp) != NULL) {
- memory_stat_parse_line(buf, mem_st);
- }
- fclose(fp);
+ while (fgets(buf, PAGE_SIZE, fp) != NULL ) {
+ memory_stat_parse_line(buf, mem_st);
+ }
+ fclose(fp);
- return 0;
-}
-
-static int memory_stat_from_procfs(struct memory_stat* mem_st, int pid) {
- char path[PATH_MAX];
- char buffer[PROC_STAT_BUFFER_SIZE];
- int fd, ret;
-
- snprintf(path, sizeof(path), PROC_STAT_FILE_PATH, pid);
- if ((fd = open(path, O_RDONLY | O_CLOEXEC)) < 0) {
- ALOGE("%s open failed: %s", path, strerror(errno));
- return -1;
- }
-
- ret = read(fd, buffer, sizeof(buffer));
- if (ret < 0) {
- ALOGE("%s read failed: %s", path, strerror(errno));
- close(fd);
- return -1;
- }
- close(fd);
-
- // field 10 is pgfault
- // field 12 is pgmajfault
- // field 22 is starttime
- // field 24 is rss_in_pages
- int64_t pgfault = 0, pgmajfault = 0, starttime = 0, rss_in_pages = 0;
- if (sscanf(buffer,
- "%*u %*s %*s %*d %*d %*d %*d %*d %*d %" SCNd64 " %*d "
- "%" SCNd64 " %*d %*u %*u %*d %*d %*d %*d %*d %*d "
- "%" SCNd64 " %*d %" SCNd64 "",
- &pgfault, &pgmajfault, &starttime, &rss_in_pages) != 4) {
- return -1;
- }
- mem_st->pgfault = pgfault;
- mem_st->pgmajfault = pgmajfault;
- mem_st->rss_in_bytes = (rss_in_pages * PAGE_SIZE);
- mem_st->process_start_time_ns = starttime * (NS_PER_SEC / sysconf(_SC_CLK_TCK));
- return 0;
+ return 0;
}
#endif
@@ -1329,11 +1291,7 @@
#ifdef LMKD_LOG_STATS
if (enable_stats_log) {
- if (per_app_memcg) {
- memory_stat_parse_result = memory_stat_from_cgroup(&mem_st, pid, uid);
- } else {
- memory_stat_parse_result = memory_stat_from_procfs(&mem_st, pid);
- }
+ memory_stat_parse_result = memory_stat_parse(&mem_st, pid, uid);
}
#endif
@@ -1360,10 +1318,7 @@
if (memory_stat_parse_result == 0) {
stats_write_lmk_kill_occurred(log_ctx, LMK_KILL_OCCURRED, uid, taskname,
procp->oomadj, mem_st.pgfault, mem_st.pgmajfault, mem_st.rss_in_bytes,
- mem_st.cache_in_bytes, mem_st.swap_in_bytes, mem_st.process_start_time_ns);
- } else if (enable_stats_log) {
- stats_write_lmk_kill_occurred(log_ctx, LMK_KILL_OCCURRED, uid, taskname, procp->oomadj,
- -1, -1, tasksize * BYTES_IN_KILOBYTE, -1, -1, -1);
+ mem_st.cache_in_bytes, mem_st.swap_in_bytes);
}
#endif
result = tasksize;
diff --git a/lmkd/statslog.c b/lmkd/statslog.c
index 689e8ae..66d1164 100644
--- a/lmkd/statslog.c
+++ b/lmkd/statslog.c
@@ -65,7 +65,7 @@
stats_write_lmk_kill_occurred(android_log_context ctx, int32_t code, int32_t uid,
char const* process_name, int32_t oom_score, int64_t pgfault,
int64_t pgmajfault, int64_t rss_in_bytes, int64_t cache_in_bytes,
- int64_t swap_in_bytes, int64_t process_start_time_ns) {
+ int64_t swap_in_bytes) {
assert(ctx != NULL);
int ret = -EINVAL;
if (!ctx) {
@@ -113,9 +113,5 @@
return ret;
}
- if ((ret = android_log_write_int64(ctx, process_start_time_ns)) < 0) {
- return ret;
- }
-
return write_to_logger(ctx, LOG_ID_STATS);
}
diff --git a/lmkd/statslog.h b/lmkd/statslog.h
index f3abe11..edebb19 100644
--- a/lmkd/statslog.h
+++ b/lmkd/statslog.h
@@ -64,13 +64,9 @@
int64_t rss_in_bytes;
int64_t cache_in_bytes;
int64_t swap_in_bytes;
- int64_t process_start_time_ns;
};
#define MEMCG_PROCESS_MEMORY_STAT_PATH "/dev/memcg/apps/uid_%u/pid_%u/memory.stat"
-#define PROC_STAT_FILE_PATH "/proc/%d/stat"
-#define PROC_STAT_BUFFER_SIZE 1024
-#define BYTES_IN_KILOBYTE 1024
/**
* Logs the change in LMKD state which is used as start/stop boundaries for logging
@@ -88,7 +84,7 @@
stats_write_lmk_kill_occurred(android_log_context ctx, int32_t code, int32_t uid,
char const* process_name, int32_t oom_score, int64_t pgfault,
int64_t pgmajfault, int64_t rss_in_bytes, int64_t cache_in_bytes,
- int64_t swap_in_bytes, int64_t process_start_time_ns);
+ int64_t swap_in_bytes);
__END_DECLS
diff --git a/usbd/usbd.cpp b/usbd/usbd.cpp
index 41cd8dd..191fb92 100644
--- a/usbd/usbd.cpp
+++ b/usbd/usbd.cpp
@@ -22,15 +22,20 @@
#include <android-base/properties.h>
#include <android/hardware/usb/gadget/1.0/IUsbGadget.h>
+#include <hidl/HidlTransportSupport.h>
+
#define PERSISTENT_USB_CONFIG "persist.sys.usb.config"
using android::base::GetProperty;
using android::base::SetProperty;
+using android::hardware::configureRpcThreadpool;
using android::hardware::usb::gadget::V1_0::GadgetFunction;
using android::hardware::usb::gadget::V1_0::IUsbGadget;
using android::hardware::Return;
int main(int /*argc*/, char** /*argv*/) {
+ configureRpcThreadpool(1, true /*callerWillJoin*/);
+
android::sp<IUsbGadget> gadget = IUsbGadget::getService();
Return<void> ret;