Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp5355525ybi; Tue, 28 May 2019 11:35:53 -0700 (PDT) X-Google-Smtp-Source: APXvYqwy8p7ILBqLDtg1g2FzhMiUzNAZ88zEMT90Z4+nTQjNUm1yr3gCDCnmH8ofJIXdhaUteqYM X-Received: by 2002:a63:e20d:: with SMTP id q13mr30539733pgh.171.1559068553447; Tue, 28 May 2019 11:35:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1559068553; cv=none; d=google.com; s=arc-20160816; b=Ts/sh+vfr4Od442a+PwCjDR1Lr9cESGEUtPquyEqbgvRXFEbMYu9UDImH1koJx5lx1 wOfm1ds8iP8INiz+x8JlqEIvKnkRULdXcGFYheoWtgLmS44LnNqndZkB19K59bUwwHrx 5yovBqaP3ibYBIL5uWUtl8GgINLrzFlYJezshtx+/P41D51H/kIWaRfouPTK1wkgIi49 FpcMsIJvgH1x2ZTexlWRfyIrIBMAqFdNmN36qFFfKexXBQ0bI/SY7CJHFh8DdK7eCYYV 1JfGkRlDuB7P7Ad/v/a0cvhcOiSjB/ha/NVpePZwlRG0iuLUCFpmnV90gOKEwQT2JsOb zZlg== 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=/dxRboK00I5JVZJIcKIh8lDmjqTZ8vT2RGIZXym9hs8=; b=LfNQA/2zrZN0+p6wFjg5MltBncIIeT/pGnelU9o3ScQ0mpdVr0SxK7/Uvb9QM6VkxJ 45XFFe9/dWLQOGdF5LlfijG4Q7Yfr9HtQ/BaiIdDq59m2y9cvHzQkXuDo3skzvyItRjz 5vJh8kLiTG3gkVAt32Y89bw491gXmElaYW7Rq7XBstiSvcaywwFIGS+XQlbmDOeG8g8V u+nwLF8JRjoHG+oxtlDWioYT302Cj6e1h1x45VBQpZIdwt2TBpzMRfxSpkZDIkDmQ1Eb yfbHzfR4OQJrJP3stqoeBtJ0RFH/4pvJjTca4tnLRWpEWE98UjM9+d0d1mwXT2MYwcCq Pt1w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=JdETCGK0; 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 v9si20978731pfm.50.2019.05.28.11.35.37; Tue, 28 May 2019 11:35:53 -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=JdETCGK0; 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 S1728022AbfE1SdI (ORCPT + 99 others); Tue, 28 May 2019 14:33:08 -0400 Received: from mail-lj1-f196.google.com ([209.85.208.196]:38266 "EHLO mail-lj1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727201AbfE1SdI (ORCPT ); Tue, 28 May 2019 14:33:08 -0400 Received: by mail-lj1-f196.google.com with SMTP id o13so28748lji.5; Tue, 28 May 2019 11:33:06 -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=/dxRboK00I5JVZJIcKIh8lDmjqTZ8vT2RGIZXym9hs8=; b=JdETCGK02W+TtswFGWYTMmY9WIEyBXPpCljaIU/VvB/d3DyEtFWnP0lJVxjUjx9TD+ BbFimxaiEpjpXaitfVH8KM8TBEOsn6oSsKdEWrPjq9D15Ew99jozw+GsV/lZqrVVZ0bd sGtow18Jv93Jk3c4kkSM9BZ05m3scy1imL1EdiSpaSjWhIrIPyNB9w8DdlCdVlnDOZNn KB5glui+lV+DZKpPu++CN6VKlXQmcVFXpxLJUgk52DMVAvzV1zTNcKZuZuMlzrMfr+zo qH7zlgas8ajm6z/0f37WMEh9ITFodHk5tXZpvMdRGXtAceFsYcaEo3ESqN2B34xySD+d KVXQ== 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=/dxRboK00I5JVZJIcKIh8lDmjqTZ8vT2RGIZXym9hs8=; b=hStiXKQEcsLyXn9s3UUQ9FM3CXz1q2oIn9QATiYEh2nhthQ466gw9R1CAf1LQoLHVT V0xSfg4TUvGYhnl8Ts4dWFX3q4zK60cJpxkC5HlskMajTnWZyoVOSN6BnFKLyfJXk8ge hpkPfWPxlNzQzxyTtV1mOqm+m6T0FmlKSnFhN52RWTi8RulWSAcKZZgvmTIc8gZ55AcN BMwEvtuHMcxKTvQeBjo+hGc7K3BDZ/4e0Q7OC/UE0UuouXSM+PnKKXgo2G+NpXaKyhbf 2oGQluKOgv7+UlSJXS8AglT7gxDxvun37i8CjSFS4QmtrVBWsBfQmA7ViSrpTPtl0X4K SikA== X-Gm-Message-State: APjAAAUgeG9NwvpGLc881l3Kx4jkhXUyb7uisqNCe9xuPSmggd3ANiXW ti7gG2rr3NaaNknDfDK1osw= X-Received: by 2002:a2e:9193:: with SMTP id f19mr24449382ljg.111.1559068386280; Tue, 28 May 2019 11:33:06 -0700 (PDT) Received: from esperanza ([176.120.239.149]) by smtp.gmail.com with ESMTPSA id a7sm171218lji.13.2019.05.28.11.33.04 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 28 May 2019 11:33:05 -0700 (PDT) Date: Tue, 28 May 2019 21:33:02 +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 6/7] mm: reparent slab memory on cgroup removal Message-ID: <20190528183302.zv75bsxxblc6v4dt@esperanza> References: <20190521200735.2603003-1-guro@fb.com> <20190521200735.2603003-7-guro@fb.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20190521200735.2603003-7-guro@fb.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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.