[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20180510123843.GB29222@redhat.com>
Date: Thu, 10 May 2018 14:38:43 +0200
From: Oleg Nesterov <oleg@...hat.com>
To: "Eric W. Biederman" <ebiederm@...ssion.com>
Cc: Johannes Weiner <hannes@...xchg.org>,
Michal Hocko <mhocko@...nel.org>,
Kirill Tkhai <ktkhai@...tuozzo.com>, akpm@...ux-foundation.org,
peterz@...radead.org, viro@...iv.linux.org.uk, mingo@...nel.org,
paulmck@...ux.vnet.ibm.com, keescook@...omium.org, riel@...hat.com,
tglx@...utronix.de, kirill.shutemov@...ux.intel.com,
marcos.souza.org@...il.com, hoeun.ryu@...il.com,
pasha.tatashin@...cle.com, gs051095@...il.com, dhowells@...hat.com,
rppt@...ux.vnet.ibm.com, linux-kernel@...r.kernel.org,
Balbir Singh <balbir@...ux.vnet.ibm.com>,
Tejun Heo <tj@...nel.org>
Subject: Re: [PATCH] memcg: Replace mm->owner with mm->memcg
On 05/09, Eric W. Biederman wrote:
>
> Oleg Nesterov <oleg@...hat.com> writes:
>
> >> The patch does solve the issue. There should be nothing a userspace
> >> process can observe that should tell it where in the middle of exec
> >> such a migration happend so placing the migration at what from the
> >> kernel's perspective might be technically later should not be a problem.
> >>
> >> If it is a problem the issue is that there is a way to observe the
> >> difference.
> >
> > So. The task migrates from some MEMCG right after bprm_mm_init().
> >
> > copy_strings() triggers OOM in MEMCG. This is quite possible, it can use a lot
> > of memory and that is why we have acct_arg_size() to make these allocations
> > visible to oom killer.
> >
> > task_in_mem_cgroup(MEMCG) returns false and oom killer has to kill another
> > innocent process in MEMCG.
> >
> > Does this look like a way to observe the difference?
>
> Sort of.
>
> I don't know how the memcg gets away without migrating charges
> when it migrates a process. With charges not being migrated
> I don't think this is observable.
Not sure I understand how this connects to accounting...
But yes sure, with or without your change, mem_cgroup_move_task() obviously
can't see the the nascent bprm->mm. I have no idea if this is important or
not, and iiuc cgroup v2 doesn't even support ->move_charge_at_immigrate.
As for accounting, I still think that it would be better to nullify ->memcg in
mm_init_memcg(), simply because we can not initialize it properly, we can race
with migration until exec_mmap/cgroup_post_fork which need to update ->memcg
anyway.
Yes, this means a special case in get_mem_cgroup_from_mm().
Oleg.
> That does look like a real issue however.
>
> >> > Perhaps we can change get_mem_cgroup_from_mm() to use
> >> > mem_cgroup_from_css(current, memory_cgrp_id) if mm->memcg == NULL?
> >>
> >> Please God no. Having any unnecessary special case is just going to
> >> confuse people and cause bugs.
> >
> > To me the unnecessary special case is the new_mm->memcg which is used for
> > accounting but doesn't follow migration till exec_mmap(). But I won't
> > argue.
>
> Eric
Powered by blists - more mailing lists