Commit 224abf92b2f439a9030f21d2926ec8047d1ffcdb

Authored by Nick Piggin
Committed by Linus Torvalds
1 parent 9328b8faae

[PATCH] mm: bad_page optimisation

Cut down size slightly by not passing bad_page the function name (it should be
able to be determined by dump_stack()).  And cut down the number of printks in
bad_page.

Also, cut down some branching in the destroy_compound_page path.

Signed-off-by: Nick Piggin <npiggin@suse.de>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>

Showing 1 changed file with 20 additions and 24 deletions Side-by-side Diff

... ... @@ -132,16 +132,16 @@
132 132 }
133 133 #endif
134 134  
135   -static void bad_page(const char *function, struct page *page)
  135 +static void bad_page(struct page *page)
136 136 {
137   - printk(KERN_EMERG "Bad page state at %s (in process '%s', page %p)\n",
138   - function, current->comm, page);
139   - printk(KERN_EMERG "flags:0x%0*lx mapping:%p mapcount:%d count:%d\n",
140   - (int)(2*sizeof(unsigned long)), (unsigned long)page->flags,
141   - page->mapping, page_mapcount(page), page_count(page));
142   - printk(KERN_EMERG "Backtrace:\n");
  137 + printk(KERN_EMERG "Bad page state in process '%s'\n"
  138 + "page:%p flags:0x%0*lx mapping:%p mapcount:%d count:%d\n"
  139 + "Trying to fix it up, but a reboot is needed\n"
  140 + "Backtrace:\n",
  141 + current->comm, page, (int)(2*sizeof(unsigned long)),
  142 + (unsigned long)page->flags, page->mapping,
  143 + page_mapcount(page), page_count(page));
143 144 dump_stack();
144   - printk(KERN_EMERG "Trying to fix it up, but a reboot is needed\n");
145 145 page->flags &= ~(1 << PG_lru |
146 146 1 << PG_private |
147 147 1 << PG_locked |
148 148  
149 149  
... ... @@ -194,19 +194,15 @@
194 194 int i;
195 195 int nr_pages = 1 << order;
196 196  
197   - if (!PageCompound(page))
198   - return;
  197 + if (unlikely(page[1].index != order))
  198 + bad_page(page);
199 199  
200   - if (page[1].index != order)
201   - bad_page(__FUNCTION__, page);
202   -
203 200 for (i = 0; i < nr_pages; i++) {
204 201 struct page *p = page + i;
205 202  
206   - if (!PageCompound(p))
207   - bad_page(__FUNCTION__, page);
208   - if (page_private(p) != (unsigned long)page)
209   - bad_page(__FUNCTION__, page);
  203 + if (unlikely(!PageCompound(p) |
  204 + (page_private(p) != (unsigned long)page)))
  205 + bad_page(page);
210 206 ClearPageCompound(p);
211 207 }
212 208 }
... ... @@ -316,7 +312,7 @@
316 312 unsigned long page_idx;
317 313 int order_size = 1 << order;
318 314  
319   - if (unlikely(order))
  315 + if (unlikely(PageCompound(page)))
320 316 destroy_compound_page(page, order);
321 317  
322 318 page_idx = page_to_pfn(page) & ((1 << MAX_ORDER) - 1);
... ... @@ -348,7 +344,7 @@
348 344 zone->free_area[order].nr_free++;
349 345 }
350 346  
351   -static inline int free_pages_check(const char *function, struct page *page)
  347 +static inline int free_pages_check(struct page *page)
352 348 {
353 349 if (unlikely(page_mapcount(page) |
354 350 (page->mapping != NULL) |
... ... @@ -363,7 +359,7 @@
363 359 1 << PG_swapcache |
364 360 1 << PG_writeback |
365 361 1 << PG_reserved ))))
366   - bad_page(function, page);
  362 + bad_page(page);
367 363 if (PageDirty(page))
368 364 __ClearPageDirty(page);
369 365 /*
... ... @@ -422,7 +418,7 @@
422 418 #endif
423 419  
424 420 for (i = 0 ; i < (1 << order) ; ++i)
425   - reserved += free_pages_check(__FUNCTION__, page + i);
  421 + reserved += free_pages_check(page + i);
426 422 if (reserved)
427 423 return;
428 424  
... ... @@ -517,7 +513,7 @@
517 513 1 << PG_swapcache |
518 514 1 << PG_writeback |
519 515 1 << PG_reserved ))))
520   - bad_page(__FUNCTION__, page);
  516 + bad_page(page);
521 517  
522 518 /*
523 519 * For now, we report if PG_reserved was found set, but do not
... ... @@ -716,7 +712,7 @@
716 712  
717 713 if (PageAnon(page))
718 714 page->mapping = NULL;
719   - if (free_pages_check(__FUNCTION__, page))
  715 + if (free_pages_check(page))
720 716 return;
721 717  
722 718 inc_page_state(pgfree);