Re: [patch v2 1/2] oom: avoid killing a task if a thread sharing its mm cannot be killed

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Wed, 18 Aug 2010, KAMEZAWA Hiroyuki wrote:

> > I was thinking about adding an "unsinged long oom_kill_disable_count" to 
> > struct mm_struct that would atomically increment anytime a task attached 
> > to it had a signal->oom_score_adj of OOM_SCORE_ADJ_MIN.
> > 
> > The proc handler when changing /proc/pid/oom_score_adj would inc or dec 
> > the counter depending on the new value, and exit_mm() would dec the 
> > counter if current->signal->oom_score_adj is OOM_SCORE_ADJ_MIN.
> > 
> > What do you think?
> > 
> 
> Hmm. I want to make hooks to "exit" small. 
> 


Is it worth adding

	if (unlikely(current->signal->oom_score_adj == OOM_SCORE_ADJ_MIN))
		atomic_dec(&current->mm->oom_disable_count);

to exit_mm() under task_lock() to avoid the O(n^2) select_bad_process() on 
oom?  Or do you think that's too expensive?

> One idea is.
> 
> add a new member
> 		mm->unkiilable_by_oom_jiffies.
> 
> And add
> > +static bool is_mm_unfreeable(struct mm_struct *mm)
> > +{
> > +	struct task_struct *p;
> > +
> 	if (mm->unkillable_by_oom_jiffies < jiffies)
> 		return true;
> 
> > +	for_each_process(p)
> > +		if (p->mm == mm && !(p->flags & PF_KTHREAD) &&
> > +		    p->signal->oom_score_adj == OOM_SCORE_ADJ_MIN) 
> 
> 			mm->unkillable_by_oom_jiffies = jiffies + HZ;
> 
> > +			return true;
> > +	return false;
> > +}+static bool is_mm_unfreeable(struct mm_struct *mm)
> 

This probably isn't fast enough for the common case, which is when no 
tasks for "mm" have an oom_score_adj of OOM_SCORE_ADJ_MIN, since it still 
iterates through every task.

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@xxxxxxxxxx  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@xxxxxxxxx";> email@xxxxxxxxx </a>


[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Bugtraq]     [Linux]     [Linux OMAP]     [Linux MIPS]     [ECOS]     [Asterisk Internet PBX]     [Linux API]