From: Matthew Wilcox <willy@linux.intel.com>
To: linux-kernel@vger.kernel.org
Cc: Matthew Wilcox <willy@linux.intel.com>
Subject: [PATCH 1/4] Avoid taking waitqueue lock in dmapool
Date: Wed, 26 Sep 2007 15:01:16 -0400 [thread overview]
Message-ID: <11908332791719-git-send-email-willy@linux.intel.com> (raw)
In-Reply-To: <20070926185757.GM3899@parisc-linux.org>
With one trivial change (taking the lock slightly earlier on wakeup
from schedule), all uses of the waitq are under the pool lock, so we
can use the locked (or __) versions of the wait queue functions, and
avoid the extra spinlock.
Signed-off-by: Matthew Wilcox <willy@linux.intel.com>
---
mm/dmapool.c | 9 +++++----
1 files changed, 5 insertions(+), 4 deletions(-)
diff --git a/mm/dmapool.c b/mm/dmapool.c
index 6201371..a359b5e 100644
--- a/mm/dmapool.c
+++ b/mm/dmapool.c
@@ -273,8 +273,8 @@ void *dma_pool_alloc(struct dma_pool *pool, gfp_t mem_flags,
size_t offset;
void *retval;
- restart:
spin_lock_irqsave(&pool->lock, flags);
+ restart:
list_for_each_entry(page, &pool->page_list, page_list) {
int i;
/* only cachable accesses here ... */
@@ -296,12 +296,13 @@ void *dma_pool_alloc(struct dma_pool *pool, gfp_t mem_flags,
DECLARE_WAITQUEUE(wait, current);
current->state = TASK_INTERRUPTIBLE;
- add_wait_queue(&pool->waitq, &wait);
+ __add_wait_queue(&pool->waitq, &wait);
spin_unlock_irqrestore(&pool->lock, flags);
schedule_timeout(POOL_TIMEOUT_JIFFIES);
- remove_wait_queue(&pool->waitq, &wait);
+ spin_lock_irqsave(&pool->lock, flags);
+ __remove_wait_queue(&pool->waitq, &wait);
goto restart;
}
retval = NULL;
@@ -401,7 +402,7 @@ void dma_pool_free(struct dma_pool *pool, void *vaddr, dma_addr_t dma)
page->in_use--;
set_bit(block, &page->bitmap[map]);
if (waitqueue_active(&pool->waitq))
- wake_up(&pool->waitq);
+ wake_up_locked(&pool->waitq);
/*
* Resist a temptation to do
* if (!is_page_busy(bpp, page->bitmap)) pool_free_page(pool, page);
--
1.5.3.1
next prev parent reply other threads:[~2007-09-26 19:01 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-09-26 18:57 dmapool Matthew Wilcox
2007-09-26 19:01 ` Matthew Wilcox [this message]
2007-09-26 21:10 ` [PATCH 1/4] Avoid taking waitqueue lock in dmapool David Miller
2007-09-26 19:01 ` [PATCH 2/4] dmapool: Validate parameters to dma_pool_create Matthew Wilcox
2007-09-26 19:47 ` roel
[not found] ` <20070926214022.GA14710@linuxntel.com>
2007-09-26 21:08 ` roel
2007-09-26 21:10 ` David Miller
2007-09-26 19:01 ` [PATCH 3/4] Change dmapool free block management Matthew Wilcox
2007-09-26 19:23 ` Roland Dreier
2007-09-26 20:07 ` roel
2007-09-26 21:13 ` David Miller
2007-09-26 19:01 ` [PATCH 4/4] dmapool: Improve memory usage for devices which can't cross boundaries Matthew Wilcox
2007-09-26 20:12 ` roel
2007-09-26 21:14 ` David Miller
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=11908332791719-git-send-email-willy@linux.intel.com \
--to=willy@linux.intel.com \
--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