Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1408935

Re: [PATCH 3/6] mm, oom_adj: make sure processes sharing mm have same view of oom_score_adj

From Vladimir Davydov <vdavydov@virtuozzo.com>
Newsgroups linux.kernel
Subject Re: [PATCH 3/6] mm, oom_adj: make sure processes sharing mm have same view of oom_score_adj
Date 2016-05-30 11:30 +0200
Message-ID <rErGh-2in-15@gated-at.bofh.it> (permalink)
References <rD2TD-6uy-5@gated-at.bofh.it> <rD2TE-6uy-27@gated-at.bofh.it> <rDnY6-2JR-17@gated-at.bofh.it> <rDsEq-5Ht-27@gated-at.bofh.it> <rEpuP-YG-47@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


On Mon, May 30, 2016 at 09:07:05AM +0200, Michal Hocko wrote:
> On Fri 27-05-16 19:18:21, Vladimir Davydov wrote:
> > On Fri, May 27, 2016 at 01:18:03PM +0200, Michal Hocko wrote:
> > ...
> > > @@ -1087,7 +1105,25 @@ static int __set_oom_adj(struct file *file, int oom_adj, bool legacy)
> > >  	unlock_task_sighand(task, &flags);
> > >  err_put_task:
> > >  	put_task_struct(task);
> > > +
> > > +	if (mm) {
> > > +		struct task_struct *p;
> > > +
> > > +		rcu_read_lock();
> > > +		for_each_process(p) {
> > > +			task_lock(p);
> > > +			if (!p->vfork_done && process_shares_mm(p, mm)) {
> > > +				p->signal->oom_score_adj = oom_adj;
> > > +				if (!legacy && has_capability_noaudit(current, CAP_SYS_RESOURCE))
> > > +					p->signal->oom_score_adj_min = (short)oom_adj;
> > > +			}
> > > +			task_unlock(p);
> > 
> > I.e. you write to /proc/pid1/oom_score_adj and get
> > /proc/pid2/oom_score_adj updated if pid1 and pid2 share mm?
> > IMO that looks unexpected from userspace pov.
> 
> How much different it is from threads in the same thread group?
> Processes sharing the mm without signals is a rather weird threading
> model isn't it?

I think so too. I wouldn't be surprised if it turned out that nobody had
ever used it. But may be there's someone out there who does.

> Currently we just lie to users about their oom_score_adj
> in this weird corner case.

Hmm, looks like a bug, but nobody has ever complained about it.

> The only exception was OOM_SCORE_ADJ_MIN
> where we really didn't kill the task but all other values are simply
> ignored in practice.
> 
> > May be, we'd better add mm->oom_score_adj and set it to the min
> > signal->oom_score_adj over all processes sharing it? This would
> > require iterating over all processes every time oom_score_adj gets
> > updated, but that's a slow path.
> 
> Not sure I understand. So you would prefer that mm->oom_score_adj might
> disagree with p->signal->oom_score_adj?

No, I wouldn't. I'd rather agree that oom_score_adj should be per mm,
because we choose the victim basing solely on mm stats.

What I mean is we don't touch p->signal->oom_score_adj of other tasks
sharing mm, but instead store minimal oom_score_adj over all tasks
sharing mm in the mm_struct whenever a task's oom_score_adj is modified.
And use mm->oom_score_adj instead of signal->oom_score_adj in oom killer
code. This would save us from any accusations of user API modifications
and it would also make the oom code a bit easier to follow IMHO.

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

[PATCH 0/5] Handle oom bypass more gracefully Michal Hocko <mhocko@kernel.org> - 2016-05-26 14:50 +0200
  [PATCH 3/6] mm, oom_adj: make sure processes sharing mm have same view of oom_score_adj Michal Hocko <mhocko@kernel.org> - 2016-05-26 14:50 +0200
    Re: [PATCH 3/6] mm, oom_adj: make sure processes sharing mm have  same view of oom_score_adj Michal Hocko <mhocko@kernel.org> - 2016-05-27 13:20 +0200
      Re: [PATCH 3/6] mm, oom_adj: make sure processes sharing mm have  same view of oom_score_adj Vladimir Davydov <vdavydov@virtuozzo.com> - 2016-05-27 18:20 +0200
        Re: [PATCH 3/6] mm, oom_adj: make sure processes sharing mm have  same view of oom_score_adj Michal Hocko <mhocko@kernel.org> - 2016-05-30 09:10 +0200
          Re: [PATCH 3/6] mm, oom_adj: make sure processes sharing mm have  same view of oom_score_adj Vladimir Davydov <vdavydov@virtuozzo.com> - 2016-05-30 11:30 +0200
            Re: [PATCH 3/6] mm, oom_adj: make sure processes sharing mm have  same view of oom_score_adj Michal Hocko <mhocko@kernel.org> - 2016-05-30 11:50 +0200
              Re: [PATCH 3/6] mm, oom_adj: make sure processes sharing mm have  same view of oom_score_adj Vladimir Davydov <vdavydov@virtuozzo.com> - 2016-05-30 12:50 +0200
                Re: [PATCH 3/6] mm, oom_adj: make sure processes sharing mm have  same view of oom_score_adj Michal Hocko <mhocko@kernel.org> - 2016-05-30 13:20 +0200
                Re: [PATCH 3/6] mm, oom_adj: make sure processes sharing mm have  same view of oom_score_adj Vladimir Davydov <vdavydov@virtuozzo.com> - 2016-05-30 14:30 +0200
                Re: [PATCH 3/6] mm, oom_adj: make sure processes sharing mm have  same view of oom_score_adj Michal Hocko <mhocko@kernel.org> - 2016-05-30 14:30 +0200
  [PATCH 1/6] mm, oom: do not loop over all tasks if there are no external tasks sharing mm Michal Hocko <mhocko@kernel.org> - 2016-05-26 14:50 +0200
    Re: [PATCH 1/6] mm, oom: do not loop over all tasks if there are no external tasks sharing mm Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp> - 2016-05-26 16:40 +0200
      Re: [PATCH 1/6] mm, oom: do not loop over all tasks if there are no  external tasks sharing mm Michal Hocko <mhocko@kernel.org> - 2016-05-26 17:00 +0200
        Re: [PATCH 1/6] mm, oom: do not loop over all tasks if there are noexternal tasks sharing mm Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp> - 2016-05-26 17:30 +0200
          Re: [PATCH 1/6] mm, oom: do not loop over all tasks if there are  noexternal tasks sharing mm Michal Hocko <mhocko@kernel.org> - 2016-05-26 17:40 +0200
            Re: [PATCH 1/6] mm, oom: do not loop over all tasks if there are no external tasks sharing mm Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp> - 2016-05-26 18:20 +0200
              Re: [PATCH 1/6] mm, oom: do not loop over all tasks if there are no  external tasks sharing mm Michal Hocko <mhocko@kernel.org> - 2016-05-27 08:50 +0200
                Re: [PATCH 1/6] mm, oom: do not loop over all tasks if there are no  external tasks sharing mm Michal Hocko <mhocko@kernel.org> - 2016-05-27 09:20 +0200
                Re: [PATCH 1/6] mm, oom: do not loop over all tasks if there are no  external tasks sharing mm Michal Hocko <mhocko@kernel.org> - 2016-05-27 10:10 +0200
  [PATCH 2/6] proc, oom_adj: extract oom_score_adj setting into a helper Michal Hocko <mhocko@kernel.org> - 2016-05-26 14:50 +0200
  Re: [PATCH 0/5] Handle oom bypass more gracefully Michal Hocko <mhocko@kernel.org> - 2016-05-27 18:10 +0200

csiph-web