Re: [PATCH 5/5] oom: dump_tasks() use find_lock_task_mm() too

From: KOSAKI Motohiro
Date: Wed Jun 02 2010 - 20:41:59 EST


> On Thu, Jun 3, 2010 at 9:06 AM, KOSAKI Motohiro
> <kosaki.motohiro@xxxxxxxxxxxxxx> wrote:
> > Hi
> >
> >> > @@ -344,35 +344,30 @@ static struct task_struct *select_bad_process(unsigned long *ppoints,
> >> > Â */
> >> > Âstatic void dump_tasks(const struct mem_cgroup *mem)
> >> > Â{
> >> > - Â struct task_struct *g, *p;
> >> > + Â struct task_struct *p;
> >> > + Â struct task_struct *task;
> >> >
> >> >   printk(KERN_INFO "[ pid ]  uid Âtgid total_vm   Ârss cpu oom_adj "
> >> > Â Â Â Â Â Â"name\n");
> >> > - Â do_each_thread(g, p) {
> >> > +
> >> > + Â for_each_process(p) {
> >> > Â Â Â Â Â Â struct mm_struct *mm;
> >> >
> >> > - Â Â Â Â Â if (mem && !task_in_mem_cgroup(p, mem))
> >> > + Â Â Â Â Â if (is_global_init(p) || (p->flags & PF_KTHREAD))
> >>
> >> select_bad_process needs is_global_init check to not select init as victim.
> >> But in this case, it is just for dumping information of tasks.
> >
> > But dumping oom unrelated process is useless and making confusion.
> > Do you have any suggestion? Instead, adding unkillable field?
>
> I think it's not unrelated. Of course, init process doesn't consume
> lots of memory but might consume more memory than old as time goes by
> or some BUG although it is unlikely.
>
> I think whether we print information of init or not isn't a big deal.
> But we have been done it until now and you are trying to change it.
> At least, we need some description why you want to remove it.
> Making confusion? Hmm.. I don't think it make many people confusion.

Hm. ok, I'll change logic as you said.



> >> > - Â Â Â Â Â mm = p->mm;
> >> > - Â Â Â Â Â if (!mm) {
> >> > - Â Â Â Â Â Â Â Â Â /*
> >> > - Â Â Â Â Â Â Â Â Â Â* total_vm and rss sizes do not exist for tasks with no
> >> > - Â Â Â Â Â Â Â Â Â Â* mm so there's no need to report them; they can't be
> >> > - Â Â Â Â Â Â Â Â Â Â* oom killed anyway.
> >> > - Â Â Â Â Â Â Â Â Â Â*/
> >>
> >> Please, do not remove the comment for mm newbies unless you think it's useless.
> >
> > How is this?
> >
> > Â Â Â Â Â Â Â task = find_lock_task_mm(p);
> > Â Â Â Â Â Â Â if (!task)
> > Â Â Â Â Â Â Â Â Â Â Â Â/*
> > Â Â Â Â Â Â Â Â Â Â Â Â * Probably oom vs task-exiting race was happen and ->mm
> > Â Â Â Â Â Â Â Â Â Â Â Â * have been detached. thus there's no need to report them;
> > Â Â Â Â Â Â Â Â Â Â Â Â * they can't be oom killed anyway.
> > Â Â Â Â Â Â Â Â Â Â Â Â */
> > Â Â Â Â Â Â Â Â Â Â Â Âcontinue;
> >
>
> Looks good to adding story about racing. but my point was "total_vm
> and rss sizes do not exist for tasks with no mm". But I don't want to
> bother you due to trivial.
> It depends on you. :)


old ->mm check have two intention.

a) the task is kernel thread?
b) the task have alredy detached ->mm

but a) is not strictly correct check because we should think use_mm().
therefore we appended PF_KTHREAD check. then, here find_lock_task_mm()
focus exiting race, I think.




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