From: Christoph Lameter <cl@linux-foundation.org>
To: Pekka Enberg <penberg@cs.helsinki.fi>
Cc: akpm@linux-foundation.org, Christoph Lameter <clameter@sgi.com>,
Christoph Lameter <cl@linux-foundation.org>
Cc: linux-kernel@vger.kernel.org
Cc: linux-fsdevel@vger.kernel.org
Cc: Mel Gorman <mel@skynet.ie>
Cc: andi@firstfloor.org
Cc: Rik van Riel <riel@redhat.com>
Cc: mpm@selenic.com
Cc: Dave Chinner <david@fromorbit.com>
Subject: [patch 08/19] slub/slabinfo: add defrag statistics
Date: Fri, 09 May 2008 19:21:09 -0700 [thread overview]
Message-ID: <20080801182345.763541750@lameter.com> (raw)
In-Reply-To: 20080801182324.572058187@lameter.com
[-- Attachment #1: 0008-slub-add-defrag-statistics.patch --]
[-- Type: text/plain, Size: 8843 bytes --]
Add statistics counters for slab defragmentation.
Signed-off-by: Christoph Lameter <clameter@sgi.com>
Signed-off-by: Pekka Enberg <penberg@cs.helsinki.fi>
Signed-off-by: Christoph Lameter <cl@linux-foundation.org>
---
Documentation/vm/slabinfo.c | 45 ++++++++++++++++++++++++++++++++++++--------
include/linux/slub_def.h | 6 +++++
mm/slub.c | 29 ++++++++++++++++++++++++++--
3 files changed, 70 insertions(+), 10 deletions(-)
Index: linux-2.6/Documentation/vm/slabinfo.c
===================================================================
--- linux-2.6.orig/Documentation/vm/slabinfo.c 2008-07-31 12:18:58.000000000 -0500
+++ linux-2.6/Documentation/vm/slabinfo.c 2008-07-31 12:18:58.000000000 -0500
@@ -41,6 +41,9 @@
unsigned long cpuslab_flush, deactivate_full, deactivate_empty;
unsigned long deactivate_to_head, deactivate_to_tail;
unsigned long deactivate_remote_frees, order_fallback;
+ unsigned long shrink_calls, shrink_attempt_defrag, shrink_empty_slab;
+ unsigned long shrink_slab_skipped, shrink_slab_reclaimed;
+ unsigned long shrink_object_reclaim_failed;
int numa[MAX_NODES];
int numa_partial[MAX_NODES];
} slabinfo[MAX_SLABS];
@@ -79,6 +82,7 @@
int set_debug = 0;
int show_ops = 0;
int show_activity = 0;
+int show_defragcount = 0;
/* Debug options */
int sanity = 0;
@@ -113,6 +117,7 @@
"-e|--empty Show empty slabs\n"
"-f|--first-alias Show first alias\n"
"-F|--defrag Show defragmentable caches\n"
+ "-G:--display-defrag Display defrag counters\n"
"-h|--help Show usage information\n"
"-i|--inverted Inverted list\n"
"-l|--slabs Show slabs\n"
@@ -300,6 +305,8 @@
{
if (show_activity)
printf("Name Objects Alloc Free %%Fast Fallb O\n");
+ else if (show_defragcount)
+ printf("Name Objects DefragRQ Slabs Success Empty Skipped Failed\n");
else
printf("Name Objects Objsize Space "
"Slabs/Part/Cpu O/S O %%Ra %%Ef Flg\n");
@@ -466,22 +473,28 @@
printf("Total %8lu %8lu\n\n", total_alloc, total_free);
- if (s->cpuslab_flush)
- printf("Flushes %8lu\n", s->cpuslab_flush);
-
- if (s->alloc_refill)
- printf("Refill %8lu\n", s->alloc_refill);
+ if (s->cpuslab_flush || s->alloc_refill)
+ printf("CPU Slab : Flushes=%lu Refills=%lu\n",
+ s->cpuslab_flush, s->alloc_refill);
total = s->deactivate_full + s->deactivate_empty +
s->deactivate_to_head + s->deactivate_to_tail;
if (total)
- printf("Deactivate Full=%lu(%lu%%) Empty=%lu(%lu%%) "
+ printf("Deactivate: Full=%lu(%lu%%) Empty=%lu(%lu%%) "
"ToHead=%lu(%lu%%) ToTail=%lu(%lu%%)\n",
s->deactivate_full, (s->deactivate_full * 100) / total,
s->deactivate_empty, (s->deactivate_empty * 100) / total,
s->deactivate_to_head, (s->deactivate_to_head * 100) / total,
s->deactivate_to_tail, (s->deactivate_to_tail * 100) / total);
+
+ if (s->shrink_calls)
+ printf("Shrink : Calls=%lu Attempts=%lu Empty=%lu Successful=%lu\n",
+ s->shrink_calls, s->shrink_attempt_defrag,
+ s->shrink_empty_slab, s->shrink_slab_reclaimed);
+ if (s->shrink_slab_skipped || s->shrink_object_reclaim_failed)
+ printf("Defrag : Slabs skipped=%lu Object reclaim failed=%lu\n",
+ s->shrink_slab_skipped, s->shrink_object_reclaim_failed);
}
void report(struct slabinfo *s)
@@ -598,7 +611,12 @@
total_alloc ? (s->alloc_fastpath * 100 / total_alloc) : 0,
total_free ? (s->free_fastpath * 100 / total_free) : 0,
s->order_fallback, s->order);
- }
+ } else
+ if (show_defragcount)
+ printf("%-21s %8ld %7d %7d %7d %7d %7d %7d\n",
+ s->name, s->objects, s->shrink_calls, s->shrink_attempt_defrag,
+ s->shrink_slab_reclaimed, s->shrink_empty_slab,
+ s->shrink_slab_skipped, s->shrink_object_reclaim_failed);
else
printf("%-21s %8ld %7d %8s %14s %4d %1d %3ld %3ld %s\n",
s->name, s->objects, s->object_size, size_str, dist_str,
@@ -1210,6 +1228,13 @@
slab->deactivate_to_tail = get_obj("deactivate_to_tail");
slab->deactivate_remote_frees = get_obj("deactivate_remote_frees");
slab->order_fallback = get_obj("order_fallback");
+ slab->shrink_calls = get_obj("shrink_calls");
+ slab->shrink_attempt_defrag = get_obj("shrink_attempt_defrag");
+ slab->shrink_empty_slab = get_obj("shrink_empty_slab");
+ slab->shrink_slab_skipped = get_obj("shrink_slab_skipped");
+ slab->shrink_slab_reclaimed = get_obj("shrink_slab_reclaimed");
+ slab->shrink_object_reclaim_failed =
+ get_obj("shrink_object_reclaim_failed");
slab->defrag_ratio = get_obj("defrag_ratio");
slab->remote_node_defrag_ratio =
get_obj("remote_node_defrag_ratio");
@@ -1274,6 +1299,7 @@
{ "ctor", 0, NULL, 'C' },
{ "debug", 2, NULL, 'd' },
{ "display-activity", 0, NULL, 'D' },
+ { "display-defrag", 0, NULL, 'G' },
{ "empty", 0, NULL, 'e' },
{ "first-alias", 0, NULL, 'f' },
{ "defrag", 0, NULL, 'F' },
@@ -1299,7 +1325,7 @@
page_size = getpagesize();
- while ((c = getopt_long(argc, argv, "aACd::DefFhil1noprstvzTS",
+ while ((c = getopt_long(argc, argv, "aACd::DefFGhil1noprstvzTS",
opts, NULL)) != -1)
switch (c) {
case '1':
@@ -1325,6 +1351,9 @@
case 'f':
show_first_alias = 1;
break;
+ case 'G':
+ show_defragcount = 1;
+ break;
case 'h':
usage();
return 0;
Index: linux-2.6/include/linux/slub_def.h
===================================================================
--- linux-2.6.orig/include/linux/slub_def.h 2008-07-31 12:18:58.000000000 -0500
+++ linux-2.6/include/linux/slub_def.h 2008-07-31 12:18:58.000000000 -0500
@@ -30,6 +30,12 @@
DEACTIVATE_TO_TAIL, /* Cpu slab was moved to the tail of partials */
DEACTIVATE_REMOTE_FREES,/* Slab contained remotely freed objects */
ORDER_FALLBACK, /* Number of times fallback was necessary */
+ SHRINK_CALLS, /* Number of invocations of kmem_cache_shrink */
+ SHRINK_ATTEMPT_DEFRAG, /* Slabs that were attempted to be reclaimed */
+ SHRINK_EMPTY_SLAB, /* Shrink encountered and freed empty slab */
+ SHRINK_SLAB_SKIPPED, /* Slab reclaim skipped an slab (busy etc) */
+ SHRINK_SLAB_RECLAIMED, /* Successfully reclaimed slabs */
+ SHRINK_OBJECT_RECLAIM_FAILED, /* Callbacks signaled busy objects */
NR_SLUB_STAT_ITEMS };
struct kmem_cache_cpu {
Index: linux-2.6/mm/slub.c
===================================================================
--- linux-2.6.orig/mm/slub.c 2008-07-31 12:18:58.000000000 -0500
+++ linux-2.6/mm/slub.c 2008-07-31 12:18:58.000000000 -0500
@@ -2796,6 +2796,7 @@
void *private;
unsigned long flags;
unsigned long objects;
+ struct kmem_cache_cpu *c;
local_irq_save(flags);
slab_lock(page);
@@ -2844,9 +2845,13 @@
* Check the result and unfreeze the slab
*/
leftover = page->inuse;
- if (leftover)
+ c = get_cpu_slab(s, smp_processor_id());
+ if (leftover) {
/* Unsuccessful reclaim. Avoid future reclaim attempts. */
+ stat(c, SHRINK_OBJECT_RECLAIM_FAILED);
__ClearPageSlubKickable(page);
+ } else
+ stat(c, SHRINK_SLAB_RECLAIMED);
unfreeze_slab(s, page, leftover > 0);
local_irq_restore(flags);
return leftover;
@@ -2897,11 +2902,14 @@
LIST_HEAD(zaplist);
int freed = 0;
struct kmem_cache_node *n = get_node(s, node);
+ struct kmem_cache_cpu *c;
if (n->nr_partial <= limit)
return 0;
spin_lock_irqsave(&n->list_lock, flags);
+ c = get_cpu_slab(s, smp_processor_id());
+ stat(c, SHRINK_CALLS);
list_for_each_entry_safe(page, page2, &n->partial, lru) {
if (!slab_trylock(page))
/* Busy slab. Get out of the way */
@@ -2921,12 +2929,14 @@
list_move(&page->lru, &zaplist);
if (s->kick) {
+ stat(c, SHRINK_ATTEMPT_DEFRAG);
n->nr_partial--;
__SetPageSlubFrozen(page);
}
slab_unlock(page);
} else {
/* Empty slab page */
+ stat(c, SHRINK_EMPTY_SLAB);
list_del(&page->lru);
n->nr_partial--;
slab_unlock(page);
@@ -4355,6 +4365,12 @@
STAT_ATTR(DEACTIVATE_TO_TAIL, deactivate_to_tail);
STAT_ATTR(DEACTIVATE_REMOTE_FREES, deactivate_remote_frees);
STAT_ATTR(ORDER_FALLBACK, order_fallback);
+STAT_ATTR(SHRINK_CALLS, shrink_calls);
+STAT_ATTR(SHRINK_ATTEMPT_DEFRAG, shrink_attempt_defrag);
+STAT_ATTR(SHRINK_EMPTY_SLAB, shrink_empty_slab);
+STAT_ATTR(SHRINK_SLAB_SKIPPED, shrink_slab_skipped);
+STAT_ATTR(SHRINK_SLAB_RECLAIMED, shrink_slab_reclaimed);
+STAT_ATTR(SHRINK_OBJECT_RECLAIM_FAILED, shrink_object_reclaim_failed);
#endif
static struct attribute *slab_attrs[] = {
@@ -4409,6 +4425,12 @@
&deactivate_to_tail_attr.attr,
&deactivate_remote_frees_attr.attr,
&order_fallback_attr.attr,
+ &shrink_calls_attr.attr,
+ &shrink_attempt_defrag_attr.attr,
+ &shrink_empty_slab_attr.attr,
+ &shrink_slab_skipped_attr.attr,
+ &shrink_slab_reclaimed_attr.attr,
+ &shrink_object_reclaim_failed_attr.attr,
#endif
NULL
};
--
next prev parent reply other threads:[~2008-08-01 18:32 UTC|newest]
Thread overview: 64+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-05-10 2:21 [patch 00/19] Slab Fragmentation Reduction V13 Christoph Lameter
2008-05-10 2:21 ` [patch 01/19] slub: Add defrag_ratio field and sysfs support Christoph Lameter
2008-05-10 2:21 ` [patch 02/19] slub: Replace ctor field with ops field in /sys/slab/* Christoph Lameter
2008-05-10 2:21 ` [patch 03/19] slub: Add get() and kick() methods Christoph Lameter
2008-05-10 2:21 ` [patch 04/19] slub: Sort slab cache list and establish maximum objects for defrag slabs Christoph Lameter
2008-05-10 2:21 ` [patch 05/19] slub: Slab defrag core Christoph Lameter
2008-05-10 2:21 ` [patch 06/19] slub: Add KICKABLE to avoid repeated kick() attempts Christoph Lameter
2008-05-10 2:21 ` [patch 07/19] slub: Extend slabinfo to support -D and -F options Christoph Lameter
2008-05-10 2:21 ` Christoph Lameter [this message]
2008-05-10 2:21 ` [patch 09/19] slub: Trigger defragmentation from memory reclaim Christoph Lameter
2008-05-10 2:21 ` [patch 10/19] buffer heads: Support slab defrag Christoph Lameter
2008-05-10 2:21 ` [patch 11/19] inodes: Support generic defragmentation Christoph Lameter
2008-05-10 2:21 ` [patch 12/19] Filesystem: Ext2 filesystem defrag Christoph Lameter
2008-05-10 2:21 ` [patch 13/19] Filesystem: Ext3 " Christoph Lameter
2008-05-10 2:21 ` [patch 14/19] Filesystem: Ext4 " Christoph Lameter
2008-08-03 1:54 ` Theodore Tso
2008-08-13 7:26 ` Pekka Enberg
2008-05-10 2:21 ` [patch 15/19] Filesystem: XFS slab defragmentation Christoph Lameter
2008-08-03 1:42 ` Dave Chinner
2008-08-04 13:36 ` Christoph Lameter
2008-05-10 2:21 ` [patch 16/19] Filesystem: /proc filesystem support for slab defrag Christoph Lameter
2008-05-10 2:21 ` [patch 17/19] Filesystem: Slab defrag: Reiserfs support Christoph Lameter
2008-05-10 2:21 ` [patch 18/19] dentries: Add constructor Christoph Lameter
2008-05-10 2:21 ` [patch 19/19] dentries: dentry defragmentation Christoph Lameter
2008-08-03 1:58 ` No, really, stop trying to delete slab until you've finished making slub perform as well Matthew Wilcox
2008-08-03 21:25 ` Pekka Enberg
2008-08-04 2:37 ` Rene Herman
2008-08-04 21:22 ` Pekka Enberg
2008-08-04 21:41 ` Christoph Lameter
2008-08-04 23:09 ` Rene Herman
2008-08-04 13:43 ` Christoph Lameter
2008-08-04 14:48 ` Jamie Lokier
2008-08-04 15:21 ` Jamie Lokier
2008-08-04 16:35 ` Christoph Lameter
2008-08-04 15:11 ` Rik van Riel
2008-08-04 16:02 ` Christoph Lameter
2008-08-04 16:47 ` KOSAKI Motohiro
2008-08-04 17:13 ` Christoph Lameter
2008-08-04 17:20 ` Pekka Enberg
2008-08-05 12:06 ` KOSAKI Motohiro
2008-08-05 14:59 ` Christoph Lameter
2008-08-06 12:36 ` KOSAKI Motohiro
2008-08-06 14:24 ` Christoph Lameter
2008-08-13 10:46 ` KOSAKI Motohiro
2008-08-13 13:10 ` Christoph Lameter
2008-08-13 14:14 ` KOSAKI Motohiro
2008-08-13 14:16 ` Pekka Enberg
2008-08-13 14:31 ` Christoph Lameter
2008-08-13 15:05 ` KOSAKI Motohiro
2008-08-14 19:44 ` Christoph Lameter
2008-08-15 16:44 ` KOSAKI Motohiro
2008-08-15 18:24 ` Christoph Lameter
2008-08-15 19:42 ` Christoph Lameter
2008-08-18 10:08 ` KOSAKI Motohiro
2008-08-18 10:34 ` KOSAKI Motohiro
2008-08-18 14:08 ` Christoph Lameter
2008-08-19 10:34 ` KOSAKI Motohiro
2008-08-19 13:51 ` Christoph Lameter
2008-08-20 11:46 ` KOSAKI Motohiro
2008-08-14 7:15 ` Pekka Enberg
2008-08-14 14:45 ` Christoph Lameter
2008-08-14 15:06 ` Christoph Lameter
2008-08-04 17:19 ` Christoph Lameter
-- strict thread matches above, loose matches on Subject: below --
2008-08-11 15:06 [patch 00/19] Slab Fragmentation Reduction V14 Christoph Lameter
2008-08-11 15:06 ` [patch 08/19] slub/slabinfo: add defrag statistics Christoph Lameter
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20080801182345.763541750@lameter.com \
--to=cl@linux-foundation.org \
--cc=akpm@linux-foundation.org \
--cc=clameter@sgi.com \
--cc=penberg@cs.helsinki.fi \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).