Received: by 2002:a25:f815:0:0:0:0:0 with SMTP id u21csp2405556ybd; Thu, 27 Jun 2019 11:45:27 -0700 (PDT) X-Google-Smtp-Source: APXvYqzZosMq+wz7kVbi7NbPWpjoV5F40zUg5yIjLy2FOxKW5z+GreGPC8lSVg1BLb0BiWw6sJb1 X-Received: by 2002:a63:257:: with SMTP id 84mr5254794pgc.142.1561661127692; Thu, 27 Jun 2019 11:45:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1561661127; cv=none; d=google.com; s=arc-20160816; b=tkFuypN4f4KwzaambufUAGYJJSJM0HQ1LXWFJUyHWZ7Uwy3N3rpMJQamksdGA5jC69 2WETiCM8vbY8DpVPna2vj/oA94dTsG55dfPQR+6BEQv7co8BLDCXhWiwlG6dxEaOvL8u iKYdKWk99kMV9yB2AjOlvZ/p5kiilccG+CYP8/3cRdaXRMLv8Ik6xV2rLWWI9bkVNRHL hXplxQy0ogV+j5vayHJuElvE7qRZeI9m9YiYUG5U/ixhE1r6Lw1T/VJnrvJA/YLJgmTP 8Q6NQMtR/bJ0hPOwYv/PJ9x3bUkFhuT8LLf09dMkMCAz3S17leDHZmmSWEbh3b19qTFx sCaw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from; bh=5eXF8HrcHLv0bUZt40sU/7oY+axHQovPmK50YAhtR10=; b=kCJtWkTDaZpV2Br6gpViLC8mqviUu6H+dJooBj1ISHwizGPlAUyOwYZQ2xzN1ZEqrw DBbij1wGoJUldqYIpUiyT7xWvvYri4nIuIjwM+ojFHDnBdR/Waq4qyuiIT0wXYzexkH8 FjG4f6qD30dXUoTdtoxBM6yVIFmjNVDyNt9mJjjnYXlZ2qNYbWNAUdbg/jQW1dguaJRL HojBdIEJIPBY2jcSF59DUiV66B6Wg4OMbQFnap0XTH5rXW6YA48e5mJpnlT+KZvl5iep ztFiyL7YTssbbEc7YrVrFTnc0ATMi0npS43w8njkogCg5IWjm5gxwQgA7qnU2guda0hy dX6w== ARC-Authentication-Results: i=1; mx.google.com; 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=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id h125si326120pfb.176.2019.06.27.11.45.12; Thu, 27 Jun 2019 11:45:27 -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; 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=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726651AbfF0SoD (ORCPT + 99 others); Thu, 27 Jun 2019 14:44:03 -0400 Received: from mx1.redhat.com ([209.132.183.28]:50234 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726441AbfF0SoD (ORCPT ); Thu, 27 Jun 2019 14:44:03 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 64712C05B1CD; Thu, 27 Jun 2019 18:43:46 +0000 (UTC) Received: from llong.com (dhcp-17-85.bos.redhat.com [10.18.17.85]) by smtp.corp.redhat.com (Postfix) with ESMTP id 8CCD160126; Thu, 27 Jun 2019 18:43:37 +0000 (UTC) From: Waiman Long To: Christoph Lameter , Pekka Enberg , David Rientjes , Joonsoo Kim , Andrew Morton Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, Michal Hocko , Roman Gushchin , Johannes Weiner , Shakeel Butt , Vladimir Davydov , Waiman Long Subject: [PATCH-next v2] mm, memcg: Add ":deact" tag for reparented kmem caches in memcg_slabinfo Date: Thu, 27 Jun 2019 14:43:24 -0400 Message-Id: <20190627184324.5875-1-longman@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.32]); Thu, 27 Jun 2019 18:44:02 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org With Roman's kmem cache reparent patch, multiple kmem caches of the same type can be seen attached to the same memcg id. All of them, except maybe one, are reparent'ed kmem caches. It can be useful to tag those reparented caches by adding a new slab flag "SLAB_DEACTIVATED" to those kmem caches that will be reparent'ed if it cannot be destroyed completely. For the reparent'ed memcg kmem caches, the tag ":deact" will now be shown in /memcg_slabinfo. [v2: Set the flag in the common code as suggested by Roman.] Signed-off-by: Waiman Long Reviewed-by: Shakeel Butt Acked-by: Roman Gushchin --- include/linux/slab.h | 4 ++++ mm/slab_common.c | 15 +++++++++------ 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/include/linux/slab.h b/include/linux/slab.h index fecf40b7be69..19ab1380f875 100644 --- a/include/linux/slab.h +++ b/include/linux/slab.h @@ -116,6 +116,10 @@ /* Objects are reclaimable */ #define SLAB_RECLAIM_ACCOUNT ((slab_flags_t __force)0x00020000U) #define SLAB_TEMPORARY SLAB_RECLAIM_ACCOUNT /* Objects are short-lived */ + +/* Slab deactivation flag */ +#define SLAB_DEACTIVATED ((slab_flags_t __force)0x10000000U) + /* * ZERO_SIZE_PTR will be returned for zero sized kmalloc requests. * diff --git a/mm/slab_common.c b/mm/slab_common.c index 146d8eaa639c..464faaa9fd81 100644 --- a/mm/slab_common.c +++ b/mm/slab_common.c @@ -771,6 +771,7 @@ static void kmemcg_cache_deactivate(struct kmem_cache *s) return; __kmemcg_cache_deactivate(s); + s->flags |= SLAB_DEACTIVATED; /* * memcg_kmem_wq_lock is used to synchronize memcg_params.dying @@ -1533,7 +1534,7 @@ static int memcg_slabinfo_show(struct seq_file *m, void *unused) struct slabinfo sinfo; mutex_lock(&slab_mutex); - seq_puts(m, "# "); + seq_puts(m, "# "); seq_puts(m, " \n"); list_for_each_entry(s, &slab_root_caches, root_caches_node) { /* @@ -1544,22 +1545,24 @@ static int memcg_slabinfo_show(struct seq_file *m, void *unused) memset(&sinfo, 0, sizeof(sinfo)); get_slabinfo(s, &sinfo); - seq_printf(m, "%-17s root %6lu %6lu %6lu %6lu\n", + seq_printf(m, "%-17s root %6lu %6lu %6lu %6lu\n", cache_name(s), sinfo.active_objs, sinfo.num_objs, sinfo.active_slabs, sinfo.num_slabs); for_each_memcg_cache(c, s) { struct cgroup_subsys_state *css; - char *dead = ""; + char *status = ""; css = &c->memcg_params.memcg->css; if (!(css->flags & CSS_ONLINE)) - dead = ":dead"; + status = ":dead"; + else if (c->flags & SLAB_DEACTIVATED) + status = ":deact"; memset(&sinfo, 0, sizeof(sinfo)); get_slabinfo(c, &sinfo); - seq_printf(m, "%-17s %4d%5s %6lu %6lu %6lu %6lu\n", - cache_name(c), css->id, dead, + seq_printf(m, "%-17s %4d%-6s %6lu %6lu %6lu %6lu\n", + cache_name(c), css->id, status, sinfo.active_objs, sinfo.num_objs, sinfo.active_slabs, sinfo.num_slabs); } -- 2.18.1