From: Nick Piggin <nickpiggin@yahoo.com.au>
To: Andrew Morton <akpm@osdl.org>
Cc: Linux Memory Management <linux-mm@kvack.org>,
Linus Torvalds <torvalds@osdl.org>
Subject: [PATCH 1/3] keep count of free areas
Date: Wed, 27 Oct 2004 18:00:57 +1000 [thread overview]
Message-ID: <417F55B9.7090306@yahoo.com.au> (raw)
In-Reply-To: <417F5584.2070400@yahoo.com.au>
[-- Attachment #1: Type: text/plain, Size: 4 bytes --]
1/3
[-- Attachment #2: vm-free-order-pages.patch --]
[-- Type: text/x-patch, Size: 3618 bytes --]
Keep track of the number of free pages of each order in the buddy allocator.
Signed-off-by: Nick Piggin <nickpiggin@yahoo.com.au>
---
linux-2.6-npiggin/include/linux/mmzone.h | 1 +
linux-2.6-npiggin/mm/page_alloc.c | 23 +++++++++--------------
2 files changed, 10 insertions(+), 14 deletions(-)
diff -puN mm/page_alloc.c~vm-free-order-pages mm/page_alloc.c
--- linux-2.6/mm/page_alloc.c~vm-free-order-pages 2004-10-27 14:27:31.000000000 +1000
+++ linux-2.6-npiggin/mm/page_alloc.c 2004-10-27 16:41:28.000000000 +1000
@@ -209,6 +209,7 @@ static inline void __free_pages_bulk (st
BUG_ON(bad_range(zone, buddy1));
BUG_ON(bad_range(zone, buddy2));
list_del(&buddy1->lru);
+ area->nr_free--;
mask <<= 1;
order++;
area++;
@@ -216,6 +217,7 @@ static inline void __free_pages_bulk (st
page_idx &= mask;
}
list_add(&(base + page_idx)->lru, &area->free_list);
+ area->nr_free++;
}
static inline void free_pages_check(const char *function, struct page *page)
@@ -317,6 +319,7 @@ expand(struct zone *zone, struct page *p
size >>= 1;
BUG_ON(bad_range(zone, &page[size]));
list_add(&page[size].lru, &area->free_list);
+ area->nr_free++;
MARK_USED(index + size, high, area);
}
return page;
@@ -380,6 +383,7 @@ static struct page *__rmqueue(struct zon
page = list_entry(area->free_list.next, struct page, lru);
list_del(&page->lru);
+ area->nr_free--;
index = page - zone->zone_mem_map;
if (current_order != MAX_ORDER-1)
MARK_USED(index, current_order, area);
@@ -1120,7 +1124,6 @@ void show_free_areas(void)
}
for_each_zone(zone) {
- struct list_head *elem;
unsigned long nr, flags, order, total = 0;
show_node(zone);
@@ -1132,9 +1135,7 @@ void show_free_areas(void)
spin_lock_irqsave(&zone->lock, flags);
for (order = 0; order < MAX_ORDER; order++) {
- nr = 0;
- list_for_each(elem, &zone->free_area[order].free_list)
- ++nr;
+ nr = zone->free_area[order].nr_free;
total += nr << order;
printk("%lu*%lukB ", nr, K(1UL) << order);
}
@@ -1460,6 +1461,7 @@ void zone_init_free_lists(struct pglist_
bitmap_size = pages_to_bitmap_size(order, size);
zone->free_area[order].map =
(unsigned long *) alloc_bootmem_node(pgdat, bitmap_size);
+ zone->free_area[order].nr_free = 0;
}
}
@@ -1647,8 +1649,7 @@ static void frag_stop(struct seq_file *m
}
/*
- * This walks the freelist for each zone. Whilst this is slow, I'd rather
- * be slow here than slow down the fast path by keeping stats - mjbligh
+ * This walks the free areas for each zone.
*/
static int frag_show(struct seq_file *m, void *arg)
{
@@ -1664,14 +1665,8 @@ static int frag_show(struct seq_file *m,
spin_lock_irqsave(&zone->lock, flags);
seq_printf(m, "Node %d, zone %8s ", pgdat->node_id, zone->name);
- for (order = 0; order < MAX_ORDER; ++order) {
- unsigned long nr_bufs = 0;
- struct list_head *elem;
-
- list_for_each(elem, &(zone->free_area[order].free_list))
- ++nr_bufs;
- seq_printf(m, "%6lu ", nr_bufs);
- }
+ for (order = 0; order < MAX_ORDER; ++order)
+ seq_printf(m, "%6lu ", zone->free_area[order].nr_free);
spin_unlock_irqrestore(&zone->lock, flags);
seq_putc(m, '\n');
}
diff -puN include/linux/mmzone.h~vm-free-order-pages include/linux/mmzone.h
--- linux-2.6/include/linux/mmzone.h~vm-free-order-pages 2004-10-27 14:27:31.000000000 +1000
+++ linux-2.6-npiggin/include/linux/mmzone.h 2004-10-27 16:41:28.000000000 +1000
@@ -23,6 +23,7 @@
struct free_area {
struct list_head free_list;
unsigned long *map;
+ unsigned long nr_free;
};
struct pglist_data;
_
next prev parent reply other threads:[~2004-10-27 8:00 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2004-10-27 8:00 [PATCH 0/3] teach kswapd about higher order allocations Nick Piggin
2004-10-27 8:00 ` Nick Piggin [this message]
2004-10-27 8:02 ` [PATCH 2/3] higher order watermarks Nick Piggin
2004-10-27 8:02 ` [PATCH 3/3] teach kswapd about higher order areas Nick Piggin
2004-10-27 8:13 ` Nick Piggin
2004-11-04 8:57 ` [PATCH 2/3] higher order watermarks Marcelo Tosatti
2004-11-04 12:20 ` Nick Piggin
2004-11-04 9:55 ` Marcelo Tosatti
2004-11-05 1:06 ` Nick Piggin
2004-11-04 22:47 ` Marcelo Tosatti
2004-11-05 2:08 ` Andrew Morton
2004-11-05 2:14 ` Nick Piggin
2004-11-04 10:02 ` Marcelo Tosatti
2004-11-05 1:12 ` Nick Piggin
2004-11-10 16:23 ` Marcelo Tosatti
2004-11-11 1:41 ` Nick Piggin
2004-11-11 10:18 ` Marcelo Tosatti
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=417F55B9.7090306@yahoo.com.au \
--to=nickpiggin@yahoo.com.au \
--cc=akpm@osdl.org \
--cc=linux-mm@kvack.org \
--cc=torvalds@osdl.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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.