On Tue, 17 Aug 2010 19:36:02 -0700 (PDT) David Rientjes <rientjes@xxxxxxxxxx> wrote: > On Wed, 18 Aug 2010, KAMEZAWA Hiroyuki wrote: > > > > The oom killer's goal is to kill a memory-hogging task so that it may > > > exit, free its memory, and allow the current context to allocate the > > > memory that triggered it in the first place. Thus, killing a task is > > > pointless if other threads sharing its mm cannot be killed because of its > > > /proc/pid/oom_adj or /proc/pid/oom_score_adj value. > > > > > > This patch checks all user threads on the system to determine whether > > > oom_badness(p) should return 0 for p, which means it should not be killed. > > > If a thread shares p's mm and is unkillable, p is considered to be > > > unkillable as well. > > > > > > Kthreads are not considered toward this rule since they only temporarily > > > assume a task's mm via use_mm(). > > > > > > Signed-off-by: David Rientjes <rientjes@xxxxxxxxxx> > > > > Acked-by: KAMEZAWA Hiroyuki <kamezawa.hiroyu@xxxxxxxxxxxxxx> > > > > Thanks! > > > Thank you. BTW, do you have good idea for speed-up ? > > This code seems terribly slow when a system has many processes. > > > > 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. 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) Maybe no new lock is required and this not-accurate one will work enough. Thanks, -Kame -- 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>