Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp5564328ybi; Tue, 28 May 2019 15:25:08 -0700 (PDT) X-Google-Smtp-Source: APXvYqzXQZQK7+W5htMQ4cQXFVbEdSzkL5QVPu6yJJp2GEiFb1j4vBwQVDim8RHrENTqa5juqnPv X-Received: by 2002:a17:902:9885:: with SMTP id s5mr16770169plp.102.1559082308514; Tue, 28 May 2019 15:25:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1559082308; cv=none; d=google.com; s=arc-20160816; b=JVgEZrMVG4BPp++t0zZ7ioCsXxo7ryrjN41em1tdldhyS14K1Xp1R6v4reoTeSVAoX CSJZal360o9JHDuQFUxXUUYWsHT+EpKbFhCMNi2C5o6NoZxB+qGakzH1CxoQ1ik+qKug 8E+HWnHwZWG5YB6xH17FpQf6fK3EYeki3AFd4LruBMblaAO8PVEgpA5xxF1sQqalhxFf IIlXyFVNquQFt71crAgm3rnCzi9HxufypiFjg7h1CwYIB1x/rtY9F3+DgAEwLKWcelQY qbg9NBHK9SLgrRbEU5/dxYEVhmzFGjMMUIFsZwveQjI6MGqpac/YnEx8j3epBeRO2RwI 25eg== 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; bh=SLwBA8MbvD2QC0ep8E6TWiO4osZD4fu2h/9Z2V53XVU=; b=B81GCcEPFVSwVODWGIlwHFoYgDPTPPE00zRJptbQNqStXqhbEFIyDOqeVIS8dQrccK Oh+RIkBX06pEe24OTJbWZEXzdRwBrk/rH7jwA/XB+1PreJSPXf40Uu0V6lV9JDGp/BK0 wZ3AAlD+hZKrQQNtazuU/lljEwYtSoPImg08saBGMMtkNhbKJ6EQY+gsGrCf2RzFkrwv whV4tp9fRMWb75akRk+f3OIPJ4yj6AqAQVVgGc0HEflsuNoDotBsHiNg6cs4amYfi7YZ oa7i7o0S2qgNCuPlP05fJnKQ2+MxoFdvfnBRywTAwGSimxC6CgqyztpP4UPXieVn3U1m IKQA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@cmpxchg-org.20150623.gappssmtp.com header.s=20150623 header.b=1U+7o4fD; 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=cmpxchg.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id w27si25018923pgl.277.2019.05.28.15.24.53; Tue, 28 May 2019 15:25:08 -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=@cmpxchg-org.20150623.gappssmtp.com header.s=20150623 header.b=1U+7o4fD; 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=cmpxchg.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727268AbfE1WQR (ORCPT + 99 others); Tue, 28 May 2019 18:16:17 -0400 Received: from mail-pf1-f194.google.com ([209.85.210.194]:34777 "EHLO mail-pf1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726812AbfE1WQR (ORCPT ); Tue, 28 May 2019 18:16:17 -0400 Received: by mail-pf1-f194.google.com with SMTP id n19so192481pfa.1 for ; Tue, 28 May 2019 15:16:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cmpxchg-org.20150623.gappssmtp.com; s=20150623; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=SLwBA8MbvD2QC0ep8E6TWiO4osZD4fu2h/9Z2V53XVU=; b=1U+7o4fD7tmYoGz+yUlK3xEC1BolyoWKEYDkAchX/oKTIdCJ03mkyuokQEfbvRSu2J aGd9YozwjkbKIRGDOUx6V5TNQV10fBydRP3/Rref/HmapwqQZiV9R4GRFjbMDQgluno+ 0zHhUoORAlPNG66tv0aBbi6J1l5JMOKKBFrNXSeq1LkzuGBuaLOfIVr2A802gf+RC1pL +oa0FYRQhTCfhF5qx4XRkKaaxYuVA6TXhvlkdl7eTRQtFWHk8AIvAGmY8XmG0Lr5F0w0 2GAmIemcB/o8diV8Hr/dq8X+6wB9bHxgvYLAnWqThhUoTxyo31DHn2/FkNsat0MFD2go 3t4A== 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:user-agent; bh=SLwBA8MbvD2QC0ep8E6TWiO4osZD4fu2h/9Z2V53XVU=; b=aIYBHFIl4kryZSk9/nt+GR8lnAb62nVoUOUCj/dKjIKPV/EQJIUE37U8U9If1QSofW W8xCQd1QqRW73fwPzB1jI5H60GMeyBuYYdD5CegM08cdC2PshQdv9JdWwCaNzDYsD2my N5LH9SwPAQZSIDWUfU/8N1OlROXO7lAhXG9Ms7ECCqQWvufAqEsLy8U/b/ET2yg+nr5+ +gc2/ojM1tEkXsLxA3/xbJRGSjBGEEFKSmf2oqERNuw12mqiR+YjZ3G40T20Pak2Qdxo MUZ8GYd4D5NczMhGZzFW7sJ0VbgqyO7sJ4aT1OFQfanjURaVV+ncVuW2eDarmfJJ9Iu2 4Zog== X-Gm-Message-State: APjAAAUF4kbRQ5A6j3jrGOi+jqLHUpiAH4WibVWk+F46Ya6PYKm2pT7x t4fsLcDLkzLVAn4J2ygqMSO6hg== X-Received: by 2002:aa7:8e46:: with SMTP id d6mr117346607pfr.91.1559081776764; Tue, 28 May 2019 15:16:16 -0700 (PDT) Received: from localhost ([2620:10d:c091:500::1:77ab]) by smtp.gmail.com with ESMTPSA id f30sm3238124pjg.13.2019.05.28.15.16.15 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 28 May 2019 15:16:16 -0700 (PDT) Date: Tue, 28 May 2019 18:16:14 -0400 From: Johannes Weiner To: Roman Gushchin Cc: Vladimir Davydov , Andrew Morton , "linux-mm@kvack.org" , "linux-kernel@vger.kernel.org" , Kernel Team , Michal Hocko , Rik van Riel , Shakeel Butt , Christoph Lameter , "cgroups@vger.kernel.org" , Waiman Long Subject: Re: [PATCH v5 6/7] mm: reparent slab memory on cgroup removal Message-ID: <20190528221614.GD26614@cmpxchg.org> References: <20190521200735.2603003-1-guro@fb.com> <20190521200735.2603003-7-guro@fb.com> <20190528183302.zv75bsxxblc6v4dt@esperanza> <20190528195808.GA27847@tower.DHCP.thefacebook.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20190528195808.GA27847@tower.DHCP.thefacebook.com> User-Agent: Mutt/1.11.4 (2019-03-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, May 28, 2019 at 07:58:17PM +0000, Roman Gushchin wrote: > On Tue, May 28, 2019 at 09:33:02PM +0300, Vladimir Davydov wrote: > > On Tue, May 21, 2019 at 01:07:34PM -0700, Roman Gushchin wrote: > > > Let's reparent memcg slab memory on memcg offlining. This allows us > > > to release the memory cgroup without waiting for the last outstanding > > > kernel object (e.g. dentry used by another application). > > > > > > So instead of reparenting all accounted slab pages, let's do reparent > > > a relatively small amount of kmem_caches. Reparenting is performed as > > > a part of the deactivation process. > > > > > > Since the parent cgroup is already charged, everything we need to do > > > is to splice the list of kmem_caches to the parent's kmem_caches list, > > > swap the memcg pointer and drop the css refcounter for each kmem_cache > > > and adjust the parent's css refcounter. Quite simple. > > > > > > Please, note that kmem_cache->memcg_params.memcg isn't a stable > > > pointer anymore. It's safe to read it under rcu_read_lock() or > > > with slab_mutex held. > > > > > > We can race with the slab allocation and deallocation paths. It's not > > > a big problem: parent's charge and slab global stats are always > > > correct, and we don't care anymore about the child usage and global > > > stats. The child cgroup is already offline, so we don't use or show it > > > anywhere. > > > > > > Local slab stats (NR_SLAB_RECLAIMABLE and NR_SLAB_UNRECLAIMABLE) > > > aren't used anywhere except count_shadow_nodes(). But even there it > > > won't break anything: after reparenting "nodes" will be 0 on child > > > level (because we're already reparenting shrinker lists), and on > > > parent level page stats always were 0, and this patch won't change > > > anything. > > > > > > Signed-off-by: Roman Gushchin > > > Reviewed-by: Shakeel Butt > > > > This one looks good to me. I can't see why anything could possibly go > > wrong after this change. > > Hi Vladimir! > > Thank you for looking into the series. Really appreciate it! > > It looks like outstanding questions are: > 1) synchronization around the dying flag > 2) removing CONFIG_SLOB in 2/7 > 3) early sysfs_slab_remove() > 4) mem_cgroup_from_kmem in 7/7 > > Please, let me know if I missed anything. > > I'm waiting now for Johanness's review, so I'll address these issues > in background and post the next (and hopefully) final version. The todo items here aside, the series looks good to me - although I'm glad that Vladimir gave it a much more informed review than I could.