From: Mel Gorman <mel@csn.ul.ie>
To: akpm@osdl.org
Cc: linux-mm@kvack.org, lhms-devel@lists.sourceforge.net,
linux-kernel@vger.kernel.org, Mel Gorman <mel@csn.ul.ie>
Subject: [PATCH 7/7] Fragmentation Avoidance V19: 007_stats
Date: Sun, 30 Oct 2005 18:34:30 +0000 (GMT) [thread overview]
Message-ID: <20051030183429.22266.85501.sendpatchset@skynet.csn.ul.ie> (raw)
In-Reply-To: <20051030183354.22266.42795.sendpatchset@skynet.csn.ul.ie>
It is not necessary to apply this patch to get all the anti-fragmentation
code. This patch adds a new config option called CONFIG_ALLOCSTATS. If
set, a number of new bean counters are added that are related to the
anti-fragmentation code. The information is exported via /proc/buddyinfo. This
is very useful when debugging why high-order pages are not available for
allocation.
Signed-off-by: Mel Gorman <mel@csn.ul.ie>
diff -rup -X /usr/src/patchset-0.5/bin//dontdiff linux-2.6.14-rc5-mm1-006_percpu/include/linux/mmzone.h linux-2.6.14-rc5-mm1-007_stats/include/linux/mmzone.h
--- linux-2.6.14-rc5-mm1-006_percpu/include/linux/mmzone.h 2005-10-30 13:38:14.000000000 +0000
+++ linux-2.6.14-rc5-mm1-007_stats/include/linux/mmzone.h 2005-10-30 13:38:56.000000000 +0000
@@ -193,6 +193,17 @@ struct zone {
/* Number of pages currently used for RCLM_FALLBACK */
unsigned long fallback_reserve;
+#ifdef CONFIG_ALLOCSTATS
+ /*
+ * These are beancounters that track how the placement policy
+ * of the buddy allocator is performing
+ */
+ unsigned long fallback_count[RCLM_TYPES];
+ unsigned long alloc_count[RCLM_TYPES];
+ unsigned long reserve_count[RCLM_TYPES];
+ unsigned long kernnorclm_full_steal;
+ unsigned long kernnorclm_partial_steal;
+#endif
ZONE_PADDING(_pad1_)
/* Fields commonly accessed by the page reclaim scanner */
@@ -292,6 +303,17 @@ struct zone {
char *name;
} ____cacheline_maxaligned_in_smp;
+#ifdef CONFIG_ALLOCSTATS
+#define inc_fallback_count(zone, type) zone->fallback_count[type]++
+#define inc_alloc_count(zone, type) zone->alloc_count[type]++
+#define inc_kernnorclm_partial_steal(zone) zone->kernnorclm_partial_steal++
+#define inc_kernnorclm_full_steal(zone) zone->kernnorclm_full_steal++
+#else
+#define inc_fallback_count(zone, type) do {} while (0)
+#define inc_alloc_count(zone, type) do {} while (0)
+#define inc_kernnorclm_partial_steal(zone) do {} while (0)
+#define inc_kernnorclm_full_steal(zone) do {} while (0)
+#endif
/*
* The "priority" of VM scanning is how much of the queues we will scan in one
@@ -319,12 +341,19 @@ static inline void inc_reserve_count(str
{
if (type == RCLM_FALLBACK)
zone->fallback_reserve += PAGES_PER_MAXORDER;
+#ifdef CONFIG_ALLOCSTATS
+ zone->reserve_count[type]++;
+#endif
}
static inline void dec_reserve_count(struct zone *zone, int type)
{
if (type == RCLM_FALLBACK && zone->fallback_reserve)
zone->fallback_reserve -= PAGES_PER_MAXORDER;
+#ifdef CONFIG_ALLOCSTATS
+ if (zone->reserve_count[type] > 0)
+ zone->reserve_count[type]--;
+#endif
}
/*
diff -rup -X /usr/src/patchset-0.5/bin//dontdiff linux-2.6.14-rc5-mm1-006_percpu/lib/Kconfig.debug linux-2.6.14-rc5-mm1-007_stats/lib/Kconfig.debug
--- linux-2.6.14-rc5-mm1-006_percpu/lib/Kconfig.debug 2005-10-30 13:20:06.000000000 +0000
+++ linux-2.6.14-rc5-mm1-007_stats/lib/Kconfig.debug 2005-10-30 13:38:56.000000000 +0000
@@ -77,6 +77,17 @@ config SCHEDSTATS
application, you can say N to avoid the very slight overhead
this adds.
+config ALLOCSTATS
+ bool "Collection buddy allocator statistics"
+ depends on DEBUG_KERNEL && PROC_FS
+ help
+ If you say Y here, additional code will be inserted into the
+ page allocator routines to collect statistics on the allocator
+ behavior and provide them in /proc/buddyinfo. These stats are
+ useful for measuring fragmentation in the buddy allocator. If
+ you are not debugging or measuring the allocator, you can say N
+ to avoid the slight overhead this adds.
+
config DEBUG_SLAB
bool "Debug memory allocations"
depends on DEBUG_KERNEL
diff -rup -X /usr/src/patchset-0.5/bin//dontdiff linux-2.6.14-rc5-mm1-006_percpu/mm/page_alloc.c linux-2.6.14-rc5-mm1-007_stats/mm/page_alloc.c
--- linux-2.6.14-rc5-mm1-006_percpu/mm/page_alloc.c 2005-10-30 13:38:14.000000000 +0000
+++ linux-2.6.14-rc5-mm1-007_stats/mm/page_alloc.c 2005-10-30 13:38:56.000000000 +0000
@@ -187,6 +187,11 @@ EXPORT_SYMBOL(zone_table);
static char *zone_names[MAX_NR_ZONES] = { "DMA", "DMA32", "Normal", "HighMem" };
int min_free_kbytes = 1024;
+#ifdef CONFIG_ALLOCSTATS
+static char *type_names[RCLM_TYPES] = { "KernNoRclm", "EasyRclm",
+ "KernRclm", "Fallback"};
+#endif /* CONFIG_ALLOCSTATS */
+
unsigned long __initdata nr_kernel_pages;
unsigned long __initdata nr_all_pages;
@@ -684,6 +689,9 @@ fallback_buddy_reserve(int start_allocty
dec_reserve_count(zone, get_pageblock_type(zone,page));
set_pageblock_type(zone, page, reserve_type);
inc_reserve_count(zone, reserve_type);
+ inc_kernnorclm_full_steal(zone);
+ } else {
+ inc_kernnorclm_partial_steal(zone);
}
return area;
}
@@ -726,6 +734,15 @@ fallback_alloc(int alloctype, struct zon
current_order, area);
}
+
+ /*
+ * If the current alloctype is RCLM_FALLBACK, it means
+ * that the requested pool and fallback pool are both
+ * depleted and we are falling back to other pools.
+ * At this point, pools are starting to get fragmented
+ */
+ if (alloctype == RCLM_FALLBACK)
+ inc_fallback_count(zone, start_alloctype);
}
return NULL;
@@ -742,6 +759,8 @@ static struct page *__rmqueue(struct zon
unsigned int current_order;
struct page *page;
+ inc_alloc_count(zone, alloctype);
+
for (current_order = order; current_order < MAX_ORDER; ++current_order) {
area = &zone->free_area_lists[alloctype][current_order];
if (list_empty(&area->free_list))
@@ -2373,6 +2392,9 @@ static __devinit void init_currently_emp
memmap_init(size, pgdat->node_id, zone_idx(zone), zone_start_pfn);
zone_init_free_lists(pgdat, zone, zone->spanned_pages);
+#ifdef CONFIG_ALLOCSTATS
+ zone->reserve_count[RCLM_NORCLM] = zone->present_pages >> (MAX_ORDER-1);
+#endif /* CONFIG_ALLOCSTATS */
}
/*
@@ -2528,6 +2550,18 @@ static int frag_show(struct seq_file *m,
int order, t;
struct free_area *area;
unsigned long nr_bufs = 0;
+#ifdef CONFIG_ALLOCSTATS
+ int i;
+ unsigned long kernnorclm_full_steal = 0;
+ unsigned long kernnorclm_partial_steal = 0;
+ unsigned long reserve_count[RCLM_TYPES];
+ unsigned long fallback_count[RCLM_TYPES];
+ unsigned long alloc_count[RCLM_TYPES];
+
+ memset(reserve_count, 0, sizeof(reserve_count));
+ memset(fallback_count, 0, sizeof(fallback_count));
+ memset(alloc_count, 0, sizeof(alloc_count));
+#endif
for (zone = node_zones; zone - node_zones < MAX_NR_ZONES; ++zone) {
if (!zone->present_pages)
@@ -2548,6 +2582,86 @@ static int frag_show(struct seq_file *m,
spin_unlock_irqrestore(&zone->lock, flags);
seq_putc(m, '\n');
}
+
+#ifdef CONFIG_ALLOCSTATS
+ /* Show statistics for each allocation type */
+ seq_printf(m, "\nPer-allocation-type statistics");
+ for (zone = node_zones; zone - node_zones < MAX_NR_ZONES; ++zone) {
+ if (!zone->present_pages)
+ continue;
+
+ spin_lock_irqsave(&zone->lock, flags);
+ for (t = 0; t < RCLM_TYPES; t++) {
+ struct list_head *elem;
+ seq_printf(m, "\nNode %d, zone %8s, type %10s ",
+ pgdat->node_id, zone->name,
+ type_names[t]);
+ for (order = 0; order < MAX_ORDER; ++order) {
+ nr_bufs = 0;
+
+ list_for_each(elem, &zone->free_area_lists[t][order].free_list)
+ ++nr_bufs;
+ seq_printf(m, "%6lu ", nr_bufs);
+ }
+ }
+
+ /* Scan global list */
+ seq_printf(m, "\n");
+ seq_printf(m, "Node %d, zone %8s, type %10s",
+ pgdat->node_id, zone->name,
+ "MAX_ORDER");
+ nr_bufs = 0;
+ for (t = 0; t < RCLM_TYPES; t++) {
+ nr_bufs +=
+ zone->free_area_lists[t][MAX_ORDER-1].nr_free;
+ }
+ seq_printf(m, "%6lu ", nr_bufs);
+ seq_printf(m, "\n");
+
+ seq_printf(m, "%s Zone beancounters\n", zone->name);
+ seq_printf(m, "Fallback reserve: %lu (%lu blocks)\n",
+ zone->fallback_reserve,
+ zone->fallback_reserve >> (MAX_ORDER-1));
+ seq_printf(m, "Fallback needed: %lu (%lu blocks)\n",
+ zone->present_pages >> 3,
+ (zone->present_pages >> 3) >> (MAX_ORDER-1));
+ seq_printf(m, "Partial steal: %lu\n",
+ zone->kernnorclm_partial_steal);
+ seq_printf(m, "Full steal: %lu\n",
+ zone->kernnorclm_full_steal);
+
+ kernnorclm_partial_steal += zone->kernnorclm_partial_steal;
+ kernnorclm_full_steal += zone->kernnorclm_full_steal;
+ seq_putc(m, '\n');
+
+ for (i = 0; i< RCLM_TYPES; i++) {
+ seq_printf(m, "%-10s Allocs: %-10lu Reserve: %-10lu Fallbacks: %-10lu\n",
+ type_names[i],
+ zone->alloc_count[i],
+ zone->reserve_count[i],
+ zone->fallback_count[i]);
+ alloc_count[i] += zone->alloc_count[i];
+ reserve_count[i] += zone->reserve_count[i];
+ fallback_count[i] += zone->fallback_count[i];
+ }
+
+ spin_unlock_irqrestore(&zone->lock, flags);
+ }
+
+
+ /* Show bean counters */
+ seq_printf(m, "\nGlobal beancounters\n");
+ seq_printf(m, "Partial steal: %lu\n", kernnorclm_partial_steal);
+ seq_printf(m, "Full steal: %lu\n", kernnorclm_full_steal);
+
+ for (i = 0; i< RCLM_TYPES; i++) {
+ seq_printf(m, "%-10s Allocs: %-10lu Reserve: %-10lu Fallbacks: %-10lu\n",
+ type_names[i],
+ alloc_count[i],
+ reserve_count[i],
+ fallback_count[i]);
+ }
+#endif /* CONFIG_ALLOCSTATS */
return 0;
}
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
next prev parent reply other threads:[~2005-10-30 18:34 UTC|newest]
Thread overview: 185+ messages / expand[flat|nested] mbox.gz Atom feed top
2005-10-30 18:33 [PATCH 0/7] Fragmentation Avoidance V19 Mel Gorman
2005-10-30 18:34 ` [PATCH 1/7] Fragmentation Avoidance V19: 001_antidefrag_flags Mel Gorman
2005-10-30 18:34 ` [PATCH 2/7] Fragmentation Avoidance V19: 002_usemap Mel Gorman
2005-10-30 18:34 ` [PATCH 3/7] Fragmentation Avoidance V19: 003_fragcore Mel Gorman
2005-10-30 18:34 ` [PATCH 4/7] Fragmentation Avoidance V19: 004_fallback Mel Gorman
2005-10-30 18:34 ` [PATCH 5/7] Fragmentation Avoidance V19: 005_largealloc_tryharder Mel Gorman
2005-10-30 18:34 ` [PATCH 6/7] Fragmentation Avoidance V19: 006_percpu Mel Gorman
2005-10-30 18:34 ` Mel Gorman [this message]
2005-10-31 5:57 ` [Lhms-devel] [PATCH 0/7] Fragmentation Avoidance V19 Mike Kravetz
2005-10-31 6:37 ` Nick Piggin
2005-10-31 7:54 ` Andrew Morton
2005-10-31 7:11 ` Nick Piggin
2005-10-31 16:19 ` Mel Gorman
2005-10-31 23:54 ` Nick Piggin
2005-11-01 1:28 ` Mel Gorman
2005-11-01 1:42 ` Nick Piggin
2005-10-31 14:34 ` Martin J. Bligh
2005-10-31 19:24 ` Andrew Morton
2005-10-31 19:40 ` Martin J. Bligh
2005-10-31 23:59 ` Nick Piggin
2005-11-01 1:36 ` Mel Gorman
2005-10-31 23:29 ` Nick Piggin
2005-11-01 0:59 ` Mel Gorman
2005-11-01 1:31 ` Nick Piggin
2005-11-01 2:07 ` Mel Gorman
2005-11-01 2:35 ` Nick Piggin
2005-11-01 11:57 ` Mel Gorman
2005-11-01 13:56 ` Ingo Molnar
2005-11-01 14:10 ` Dave Hansen
2005-11-01 14:29 ` Ingo Molnar
2005-11-01 14:49 ` Dave Hansen
2005-11-01 15:01 ` Ingo Molnar
2005-11-01 15:22 ` Dave Hansen
2005-11-02 8:49 ` Ingo Molnar
2005-11-02 9:02 ` Nick Piggin
2005-11-02 9:17 ` Ingo Molnar
2005-11-02 9:32 ` Dave Hansen
2005-11-02 9:48 ` Nick Piggin
2005-11-02 10:54 ` Dave Hansen
2005-11-02 15:02 ` Martin J. Bligh
2005-11-03 3:21 ` Nick Piggin
2005-11-03 15:36 ` Martin J. Bligh
2005-11-03 15:40 ` Arjan van de Ven
2005-11-03 15:51 ` Linus Torvalds
2005-11-03 15:57 ` Martin J. Bligh
2005-11-03 16:20 ` Arjan van de Ven
2005-11-03 16:27 ` Mel Gorman
2005-11-03 16:46 ` Linus Torvalds
2005-11-03 16:52 ` Martin J. Bligh
2005-11-03 17:19 ` Linus Torvalds
2005-11-03 17:48 ` Dave Hansen
2005-11-03 17:51 ` Martin J. Bligh
2005-11-03 17:59 ` Arjan van de Ven
2005-11-03 18:08 ` Linus Torvalds
2005-11-03 18:17 ` Martin J. Bligh
2005-11-03 18:44 ` Linus Torvalds
2005-11-03 18:51 ` Martin J. Bligh
2005-11-03 19:35 ` Linus Torvalds
2005-11-03 22:40 ` Martin J. Bligh
2005-11-03 22:56 ` Linus Torvalds
2005-11-03 23:01 ` Martin J. Bligh
2005-11-04 0:58 ` Nick Piggin
2005-11-04 1:06 ` Linus Torvalds
2005-11-04 1:20 ` Paul Mackerras
2005-11-04 1:22 ` Nick Piggin
2005-11-04 1:48 ` Mel Gorman
2005-11-04 1:59 ` Nick Piggin
2005-11-04 2:35 ` Mel Gorman
2005-11-04 1:26 ` Mel Gorman
2005-11-03 21:11 ` Mel Gorman
2005-11-03 18:03 ` Linus Torvalds
2005-11-03 20:00 ` Paul Jackson
2005-11-03 20:46 ` Mel Gorman
2005-11-03 18:48 ` Martin J. Bligh
2005-11-03 19:08 ` Linus Torvalds
2005-11-03 22:37 ` Martin J. Bligh
2005-11-03 23:16 ` Linus Torvalds
2005-11-03 23:39 ` Martin J. Bligh
2005-11-04 0:42 ` Nick Piggin
2005-11-04 4:39 ` Andrew Morton
2005-11-04 16:22 ` Mel Gorman
2005-11-03 15:53 ` Martin J. Bligh
2005-11-02 14:57 ` Martin J. Bligh
2005-11-01 16:48 ` Kamezawa Hiroyuki
2005-11-01 16:59 ` Kamezawa Hiroyuki
2005-11-01 17:19 ` Mel Gorman
2005-11-02 0:32 ` KAMEZAWA Hiroyuki
2005-11-02 11:22 ` Mel Gorman
2005-11-01 18:06 ` linux-os (Dick Johnson)
2005-11-02 7:19 ` Ingo Molnar
2005-11-02 7:46 ` Gerrit Huizenga
2005-11-02 8:50 ` Nick Piggin
2005-11-02 9:12 ` Gerrit Huizenga
2005-11-02 9:37 ` Nick Piggin
2005-11-02 10:17 ` Gerrit Huizenga
2005-11-02 23:47 ` Rob Landley
2005-11-03 4:43 ` Nick Piggin
2005-11-03 6:07 ` Rob Landley
2005-11-03 7:34 ` Nick Piggin
2005-11-03 17:54 ` Rob Landley
2005-11-03 20:13 ` Jeff Dike
2005-11-03 16:35 ` Jeff Dike
2005-11-03 16:23 ` Badari Pulavarty
2005-11-03 18:27 ` Jeff Dike
2005-11-03 18:49 ` Rob Landley
2005-11-04 4:52 ` Andrew Morton
2005-11-04 5:35 ` Paul Jackson
2005-11-04 5:48 ` Andrew Morton
2005-11-04 6:42 ` Paul Jackson
2005-11-04 7:10 ` Andrew Morton
2005-11-04 7:45 ` Paul Jackson
2005-11-04 8:02 ` Andrew Morton
2005-11-04 9:52 ` Paul Jackson
2005-11-04 15:27 ` Martin J. Bligh
2005-11-04 15:19 ` Martin J. Bligh
2005-11-04 17:38 ` Andrew Morton
2005-11-04 6:16 ` Bron Nelson
2005-11-04 7:26 ` [patch] swapin rlimit Ingo Molnar
2005-11-04 7:36 ` Andrew Morton
2005-11-04 8:07 ` Ingo Molnar
2005-11-04 10:06 ` Paul Jackson
2005-11-04 15:24 ` Martin J. Bligh
2005-11-04 8:18 ` Arjan van de Ven
2005-11-04 10:04 ` Paul Jackson
2005-11-04 15:14 ` Rob Landley
2005-11-04 10:14 ` Bernd Petrovitsch
2005-11-04 10:21 ` Ingo Molnar
2005-11-04 11:17 ` Bernd Petrovitsch
2005-11-02 10:41 ` [Lhms-devel] [PATCH 0/7] Fragmentation Avoidance V19 Ingo Molnar
2005-11-02 11:04 ` Gerrit Huizenga
2005-11-02 12:00 ` Ingo Molnar
2005-11-02 12:42 ` Dave Hansen
2005-11-02 15:02 ` Gerrit Huizenga
2005-11-03 0:10 ` Rob Landley
2005-11-02 7:57 ` Nick Piggin
2005-11-02 0:51 ` Nick Piggin
2005-11-02 7:42 ` Dave Hansen
2005-11-02 8:24 ` Nick Piggin
2005-11-02 8:33 ` Yasunori Goto
2005-11-02 8:43 ` Nick Piggin
2005-11-02 14:51 ` Martin J. Bligh
2005-11-02 23:28 ` Rob Landley
2005-11-03 5:26 ` Jeff Dike
2005-11-03 5:41 ` Rob Landley
2005-11-04 3:26 ` [uml-devel] " Blaisorblade
2005-11-04 15:50 ` Rob Landley
2005-11-04 17:18 ` Blaisorblade
2005-11-04 17:44 ` Rob Landley
2005-11-02 12:38 ` [Lhms-devel] [PATCH 0/7] Fragmentation Avoidance V19 - Summary Mel Gorman
2005-11-03 3:14 ` Nick Piggin
2005-11-03 12:19 ` Mel Gorman
2005-11-10 18:47 ` Steve Lord
2005-11-03 15:34 ` Martin J. Bligh
2005-11-01 14:41 ` [Lhms-devel] [PATCH 0/7] Fragmentation Avoidance V19 Mel Gorman
2005-11-01 14:46 ` Ingo Molnar
2005-11-01 15:23 ` Mel Gorman
2005-11-01 18:33 ` Rob Landley
2005-11-01 19:02 ` Ingo Molnar
2005-11-01 14:50 ` Dave Hansen
2005-11-01 15:24 ` Mel Gorman
2005-11-02 5:11 ` Andrew Morton
2005-11-01 18:23 ` Rob Landley
2005-11-01 20:31 ` Joel Schopp
2005-11-01 20:59 ` Joel Schopp
2005-11-02 1:06 ` Nick Piggin
2005-11-02 1:41 ` Martin J. Bligh
2005-11-02 2:03 ` Nick Piggin
2005-11-02 2:24 ` Martin J. Bligh
2005-11-02 2:49 ` Nick Piggin
2005-11-02 4:39 ` Martin J. Bligh
2005-11-02 5:09 ` Nick Piggin
2005-11-02 5:14 ` Martin J. Bligh
2005-11-02 6:23 ` KAMEZAWA Hiroyuki
2005-11-02 10:15 ` Nick Piggin
2005-11-02 7:19 ` Yasunori Goto
2005-11-02 11:48 ` Mel Gorman
2005-11-02 11:41 ` Mel Gorman
2005-11-02 11:37 ` Mel Gorman
2005-11-02 15:11 ` Mel Gorman
2005-11-01 15:25 ` Martin J. Bligh
2005-11-01 15:33 ` Dave Hansen
2005-11-01 16:57 ` Mel Gorman
2005-11-01 17:00 ` Mel Gorman
2005-11-01 18:58 ` Rob Landley
2005-11-01 14:40 ` Avi Kivity
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=20051030183429.22266.85501.sendpatchset@skynet.csn.ul.ie \
--to=mel@csn.ul.ie \
--cc=akpm@osdl.org \
--cc=lhms-devel@lists.sourceforge.net \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
/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