===== include/linux/gfp.h 1.18 vs edited ===== --- 1.18/include/linux/gfp.h 2004-05-22 14:56:25 -07:00 +++ edited/include/linux/gfp.h 2004-08-12 14:18:03 -07:00 @@ -5,6 +5,7 @@ #include #include #include +#include struct vm_area_struct; @@ -84,6 +85,26 @@ return __alloc_pages(gfp_mask, order, NODE_DATA(nid)->node_zonelists + (gfp_mask & GFP_ZONEMASK)); +} + +DECLARE_PER_CPU(int, next_rr_node); + +/** + * alloc_pages_round_robin - distribute allocated pages across nodes + * @gfp_mask: GFP_* flags + * @order: allocate 2^order pages + * + * alloc_pages_round_robin() will simply allocate from a different node + * than was allocated from in the last call using the next_rr_node variable. + * We use __get_cpu_var since we don't care about disabling preemption (we're + * using a mod function so nid will always be less than numnodes). A per-cpu + * variable will make round robin allocations scale a bit better. + */ +static inline struct page *alloc_pages_round_robin(unsigned int gfp_mask, + unsigned int order) +{ + return alloc_pages_node(__get_cpu_var(next_rr_node)++ % numnodes, + gfp_mask, order); } #ifdef CONFIG_NUMA ===== include/linux/pagemap.h 1.43 vs edited ===== --- 1.43/include/linux/pagemap.h 2004-06-24 01:55:57 -07:00 +++ edited/include/linux/pagemap.h 2004-08-12 14:10:41 -07:00 @@ -52,12 +52,12 @@ static inline struct page *page_cache_alloc(struct address_space *x) { - return alloc_pages(mapping_gfp_mask(x), 0); + return alloc_pages_round_robin(mapping_gfp_mask(x), 0); } static inline struct page *page_cache_alloc_cold(struct address_space *x) { - return alloc_pages(mapping_gfp_mask(x)|__GFP_COLD, 0); + return alloc_pages_round_robin(mapping_gfp_mask(x)|__GFP_COLD, 0); } typedef int filler_t(void *, struct page *); ===== mm/page_alloc.c 1.224 vs edited ===== --- 1.224/mm/page_alloc.c 2004-08-07 23:43:41 -07:00 +++ edited/mm/page_alloc.c 2004-08-12 14:12:07 -07:00 @@ -41,6 +41,7 @@ long nr_swap_pages; int numnodes = 1; int sysctl_lower_zone_protection = 0; +DEFINE_PER_CPU(int, next_rr_node); EXPORT_SYMBOL(totalram_pages); EXPORT_SYMBOL(nr_swap_pages);