Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp5400615ybi; Tue, 28 May 2019 12:22:51 -0700 (PDT) X-Google-Smtp-Source: APXvYqx0OQm2LdgfzL2pnhuaS04vXe2NXpYsmQTRUX8iRDq8hySrj7V/M6IfEb8PX3A5l5NS3t57 X-Received: by 2002:a63:6f0b:: with SMTP id k11mr133486943pgc.342.1559071371665; Tue, 28 May 2019 12:22:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1559071371; cv=none; d=google.com; s=arc-20160816; b=qL0vWLgKwY68+OyBoHDxR7nNFk6rlK8rskFUAWqAI02rhpKxQKxMwYcdgBj/vUI5aZ AyX5mJ2QU4i00Of5zoAQeJN+PRu3wGxkItoZ1CZPnFT2LwYasXVNDYJMEfeHiAcfSeyL sZRR1Sq72vAxKv/PiX8Zun+82+6x0esJWQi4sM5ANy3PZ3MR8YlAgPjvIrBiUu2YNtE+ h42pKS8//XOt9UIBkEHyuP2vv6D2dirLpQwp8lxys8OqoVvU6FFQ8Tam0s0DFJFRgykV UXn6+5PRJQIz9Gkw9aVJPBbbd8cfTdTXk4vhYLils2ANYzE5Xd/K8aDbG6u90qCBvb6O GEMg== 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; bh=gzRimgoeRu7R/UsHOkPXtR9NqQokG6oQDoPTeeW4GsA=; b=ctr9CfGd9YGFPVSa9X/3ZL4HCNtGKbgVdq/cvN9Vv21C5y42nSOjjxlMmbqL3nnhzq VEdoFJ3DjzZZop3HuPOldSd6T1vusrodMR9/hlLFMb5B9pilODbOpT454itzlE8FwR/V lteSZshiifUVaqKn5t0yAGxJPZLRQ4HuCXaxar8yt1hofnpjz34ZDGFHXKnS16FWmwlC DuHtbVugga8c8G8dRXFgqEFnFg28q6VQxUgGPnDKBYHCCgYFJr0JsYY3itdoKUF+eg04 LgmDAC4tB1+sSFTbDHbz5acTshj5sE9p/NkcxQzywaibhgzATj9Q9lfyFYQAxtAhZSkU yVsw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=K5mTZO29; 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 a15si26937335pfa.85.2019.05.28.12.22.36; Tue, 28 May 2019 12:22:51 -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=K5mTZO29; 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 S1727788AbfE1SAb (ORCPT + 99 others); Tue, 28 May 2019 14:00:31 -0400 Received: from mail-lf1-f66.google.com ([209.85.167.66]:35488 "EHLO mail-lf1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726576AbfE1SAb (ORCPT ); Tue, 28 May 2019 14:00:31 -0400 Received: by mail-lf1-f66.google.com with SMTP id a25so5453985lfg.2; Tue, 28 May 2019 11:00: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=gzRimgoeRu7R/UsHOkPXtR9NqQokG6oQDoPTeeW4GsA=; b=K5mTZO29tbBaLBfmC9xktb9UyEHFJm7cNGH2ho7TmDNYxAatoyUag706Zd7cjqjf28 KkeBW1GaNsqZpGtuXpPL2jgCnJM5DuHaiEWuudtfGOhqTqHMJOGDCHv8YAGmcWlXiSLK tvB79wzMLr5Um6QS7j3cKNsAv1752T6NIpZ/9dqKNuDh+uFqgoopmTVuvev/Ic1UEPV9 POninSj+/FBXrDQrPHxHzYlplgfdBdt11aQdVLcmU7bI3aGISf73jtSTKnsqq7hOE1Hl V+x+dWvcxXzA/c6PZ2CFDN+iGZBodzbs4Zs7PsfeskXJix3j7cStbEXLgSLKM7CJ7KPj kKnQ== 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=gzRimgoeRu7R/UsHOkPXtR9NqQokG6oQDoPTeeW4GsA=; b=h85yshqRCD1LEnsQ0HX2/pgBCBkP1RKjMmh5fipdgyWJItrphhxCJbp4GCOlrKs6Vy B4bIXJCnVoN1Q9EGPWKgBVADYVaQjCh+LojtYSoTgnPPlHgzzacPZWOLlt0WAxyP7uRy 0lDrlScMMsybeXaKDkJGCYd9hHK9AzfRHjXGdBA+eeT6p1rffPtCXX0pJkk3D6X0NMnl uI0gJHtHEB5YGE+Z0Mli/6vSW+z3R34npZvB8Uuy3YzEZigoGTOTE2/Se6IHYl6fOU85 EjsUeF7bKoEQnJUybK8a4YKlEpn9YIsH+tzF1Ir1vWy5hs2PgfjdN/nMKCgn9HrQ500s rcnw== X-Gm-Message-State: APjAAAXyRQ+tb9sLWe9BMyDyqq90xkuJ3J7J9wspxOr5J+EGTlH09dX+ Ga9zKhNpPaQEAtjaEiJi0FI= X-Received: by 2002:ac2:5285:: with SMTP id q5mr8975099lfm.146.1559066429696; Tue, 28 May 2019 11:00:29 -0700 (PDT) Received: from esperanza ([176.120.239.149]) by smtp.gmail.com with ESMTPSA id e19sm3048133ljj.62.2019.05.28.11.00.28 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 28 May 2019 11:00:29 -0700 (PDT) Date: Tue, 28 May 2019 21:00:26 +0300 From: Vladimir Davydov To: Roman Gushchin Cc: Andrew Morton , linux-mm@kvack.org, linux-kernel@vger.kernel.org, kernel-team@fb.com, Johannes Weiner , Michal Hocko , Rik van Riel , Shakeel Butt , Christoph Lameter , cgroups@vger.kernel.org, Waiman Long Subject: Re: [PATCH v5 5/7] mm: rework non-root kmem_cache lifecycle management Message-ID: <20190528180026.zb6yaxdeapwx5r3v@esperanza> References: <20190521200735.2603003-1-guro@fb.com> <20190521200735.2603003-6-guro@fb.com> <20190528170828.zrkvcdsj3d3jzzzo@esperanza> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20190528170828.zrkvcdsj3d3jzzzo@esperanza> 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 08:08:28PM +0300, Vladimir Davydov wrote: > Hello Roman, > > On Tue, May 21, 2019 at 01:07:33PM -0700, Roman Gushchin wrote: > > This commit makes several important changes in the lifecycle > > of a non-root kmem_cache, which also affect the lifecycle > > of a memory cgroup. > > > > Currently each charged slab page has a page->mem_cgroup pointer > > to the memory cgroup and holds a reference to it. > > Kmem_caches are held by the memcg and are released with it. > > It means that none of kmem_caches are released unless at least one > > reference to the memcg exists, which is not optimal. > > > > So the current scheme can be illustrated as: > > page->mem_cgroup->kmem_cache. > > > > To implement the slab memory reparenting we need to invert the scheme > > into: page->kmem_cache->mem_cgroup. > > > > Let's make every page to hold a reference to the kmem_cache (we > > already have a stable pointer), and make kmem_caches to hold a single > > reference to the memory cgroup. > > Is there any reason why we can't reference both mem cgroup and kmem > cache per each charged kmem page? I mean, > > page->mem_cgroup references mem_cgroup > page->kmem_cache references kmem_cache > mem_cgroup references kmem_cache while it's online > > TBO it seems to me that not taking a reference to mem cgroup per charged > kmem page makes the code look less straightforward, e.g. as you > mentioned in the commit log, we have to use mod_lruvec_state() for memcg > pages and mod_lruvec_page_state() for root pages. I think I completely missed the point here. In the following patch you move kmem caches from a child to the parent cgroup on offline (aka reparent them). That's why you can't maintain page->mem_cgroup. Sorry for misunderstanding.