Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp806221imm; Fri, 1 Jun 2018 09:51:25 -0700 (PDT) X-Google-Smtp-Source: ADUXVKKxE2yOopnmUCk/u65sShnkNcrLSCgNfLuzYB6BW5F6rFD1MaghPMnOsiX1/D1rNSHD0WPL X-Received: by 2002:a17:902:2924:: with SMTP id g33-v6mr12032455plb.26.1527871885700; Fri, 01 Jun 2018 09:51:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527871885; cv=none; d=google.com; s=arc-20160816; b=Xt3naXr9DDsy537CRrMSoMPrqeRRmbg6UFBzCo0BhNVt6QJTTt0gDaNKdcl84Ly75I R2xV3Mj9tuMPIGyBQUXaitpeFyJ9DpQAlYNAqj61rhxC3WSGM6ycj5RUvaYkmnBMZqHu g7I2tyhbUEmpyOiWiixRJZPJhLhbOLwXiGeJfLCEtqa/blRHESHUOMoqexf0TngS62ei cPVILfoasrGTATup6osx0CHM7ofT7OWP1YZUFErvI5gnlI6Fztr+nHKU1zTOl4kU9zqy GCcTrMF9HzcYBXwPRkZQLKWmDajnsSzWlx2y8pEPWeNENrscMEGdsDMKeIQVaJDgvrjK sj3Q== 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:dkim-signature:arc-authentication-results; bh=0JPcEa/5w1E4Qz7iaoJZHoHZHHdNZ11eKt5N6gts+fY=; b=1CqPOga/EYyAELBH54uGs6AFQTxWVQXnXhViM1Hu2A4LHj06Din+Ch0Jwnn8E4PqQ5 XvpvvjD23c9OXzN9IXX8XTJnnTLv7+FI0eSuj5OIIyBliS/xLfNzY4dvO1MAaesEYs6f gGicxY9ogNhq9229jUaIL8YAcqsaE0ZDS7kNMAA5OFtZShHeTY+isqxBvY7Nu2jwx/Kc zUHqVvHcoi6J8rxVy8rnjEDcHa/ufRkulaEb592p0GiNlxet5rBSriTz161L6Cv35n0E UkKR4cg8JNu5dtafiOREgRqeqf2IdtIsWUjLTMUaU8rM5ACw/Geeh4M17k9cJCbC9ef7 o9yQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b=jK9HIuRK; 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=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id m28-v6si5418650pgn.197.2018.06.01.09.51.10; Fri, 01 Jun 2018 09:51:25 -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; dkim=fail header.i=@gmail.com header.s=20161025 header.b=jK9HIuRK; 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=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753136AbeFAQuk (ORCPT + 99 others); Fri, 1 Jun 2018 12:50:40 -0400 Received: from mail-yb0-f195.google.com ([209.85.213.195]:37242 "EHLO mail-yb0-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753036AbeFAQui (ORCPT ); Fri, 1 Jun 2018 12:50:38 -0400 Received: by mail-yb0-f195.google.com with SMTP id h141-v6so1747496ybg.4 for ; Fri, 01 Jun 2018 09:50:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=0JPcEa/5w1E4Qz7iaoJZHoHZHHdNZ11eKt5N6gts+fY=; b=jK9HIuRKKkJYLdsynDnTUJYWLKz763YM3aU8v3y2XY9h6ps866RuqLaLt4m0zSGwjF nBQWcAn15RtnQ4ZVU2kQ//dzWvy/aypDYWijU28AINcep9t+QrjYbbDPdt4vLoVLrSrm 3R/sEf0u6+hLDuhutyeo8vxL6wsWuBu30dcFj7Lf+3S4CG72/QblNk1bCoQkpejAK5NS HtX0lNo6Bf0ey5kwVaIxlgQNWBsJsPKFp81VRDId80Mb2G+hE6Mv53AqaNoCh+gykNvc L3VdRcuNfrQDvr4QmFyVuWJZ70ET0IjPUU9BnB0Rb/9uYQ4r0MYCVzsnkQ6zrmXpRb0y 1VIA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:date:from:to:cc:subject:message-id :references:mime-version:content-disposition:in-reply-to:user-agent; bh=0JPcEa/5w1E4Qz7iaoJZHoHZHHdNZ11eKt5N6gts+fY=; b=c3rZwgCiDVE1UQ9aBQkorS6U6idPzAKzCHa8CzJ8ns/5xf6UNl0MFLbytkm9urKvNE RXjn9TfIX6GIKsO9CRjEUSvYjO4FqX59w2P/5MLKj2ubCqD0PqLdkS0TYzo/K/XL1vmO VXuVFGlCW+okywU04tjt7Jt0w9GdDv9PLNuCfSlxLv/eNPFBy9sXZgsrX9KGbNLBD6zX 1npSxZbdQ+OCMakqWkj2wE8SpF9O8yBC8F560dLwa7CtsOmI4GNbwSkf1VdZdsotkmYD 4GFtN/KaUMqyldPb6C3bd1ZPlLbMljRnHDPwrxPHUTfSjZ7wfVbfgvuakg6u+lxqO3lv TNVA== X-Gm-Message-State: ALKqPwdgP6/tNZ/DSQdTC6tmggz1M/HF8w37Y2seXVr/yjgI69qqoMAa XJ28mFDYzBvHQ604EAvoCcM= X-Received: by 2002:a25:4d57:: with SMTP id a84-v6mr6528195ybb.286.1527871837651; Fri, 01 Jun 2018 09:50:37 -0700 (PDT) Received: from localhost ([2620:10d:c091:200::fbb7]) by smtp.gmail.com with ESMTPSA id x124-v6sm6749794ywd.109.2018.06.01.09.50.36 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 01 Jun 2018 09:50:36 -0700 (PDT) Date: Fri, 1 Jun 2018 09:50:34 -0700 From: Tejun Heo To: "Eric W. Biederman" Cc: Michal Hocko , Andrew Morton , Johannes Weiner , Kirill Tkhai , 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 , Oleg Nesterov Subject: Re: [RFC][PATCH 1/2] memcg: Ensure every task that uses an mm is in the same memory cgroup Message-ID: <20180601165034.GX1351649@devbig577.frc2.facebook.com> References: <20180510121418.GD5325@dhcp22.suse.cz> <20180522125757.GL20020@dhcp22.suse.cz> <87wovu889o.fsf@xmission.com> <20180524111002.GB20441@dhcp22.suse.cz> <20180524141635.c99b7025a73a709e179f92a2@linux-foundation.org> <20180530121721.GD27180@dhcp22.suse.cz> <87wovjacrh.fsf@xmission.com> <87wovj8e1d.fsf_-_@xmission.com> <87y3fywodn.fsf_-_@xmission.com> <87sh66wobu.fsf_-_@xmission.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <87sh66wobu.fsf_-_@xmission.com> User-Agent: Mutt/1.5.21 (2010-09-15) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hello, Eric. On Fri, Jun 01, 2018 at 09:53:09AM -0500, Eric W. Biederman wrote: > > From a userspace perspective the cgroup of a mm is determined by which > the cgroup the task belongs too. As practically an mm can only belong to > a single memory cgroup having multiple tasks with the same mm in different > memory cgroups is not well defined. > > Avoid the difficulties of dealing with crazy semantics and restrict all > tasks that share a single mm to the same memory cgroup. > > This is accomplished by adding a new function mem_cgroup_mm_can_attach > that checks this condition with a straight forward algorithm. In the worst > case it is O(N^2). In the common case it should be O(N) in the number of > tasks being migrated. As typically only a single process and thus a single > process is being migrated and it is optimized for that case. > > There are users of mmget such as proc that can create references to an > mm this function can not find. This results in an unnecessary > migration failure. It does not break the invariant that every task of > an mm stays in the same memory cgroup. So this condition is annoying > but harmelss. > > This requires multi-threaded mm's to be migrated using the procs file. > > This effectively forbids process with mm's shared processes being migrated. > Although enabling the control file might work. So, I don't think we need to support putting tasks which share a mm in different cgroups. That said, if we're gonna put in that restriction, I think it should be in cgroup core rather than memcg can_attach. The only thing we'd need to do is widening what cgroup migration considers to be a process. Thanks. -- tejun