Received: by 2002:a25:f815:0:0:0:0:0 with SMTP id u21csp93498ybd; Tue, 25 Jun 2019 17:16:19 -0700 (PDT) X-Google-Smtp-Source: APXvYqxfI/d3HbkvX1FAUYN2xpge+OqBbdz+2f10OFEzVOPUfSfZip2O6UkS2E+6rRR7+scU+YDg X-Received: by 2002:a17:902:2868:: with SMTP id e95mr1438516plb.319.1561508179301; Tue, 25 Jun 2019 17:16:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1561508179; cv=none; d=google.com; s=arc-20160816; b=f/k+yLS/YSZtWgY9U/LapjsGZ1R5KE2+rPQgpKovDtusasCigR+ZM5f+7GAAfd83EO 73ABQLCf74Da43jvj9nzFNRqYfW3pV1CXag4uRHvr+DroIYSYkhTUB9uJqqakxKLNO1J e2k09SqsabetqyiRAOGSlyDKZl6Sblk12cbu3a/lJdDuQ07DUXHStoNpV48J0v/JhoIN wgaPcA8p0b/dmKBUwFWPe1aorviRPe08NV3Zl7wiio0XMzlk+q6AFaxS4GkbGRGg9Voc zHFDt0PMVfahxcymZGh7UCw4k6XtcgE/9oWJdCmRoG5fJFAWz68ccsJpssJ7UupkOFLL JTJg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=KKVa5Ei85vO/xl8eKxbG6qTUC2Z/5faLfHmHsNuzkTM=; b=BwXqrBuKSOH4XJh4UaJtDGNx6KdLSS8H4LT/YTpdwu4oUiDj996Ze5X5k/+QA6TZEi DmtYtBcUPwroTQmaqIjs5+ddX+J4O8QjOh40+zFE5A29irv3sxle3iAqNSICngiMYdA/ EoLE07/DIbK9bLNpv7IVGNBOjwmVpwHBJmgTtkxLYvzDTbGVNsWtGOXFSD+HpvPiI2z+ 2qnNLMo7FLeYoTZfDKzXyEJIlVfvy4XVz8eMoqR4NUuZDhvvIKDwgTFW5vKRPCIwRCpm ND5AyGaAmmK8juNro0S3wDzAdUL8nT8StRI9SvhkSYQmMlQAqJzupyUDMwI5dDSKt36a TRMQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b="Ah/LPaiX"; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id h3si7357782pgm.365.2019.06.25.17.16.03; Tue, 25 Jun 2019 17:16:19 -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=@google.com header.s=20161025 header.b="Ah/LPaiX"; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726354AbfFZAPZ (ORCPT + 99 others); Tue, 25 Jun 2019 20:15:25 -0400 Received: from mail-yw1-f67.google.com ([209.85.161.67]:38394 "EHLO mail-yw1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725782AbfFZAPY (ORCPT ); Tue, 25 Jun 2019 20:15:24 -0400 Received: by mail-yw1-f67.google.com with SMTP id k125so163366ywe.5 for ; Tue, 25 Jun 2019 17:15:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=KKVa5Ei85vO/xl8eKxbG6qTUC2Z/5faLfHmHsNuzkTM=; b=Ah/LPaiXFjkiiPD77qZcdlWGO13E2LGO4ZIJGolulIyLP4ucxhY+XFE2dcLhlYzbB3 6BqGf1qlPAtAc4t51PD4a5o866Hrmru/gdSHFEzovDQZawzBoAmkSZ8fFpw548ilFx/U hnfAWZHGRpPl++/3NbDHb7UL2MqkpXcoHip/NaD4nWPEpNVYFxN+5K5gOJhjm4n4pJwF z5BEw8DVUKjWxZ31//Fk0/K3hkUP81CYNDfewsLGwCbrHqwf9U2z6ZddYpT9BiQxdPcu 1La96rfXWbZp9VkK4Sf3sAbCvIrp9EIT93lB0PPTIR47atoSKU+g8l6XtC4AZgsbqRmz qSFw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=KKVa5Ei85vO/xl8eKxbG6qTUC2Z/5faLfHmHsNuzkTM=; b=Z7MKdSWxfXjbwMbR68w5O/oMJAnC1MiF/ZCszFhoMFCi6LJntBQoeAWp67c7MKLTKI hhmkGIOVh40pAhq9fUwsWNOgRqwwTqjt9QabF0pCboXkowLqrogOMspxDCIa/ExVL4gf VsI4p8qMwUiN/Jq5qo0a5eNsVuvxco9/MzEK4lqmTMNKj3rWeAY+tvRq52r0JTMjtSqI lThQhAOur/kLi/ZM8jHPqDIcCQ6xHU+meXdg9RMm5stpaq4Hq/ajkkykFOHKXntulY8H J5ctdM1N6FbvgEehgQsXvEXwAMrDaUvN9NnjVutPOa6mqKZNDpN3n91i0qFB2ukyrH4x M0Tg== X-Gm-Message-State: APjAAAV8jwlmNmiX+Ols8VKg4znx4EUQ3DoLcI56nikueRkzqIiHEBjQ h3IAAW1ejjDOjIHNwsUuyHJXj/MTXatar5qHGRY/Jw== X-Received: by 2002:a81:4c44:: with SMTP id z65mr1001089ywa.4.1561508123747; Tue, 25 Jun 2019 17:15:23 -0700 (PDT) MIME-Version: 1.0 References: <20190611231813.3148843-1-guro@fb.com> <20190611231813.3148843-11-guro@fb.com> In-Reply-To: <20190611231813.3148843-11-guro@fb.com> From: Shakeel Butt Date: Tue, 25 Jun 2019 17:15:12 -0700 Message-ID: Subject: Re: [PATCH v7 10/10] mm: reparent memcg kmem_caches on cgroup removal To: Roman Gushchin Cc: Andrew Morton , Vladimir Davydov , Linux MM , LKML , Kernel Team , Johannes Weiner , Waiman Long Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Jun 11, 2019 at 4:18 PM Roman Gushchin wrote: > > Let's reparent non-root kmem_caches 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). > > 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, drop the css refcounter for each kmem_cache > and adjust the parent's css refcounter. > > Please, note that kmem_cache->memcg_params.memcg isn't a stable > pointer anymore. It's safe to read it under rcu_read_lock(), > cgroup_mutex held, or any other way that protects the memory cgroup > from being released. > > 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 The reparenting of top level memcg and "return true" is fixed in the later patch. Reviewed-by: Shakeel Butt