From 0151010442c33d0a79368a9e30f1979b0858ba5b Mon Sep 17 00:00:00 2001 From: Yi-wei Zhao Date: Tue, 30 Dec 2014 16:48:30 -0600 Subject: drivers:lmk: 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: current: average time to find a task to kill : 1004us optimized: average time to find a task to kill: 43us Change-Id: I32504e9f2f370d58c038eea7457d95c8ed8b6b9b Signed-off-by: Hong-Mei Li Signed-off-by: Yi-wei Zhao Reviewed-on: http://gerrit.mot.com/701205 SLTApproved: Slta Waiver Tested-by: Jira Key Submit-Approved: Jira Key Conflicts: drivers/staging/android/Kconfig include/linux/sched.h --- include/linux/sched.h | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'include/linux') diff --git a/include/linux/sched.h b/include/linux/sched.h index 87c9f2f0a..4b6320c37 100644 --- a/include/linux/sched.h +++ b/include/linux/sched.h @@ -1206,6 +1206,9 @@ struct task_struct { #endif struct list_head tasks; +#ifdef CONFIG_ANDROID_LMK_ADJ_RBTREE + struct rb_node adj_node; +#endif #ifdef CONFIG_SMP struct plist_node pushable_tasks; #endif @@ -1576,6 +1579,14 @@ static inline struct pid *task_tgid(struct task_struct *task) return task->group_leader->pids[PIDTYPE_PID].pid; } +#ifdef CONFIG_ANDROID_LMK_ADJ_RBTREE +extern void add_2_adj_tree(struct task_struct *task); +extern void delete_from_adj_tree(struct task_struct *task); +#else +static inline void add_2_adj_tree(struct task_struct *task) { } +static inline void delete_from_adj_tree(struct task_struct *task) { } +#endif + /* * Without tasklist or rcu lock it is not safe to dereference * the result of task_pgrp/task_session even if task == current, -- cgit v1.2.3