resolve merge conflicts of f062a2cd9eef32ac9458faee7d056c06f2f4168b to pi-dev-plus-aosp

Test: I solemnly swear I tested this conflict resolution.
Change-Id: I5eb1bc16bf25b27172b6d2ea355768df2f6d8ff7
This commit is contained in:
Mark Salyzyn 2018-04-06 07:56:49 -07:00
commit 9e918598df
2 changed files with 27 additions and 18 deletions

View File

@ -3,8 +3,8 @@ cc_binary {
srcs: ["lmkd.c"], srcs: ["lmkd.c"],
shared_libs: [ shared_libs: [
"liblog",
"libcutils", "libcutils",
"liblog",
], ],
static_libs: [ static_libs: [
"libstatslogc", "libstatslogc",

43
lmkd.c
View File

@ -29,8 +29,8 @@
#include <sys/eventfd.h> #include <sys/eventfd.h>
#include <sys/mman.h> #include <sys/mman.h>
#include <sys/socket.h> #include <sys/socket.h>
#include <sys/types.h>
#include <sys/sysinfo.h> #include <sys/sysinfo.h>
#include <sys/types.h>
#include <unistd.h> #include <unistd.h>
#include <cutils/properties.h> #include <cutils/properties.h>
@ -81,7 +81,7 @@
#define SYSTEM_ADJ (-900) #define SYSTEM_ADJ (-900)
/* default to old in-kernel interface if no memory pressure events */ /* default to old in-kernel interface if no memory pressure events */
static int use_inkernel_interface = 1; static bool use_inkernel_interface = true;
static bool has_inkernel_module; static bool has_inkernel_module;
/* memory pressure levels */ /* memory pressure levels */
@ -335,8 +335,9 @@ static void cmd_procprio(LMKD_CTRL_PACKET packet) {
return; return;
} }
if (use_inkernel_interface) if (use_inkernel_interface) {
return; return;
}
if (params.oomadj >= 900) { if (params.oomadj >= 900) {
soft_limit_mult = 0; soft_limit_mult = 0;
@ -402,8 +403,9 @@ static void cmd_procprio(LMKD_CTRL_PACKET packet) {
static void cmd_procremove(LMKD_CTRL_PACKET packet) { static void cmd_procremove(LMKD_CTRL_PACKET packet) {
struct lmk_procremove params; struct lmk_procremove params;
if (use_inkernel_interface) if (use_inkernel_interface) {
return; return;
}
lmkd_pack_get_procremove(packet, &params); lmkd_pack_get_procremove(packet, &params);
pid_remove(params.pid); pid_remove(params.pid);
@ -1232,21 +1234,28 @@ int main(int argc __unused, char **argv __unused) {
statslog_init(&log_ctx, &enable_stats_log); statslog_init(&log_ctx, &enable_stats_log);
#endif #endif
// MCL_ONFAULT pins pages as they fault instead of loading if (!init()) {
// everything immediately all at once. (Which would be bad, if (!use_inkernel_interface) {
// because as of this writing, we have a lot of mapped pages we /*
// never use.) Old kernels will see MCL_ONFAULT and fail with * MCL_ONFAULT pins pages as they fault instead of loading
// EINVAL; we ignore this failure. * everything immediately all at once. (Which would be bad,
// * because as of this writing, we have a lot of mapped pages we
// N.B. read the man page for mlockall. MCL_CURRENT | MCL_ONFAULT * never use.) Old kernels will see MCL_ONFAULT and fail with
// pins ⊆ MCL_CURRENT, converging to just MCL_CURRENT as we fault * EINVAL; we ignore this failure.
// in pages. *
if (mlockall(MCL_CURRENT | MCL_FUTURE | MCL_ONFAULT) && errno != EINVAL) * N.B. read the man page for mlockall. MCL_CURRENT | MCL_ONFAULT
ALOGW("mlockall failed: errno=%d", errno); * pins MCL_CURRENT, converging to just MCL_CURRENT as we fault
* in pages.
*/
if (mlockall(MCL_CURRENT | MCL_FUTURE | MCL_ONFAULT) && (errno != EINVAL)) {
ALOGW("mlockall failed %s", strerror(errno));
}
sched_setscheduler(0, SCHED_FIFO, &param);
}
sched_setscheduler(0, SCHED_FIFO, &param);
if (!init())
mainloop(); mainloop();
}
#ifdef LMKD_LOG_STATS #ifdef LMKD_LOG_STATS
statslog_destroy(&log_ctx); statslog_destroy(&log_ctx);