Re: [PATCH 4/6] staging: android/lowmemorykiller: Better mm handling

From: KOSAKI Motohiro
Date: Mon Feb 06 2012 - 16:37:02 EST


>  static int lowmem_shrink(struct shrinker *s, struct shrink_control *sc)
>  {
> -       struct task_struct *p;
> +       struct task_struct *tsk;
>        struct task_struct *selected = NULL;
>        int rem = 0;
>        int tasksize;
> @@ -134,15 +134,17 @@ static int lowmem_shrink(struct shrinker *s, struct shrink_control *sc)
>        selected_oom_adj = min_adj;
>
>        rcu_read_lock();
> -       for_each_process(p) {
> -               struct mm_struct *mm;
> +       for_each_process(tsk) {
> +               struct task_struct *p;
>                struct signal_struct *sig;
>                int oom_adj;
>
> -               task_lock(p);
> -               mm = p->mm;
> +               p = find_lock_task_mm(tsk);
> +               if (!p)
> +                       continue;
> +
>                sig = p->signal;
> -               if (!mm || !sig) {
> +               if (!sig) {
>                        task_unlock(p);
>                        continue;
>                }
> @@ -151,7 +153,7 @@ static int lowmem_shrink(struct shrinker *s, struct shrink_control *sc)
>                        task_unlock(p);
>                        continue;
>                }
> -               tasksize = get_mm_rss(mm);
> +               tasksize = get_mm_rss(p->mm);
>                task_unlock(p);
>                if (tasksize <= 0)
>                        continue;

ack.
--
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/