From: Nick Piggin <nickpiggin@yahoo.com.au>
To: Linux Kernel Mailing List <Linux-Kernel@vger.kernel.org>
Subject: [patch 1/14] mm: opt rmqueue
Date: Sun, 06 Nov 2005 19:20:12 +1100 [thread overview]
Message-ID: <436DBCBC.5000906@yahoo.com.au> (raw)
In-Reply-To: <436DBAC3.7090902@yahoo.com.au>
[-- Attachment #1: Type: text/plain, Size: 34 bytes --]
1/14
--
SUSE Labs, Novell Inc.
[-- Attachment #2: mm-pagealloc-opt.patch --]
[-- Type: text/plain, Size: 2906 bytes --]
Slightly optimise some page allocation and freeing functions by
taking advantage of knowing whether or not interrupts are disabled.
Index: linux-2.6/mm/page_alloc.c
===================================================================
--- linux-2.6.orig/mm/page_alloc.c
+++ linux-2.6/mm/page_alloc.c
@@ -373,11 +373,10 @@ static int
free_pages_bulk(struct zone *zone, int count,
struct list_head *list, unsigned int order)
{
- unsigned long flags;
struct page *page = NULL;
int ret = 0;
- spin_lock_irqsave(&zone->lock, flags);
+ spin_lock(&zone->lock);
zone->all_unreclaimable = 0;
zone->pages_scanned = 0;
while (!list_empty(list) && count--) {
@@ -387,12 +386,13 @@ free_pages_bulk(struct zone *zone, int c
__free_pages_bulk(page, zone, order);
ret++;
}
- spin_unlock_irqrestore(&zone->lock, flags);
+ spin_unlock(&zone->lock);
return ret;
}
void __free_pages_ok(struct page *page, unsigned int order)
{
+ unsigned long flags;
LIST_HEAD(list);
int i;
@@ -410,7 +410,9 @@ void __free_pages_ok(struct page *page,
free_pages_check(__FUNCTION__, page + i);
list_add(&page->lru, &list);
kernel_map_pages(page, 1<<order, 0);
+ local_irq_save(flags);
free_pages_bulk(page_zone(page), 1, &list, order);
+ local_irq_restore(flags);
}
@@ -526,12 +528,11 @@ static struct page *__rmqueue(struct zon
static int rmqueue_bulk(struct zone *zone, unsigned int order,
unsigned long count, struct list_head *list)
{
- unsigned long flags;
int i;
int allocated = 0;
struct page *page;
- spin_lock_irqsave(&zone->lock, flags);
+ spin_lock(&zone->lock);
for (i = 0; i < count; ++i) {
page = __rmqueue(zone, order);
if (page == NULL)
@@ -539,7 +540,7 @@ static int rmqueue_bulk(struct zone *zon
allocated++;
list_add_tail(&page->lru, list);
}
- spin_unlock_irqrestore(&zone->lock, flags);
+ spin_unlock(&zone->lock);
return allocated;
}
@@ -576,6 +577,7 @@ void drain_remote_pages(void)
#if defined(CONFIG_PM) || defined(CONFIG_HOTPLUG_CPU)
static void __drain_pages(unsigned int cpu)
{
+ unsigned long flags;
struct zone *zone;
int i;
@@ -587,8 +589,10 @@ static void __drain_pages(unsigned int c
struct per_cpu_pages *pcp;
pcp = &pset->pcp[i];
+ local_irq_save(flags);
pcp->count -= free_pages_bulk(zone, pcp->count,
&pcp->list, 0);
+ local_irq_restore(flags);
}
}
}
@@ -726,16 +730,14 @@ buffered_rmqueue(struct zone *zone, int
if (pcp->count <= pcp->low)
pcp->count += rmqueue_bulk(zone, 0,
pcp->batch, &pcp->list);
- if (pcp->count) {
+ if (likely(pcp->count)) {
page = list_entry(pcp->list.next, struct page, lru);
list_del(&page->lru);
pcp->count--;
}
local_irq_restore(flags);
put_cpu();
- }
-
- if (page == NULL) {
+ } else {
spin_lock_irqsave(&zone->lock, flags);
page = __rmqueue(zone, order);
spin_unlock_irqrestore(&zone->lock, flags);
next prev parent reply other threads:[~2005-11-06 8:18 UTC|newest]
Thread overview: 33+ messages / expand[flat|nested] mbox.gz Atom feed top
2005-11-06 8:11 [rfc][patch 0/14] mm: performance improvements Nick Piggin
2005-11-06 8:20 ` Nick Piggin [this message]
2005-11-06 8:20 ` [patch 2/14] mm: Nick Piggin
2005-11-06 8:20 ` [patch 2/14] mm: pte prefetch Nick Piggin
2005-11-06 8:21 ` [patch 3/14] mm: release opt Nick Piggin
2005-11-06 8:22 ` [patch 4/14] mm: rmap opt Nick Piggin
2005-11-06 8:23 ` [patch 5/14] mm: set_page_refs opt Nick Piggin
2005-11-06 8:24 ` [patch 6/14] mm: microopt conditions Nick Piggin
2005-11-06 8:24 ` [patch 7/14] mm: remove bad_range Nick Piggin
2005-11-06 8:25 ` [patch 8/14] mm: remove pcp_low Nick Piggin
2005-11-06 8:25 ` [patch 9/14] mm: page_state opt Nick Piggin
2005-11-06 8:26 ` [patch 10/14] mm: single pcp list Nick Piggin
2005-11-06 8:26 ` [patch 11/14] mm: increase pcp size Nick Piggin
2005-11-06 8:27 ` [patch 12/14] mm: variable " Nick Piggin
2005-11-06 8:27 ` [patch 13/14] mm: cleanup zone_pcp Nick Piggin
2005-11-06 8:28 ` [patch 14/14] mm: page_alloc cleanups Nick Piggin
2005-11-13 2:38 ` [patch 9/14] mm: page_state opt Andi Kleen
2005-11-06 17:37 ` [patch 7/14] mm: remove bad_range Bob Picco
2005-11-07 0:58 ` Nick Piggin
2005-11-07 3:00 ` Bob Picco
2005-11-07 3:05 ` Nick Piggin
2005-11-07 1:40 ` [patch 5/14] mm: set_page_refs opt Christoph Hellwig
2005-11-07 1:45 ` Nick Piggin
2005-11-06 8:35 ` [patch 2/14] mm: pte prefetch Arjan van de Ven
2005-11-06 8:51 ` Nick Piggin
2005-11-06 17:37 ` [patch 1/14] mm: opt rmqueue Andi Kleen
2005-11-07 1:06 ` Nick Piggin
2005-11-07 3:23 ` Andi Kleen
2005-11-07 3:43 ` Nick Piggin
2005-11-07 1:39 ` [rfc][patch 0/14] mm: performance improvements Christoph Hellwig
2005-11-07 1:51 ` Nick Piggin
2005-11-07 3:57 ` Paul Jackson
2005-11-07 4:51 ` Nick Piggin
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=436DBCBC.5000906@yahoo.com.au \
--to=nickpiggin@yahoo.com.au \
--cc=Linux-Kernel@vger.kernel.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox