lkml.org 
[lkml]   [2018]   [Aug]   [1]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH 3/3] mm, oom: introduce memory.oom.group
On Wed, Aug 01, 2018 at 07:55:03AM +0200, Michal Hocko wrote:
> On Tue 31-07-18 18:14:48, Roman Gushchin wrote:
> > On Tue, Jul 31, 2018 at 11:07:00AM +0200, Michal Hocko wrote:
> > > On Mon 30-07-18 11:01:00, Roman Gushchin wrote:
> > > > +struct mem_cgroup *mem_cgroup_get_oom_group(struct task_struct *victim,
> > > > + struct mem_cgroup *oom_domain)
> > > > +{
> > > > + struct mem_cgroup *oom_group = NULL;
> > > > + struct mem_cgroup *memcg;
> > > > +
> > > > + if (!cgroup_subsys_on_dfl(memory_cgrp_subsys))
> > > > + return NULL;
> > > > +
> > > > + if (!oom_domain)
> > > > + oom_domain = root_mem_cgroup;
> > > > +
> > > > + rcu_read_lock();
> > > > +
> > > > + memcg = mem_cgroup_from_task(victim);
> > > > + if (!memcg || memcg == root_mem_cgroup)
> > > > + goto out;
> > >
> > > When can we have memcg == NULL? victim should be always non-NULL.
> > > Also why do you need to special case the root_mem_cgroup here. The loop
> > > below should handle that just fine no?
> >
> > Idk, I prefer to keep an explicit root_mem_cgroup check,
> > rather than traversing the tree and relying on an inability
> > to set oom_group on the root.
>
> I will not insist but this just makes the code harder to read.

Just FYI, I'd prefer the explicit check. The loop would do the right
thing, but it's a little too implicit and subtle for my taste...

\
 
 \ /
  Last update: 2018-08-01 19:45    [W:0.089 / U:3.108 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site