Skip to contentSkip to conversation

lazy_buddy-2.5.19-3

PATCH William Lee Irwin III 1 participant 1 message Jun 1, 2002

Subsystems (5)
lore
Share & tools
lore
#0 lore raw

This is a bugfix and cleanup release. lazy_buddy-2.5.19-2 was skipped due to suspicions of lurking bugs needing to be fixed.

Deferred coalescing is an important allocator optimization. In the case of binary buddy system allocators prior implementations have successfully yielded between 10% and 32% reductions in the average latency of allocation and freeing operations. The following patch is a rework of the buddy allocator in page_alloc.c to use deferred coalescing.

It should be noted that the performance comparison mentioned above is taken from measurements of its usage in other operating systems, and as such is not necessarily directly applicable to or an accurate predictor of how it will perform within Linux, although it motivated the author to implement it for evaluation of its effectiveness here.

The results achieved by this specific implementation are as of yet not entirely known, but some non-rigorous testing seems to reveal approximate parity with mainline. Ruth, Randy, I'd be much obliged to hear of the results of more rigorous testing to determine quality of implementation issues still needing to be addressed.

Pavel, your input on the interactions of this patch with swsusp would be well-appreciated, especially your comments on is_head_of_free_region().

An impressive set of cleanups is due to Christoph Hellwig:
(1) repair a comment to explain that Vahalia's cited performance improvement numbers applied to a general purpose kernel allocator, not a page-level allocator
(2) merging buddy_dequeue() with its only caller.
(3) use LIST_HEAD() for active_list and inactive_list and get repetitive reinitialization out of free_area_init_core()
(4) drop unnecessary includes
(5) wrap up bit clearing with ClearPageChecked(), and add to page-flags.h
(6) streamline deferred_dequeue() by shifting the burden of checks onto the caller
(7) eliminating the duplication of is_head_of_free_region() due to mismerge with swsusp changes

Also, discovery of a botched ->local_pages handling cleanup is due to Andrew Morton.

TODO:

(1)  use split_pages() to handle the corner case for which it was written
(2)  trim down commentary for conciseness
(3)  experiment with other coalescing methods for comparative analysis
(4)  rigorous benchmarking
(5)  backport to 2.4 and several 2.4-based trees
(6)  analyze performance deficits and optimize based on that analysis
(7)  collect statistics on allocation rates for various orders
(8)  collect statistics on allocation failures due to fragmentation
(9)  collect qualitative information on long-term fragmentation behavior

(10) convert fragmentation statistics to the seq_file() framework

The following TODO items fall into the category of follow-on patches:
(11) gang allocation support
(12) per-cpu pools
(13) gang preassembly and bulk transfer during gang allocation and refill of per-cpu pools

This patch is also available from:
ftp://ftp.kernel.org/pub/linux/kernel/people/wli/vm/lazy_buddy/lazy_buddy-2.5.19-3 bk://linux-wli.bkbits.net/lazy_buddy/

Cheers,
Bill

fs/proc/proc_misc.c +22 -2
diff -urN --exclude [xprs].* linux-2.5/fs/proc/proc_misc.c lazy_buddy/fs/proc/proc_misc.c
@@ -131,6 +131,7 @@
 	struct sysinfo i;
 	int len;
 	struct page_state ps;
+	extern unsigned long nr_deferred_pages(void);
 
 	get_page_state(&ps);
 /*
@@ -158,7 +159,8 @@
 		"SwapTotal:    %8lu kB\n"
 		"SwapFree:     %8lu kB\n"
 		"Dirty:        %8lu kB\n"
-		"Writeback:    %8lu kB\n",
+		"Writeback:    %8lu kB\n"
+		"Deferred:     %8lu kB\n",
 		K(i.totalram),
 		K(i.freeram),
 		K(i.sharedram),
@@ -173,13 +175,30 @@
 		K(i.totalswap),
 		K(i.freeswap),
 		K(ps.nr_dirty),
-		K(ps.nr_writeback)
+		K(ps.nr_writeback),
+		K(nr_deferred_pages())
 		);
 
 	return proc_calc_metrics(page, start, off, count, eof, len);
 #undef K
 }
 
+extern int fragmentation_stats(char *, int);
+static int fragmentation_read_proc(	char *page,
+					char **start,
+					off_t off,
+					int count,
+					int *eof,
+					void *data)
+{
+	int nid, len = 0;
+
+	for (nid = 0; nid < numnodes; ++nid)
+		len += fragmentation_stats(page + len, nid);
+
+	return proc_calc_metrics(page, start, off, count, eof, len);
+}
+
 static int version_read_proc(char *page, char **start, off_t off,
 				 int count, int *eof, void *data)
 {
@@ -543,6 +562,7 @@
 		{"loadavg",     loadavg_read_proc},
 		{"uptime",	uptime_read_proc},
 		{"meminfo",	meminfo_read_proc},
+		{"fraginfo",	fragmentation_read_proc},
 		{"version",	version_read_proc},
 #ifdef CONFIG_PROC_HARDWARE
 		{"hardware",	hardware_read_proc},
include/linux/mmzone.h +11 -4
diff -urN --exclude [xprs].* linux-2.5/include/linux/mmzone.h lazy_buddy/include/linux/mmzone.h
@@ -20,8 +20,9 @@
 #endif
 
 typedef struct free_area_struct {
-	struct list_head	free_list;
-	unsigned long		*map;
+	unsigned long	globally_free, active, locally_free;
+	list_t		free_list, deferred_pages;
+	unsigned long	*map;
 } free_area_t;
 
 struct pglist_data;
@@ -142,8 +143,14 @@
 extern int numnodes;
 extern pg_data_t *pgdat_list;
 
-#define memclass(pgzone, classzone)	(((pgzone)->zone_pgdat == (classzone)->zone_pgdat) \
-			&& ((pgzone) <= (classzone)))
+static inline int memclass(zone_t *page_zone, zone_t *classzone)
+{
+	if (page_zone->zone_pgdat != classzone->zone_pgdat)
+		return 0;
+	if (page_zone > classzone)
+		return 0;
+	return 1;
+}
 
 /*
  * The following two are not meant for general usage. They are here as
include/linux/page-flags.h +1 -0
diff -urN --exclude [xprs].* linux-2.5/include/linux/page-flags.h lazy_buddy/include/linux/page-flags.h
@@ -169,6 +169,7 @@
 
 #define PageChecked(page)	test_bit(PG_checked, &(page)->flags)
 #define SetPageChecked(page)	set_bit(PG_checked, &(page)->flags)
+#define ClearPageChecked(page)	clear_bit(PG_checked, &(page)->flags)
 
 #define PageReserved(page)	test_bit(PG_reserved, &(page)->flags)
 #define SetPageReserved(page)	set_bit(PG_reserved, &(page)->flags)
mm/bootmem.c +4 -0
diff -urN --exclude [xprs].* linux-2.5/mm/bootmem.c lazy_buddy/mm/bootmem.c
@@ -241,6 +241,7 @@
 	return ret;
 }
 
+extern void forced_coalesce(zone_t *zone);
 static unsigned long __init free_all_bootmem_core(pg_data_t *pgdat)
 {
 	struct page *page = pgdat->node_mem_map;
@@ -287,6 +288,9 @@
 	}
 	total += count;
 	bdata->node_bootmem_map = NULL;
+
+	for (i = 0; i < MAX_NR_ZONES; ++i)
+		forced_coalesce(&pgdat->node_zones[i]);
 
 	return total;
 }
mm/page_alloc.c +493 -217

930 lines not on this page · raw message

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/