lazy buddy prototype
Subsystems (6)
Brewed this one up Sunday. Lightly tested. i386-only. Also available from
bk://linux-wli.bkbits.net/lazy_buddy ftp://ftp.kernel.org/pub/linux/kernel/wli/vm/lazy_buddy/lazy_buddy-2.5.17-1
TODO:
(1) remove debug code (2) move the work in dequeue()/enqueue() to buddy_alloc()/buddy_free() (3) use dequeue() and enqueue() for address-ordered queueing (4) write lg() for other architectures or use something else (5) kill boottime_defragment() (6) stress testing, find bugs if present (7) benchmarking (8) audit for unnecessary cacheline dirtying (9) audit for proper obeisance of the reclaiming/accelerated thresholds
(10) port to 2.4.x & rmap
(11) optimize
(12) figure out if the mask twiddling for ->deferred_pages[] is worth it
(13) figure out some way to get fragmentation stats out of the buddy bitmap
Cheers,
Bill
fs/proc/proc_misc.c +5 -2
@@ -132,6 +132,7 @@int len;int pg_size ;struct page_state ps; +extern unsigned long nr_deferred_pages (void );get_page_state (&ps);/*
@@ -161,7 +162,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),
@@ -177,7 +179,8 @@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);
include/asm-i386/bitops.h +14 -0
@@ -401,6 +401,20 @@ }/** +* lg - integer logarithm, or floor(ln(n)/ln(2)) +* @word: The word to search +* +* Undefined if 0, one should check against 0 first. +*/ +static inline unsigned long lg (unsigned long n) +{ + __asm__("bsrl %1,%0" + :"=r" (n) + :"r" (n)); +return n; +} + +/** * __ffs - find first bit in word. * @word: The word to search *
include/linux/mmzone.h +9 -0
@@ -42,11 +42,15 @@unsigned long free_pages;unsigned long pages_min, pages_low, pages_high;int need_balance; +unsigned long pages_granted; +unsigned long pages_deferred;/* * free areas of different sizes */ free_area_t free_area[MAX_ORDER ]; +unsigned long deferred_mask; +list_t deferred_pages[MAX_ORDER ];/* * wait_table -- the array holding the hash table
@@ -144,6 +148,11 @@#define memclass (pgzone, classzone) (((pgzone)->zone_pgdat == (classzone)->zone_pgdat) \ && ((pgzone) <= (classzone))) + +static inline unsigned long zone_free_pages (zone_t *zone) +{ +return zone->free_pages + zone->pages_deferred; +}/* * The following two are not meant for general usage. They are here as
include/linux/page-flags.h +12 -0
@@ -64,6 +64,7 @@#define PG_private 12/* Has something at ->private */ #define PG_writeback 13/* Page is under writeback */ +#define PG_deferred 14/* page not marked in buddy bitmap */ /* * Global page accounting. One instance per CPU.
@@ -174,6 +175,17 @@#define SetPagePrivate (page) set_bit(PG_private, &(page)->flags)#define ClearPagePrivate (page) clear_bit(PG_private, &(page)->flags)#define PagePrivate (page) test_bit(PG_private, &(page)->flags) + +#ifdef DEBUG_LAZY_BUDDY +#if DEBUG_LAZY_BUDDY >0 +#define PageDeferred (page) test_bit(PG_deferred, &(page)->flags) +#define SetPageDeferred (page) set_bit(PG_deferred, &(page)->flags) +#define ClearPageDeferred (page) clear_bit(PG_deferred, &(page)->flags) +#else +#define SetPageDeferred (page) do { ; } while(0) +#define ClearPageDeferred (page) do { ; } while(0) +#endif /* DEBUG_LAZY_BUDDY > 0 */ +#endif /* DEBUG_LAZY_BUDDY */ #define PageWriteback (page) test_bit(PG_writeback, &(page)->flags)#define SetPageWriteback (page) \
mm/bootmem.c +4 -0
@@ -241,6 +241,7 @@return ret; } +extern void FASTCALL (boottime_defragment (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) +boottime_defragment (&pgdat->node_zones[i]);return total; }
mm/page_alloc.c +360 -45
537 lines not on this page · raw message
mm/vmscan.c +1 -1
@@ -672,7 +672,7 @@ first_classzone = classzone->zone_pgdat->node_zones;while (classzone >= first_classzone) { -if (classzone->free_pages > classzone->pages_high) +if (zone_free_pages (classzone) > classzone->pages_high)return 0 ; classzone--; }
--
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/
Quoted 1 line · William Lee Irwin III
TODO:
[...]
Quoted 1 line
(13) figure out some way to get fragmentation stats out of the buddy bitmap
And an important omission, of which Andrew Morton reminded me:
(14) document it
Cheers,
Bill
--
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/
Quoted 3 lines · William Lee Irwin III
Quoted 1 line
TODO:
[...]
Quoted 1 line
(13) figure out some way to get fragmentation stats out of the buddy bitmap
Quoted 2 lines · William Lee Irwin III
And an important omission, of which Andrew Morton reminded me:
(14) document it
and from Ben LaHaise:
(15) collect statistics on the allocation rates for various orders
and concomitant to this:
(16) collect statistics on allocation failures due to fragmentation
Cheers,
Bill
--
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/