From patchwork Fri Apr 26 02:26:20 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Tobin C. Harding" X-Patchwork-Id: 10917983 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 7D5BF912 for ; Fri, 26 Apr 2019 02:27:37 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6B34128C5E for ; Fri, 26 Apr 2019 02:27:37 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 5F82828D2F; Fri, 26 Apr 2019 02:27:37 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id DCC6A28C5E for ; Fri, 26 Apr 2019 02:27:36 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id E1A966B0007; Thu, 25 Apr 2019 22:27:35 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id DCA336B0008; Thu, 25 Apr 2019 22:27:35 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id C927F6B000A; Thu, 25 Apr 2019 22:27:35 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-qt1-f199.google.com (mail-qt1-f199.google.com [209.85.160.199]) by kanga.kvack.org (Postfix) with ESMTP id A7D996B0007 for ; Thu, 25 Apr 2019 22:27:35 -0400 (EDT) Received: by mail-qt1-f199.google.com with SMTP id j49so1626317qtk.19 for ; Thu, 25 Apr 2019 19:27:35 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:dkim-signature:from:to:cc:subject:date :message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=aATYrCxRlNMszFJ57g3u99UUP818320yu7bmbbR1Mt4=; b=Y+Ne6DMqsoXxzCiNhKSg0qqIFOggY36e7EnolXxW2b7usw4j3qci7waL3jHjjZlk4D TY9l3IYstGckEVpGHKsjhSYV3ATjS7Ohd5tjAraw76pLs9PPi09o5JDtQFlkUNtos8ub 3IE0gLii5SFh4jNrZ92aFpM0afeYpAvESF17PX+fji7cbV2gGWHR6o3NzLQw8bRaM3Di z8PY0dhrLY5Qx4/FADUSCtQc9DVUIC/WBd5Domc3SuDikF8cwx90ZEDCtGDxaP/EskbA kulQLhy6nXy9vQ7I9gmnei57yAgi75TQQwDZAS5F/su1xCroDmqxZ5DHnQVSUfzew4lf ifOA== X-Gm-Message-State: APjAAAXuz+zUR/bs45hDsV2pfzjLozcOc5z5sS4H6JQIwal9BVYF9DkE zB6PUmHthtmewQF+7uQdEEilDCyI81Gab9eC3BZVB3HfRRdKqqQ+f8yEcIPz437EHROWwAs1aAr M2nV1AJhYup0dYYl3eB46lOf+IZWUuuDKHTWq2P6CUxt7/0PWQVEI0Da4RuwGEFg= X-Received: by 2002:a37:8fc3:: with SMTP id r186mr33957507qkd.102.1556245655455; Thu, 25 Apr 2019 19:27:35 -0700 (PDT) X-Google-Smtp-Source: APXvYqzOaftDGbrT3tTx/jYEMHsG+KYRUTHmTwr/08IGa5MLwDvaycehR8aKiVLVgzMwS/N3Nbol X-Received: by 2002:a37:8fc3:: with SMTP id r186mr33957458qkd.102.1556245654378; Thu, 25 Apr 2019 19:27:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1556245654; cv=none; d=google.com; s=arc-20160816; b=fIdjIE+kAJLx2Yg6zDcGoU9CrZZvVr46Dc6CUuTkbGfBVG0e3DY0dbDCJC+CgiOY5k bQOccHXqiAZvu+V9tJgQKjgZHxJVQ/RBCuJ5N3I3f6vTpc4t/rcgun0i3avjHp3tOVLK 8tPts7pF5DIq//UntDLSDKRPkCL6HJ+hK+y7W8lITAsC7gHx5bbZ+X2W3lTDD+7HdEJC cMLeg12xDoliA3IwG9Dxe/ZgD+I0k6VQ+yc6FNRJZUlxkvlBuj1TuRBRxcgrH2JZDQCb NHRdwneVlClxXE68OpD8H4QuJww6nSwAg+dYIaDYaT3hTA5Uf9SYbsgv5rCHzvFk6/+F 8deQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:dkim-signature; bh=aATYrCxRlNMszFJ57g3u99UUP818320yu7bmbbR1Mt4=; b=Bxj2xSrhxKmKo9P2N4oqg2UM8owz1zsvRDnc02erqq5YHRmNm2IF7xd7x1D1lo34rj vU3YZqtx4PkaXZQvg5Sudk2ybJ+bjynHqljMvvIC806mddPyftPaBaQ3mo+DPJ4QnrdW uNwJkfdKPvEG/RYCyg39+/9Q9AFelsyQV+Ek1g12lFWZnF9BGaMbtJIQKJnyQ1rTrWeK nY1neJrnJd/VXLAb4S1lzsEsQYgGJ0D3571MkxnTlsY/HnJW+nBDAnFqQjY0nX5rKx5R v5IsGFN/rrbHv5zxfBM1BA42f8IjXmsygj4FD14KnkEy5KWvsvPgPwK+fT15UB4qpXG7 7psw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@messagingengine.com header.s=fm2 header.b=68vQh+yi; spf=softfail (google.com: domain of transitioning tobin@kernel.org does not designate 66.111.4.221 as permitted sender) smtp.mailfrom=tobin@kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from new1-smtp.messagingengine.com (new1-smtp.messagingengine.com. [66.111.4.221]) by mx.google.com with ESMTPS id g15si5333454qki.133.2019.04.25.19.27.34 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 25 Apr 2019 19:27:34 -0700 (PDT) Received-SPF: softfail (google.com: domain of transitioning tobin@kernel.org does not designate 66.111.4.221 as permitted sender) client-ip=66.111.4.221; Authentication-Results: mx.google.com; dkim=pass header.i=@messagingengine.com header.s=fm2 header.b=68vQh+yi; spf=softfail (google.com: domain of transitioning tobin@kernel.org does not designate 66.111.4.221 as permitted sender) smtp.mailfrom=tobin@kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from compute3.internal (compute3.nyi.internal [10.202.2.43]) by mailnew.nyi.internal (Postfix) with ESMTP id 0D24710FA2; Thu, 25 Apr 2019 22:27:34 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute3.internal (MEProxy); Thu, 25 Apr 2019 22:27:34 -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=aATYrCxRlNMszFJ57g3u99UUP818320yu7bmbbR1Mt4=; b=68vQh+yi M75/HLJuUgg97N18rXVBRlHToOk742865TAoiRxWPyqFG95mjm3E1uVuLFsiRLAb ABG5WUNf5jgQSzekVQs/9nDOXKVGCVOnUArwPFrh0awYu8ci3FP634CLHaJBhw3l 6RmMNRAFD9kyEY3rm9PVwfvLQTlWTwuORh2yMtwL1Q5YZiS4ccHYbWv0/y7+NDJb Y/KS23rBvGHqQycUP5jhobVbGU6iAAx2Ushd3IpWLsw9sTtG5PUML+VkO+Yl9laK puyiw1HZF2rnA8OuIreveUWdo0/p+TbSqIu2mDBUaMk4JpTcfikINciam/RbI0qh 9zw7LoJdGLb1Kg== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeduuddrheehgdehlecutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenuc fjughrpefhvffufffkofgjfhgggfestdekredtredttdenucfhrhhomhepfdfvohgsihhn ucevrdcujfgrrhguihhnghdfuceothhosghinheskhgvrhhnvghlrdhorhhgqeenucfkph epuddvgedrudeiledrudehledrvddutdenucfrrghrrghmpehmrghilhhfrhhomhepthho sghinheskhgvrhhnvghlrdhorhhgnecuvehluhhsthgvrhfuihiivgepud X-ME-Proxy: Received: from eros.localdomain (124-169-159-210.dyn.iinet.net.au [124.169.159.210]) by mail.messagingengine.com (Postfix) with ESMTPA id 70F8F103C8; Thu, 25 Apr 2019 22:27:28 -0400 (EDT) From: "Tobin C. Harding" To: Andrew Morton Cc: "Tobin C. Harding" , Jesper Dangaard Brouer , Pekka Enberg , Vlastimil Babka , Christoph Lameter , David Rientjes , Joonsoo Kim , Tejun Heo , Qian Cai , Linus Torvalds , Mel Gorman , Alexander Duyck , Michal Hocko , Brendan Gregg , linux-mm@kvack.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 2/4] tools/vm/slabinfo: Add partial slab listing to -X Date: Fri, 26 Apr 2019 12:26:20 +1000 Message-Id: <20190426022622.4089-3-tobin@kernel.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190426022622.4089-1-tobin@kernel.org> References: <20190426022622.4089-1-tobin@kernel.org> MIME-Version: 1.0 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: X-Virus-Scanned: ClamAV using ClamSMTP We would like to see how fragmented the SLUB allocator is, one window into fragmentation is the total number of partial slabs. Currently `slabinfo -X` shows slabs sorted by loss and by size. We can use this option to also show slabs sorted by number of partial slabs. Option '-X' can be used in conjunction with '-N' to control the number of slabs shown e.g. list of top 5 slabs: slabinfo -X -N5 Add list of slabs ordered by number of partial slabs to output of `slabinfo -X`. Signed-off-by: Tobin C. Harding --- tools/vm/slabinfo.c | 41 ++++++++++++++++++++++++++++------------- 1 file changed, 28 insertions(+), 13 deletions(-) diff --git a/tools/vm/slabinfo.c b/tools/vm/slabinfo.c index e9b5437b2f28..3f3a2db65794 100644 --- a/tools/vm/slabinfo.c +++ b/tools/vm/slabinfo.c @@ -79,6 +79,7 @@ int sort_size; int sort_active; int set_debug; int show_ops; +int sort_partial; int show_activity; int output_lines = -1; int sort_loss; @@ -1047,6 +1048,8 @@ static void sort_slabs(void) result = slab_activity(s1) < slab_activity(s2); else if (sort_loss) result = slab_waste(s1) < slab_waste(s2); + else if (sort_partial) + result = s1->partial < s2->partial; else result = strcasecmp(s1->name, s2->name); @@ -1307,27 +1310,39 @@ static void output_slabs(void) } } +static void _xtotals(char *heading, char *underline, + int loss, int size, int partial) +{ + printf("%s%s", heading, underline); + line = 0; + sort_loss = loss; + sort_size = size; + sort_partial = partial; + sort_slabs(); + output_slabs(); +} + static void xtotals(void) { + char *heading, *underline; + totals(); link_slabs(); rename_slabs(); - printf("\nSlabs sorted by size\n"); - printf("--------------------\n"); - sort_loss = 0; - sort_size = 1; - sort_slabs(); - output_slabs(); + heading = "\nSlabs sorted by size\n"; + underline = "--------------------\n"; + _xtotals(heading, underline, 0, 1, 0); + + heading = "\nSlabs sorted by loss\n"; + underline = "--------------------\n"; + _xtotals(heading, underline, 1, 0, 0); + + heading = "\nSlabs sorted by number of partial slabs\n"; + underline = "---------------------------------------\n"; + _xtotals(heading, underline, 0, 0, 1); - printf("\nSlabs sorted by loss\n"); - printf("--------------------\n"); - line = 0; - sort_loss = 1; - sort_size = 0; - sort_slabs(); - output_slabs(); printf("\n"); }