Received: by 10.192.165.148 with SMTP id m20csp230550imm; Fri, 4 May 2018 09:23:00 -0700 (PDT) X-Google-Smtp-Source: AB8JxZoS9q41mBMH6zEnXvscVK9cn7Y7KFrM2eIeuItO5bjXW65IzgeRaQBcgeGTGLqxP2mdhVgE X-Received: by 2002:a63:705d:: with SMTP id a29-v6mr23068933pgn.202.1525450980356; Fri, 04 May 2018 09:23:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1525450980; cv=none; d=google.com; s=arc-20160816; b=zTUoMLzH92fKF6+7DT9BEr3qfiG4VbD+47+XOlWkyJwsvbgSfKpDJOhe7aQm4an2XU S35OaWyoheT0uBF8pVULjk/EhUqqfxUZLCcUcROiqfpO7TZ+IHRnhlJhVFoBk/n1KXza wpRA9XvIS2bwNQkEbh4vbQ4xgzVlmZzGs4ojbcjf/nXbcvwmJSLU7uR8f/9LRQ2AkQUX 7T11UTfBBLsZkkUbw6Bxzk7cyQ1dCmj4jx1lxUj5Ui3h9aiSlkvAMxXXnwGKPZjD6zEA 9O2czbqYMct7ERKCeC48c9JGI0pagR7nX85H7j0tvpUxfBUuoODs4+vGkT0tXIU3htaX hbpA== 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=nSYLJea9S/YyQ/G+G3LYE1NREUgf/JHFYcRSXnxKvOI=; b=Tjwz2kGCmVsOdK8f3Yof34mh4eVlsU8Mkm0Z4vxjaVihEkWA22LAJsMZ4Snpp3PjV4 iyAvFudOyWWYlrLInBGz8cNP6iLiBsfDjEfaMWHxMZte6sbn/EvfDouF1C4sJhSz3maX ogEEas6I1Kuki9LNPkUTEl+7EY0q4+7gX2MuHt2X62Vjlh1i/JETHiT2Ya6I6XKSfiH0 G+WroyJiVv//d0ze8Zbyv45F/DZHwbmUrMGq8rNZlNVRZDI+2VckRWKqt24y1HDi1OjH 1IOgREJG9ukIn/4Kt/3QF26uPb1Ap2AqwoVqMgejTWpQRlzRblcbM+V1nJpgp6KQWrYv kMUg== 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 90-v6si15998427plc.205.2018.05.04.09.22.45; Fri, 04 May 2018 09:23:00 -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 S1751701AbeEDQWP (ORCPT + 99 others); Fri, 4 May 2018 12:22:15 -0400 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:37546 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751425AbeEDQWO (ORCPT ); Fri, 4 May 2018 12:22:14 -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 CBE56406C745; Fri, 4 May 2018 16:22:13 +0000 (UTC) Received: from dhcp-27-174.brq.redhat.com (unknown [10.34.27.30]) by smtp.corp.redhat.com (Postfix) with SMTP id 428172166BAD; Fri, 4 May 2018 16:22:10 +0000 (UTC) Received: by dhcp-27-174.brq.redhat.com (nbSMTP-1.00) for uid 1000 oleg@redhat.com; Fri, 4 May 2018 18:22:13 +0200 (CEST) Date: Fri, 4 May 2018 18:22:09 +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: <20180504162209.GB26573@redhat.com> References: <87h8nr2sa3.fsf_-_@xmission.com> <20180502084708.GC26305@dhcp22.suse.cz> <20180502132026.GB16060@cmpxchg.org> <87lgd1zww0.fsf_-_@xmission.com> <20180503133338.GA23401@redhat.com> <87y3h0x0qg.fsf@xmission.com> <20180504142056.GA26151@redhat.com> <87r2mrh4is.fsf@xmission.com> <20180504145435.GA26573@redhat.com> <87y3gzfmjt.fsf@xmission.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <87y3gzfmjt.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.5]); Fri, 04 May 2018 16:22:13 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.5]); Fri, 04 May 2018 16:22:13 +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/04, Eric W. Biederman wrote: > > Oleg Nesterov writes: > > > I'd vote for the change in exec_mmap(). This way mm_init_memcg() can just > > nullify mm->memcg. > > There is at least one common path where we need the memory control group > properly initialized so memory allocations don't escape the memory > control group. > > do_execveat_common > copy_strings > get_arg_page > get_user_pages_remote > __get_user_pages_locked > __get_user_pages > faultin_page > handle_mm_fault > count_memcg_event_mm > __handle_mm_fault > handle_pte_fault > do_anonymous_page > mem_cgroup_try_charge > > I am surprised I can't easily find more. Apparently in load_elf_binary > we call elf_mmap after set_new_exec and install_exec_creds, making > a gracefull recovery from elf_mmap failures impossible. > > In any case we most definitely need the memory control group properly > setup before exec_mmap. Confused ... new_mm->memcg has no effect until exec_mmap(), why it can't be NULL ? and why do you think mem_cgroup_try_charge() can use the wrong memcg in this case? Oleg.