Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp1045211imm; Wed, 1 Aug 2018 09:17:38 -0700 (PDT) X-Google-Smtp-Source: AAOMgpdByaAyFR/xZAOuUZLEbsH8sacPd4jYVtTXWoLKdJIlgLBfMszxR40wboTo7uI2Kqtse5uA X-Received: by 2002:a63:291:: with SMTP id 139-v6mr25406661pgc.365.1533140258508; Wed, 01 Aug 2018 09:17:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1533140258; cv=none; d=google.com; s=arc-20160816; b=tGzV5E4x8ZpK4lU0o0cw1wkb5MetzhU3ZnSZeXQklvd4w7l5Ik2J12XCortecgQh3q +oqo6mzR6QQMiAFHS9p+vNLCrw1QnmL6NV3VMSm77oX3HNQYBjenRMZIRwm+ESS8V08f aSvMI7tV1K+DF1lZIB25fLdQpYHczjvBxql5IswumWSEBjcn+tbMTc+FigR19Toh8VK6 pPS5WFUTQBQ+6HxsumBmhtt2zYE+jRalwcR1mv/w0ONqJDhbW+lxGhFOjm2keUUWKTSI M+4MVKlTVuPDaqVq15Yii054OKD4UN3pdP7aR/d9VzJCiReGB50ItDXUhiE1NnOiLNhS HSrw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature:arc-authentication-results; bh=+XWLmaBxsOaii9QFXMGaBQV2UtUeOG2s2buJkAeluX0=; b=WdErBxq6B/bOX8l0YFvDp2tASo5i4lhfYvmyMcXh5JMl+MRCP+4DqLCPcLopSLenYS PQEttS1zCljPjEgYwNWJZFGXzgCDR98/r/DAAynIV3ksVmO6nSwn0nfcHA0J53yS6PP/ 4MiODCNgaS3vldvfQtaSQ2JSMh6KyLG0xZtV47dpGq0/zwlbcKdHrPRgIqxAKq8bPPYq nfacHKFTqJszVud6VNx1A+QEwEhJypknfWoEf9Q3ZHSU1KxPyON+ibw8AZg+gvnDhAsa BtwFoE5g+6VM1ptjgi7lU99ftK05PVAE0dNTflCjzLH2VgplNjMoedS+UdZWUbKR8cIS 4bSg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=dPJC9rJW; 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=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id d38-v6si16161504pla.422.2018.08.01.09.17.24; Wed, 01 Aug 2018 09:17:38 -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=pass header.i=@gmail.com header.s=20161025 header.b=dPJC9rJW; 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=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2390106AbeHASC6 (ORCPT + 99 others); Wed, 1 Aug 2018 14:02:58 -0400 Received: from mail-lj1-f194.google.com ([209.85.208.194]:46525 "EHLO mail-lj1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2389854AbeHASC6 (ORCPT ); Wed, 1 Aug 2018 14:02:58 -0400 Received: by mail-lj1-f194.google.com with SMTP id 203-v6so17346726ljj.13; Wed, 01 Aug 2018 09:16:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=+XWLmaBxsOaii9QFXMGaBQV2UtUeOG2s2buJkAeluX0=; b=dPJC9rJW9lZo0406nuZmtMK6ifqUOXtoZFoirzQ2PnhF6jAfprqx2dXHg7XdMeMd+T 2uaSrxTmdTZEwCbUIhfpIIBQ41EIlIOOe28mM+J6YJDQhZ1/SF4cV4W1lcll1d1/HsMI iGUJs/3OdfzdwtHem+KjpC8YoAbCN772iGfG5Nxa1UieJXcjTbQ22DN07ZK5hcROpIzm 4MdbY/ddzyj9ScNUqIUyihRXkQsGIb4t6q2kLk1MaocCC0FPC+tCN0OQim+L4B+eIZ+B SzhZ1bdhh7d7HY0gToKUHvZK7XGunguCuw8IMf0f9DOmqRtMPJNGKZAT/OaC8FAIHoMB mHyA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=+XWLmaBxsOaii9QFXMGaBQV2UtUeOG2s2buJkAeluX0=; b=BoJ+u07Fp/lPnAxFpgy7ouHqs/DJCnz354l66qGL43RhLVSgag+Tv47i4vCDxQMY/M hGqNeFC2AZr59LZscoOpxLDyymozagmGDUQrKdKItWxJJQIxC15sZEQt5g+LiDGZiiLK ftYGpZb6TvQjNSP9llv+11TnCx8PbzjgpCLh94lksKsWMgYwNlk1lCbHjBJYWbDcNQqi YX2QC9Jz6Y5MYVFCiyn4EQQkj9HP8lcryVcMdZtsW8u61G8EH+YcQPC4wTgNIrFmy1bO zUv50BaWuUPjTg2wZoLAiDzi16bcVrU3/arQb4DvA8HDbHKROHdvLA14Js6X5xelZ3Y4 rm7Q== X-Gm-Message-State: AOUpUlEuIkIDqY19shOFXPU6bvTyZq7PClBT8b3V7qWmPDXh8QhFTcwe QcQ2nkh6CQbzNytmlVxG6o2pOhuH X-Received: by 2002:a2e:5f89:: with SMTP id x9-v6mr19769033lje.16.1533140189737; Wed, 01 Aug 2018 09:16:29 -0700 (PDT) Received: from esperanza ([185.6.245.156]) by smtp.gmail.com with ESMTPSA id m129-v6sm2453858lfe.50.2018.08.01.09.16.28 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 01 Aug 2018 09:16:28 -0700 (PDT) Date: Wed, 1 Aug 2018 19:16:26 +0300 From: Vladimir Davydov To: Johannes Weiner Cc: Andrew Morton , Michal Hocko , Kirill Tkhai , cgroups@vger.kernel.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] memcg: Remove memcg_cgroup::id from IDR on mem_cgroup_css_alloc() failure Message-ID: <20180801161626.j2575eru2x3lukfj@esperanza> References: <20180413113855.GI17484@dhcp22.suse.cz> <8a81c801-35c8-767d-54b0-df9f1ca0abc0@virtuozzo.com> <20180413115454.GL17484@dhcp22.suse.cz> <20180413121433.GM17484@dhcp22.suse.cz> <20180413125101.GO17484@dhcp22.suse.cz> <20180726162512.6056b5d7c1d2a5fbff6ce214@linux-foundation.org> <20180727193134.GA10996@cmpxchg.org> <20180729192621.py4znecoinw5mqcp@esperanza> <20180730153113.GB4567@cmpxchg.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20180730153113.GB4567@cmpxchg.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Jul 30, 2018 at 11:31:13AM -0400, Johannes Weiner wrote: > On Sun, Jul 29, 2018 at 10:26:21PM +0300, Vladimir Davydov wrote: > > On Fri, Jul 27, 2018 at 03:31:34PM -0400, Johannes Weiner wrote: > > > That said, the lifetime of the root reference on the ID is the online > > > state, we put that in css_offline. Is there a reason we need to have > > > the ID ready and the memcg in the IDR before onlining it? > > > > I fail to see any reason for this in the code. > > Me neither, thanks for double checking. > > The patch also survives stress testing cgroup creation and destruction > with the script from 73f576c04b94 ("mm: memcontrol: fix cgroup > creation failure after many small jobs"). > > > > Can we do something like this and not mess with the alloc/free > > > sequence at all? > > > > I guess so, and this definitely looks better to me. > > Cool, then I think we should merge Kirill's patch as the fix and mine > as a follow-up cleanup. > > --- > > From b4106ea1f163479da805eceada60c942bd66e524 Mon Sep 17 00:00:00 2001 > From: Johannes Weiner > Date: Mon, 30 Jul 2018 11:03:55 -0400 > Subject: [PATCH] mm: memcontrol: simplify memcg idr allocation and error > unwinding > > The memcg ID is allocated early in the multi-step memcg creation > process, which needs 2-step ID allocation and IDR publishing, as well > as two separate IDR cleanup/unwind sites on error. > > Defer the IDR allocation until the last second during onlining to > eliminate all this complexity. There is no requirement to have the ID > and IDR entry earlier than that. And the root reference to the ID is > put in the offline path, so this matches nicely. > > Signed-off-by: Johannes Weiner Acked-by: Vladimir Davydov