Received: by 10.192.165.148 with SMTP id m20csp1094007imm; Thu, 10 May 2018 05:39:13 -0700 (PDT) X-Google-Smtp-Source: AB8JxZqTvVU33atSnjdPzOEN2DAJmGNdOxos52JomyjHmyhLYMw9IgjUbBqQ/5OFu5Brq6S968Iy X-Received: by 2002:a65:4204:: with SMTP id c4-v6mr1046756pgq.26.1525955953445; Thu, 10 May 2018 05:39:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1525955953; cv=none; d=google.com; s=arc-20160816; b=QCS9tOcEyzQF+lqVcw8lpOAB7bxoMxooTbaDAgk3KrXN0kiOd27godC8zUZLtbzab5 F3JP1NITEkCVGQ7H8t7C+Ta+qIWhgm+6pjsym1O9A2wgy9b1M2C4NLj3lBTAP27uaZDr 0wc4cU715XGy5eLv3enFz6dJBhBml0iKq7PeoA7gAqozs3qupwNYOgPvjlaTZhmOIRRj jXxEsksngsyicLRzyEF0kXC0W3BJiv/bLGpqc3kgo/RBzlXevzwB9j4v7PQX44Lgfo9d hqBWbYKQDOAo5VH0jmQwZAF/FF6eM5Fw0xrzzQUfIlm9ASXzejK3UBH9VnVH2L0RqDwj bHEQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:arc-authentication-results; bh=73/SUtv1zLlTvaDtGgC9vtOoKbiJLo6s9EfIxQ3Mz7E=; b=cZbGH1g4wRPP/3nF2NV+vdqPUnkUogxs75MLQwGzj+k16XUg0fvXUye/gXE9xOGGF8 9bnyuODMEC31F5tJmR78ZcO4o6csAf5qQHRtA2D195eWmGyFNEUykOfMXECX/ZJWhyoc 0lcPtnhXYQACmkGaNDsHzMPWRRbelLG9uf7dGfiRSxAyWkHnaRWpzVPfz0gcP8shYwke hSr2CXv57RaGmYy9d8EpcJGS7XsMVa6lFT/DryabYbDPDXukuCM0A1GPQwl7IbUrL0Jg oEFL5P7zKh+L+91/X0rmnIsK10mMaXogi4oCejla8kDVVAYw4u9h79+dP9rYhuhjtwY5 OX6A== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id v12-v6si797782plg.180.2018.05.10.05.38.58; Thu, 10 May 2018 05:39:13 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757325AbeEJMit (ORCPT + 99 others); Thu, 10 May 2018 08:38:49 -0400 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:57482 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1757217AbeEJMis (ORCPT ); Thu, 10 May 2018 08:38:48 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 698B7EC000; Thu, 10 May 2018 12:38:47 +0000 (UTC) Received: from dhcp-27-174.brq.redhat.com (unknown [10.34.27.30]) by smtp.corp.redhat.com (Postfix) with SMTP id 21799215CDA7; Thu, 10 May 2018 12:38:44 +0000 (UTC) Received: by dhcp-27-174.brq.redhat.com (nbSMTP-1.00) for uid 1000 oleg@redhat.com; Thu, 10 May 2018 14:38:47 +0200 (CEST) Date: Thu, 10 May 2018 14:38:43 +0200 From: Oleg Nesterov To: "Eric W. Biederman" Cc: Johannes Weiner , Michal Hocko , Kirill Tkhai , akpm@linux-foundation.org, peterz@infradead.org, viro@zeniv.linux.org.uk, mingo@kernel.org, paulmck@linux.vnet.ibm.com, keescook@chromium.org, riel@redhat.com, tglx@linutronix.de, kirill.shutemov@linux.intel.com, marcos.souza.org@gmail.com, hoeun.ryu@gmail.com, pasha.tatashin@oracle.com, gs051095@gmail.com, dhowells@redhat.com, rppt@linux.vnet.ibm.com, linux-kernel@vger.kernel.org, Balbir Singh , Tejun Heo Subject: Re: [PATCH] memcg: Replace mm->owner with mm->memcg Message-ID: <20180510123843.GB29222@redhat.com> References: <20180504142056.GA26151@redhat.com> <87r2mrh4is.fsf@xmission.com> <20180504145435.GA26573@redhat.com> <87y3gzfmjt.fsf@xmission.com> <20180504162209.GB26573@redhat.com> <871serfk77.fsf@xmission.com> <20180507143358.GA3071@redhat.com> <87vabyvnw0.fsf@xmission.com> <20180509144016.GA25742@redhat.com> <87vabwp5p6.fsf@xmission.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <87vabwp5p6.fsf@xmission.com> User-Agent: Mutt/1.5.24 (2015-08-30) X-Scanned-By: MIMEDefang 2.78 on 10.11.54.6 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.1]); Thu, 10 May 2018 12:38:47 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.1]); Thu, 10 May 2018 12:38:47 +0000 (UTC) for IP:'10.11.54.6' DOMAIN:'int-mx06.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'oleg@redhat.com' RCPT:'' Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 05/09, Eric W. Biederman wrote: > > Oleg Nesterov 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