lmkd: Use std::array<> and remove the ARRAY_SIZE() definition am: 545067957c am: f9489027a1 am: 350a02e15d
Original change: https://android-review.googlesource.com/c/platform/system/memory/lmkd/+/1972104 Change-Id: Ibff73f0b29a47624a374d46b92e98124a3d49f19
This commit is contained in:
commit
a02c2dc079
12
lmkd.cpp
12
lmkd.cpp
|
|
@ -35,6 +35,7 @@
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
|
#include <array>
|
||||||
#include <shared_mutex>
|
#include <shared_mutex>
|
||||||
|
|
||||||
#include <cutils/properties.h>
|
#include <cutils/properties.h>
|
||||||
|
|
@ -104,7 +105,6 @@ static inline void trace_kill_end() {}
|
||||||
#define INKERNEL_MINFREE_PATH "/sys/module/lowmemorykiller/parameters/minfree"
|
#define INKERNEL_MINFREE_PATH "/sys/module/lowmemorykiller/parameters/minfree"
|
||||||
#define INKERNEL_ADJ_PATH "/sys/module/lowmemorykiller/parameters/adj"
|
#define INKERNEL_ADJ_PATH "/sys/module/lowmemorykiller/parameters/adj"
|
||||||
|
|
||||||
#define ARRAY_SIZE(x) (sizeof(x) / sizeof(*(x)))
|
|
||||||
#define EIGHT_MEGA (1 << 23)
|
#define EIGHT_MEGA (1 << 23)
|
||||||
|
|
||||||
#define TARGET_UPDATE_MIN_INTERVAL_MS 1000
|
#define TARGET_UPDATE_MIN_INTERVAL_MS 1000
|
||||||
|
|
@ -287,8 +287,8 @@ static int maxevents;
|
||||||
#define OOM_SCORE_ADJ_MIN (-1000)
|
#define OOM_SCORE_ADJ_MIN (-1000)
|
||||||
#define OOM_SCORE_ADJ_MAX 1000
|
#define OOM_SCORE_ADJ_MAX 1000
|
||||||
|
|
||||||
static int lowmem_adj[MAX_TARGETS];
|
static std::array<int, MAX_TARGETS> lowmem_adj;
|
||||||
static int lowmem_minfree[MAX_TARGETS];
|
static std::array<int, MAX_TARGETS> lowmem_minfree;
|
||||||
static int lowmem_targets_size;
|
static int lowmem_targets_size;
|
||||||
|
|
||||||
/* Fields to parse in /proc/zoneinfo */
|
/* Fields to parse in /proc/zoneinfo */
|
||||||
|
|
@ -1376,8 +1376,9 @@ static void cmd_target(int ntargets, LMKD_CTRL_PACKET packet) {
|
||||||
static struct timespec last_req_tm;
|
static struct timespec last_req_tm;
|
||||||
struct timespec curr_tm;
|
struct timespec curr_tm;
|
||||||
|
|
||||||
if (ntargets < 1 || ntargets > (int)ARRAY_SIZE(lowmem_adj))
|
if (ntargets < 1 || ntargets > (int)lowmem_adj.size()) {
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Ratelimit minfree updates to once per TARGET_UPDATE_MIN_INTERVAL_MS
|
* Ratelimit minfree updates to once per TARGET_UPDATE_MIN_INTERVAL_MS
|
||||||
|
|
@ -1469,8 +1470,9 @@ static void ctrl_command_handler(int dsock_idx) {
|
||||||
switch(cmd) {
|
switch(cmd) {
|
||||||
case LMK_TARGET:
|
case LMK_TARGET:
|
||||||
targets = nargs / 2;
|
targets = nargs / 2;
|
||||||
if (nargs & 0x1 || targets > (int)ARRAY_SIZE(lowmem_adj))
|
if (nargs & 0x1 || targets > (int)lowmem_adj.size()) {
|
||||||
goto wronglen;
|
goto wronglen;
|
||||||
|
}
|
||||||
cmd_target(targets, packet);
|
cmd_target(targets, packet);
|
||||||
break;
|
break;
|
||||||
case LMK_PROCPRIO:
|
case LMK_PROCPRIO:
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue