Received: by 10.192.165.148 with SMTP id m20csp137786imm; Fri, 4 May 2018 07:56:17 -0700 (PDT) X-Google-Smtp-Source: AB8JxZo5IFLWqjenUTmVn+0mvmJzudN5Cc959/uG4Gf0sw7CVzcJldIrIpQ8VXi47XCd2m8E4TPn X-Received: by 2002:a17:902:b702:: with SMTP id d2-v6mr23301284pls.228.1525445777058; Fri, 04 May 2018 07:56:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1525445777; cv=none; d=google.com; s=arc-20160816; b=fPcgAd8Eg5oMmC1ayik9MyxtMSqMs2Mos5LAmgJ31z+yJoG6S7qyg4XJ9c2PrnmHhH LJP5uPDhFqFHL9yE+zKVrD9i7dAQaapkCPkjAVgd7IHgPK4jeb6zqSZaQN9nV8v1fSNv lKs1qpCLilYKEdgIMO7fC4coqJuRN0FmeyOXSgNkkVKBoeVh4qgl26uzz4H09lhUx3zE 1oiOjQgMN5FJ95Ot6Dx2IVBjxIoifw4WBktDOH+pTPU4uOjoqe+fjIiSfvwVEJl4ZX/d Wr0+BGM29Cb16EbjqcItGI5L4S41F0X5CT8VpG6O8txoVbWjZ7LzDcp9j8XNXa6/T1AG XuBA== 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=zV3Qp9F8Aq14fgPXsVwsJoz3Pwi6iRAoxlYF9kE7Vec=; b=MFngCXFuM1deurePFW8M/u50iKJBWAIytmwLoQSPO0SZXYUNGN6jKt8FabMuxzj5o5 k5jZfDiwzl7GKeX8GgH5EnnFpNhyNL7eA42FFa0Eb4HlKbvhSW4Fjhofs0Lvtk/0qqwA j8x772nstamjcQfUovsqFVhnTJD6fhtPqPuH3F74cW6yLHXIJHfwmzjqDIJlzZpm9z9X dTWrZRPclX2k1lRzp+7wRlTzr5XHLd3nOhzjG1wZcZVR2yQEid6VQord7kMIJq4E2sJp X2grplIi+ks0eEo9FixdeXxdkznYUYwb4REYboCIBwzl5vtbVn9GnK4TRM41i/3ytbHb C8rw== 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 w5-v6si15083107plz.587.2018.05.04.07.56.01; Fri, 04 May 2018 07:56:17 -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 S1751314AbeEDOyl (ORCPT + 99 others); Fri, 4 May 2018 10:54:41 -0400 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:46326 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1750707AbeEDOyk (ORCPT ); Fri, 4 May 2018 10:54:40 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 3375E722C3; Fri, 4 May 2018 14:54:40 +0000 (UTC) Received: from dhcp-27-174.brq.redhat.com (unknown [10.34.27.30]) by smtp.corp.redhat.com (Postfix) with SMTP id 4EB632023272; Fri, 4 May 2018 14:54:36 +0000 (UTC) Received: by dhcp-27-174.brq.redhat.com (nbSMTP-1.00) for uid 1000 oleg@redhat.com; Fri, 4 May 2018 16:54:39 +0200 (CEST) Date: Fri, 4 May 2018 16:54:35 +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: <20180504145435.GA26573@redhat.com> References: <87r2n01q58.fsf@xmission.com> <87o9hz2sw3.fsf@xmission.com> <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> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <87r2mrh4is.fsf@xmission.com> User-Agent: Mutt/1.5.24 (2015-08-30) X-Scanned-By: MIMEDefang 2.78 on 10.11.54.4 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.2]); Fri, 04 May 2018 14:54:40 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.2]); Fri, 04 May 2018 14:54:40 +0000 (UTC) for IP:'10.11.54.4' DOMAIN:'int-mx04.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: > > > OK, what about exec() ? mm_init_memcg() initializes bprm->mm->memcg early in > > bprm_mm_init(). What if the execing task migrates before exec_mmap() ? > > We need the the cgroup when the mm is initialized. That way we have the > cgroup information when initializing the mm. Yes, we need to initialize new_mm->memcg but iiuc mostly for the error path, > I don't know if a lock preventing changing the cgroup in exec or just > a little bit of code in exec_mmap to ensure mm->memcg is properly set > is the better approach. I'd vote for the change in exec_mmap(). This way mm_init_memcg() can just nullify mm->memcg. > This does look like a very good place for an incremental patch to close > that race. Hmm. I think v2 makes more sense, but I won't argue. Oleg.