Re: [patch] oom: give current access to memory reserves if it hasbeen killed

From: David Rientjes
Date: Thu Apr 01 2010 - 15:12:42 EST


On Thu, 1 Apr 2010, Oleg Nesterov wrote:

> > > @@ -159,13 +172,9 @@ unsigned int oom_badness(struct task_str
> > > if (p->flags & PF_OOM_ORIGIN)
> > > return 1000;
> > >
> > > - task_lock(p);
> > > - mm = p->mm;
> > > - if (!mm) {
> > > - task_unlock(p);
> > > + p = find_lock_task_mm(p);
> > > + if (!p)
> > > return 0;
> > > - }
> > > -
> > > /*
> > > * The baseline for the badness score is the proportion of RAM that each
> > > * task's rss and swap space use.
> > > @@ -330,12 +339,6 @@ static struct task_struct *select_bad_pr
> > > *ppoints = 1000;
> > > }
> > >
> > > - /*
> > > - * skip kernel threads and tasks which have already released
> > > - * their mm.
> > > - */
> > > - if (!p->mm)
> > > - continue;
> > > if (p->signal->oom_score_adj == OOM_SCORE_ADJ_MIN)
> > > continue;
> >
> > You can't do this for the reason I cited in another email, oom_badness()
> > returning 0 does not exclude a task from being chosen by
> > selcet_bad_process(), it will use that task if nothing else has been found
> > yet. We must explicitly filter it from consideration by checking for
> > !p->mm.
>
> Yes, you are right. OK, oom_badness() can never return points < 0,
> we can make it int and oom_badness() can return -1 if !mm. IOW,
>
> - unsigned int points;
> + int points;
> ...
>
> points = oom_badness(...);
> if (points >= 0 && (points > *ppoints || !chosen))
> chosen = p;
>

oom_badness() and its predecessor badness() in mainline never return
negative scores, so I don't see the value in doing this; just filter the
task in select_bad_process() with !p->mm as it has always been done.
--
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/