diff options
author | Hong-Mei Li <a21834@motorola.com> | 2013-06-28 19:26:38 +0800 |
---|---|---|
committer | Simon Shields <keepcalm444@gmail.com> | 2016-06-13 14:47:39 +1000 |
commit | 6f04da23b1e3aa60626bfef868ee89a77cebd637 (patch) | |
tree | 965631521a4d3b9831846da116efda37ddeae69b /mm | |
parent | 8f5f33a7fd66e85d8d8502b5ee9c1c731ff0aeb5 (diff) | |
download | kernel_samsung_smdk4412-6f04da23b1e3aa60626bfef868ee89a77cebd637.zip kernel_samsung_smdk4412-6f04da23b1e3aa60626bfef868ee89a77cebd637.tar.gz kernel_samsung_smdk4412-6f04da23b1e3aa60626bfef868ee89a77cebd637.tar.bz2 |
staging: android: lowmemorykiller: implement task's adj rbtree
Based on the current LMK implementation, LMK has to scan all processes to
select the correct task to kill during low memory.
The basic idea for the optimization is to :
queue all tasks with oom_score_adj priority, and then LMK just selects the
proper task from the queue(rbtree) to kill.
performance improvement:
the current implementation: average time to find a task to kill : 1004us
the optimized implementation: average time to find a task to kill: 43us
Change-Id: I4dbbdd5673314dbbdabb71c3eff0dc229ce4ea91
Signed-off-by: Hong-Mei Li <a21834@motorola.com>
Reviewed-on: http://gerrit.pcs.mot.com/548917
SLT-Approved: Slta Waiver <sltawvr@motorola.com>
Tested-by: Jira Key <jirakey@motorola.com>
Reviewed-by: Yi-Wei Zhao <gbjc64@motorola.com>
Submit-Approved: Jira Key <jirakey@motorola.com>
Signed-off-by: D. Andrei Măceș <dmaces@nd.edu>
Conflicts:
drivers/staging/android/Kconfig
drivers/staging/android/lowmemorykiller.c
fs/proc/base.c
mm/oom_kill.c
Conflicts:
drivers/staging/android/lowmemorykiller.c
mm/oom_kill.c
Conflicts:
mm/oom_kill.c
Conflicts:
drivers/staging/android/lowmemorykiller.c
mm/oom_kill.c
Diffstat (limited to 'mm')
-rw-r--r-- | mm/oom_kill.c | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/mm/oom_kill.c b/mm/oom_kill.c index 7c72487..678cf2b 100644 --- a/mm/oom_kill.c +++ b/mm/oom_kill.c @@ -38,6 +38,28 @@ int sysctl_oom_kill_allocating_task; int sysctl_oom_dump_tasks = 1; static DEFINE_SPINLOCK(zone_scan_lock); +/* + * compare_swap_oom_score_adj() - compare and swap current's oom_score_adj + * @old_val: old oom_score_adj for compare + * @new_val: new oom_score_adj for swap + * + * Sets the oom_score_adj value for current to @new_val iff its present value is + * @old_val. Usually used to reinstate a previous value to prevent racing with + * userspacing tuning the value in the interim. + */ +void compare_swap_oom_score_adj(int old_val, int new_val) +{ + struct sighand_struct *sighand = current->sighand; + + spin_lock_irq(&sighand->siglock); + if (current->signal->oom_score_adj == old_val) { + current->signal->oom_score_adj = new_val; + delete_from_adj_tree(current); + add_2_adj_tree(current); + } + spin_unlock_irq(&sighand->siglock); +} + /** * test_set_oom_score_adj() - set current's oom_score_adj and return old value * @new_val: new oom_score_adj value |