Re: [PATCH v3] staging: android/lowmemorykiller: Don't grabtasklist_lock

From: Oleg Nesterov
Date: Fri Feb 03 2012 - 11:43:40 EST


On 02/03, Anton Vorontsov wrote:
>
> @@ -132,7 +133,7 @@ static int lowmem_shrink(struct shrinker *s, struct shrink_control *sc)
> }
> selected_oom_adj = min_adj;
>
> - read_lock(&tasklist_lock);
> + rcu_read_lock();
> for_each_process(p) {
> struct mm_struct *mm;
> struct signal_struct *sig;
> @@ -180,12 +181,12 @@ static int lowmem_shrink(struct shrinker *s, struct shrink_control *sc)
> lowmem_deathpending = selected;
> task_handoff_register(&task_nb);
> #endif
> - force_sig(SIGKILL, selected);
> + send_sig(SIGKILL, selected, 0);
> rem -= selected_tasksize;
> }
> lowmem_print(4, "lowmem_shrink %lu, %x, return %d\n",
> sc->nr_to_scan, sc->gfp_mask, rem);
> - read_unlock(&tasklist_lock);
> + rcu_read_unlock();

I think this is correct. As for ->mm check please look at
find_lock_task_mm().

You can also remove the !sig check.

And, forgot to mention. There is another reason why mm != NULL
check is wrong (send_sig_all too). A kernel thread can do use_mm().
You should also check PF_KTHREAD.

Oleg.

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/