Re: [patch 1/3 v3] oom: add per-mm oom disable count

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

 



> > > > > @@ -1690,6 +1697,10 @@ SYSCALL_DEFINE1(unshare, unsigned long, unshare_flags)
> > > > >  			active_mm = current->active_mm;
> > > > >  			current->mm = new_mm;
> > > > >  			current->active_mm = new_mm;
> > > > > +			if (current->signal->oom_score_adj == OOM_SCORE_ADJ_MIN) {
> > > > > +				atomic_dec(&mm->oom_disable_count);
> > > > > +				atomic_inc(&new_mm->oom_disable_count);
> > > > > +			}
> > > > >  			activate_mm(active_mm, new_mm);
> > > > >  			new_mm = mm;
> > > > >  		}
> > > > 
> > > > This place, we are grabbing task_lock(), but task_lock don't prevent
> > > > to change signal->oom_score_adj from another thread. This seems racy.
> > > > 
> > > 
> > > It does, task_lock(current) protects current->signal->oom_score_adj from 
> > > changing in oom-add-per-mm-oom-disable-count.patch.
> > > 
> > > I'll add the task_lock(p) in mm_init(), thanks for the review!
> > 
> > Wait, can you please elabolate more? task_lock() only lock one thread.
> > Why can it protect multi-thread race?
> > 
> 
> We take task_lock(tsk) whenever we change tsk->signal->oom_score_adj.

example, Process P1 has threads T1 and T2.
oom_score_adj_write() take task_lock(T1) and siglock(P1). unshare() take
task_lock(T2). How protect?





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