Received: by 2002:a17:90a:c8b:0:0:0:0 with SMTP id v11csp2352901pja; Wed, 10 Apr 2019 18:37:09 -0700 (PDT) X-Google-Smtp-Source: APXvYqyhTEMB0XMYlTW08jcsiXnlF7pRgfx/+1MOIy6ORiOKLFeQrRW6OmqLhI5fJH5J+HnHG1Y/ X-Received: by 2002:a17:902:f094:: with SMTP id go20mr47158449plb.159.1554946629878; Wed, 10 Apr 2019 18:37:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1554946629; cv=none; d=google.com; s=arc-20160816; b=rely+4/vlpP6memvPPhmTgIneXv2N2F04zBxkrbFGX4epwOjbdV3yshXKepaw69NRN /ezGCwDQgqZjgV1L53QGBtZXFZf4MGp5H7fnxX5896cmctM4S++F+m/cNk+tr7JJTjhh Expmd7N3u+f8YH6mkj5XE3jTv8w6WU6Lpmdq4yhNN7aPA3BLtk45Rmg/qUgS8W/FU9ne msFH7t06UvAxpmRgCVIetQ5hAnkrM9+3Eklr4+KVLLj3t25TaaE2N0vyG7HSkCFm2/Ea rzzFq72pK0kYm2tnRzf8ffmsm945kY7jiHt7ckze1SKCAiv/+YMhdgWYGr5E5eQLJJdO BOWg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=bxV5jBaXvA/LKL0qOR0ZLSK5IIfdrfWAd0nyjsopfiM=; b=vFWkh1H0RtcVpL8y4MNa3w9ej2fIoxNq07lu9UDzHJRApaxOWJY8XQvDqZnTavUMPW fVorwmwLAnvW8YfVLhYcRzaLMF2ddSVf0wW5gGJVL6/RwyAxzjh7iMRTrDP8h4Qa8bhy /vbEaotqcLRPHnGssGQ1ICU8GkKjUHuIvgBgwaq2PmWvJYON+3S8rohUH+P6xfbgokhg MvHJ8QuNBc9vyo892x5tnvUhebjczPn/ArjuRA0NRAirOjzXWfNrHhdHspDbdNit745z JgprzfJCsdNkJ3tzsAPT7gpVi5uDh/HSviu+A73WfJdhLgvCAKd+TEn0y5Q1tFrQ/9Hh ZQ/A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@messagingengine.com header.s=fm2 header.b=PrShYazj; 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=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id c3si12765348plo.243.2019.04.10.18.36.54; Wed, 10 Apr 2019 18:37:09 -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=@messagingengine.com header.s=fm2 header.b=PrShYazj; 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=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726831AbfDKBf4 (ORCPT + 99 others); Wed, 10 Apr 2019 21:35:56 -0400 Received: from new4-smtp.messagingengine.com ([66.111.4.230]:42279 "EHLO new4-smtp.messagingengine.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726106AbfDKBf4 (ORCPT ); Wed, 10 Apr 2019 21:35:56 -0400 Received: from compute3.internal (compute3.nyi.internal [10.202.2.43]) by mailnew.nyi.internal (Postfix) with ESMTP id 486741426A; Wed, 10 Apr 2019 21:35:55 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute3.internal (MEProxy); Wed, 10 Apr 2019 21:35:55 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:date:from :in-reply-to:message-id:mime-version:references:subject:to :x-me-proxy:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s= fm2; bh=bxV5jBaXvA/LKL0qOR0ZLSK5IIfdrfWAd0nyjsopfiM=; b=PrShYazj J7g3amgSFJOXs0AmeAmek0urDxYw9Q8khwQEVOj5lX5EDGQj03Imu0ZhqicOLmyv hAgIka9i5+Xrhl6WoQc8tUhjVAmoECKTRWLJcDu8B14MAFYb+wOQbz1AQMXunTGU ICuugwNW6g2+fzectfA24m8cMQTBDyUlbNzUgZTPWg3br70NE2AFRPmhlnZsiVll qYQOWbr6b7pBApy/AvnsWSwoFWLwTgFMUxjXdCRljrtUdfP7e1B/DQNrGi2MpHZg 2Iph5llNCS40QsxEwu7oQHA/vddwb3PrCSDJRfIy68K7jGQIY3knsHS4bg4ja2a/ jyyP2LBWhi9onQ== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeduuddrudekgdegvdcutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenuc fjughrpefhvffufffkofgjfhgggfestdekredtredttdenucfhrhhomhepfdfvohgsihhn ucevrdcujfgrrhguihhnghdfuceothhosghinheskhgvrhhnvghlrdhorhhgqeenucfkph epuddvgedrudejuddrudelrdduleegnecurfgrrhgrmhepmhgrihhlfhhrohhmpehtohgs ihhnsehkvghrnhgvlhdrohhrghenucevlhhushhtvghrufhiiigvpedt X-ME-Proxy: Received: from eros.localdomain (124-171-19-194.dyn.iinet.net.au [124.171.19.194]) by mail.messagingengine.com (Postfix) with ESMTPA id 671AAE4210; Wed, 10 Apr 2019 21:35:47 -0400 (EDT) From: "Tobin C. Harding" To: Andrew Morton Cc: "Tobin C. Harding" , Roman Gushchin , Alexander Viro , Christoph Hellwig , Pekka Enberg , David Rientjes , Joonsoo Kim , Christopher Lameter , Matthew Wilcox , Miklos Szeredi , Andreas Dilger , Waiman Long , Tycho Andersen , "Theodore Ts'o" , Andi Kleen , David Chinner , Nick Piggin , Rik van Riel , Hugh Dickins , Jonathan Corbet , linux-mm@kvack.org, linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [RFC PATCH v3 02/15] tools/vm/slabinfo: Add support for -C and -M options Date: Thu, 11 Apr 2019 11:34:28 +1000 Message-Id: <20190411013441.5415-3-tobin@kernel.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190411013441.5415-1-tobin@kernel.org> References: <20190411013441.5415-1-tobin@kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org -C lists caches that use a ctor. -M lists caches that support object migration. Add command line options to show caches with a constructor and caches that are movable (i.e. have migrate function). Co-developed-by: Christoph Lameter Signed-off-by: Tobin C. Harding --- tools/vm/slabinfo.c | 40 ++++++++++++++++++++++++++++++++++++---- 1 file changed, 36 insertions(+), 4 deletions(-) diff --git a/tools/vm/slabinfo.c b/tools/vm/slabinfo.c index 73818f1b2ef8..cbfc56c44c2f 100644 --- a/tools/vm/slabinfo.c +++ b/tools/vm/slabinfo.c @@ -33,6 +33,7 @@ struct slabinfo { unsigned int hwcache_align, object_size, objs_per_slab; unsigned int sanity_checks, slab_size, store_user, trace; int order, poison, reclaim_account, red_zone; + int movable, ctor; unsigned long partial, objects, slabs, objects_partial, objects_total; unsigned long alloc_fastpath, alloc_slowpath; unsigned long free_fastpath, free_slowpath; @@ -67,6 +68,8 @@ int show_report; int show_alias; int show_slab; int skip_zero = 1; +int show_movable; +int show_ctor; int show_numa; int show_track; int show_first_alias; @@ -109,11 +112,13 @@ static void fatal(const char *x, ...) static void usage(void) { - printf("slabinfo 4/15/2011. (c) 2007 sgi/(c) 2011 Linux Foundation.\n\n" - "slabinfo [-aADefhilnosrStTvz1LXBU] [N=K] [-dafzput] [slab-regexp]\n" + printf("slabinfo 4/15/2017. (c) 2007 sgi/(c) 2011 Linux Foundation/(c) 2017 Jump Trading LLC.\n\n" + "slabinfo [-aACDefhilMnosrStTvz1LXBU] [N=K] [-dafzput] [slab-regexp]\n" + "-a|--aliases Show aliases\n" "-A|--activity Most active slabs first\n" "-B|--Bytes Show size in bytes\n" + "-C|--ctor Show slabs with ctors\n" "-D|--display-active Switch line format to activity\n" "-e|--empty Show empty slabs\n" "-f|--first-alias Show first alias\n" @@ -121,6 +126,7 @@ static void usage(void) "-i|--inverted Inverted list\n" "-l|--slabs Show slabs\n" "-L|--Loss Sort by loss\n" + "-M|--movable Show caches that support movable objects\n" "-n|--numa Show NUMA information\n" "-N|--lines=K Show the first K slabs\n" "-o|--ops Show kmem_cache_ops\n" @@ -588,6 +594,12 @@ static void slabcache(struct slabinfo *s) if (show_empty && s->slabs) return; + if (show_ctor && !s->ctor) + return; + + if (show_movable && !s->movable) + return; + if (sort_loss == 0) store_size(size_str, slab_size(s)); else @@ -602,6 +614,10 @@ static void slabcache(struct slabinfo *s) *p++ = '*'; if (s->cache_dma) *p++ = 'd'; + if (s->ctor) + *p++ = 'C'; + if (s->movable) + *p++ = 'M'; if (s->hwcache_align) *p++ = 'A'; if (s->poison) @@ -636,7 +652,8 @@ static void slabcache(struct slabinfo *s) printf("%-21s %8ld %7d %15s %14s %4d %1d %3ld %3ld %s\n", s->name, s->objects, s->object_size, size_str, dist_str, s->objs_per_slab, s->order, - s->slabs ? (s->partial * 100) / s->slabs : 100, + s->slabs ? (s->partial * 100) / + (s->slabs * s->objs_per_slab) : 100, s->slabs ? (s->objects * s->object_size * 100) / (s->slabs * (page_size << s->order)) : 100, flags); @@ -1256,6 +1273,13 @@ static void read_slab_dir(void) slab->alloc_node_mismatch = get_obj("alloc_node_mismatch"); slab->deactivate_bypass = get_obj("deactivate_bypass"); chdir(".."); + if (read_slab_obj(slab, "ops")) { + if (strstr(buffer, "ctor :")) + slab->ctor = 1; + if (strstr(buffer, "migrate :")) + slab->movable = 1; + } + if (slab->name[0] == ':') alias_targets++; slab++; @@ -1332,6 +1356,8 @@ static void xtotals(void) } struct option opts[] = { + { "ctor", no_argument, NULL, 'C' }, + { "movable", no_argument, NULL, 'M' }, { "aliases", no_argument, NULL, 'a' }, { "activity", no_argument, NULL, 'A' }, { "debug", optional_argument, NULL, 'd' }, @@ -1367,7 +1393,7 @@ int main(int argc, char *argv[]) page_size = getpagesize(); - while ((c = getopt_long(argc, argv, "aAd::Defhil1noprstvzTSN:LXBU", + while ((c = getopt_long(argc, argv, "aACd::Defhil1MnoprstvzTSN:LXBU", opts, NULL)) != -1) switch (c) { case '1': @@ -1376,6 +1402,9 @@ int main(int argc, char *argv[]) case 'a': show_alias = 1; break; + case 'C': + show_ctor = 1; + break; case 'A': sort_active = 1; break; @@ -1399,6 +1428,9 @@ int main(int argc, char *argv[]) case 'i': show_inverted = 1; break; + case 'M': + show_movable = 1; + break; case 'n': show_numa = 1; break; -- 2.21.0