lmkd: Use std::min() and std::max() instead of defining min() and max() macros am: 80a3dba57a
Original change: https://android-review.googlesource.com/c/platform/system/memory/lmkd/+/1972103 Change-Id: Ifd1a8218fd0d6fbb4bbca9b0cc65b39c8b0e7226
This commit is contained in:
commit
c53ab08bf5
22
lmkd.cpp
22
lmkd.cpp
|
|
@ -34,6 +34,7 @@
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
|
||||||
|
#include <algorithm>
|
||||||
#include <shared_mutex>
|
#include <shared_mutex>
|
||||||
|
|
||||||
#include <cutils/properties.h>
|
#include <cutils/properties.h>
|
||||||
|
|
@ -140,9 +141,6 @@ static inline void trace_kill_end() {}
|
||||||
/* Polling period after PSI signal when pressure is low */
|
/* Polling period after PSI signal when pressure is low */
|
||||||
#define PSI_POLL_PERIOD_LONG_MS 100
|
#define PSI_POLL_PERIOD_LONG_MS 100
|
||||||
|
|
||||||
#define min(a, b) (((a) < (b)) ? (a) : (b))
|
|
||||||
#define max(a, b) (((a) > (b)) ? (a) : (b))
|
|
||||||
|
|
||||||
#define FAIL_REPORT_RLIMIT_MS 1000
|
#define FAIL_REPORT_RLIMIT_MS 1000
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
@ -556,7 +554,7 @@ static bool init_monitors();
|
||||||
static void destroy_monitors();
|
static void destroy_monitors();
|
||||||
|
|
||||||
static int clamp(int low, int high, int value) {
|
static int clamp(int low, int high, int value) {
|
||||||
return max(min(value, high), low);
|
return std::max(std::min(value, high), low);
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool parse_int64(const char* str, int64_t* ret) {
|
static bool parse_int64(const char* str, int64_t* ret) {
|
||||||
|
|
@ -2013,12 +2011,13 @@ static void killinfo_log(struct proc* procp, int min_oom_score, int rss_kb,
|
||||||
android_log_write_int32(ctx, procp->uid);
|
android_log_write_int32(ctx, procp->uid);
|
||||||
android_log_write_int32(ctx, procp->oomadj);
|
android_log_write_int32(ctx, procp->oomadj);
|
||||||
android_log_write_int32(ctx, min_oom_score);
|
android_log_write_int32(ctx, min_oom_score);
|
||||||
android_log_write_int32(ctx, (int32_t)min(rss_kb, INT32_MAX));
|
android_log_write_int32(ctx, std::min(rss_kb, (int)INT32_MAX));
|
||||||
android_log_write_int32(ctx, ki ? ki->kill_reason : NONE);
|
android_log_write_int32(ctx, ki ? ki->kill_reason : NONE);
|
||||||
|
|
||||||
/* log meminfo fields */
|
/* log meminfo fields */
|
||||||
for (int field_idx = 0; field_idx < MI_FIELD_COUNT; field_idx++) {
|
for (int field_idx = 0; field_idx < MI_FIELD_COUNT; field_idx++) {
|
||||||
android_log_write_int32(ctx, mi ? (int32_t)min(mi->arr[field_idx] * page_k, INT32_MAX): 0);
|
android_log_write_int32(ctx,
|
||||||
|
mi ? std::min(mi->arr[field_idx] * page_k, (int64_t)INT32_MAX) : 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* log lmkd wakeup information */
|
/* log lmkd wakeup information */
|
||||||
|
|
@ -2034,7 +2033,7 @@ static void killinfo_log(struct proc* procp, int min_oom_score, int rss_kb,
|
||||||
android_log_write_int32(ctx, 0);
|
android_log_write_int32(ctx, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
android_log_write_int32(ctx, (int32_t)min(swap_kb, INT32_MAX));
|
android_log_write_int32(ctx, std::min(swap_kb, (int)INT32_MAX));
|
||||||
android_log_write_int32(ctx, mi ? (int32_t)mi->field.total_gpu_kb : 0);
|
android_log_write_int32(ctx, mi ? (int32_t)mi->field.total_gpu_kb : 0);
|
||||||
if (ki) {
|
if (ki) {
|
||||||
android_log_write_int32(ctx, ki->thrashing);
|
android_log_write_int32(ctx, ki->thrashing);
|
||||||
|
|
@ -3667,12 +3666,13 @@ static void update_props() {
|
||||||
low_ram_device ? DEF_PARTIAL_STALL_LOWRAM : DEF_PARTIAL_STALL);
|
low_ram_device ? DEF_PARTIAL_STALL_LOWRAM : DEF_PARTIAL_STALL);
|
||||||
psi_complete_stall_ms = GET_LMK_PROPERTY(int32, "psi_complete_stall_ms",
|
psi_complete_stall_ms = GET_LMK_PROPERTY(int32, "psi_complete_stall_ms",
|
||||||
DEF_COMPLETE_STALL);
|
DEF_COMPLETE_STALL);
|
||||||
thrashing_limit_pct = max(0, GET_LMK_PROPERTY(int32, "thrashing_limit",
|
thrashing_limit_pct =
|
||||||
low_ram_device ? DEF_THRASHING_LOWRAM : DEF_THRASHING));
|
std::max(0, GET_LMK_PROPERTY(int32, "thrashing_limit",
|
||||||
|
low_ram_device ? DEF_THRASHING_LOWRAM : DEF_THRASHING));
|
||||||
thrashing_limit_decay_pct = clamp(0, 100, GET_LMK_PROPERTY(int32, "thrashing_limit_decay",
|
thrashing_limit_decay_pct = clamp(0, 100, GET_LMK_PROPERTY(int32, "thrashing_limit_decay",
|
||||||
low_ram_device ? DEF_THRASHING_DECAY_LOWRAM : DEF_THRASHING_DECAY));
|
low_ram_device ? DEF_THRASHING_DECAY_LOWRAM : DEF_THRASHING_DECAY));
|
||||||
thrashing_critical_pct = max(0, GET_LMK_PROPERTY(int32, "thrashing_limit_critical",
|
thrashing_critical_pct = std::max(
|
||||||
thrashing_limit_pct * 2));
|
0, GET_LMK_PROPERTY(int32, "thrashing_limit_critical", thrashing_limit_pct * 2));
|
||||||
swap_util_max = clamp(0, 100, GET_LMK_PROPERTY(int32, "swap_util_max", 100));
|
swap_util_max = clamp(0, 100, GET_LMK_PROPERTY(int32, "swap_util_max", 100));
|
||||||
filecache_min_kb = GET_LMK_PROPERTY(int64, "filecache_min_kb", 0);
|
filecache_min_kb = GET_LMK_PROPERTY(int64, "filecache_min_kb", 0);
|
||||||
stall_limit_critical = GET_LMK_PROPERTY(int64, "stall_limit_critical", 100);
|
stall_limit_critical = GET_LMK_PROPERTY(int64, "stall_limit_critical", 100);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue