* make balance_classzone() use list.h
@ 2002-06-02 23:13 William Lee Irwin III
2002-06-03 4:11 ` Rusty Russell
0 siblings, 1 reply; 3+ messages in thread
From: William Lee Irwin III @ 2002-06-02 23:13 UTC (permalink / raw)
To: linux-kernel; +Cc: trivial
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 =====
--- 1.72/mm/page_alloc.c Sun Jun 2 15:49:05 2002
+++ edited/mm/page_alloc.c Sun Jun 2 16:02:35 2002
@@ -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;
}
^ permalink raw reply [flat|nested] 3+ messages in thread* Re: make balance_classzone() use list.h
2002-06-02 23:13 make balance_classzone() use list.h William Lee Irwin III
@ 2002-06-03 4:11 ` Rusty Russell
2002-06-03 5:03 ` William Lee Irwin III
0 siblings, 1 reply; 3+ messages in thread
From: Rusty Russell @ 2002-06-03 4:11 UTC (permalink / raw)
To: William Lee Irwin III; +Cc: linux-kernel
In message <20020602231312.GR14918@holomorphy.com> you write:
> 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
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.
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: make balance_classzone() use list.h
2002-06-03 4:11 ` Rusty Russell
@ 2002-06-03 5:03 ` William Lee Irwin III
0 siblings, 0 replies; 3+ messages in thread
From: William Lee Irwin III @ 2002-06-03 5:03 UTC (permalink / raw)
To: Rusty Russell; +Cc: linux-kernel
In message <20020602231312.GR14918@holomorphy.com> you write:
>> 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
On Mon, Jun 03, 2002 at 02:11:30PM +1000, Rusty Russell wrote:
> 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
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2002-06-03 5:03 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2002-06-02 23:13 make balance_classzone() use list.h William Lee Irwin III
2002-06-03 4:11 ` Rusty Russell
2002-06-03 5:03 ` William Lee Irwin III
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.