diff options
author | Robert Benea | 2017-09-17 20:31:35 -0500 |
---|---|---|
committer | Robert Benea | 2017-09-17 20:31:35 -0500 |
commit | 19e26708c2d8e563b20868d7a651a3485498ddf1 (patch) | |
tree | f52f5bd178e8233661ed29606f6ba63c2d77f69a /lmkd | |
parent | cbd66d3c8a672ed1f762444e4bfd6cd9b44a924d (diff) | |
download | platform-system-core-19e26708c2d8e563b20868d7a651a3485498ddf1.tar.gz platform-system-core-19e26708c2d8e563b20868d7a651a3485498ddf1.tar.xz platform-system-core-19e26708c2d8e563b20868d7a651a3485498ddf1.zip |
Simplify lmkd functionality
Get min adj score when needed, instead to propagate from caller funct.
Bug:65642829
Test: tested on gobo_512
Change-Id: I87f15c5c6206d471002828a24d0462b0abb0d196
Diffstat (limited to 'lmkd')
-rw-r--r-- | lmkd/lmkd.c | 9 |
1 files changed, 4 insertions, 5 deletions
diff --git a/lmkd/lmkd.c b/lmkd/lmkd.c index 525d7b3cf..5cfa2c887 100644 --- a/lmkd/lmkd.c +++ b/lmkd/lmkd.c | |||
@@ -626,9 +626,10 @@ static int kill_one_process(struct proc* procp, int min_score_adj, bool is_criti | |||
626 | * Find a process to kill based on the current (possibly estimated) free memory | 626 | * Find a process to kill based on the current (possibly estimated) free memory |
627 | * and cached memory sizes. Returns the size of the killed processes. | 627 | * and cached memory sizes. Returns the size of the killed processes. |
628 | */ | 628 | */ |
629 | static int find_and_kill_process(int min_score_adj, bool is_critical) { | 629 | static int find_and_kill_process(bool is_critical) { |
630 | int i; | 630 | int i; |
631 | int killed_size = 0; | 631 | int killed_size = 0; |
632 | int min_score_adj = is_critical ? critical_oomadj : medium_oomadj; | ||
632 | 633 | ||
633 | for (i = OOM_SCORE_ADJ_MAX; i >= min_score_adj; i--) { | 634 | for (i = OOM_SCORE_ADJ_MAX; i >= min_score_adj; i--) { |
634 | struct proc *procp; | 635 | struct proc *procp; |
@@ -676,7 +677,6 @@ static int64_t get_memory_usage(const char* path) { | |||
676 | static void mp_event_common(bool is_critical) { | 677 | static void mp_event_common(bool is_critical) { |
677 | int ret; | 678 | int ret; |
678 | unsigned long long evcount; | 679 | unsigned long long evcount; |
679 | int min_adj_score = is_critical ? critical_oomadj : medium_oomadj; | ||
680 | int index = is_critical ? CRITICAL_INDEX : MEDIUM_INDEX; | 680 | int index = is_critical ? CRITICAL_INDEX : MEDIUM_INDEX; |
681 | int64_t mem_usage, memsw_usage; | 681 | int64_t mem_usage, memsw_usage; |
682 | int64_t mem_pressure; | 682 | int64_t mem_pressure; |
@@ -689,7 +689,7 @@ static void mp_event_common(bool is_critical) { | |||
689 | mem_usage = get_memory_usage(MEMCG_MEMORY_USAGE); | 689 | mem_usage = get_memory_usage(MEMCG_MEMORY_USAGE); |
690 | memsw_usage = get_memory_usage(MEMCG_MEMORYSW_USAGE); | 690 | memsw_usage = get_memory_usage(MEMCG_MEMORYSW_USAGE); |
691 | if (memsw_usage < 0 || mem_usage < 0) { | 691 | if (memsw_usage < 0 || mem_usage < 0) { |
692 | find_and_kill_process(min_adj_score, is_critical); | 692 | find_and_kill_process(is_critical); |
693 | return; | 693 | return; |
694 | } | 694 | } |
695 | 695 | ||
@@ -700,7 +700,6 @@ static void mp_event_common(bool is_critical) { | |||
700 | // We are swapping too much. | 700 | // We are swapping too much. |
701 | if (mem_pressure < upgrade_pressure) { | 701 | if (mem_pressure < upgrade_pressure) { |
702 | ALOGI("Event upgraded to critical."); | 702 | ALOGI("Event upgraded to critical."); |
703 | min_adj_score = critical_oomadj; | ||
704 | is_critical = true; | 703 | is_critical = true; |
705 | } | 704 | } |
706 | } | 705 | } |
@@ -720,7 +719,7 @@ static void mp_event_common(bool is_critical) { | |||
720 | is_critical = false; | 719 | is_critical = false; |
721 | } | 720 | } |
722 | 721 | ||
723 | if (find_and_kill_process(min_adj_score, is_critical) == 0) { | 722 | if (find_and_kill_process(is_critical) == 0) { |
724 | if (debug_process_killing) { | 723 | if (debug_process_killing) { |
725 | ALOGI("Nothing to kill"); | 724 | ALOGI("Nothing to kill"); |
726 | } | 725 | } |