From: Peter Zijlstra <a.p.zijlstra@chello.nl>
To: linux-mm@kvack.org
Cc: Nick Piggin <nickpiggin@yahoo.com.au>,
Peter Zijlstra <a.p.zijlstra@chello.nl>
Subject: [PATCH 09/16] mm: speculative find_get_pages_tag
Date: Thu, 07 Dec 2006 17:18:09 +0100 [thread overview]
Message-ID: <20061207162735.864300000@chello.nl> (raw)
In-Reply-To: <20061207161800.426936000@chello.nl>
[-- Attachment #1: mm-lockless-find_get_pages_tag.patch --]
[-- Type: text/plain, Size: 1904 bytes --]
implement the speculative find_get_pages_tag.
Signed-off-by: Peter Zijlstra <a.p.zijlstra@chello.nl>
---
mm/filemap.c | 42 +++++++++++++++++++++++++++++++++---------
1 file changed, 33 insertions(+), 9 deletions(-)
Index: linux-2.6-rt/mm/filemap.c
===================================================================
--- linux-2.6-rt.orig/mm/filemap.c 2006-11-30 16:59:17.000000000 +0100
+++ linux-2.6-rt/mm/filemap.c 2006-11-30 17:45:12.000000000 +0100
@@ -838,16 +838,40 @@ unsigned find_get_pages_tag(struct addre
{
unsigned int i;
unsigned int ret;
+ unsigned int nr_found;
- read_lock_irq(&mapping->tree_lock);
- /* TODO: implement lookup_tag_slot and make this lockless */
- ret = radix_tree_gang_lookup_tag(&mapping->page_tree,
- (void **)pages, *index, nr_pages, tag);
- for (i = 0; i < ret; i++)
- page_cache_get(pages[i]);
- if (ret)
- *index = pages[ret - 1]->index + 1;
- read_unlock_irq(&mapping->tree_lock);
+ rcu_read_lock();
+restart:
+ nr_found = radix_tree_gang_lookup_tag_slot(&mapping->page_tree,
+ (void ***)pages, *index, nr_pages, tag);
+
+ ret = 0;
+ for (i = 0; i < nr_found; i++) {
+ struct page *page;
+repeat:
+ page = radix_tree_deref_slot((void**)pages[i]);
+ if (unlikely(!page))
+ continue;
+ /*
+ * this can only trigger if nr_found == 1, making livelocks
+ * a non issue.
+ */
+ if (unlikely(page == RADIX_TREE_RETRY))
+ goto restart;
+
+ if (!page_cache_get_speculative(page))
+ goto repeat;
+
+ /* Has the page moved? */
+ if (unlikely(page != *((void **)pages[i]))) {
+ page_cache_release(page);
+ goto repeat;
+ }
+
+ pages[ret] = page;
+ ret++;
+ }
+ rcu_read_unlock();
return ret;
}
--
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
next prev parent reply other threads:[~2006-12-07 16:18 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-12-07 16:18 [PATCH 00/16] concurrent pagecache (against 2.6.19-rt) Peter Zijlstra
2006-12-07 16:18 ` [PATCH 01/16] radix-tree: RCU lockless readside Nick Piggin
2006-12-07 16:18 ` [PATCH 02/16] radix-tree: use indirect bit Nick Piggin
2006-12-07 16:18 ` [PATCH 03/16] radix-tree: gang_lookup_slot Nick Piggin
2006-12-07 16:18 ` [PATCH 04/16] radix-tree: gang_lookup_tag_slot Peter Zijlstra
2006-12-07 16:18 ` [PATCH 05/16] mm: speculative get page Nick Piggin
2006-12-07 16:18 ` [PATCH 06/16] mm: lockless pagecache lookups Nick Piggin
2006-12-07 16:18 ` [PATCH 07/16] mm: fix speculative page get preemption bug Peter Zijlstra
2006-12-07 16:18 ` [PATCH 08/16] mm: speculative page get for PREEMPT_RT Peter Zijlstra
2006-12-07 16:18 ` Peter Zijlstra [this message]
2006-12-07 16:18 ` [PATCH 10/16] mm: remove find_tylock_page Peter Zijlstra
2006-12-07 16:18 ` [PATCH 11/16] mm: change tree_lock into a spinlock Peter Zijlstra
2006-12-07 16:18 ` [PATCH 12/16] radix-tree: concurrent write side support Peter Zijlstra
2006-12-07 16:18 ` [PATCH 13/16] atomic_ulong_t Peter Zijlstra
2006-12-07 16:18 ` [PATCH 14/16] mm/fs: abstract address_space::nrpages Peter Zijlstra
2006-12-07 16:18 ` [PATCH 15/16] mm: lock_page_ref Peter Zijlstra
2006-12-07 16:18 ` [PATCH 16/16] mm: concurrent pagecache write side Peter Zijlstra
2006-12-11 19:03 ` [PATCH 00/16] concurrent pagecache (against 2.6.19-rt) Christoph Lameter
2006-12-11 19:24 ` Peter Zijlstra
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=20061207162735.864300000@chello.nl \
--to=a.p.zijlstra@chello.nl \
--cc=linux-mm@kvack.org \
--cc=nickpiggin@yahoo.com.au \
/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