aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/staging
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/staging')
-rw-r--r--drivers/staging/android/lowmemorykiller.c36
1 files changed, 24 insertions, 12 deletions
diff --git a/drivers/staging/android/lowmemorykiller.c b/drivers/staging/android/lowmemorykiller.c
index c6ee61c..f68459a 100644
--- a/drivers/staging/android/lowmemorykiller.c
+++ b/drivers/staging/android/lowmemorykiller.c
@@ -420,11 +420,14 @@ static const struct kparam_array __param_arr_adj = {
#ifdef CONFIG_ANDROID_LMK_ADJ_RBTREE
DEFINE_SPINLOCK(lmk_lock);
struct rb_root tasks_scoreadj = RB_ROOT;
+/*
+ * Makesure to invoke the function with holding sighand->siglock
+ */
void add_2_adj_tree(struct task_struct *task)
{
struct rb_node **link;
struct rb_node *parent = NULL;
- struct task_struct *task_entry;
+ struct signal_struct *sig_entry;
s64 key = task->signal->oom_score_adj;
/*
@@ -434,25 +437,28 @@ void add_2_adj_tree(struct task_struct *task)
link = &tasks_scoreadj.rb_node;
while (*link) {
parent = *link;
- task_entry = rb_entry(parent, struct task_struct, adj_node);
+ sig_entry = rb_entry(parent, struct signal_struct, adj_node);
- if (key < task_entry->signal->oom_score_adj)
+ if (key < sig_entry->oom_score_adj)
link = &parent->rb_right;
else
link = &parent->rb_left;
}
- rb_link_node(&task->adj_node, parent, link);
- rb_insert_color(&task->adj_node, &tasks_scoreadj);
+ rb_link_node(&task->signal->adj_node, parent, link);
+ rb_insert_color(&task->signal->adj_node, &tasks_scoreadj);
spin_unlock(&lmk_lock);
}
+/*
+ * Makesure to invoke the function with holding sighand->siglock
+ */
void delete_from_adj_tree(struct task_struct *task)
{
spin_lock(&lmk_lock);
- if (!RB_EMPTY_NODE(&task->adj_node)) {
- rb_erase(&task->adj_node, &tasks_scoreadj);
- RB_CLEAR_NODE(&task->adj_node);
+ if (!RB_EMPTY_NODE(&task->signal->adj_node)) {
+ rb_erase(&task->signal->adj_node, &tasks_scoreadj);
+ RB_CLEAR_NODE(&task->signal->adj_node);
}
spin_unlock(&lmk_lock);
}
@@ -461,20 +467,23 @@ void delete_from_adj_tree(struct task_struct *task)
static struct task_struct *pick_next_from_adj_tree(struct task_struct *task)
{
struct rb_node *next;
+ struct signal_struct *next_tsk_sig;
spin_lock(&lmk_lock);
- next = rb_next(&task->adj_node);
+ next = rb_next(&task->signal->adj_node);
spin_unlock(&lmk_lock);
if (!next)
return NULL;
- return rb_entry(next, struct task_struct, adj_node);
+ next_tsk_sig = rb_entry(next, struct signal_struct, adj_node);
+ return next_tsk_sig->curr_target->group_leader;
}
static struct task_struct *pick_first_task(void)
{
struct rb_node *left;
+ struct signal_struct *first_tsk_sig;
spin_lock(&lmk_lock);
left = rb_first(&tasks_scoreadj);
@@ -483,12 +492,14 @@ static struct task_struct *pick_first_task(void)
if (!left)
return NULL;
- return rb_entry(left, struct task_struct, adj_node);
+ first_tsk_sig = rb_entry(left, struct signal_struct, adj_node);
+ return first_tsk_sig->curr_target->group_leader;
}
static struct task_struct *pick_last_task(void)
{
struct rb_node *right;
+ struct signal_struct *last_tsk_sig;
spin_lock(&lmk_lock);
right = rb_last(&tasks_scoreadj);
@@ -497,7 +508,8 @@ static struct task_struct *pick_last_task(void)
if (!right)
return NULL;
- return rb_entry(right, struct task_struct, adj_node);
+ last_tsk_sig = rb_entry(right, struct signal_struct, adj_node);
+ return last_tsk_sig->curr_target->group_leader;
}
#endif