make balance_classzone() use list.h
Subsystems (2)
balance_classzone() does a number of open-coded list operations. This adjusts balance_classzone() to use generic list.h operations as well as renaming __freed and restructuring some of the control flow to use if (unlikely(...))) goto handle_rare_case; for additional conciseness and reducing the number of indentation levels required.
Against 2.5.19
Cheers,
Bill
===== mm/page_alloc.c 1.72 vs edited =====
mm/page_alloc.c +50 -44
@@ -265,8 +265,9 @@static struct page *FASTCALL (balance_classzone (zone_t *,unsigned int ,unsigned int ,int *));static struct page *balance_classzone (zone_t * classzone,unsigned int gfp_mask,unsigned int order,int * freed) { -struct page * page =NULL ; -int __freed =0 ; +struct page *tmp, *page =NULL ; +list_t *save, *entry, *local_pages; +int nr_pages, reclaimed =0 ;if (!(gfp_mask & __GFP_WAIT)) goto out;
@@ -275,52 +276,57 @@ current->allocation_order = order; current->flags |=PF_MEMALLOC |PF_FREE_PAGES ; - __freed =try_to_free_pages (classzone, gfp_mask, order); + reclaimed =try_to_free_pages (classzone, gfp_mask, order); current->flags &= ~(PF_MEMALLOC |PF_FREE_PAGES ); -if (current->nr_local_pages) { -struct list_head * entry, * local_pages; -struct page * tmp; -int nr_pages; - - local_pages = ¤t->local_pages; - -if (likely (__freed)) { -/* pick from the last inserted so we're lifo */ - entry = local_pages->next; -do { - tmp = list_entry(entry, struct page, list); -if (tmp->index == order &&memclass (page_zone (tmp), classzone)) { -list_del (entry); - current->nr_local_pages--; -set_page_count (tmp,1 ); - page = tmp; - -BUG_ON (PagePrivate (page)); -BUG_ON (page->mapping); -BUG_ON (PageLocked (page)); -BUG_ON (PageLRU (page)); -BUG_ON (PageActive (page)); -BUG_ON (PageDirty (page)); -BUG_ON (PageWriteback (page)); -break ; - } - }while ((entry = entry->next) != local_pages); - } - - nr_pages = current->nr_local_pages; -/* free in reverse order so that the global order will be lifo */ -while ((entry = local_pages->prev) != local_pages) { -list_del (entry); - tmp = list_entry(entry, struct page, list); -__free_pages_ok (tmp, tmp->index); -BUG_ON (!nr_pages--); - } - current->nr_local_pages =0 ; +if (!current->nr_local_pages) + goto out; + + local_pages = ¤t->local_pages; + +if (unlikely (!reclaimed)) + goto reverse_free; + +/* pick from the last inserted so we're lifo */ +list_for_each_safe (entry, save, local_pages) { + tmp = list_entry(entry, struct page, list); + +if (tmp->index != order) +continue ; +if (memclass (page_zone (tmp), classzone)) +continue ; + +list_del (entry); + current->nr_local_pages--; +set_page_count (tmp,1 ); + page = tmp; + +BUG_ON (PagePrivate (page)); +BUG_ON (page->mapping); +BUG_ON (PageLocked (page)); +BUG_ON (PageLRU (page)); +BUG_ON (PageActive (page)); +BUG_ON (PageDirty (page)); +BUG_ON (PageWriteback (page)); +break ; + } + +reverse_free: + nr_pages = current->nr_local_pages; +/* free in reverse order so that the global order will be lifo */ +while (!list_empt (local_pages)) { + entry = local_pages->prev; +list_del (entry); + tmp = list_entry(entry, struct page, list); +__free_pages_ok (tmp, tmp->index); +BUG_ON (!nr_pages); + nr_pages--; } - out: - *freed = __freed; +BUG_ON (nr_pages); + current->nr_local_pages =0 ; +out: + *freed = reclaimed;return page; }
In message <[email protected]> you write:
Quoted 7 lines
balance_classzone()does a number of open-coded list operations. This adjustsbalance_classzone()to use genericlist.hoperations as well as renaming__freedand restructuring some of the control flow to use if (unlikely(...))) gotohandle_rare_case; for additional conciseness and reducing the number of indentation levels required.Against 2.5.19
No, it seems to be against 2.5.19+some of your previous patches.
The trivial patch system (almost by definition) does not handle interdependent patches, sorry. 8(
Rusty.
--
Anyone who quotes me in their sig is an idiot. -- Rusty Russell.
In message <[email protected]> you write:
Quoted 6 lines
Quoted 6 lines
balance_classzone()does a number of open-coded list operations. This adjustsbalance_classzone()to use genericlist.hoperations as well as renaming__freedand restructuring some of the control flow to use if (unlikely(...))) gotohandle_rare_case; for additional conciseness and reducing the number of indentation levels required. Against 2.5.19
Quoted 3 lines · Rusty Russell
No, it seems to be against 2.5.19+some of your previous patches. The trivial patch system (almost by definition) does not handle interdependent patches, sorry. 8(
Ugh, it's a trivial interdependence but I'll leave this alone for the time being.
Cheers,
Bill