From: Con Kolivas <kernel@kolivas.org>
To: linux-kernel@vger.kernel.org, linux-mm@kvack.org,
Andrew Morton <akpm@linux-foundation.org>,
ck@vds.kolivas.org
Subject: [PATCH] mm: swap prefetch more improvements
Date: Mon, 14 May 2007 10:50:54 +1000 [thread overview]
Message-ID: <200705141050.55038.kernel@kolivas.org> (raw)
akpm, please queue on top of "mm: swap prefetch improvements"
---
Failed radix_tree_insert wasn't being handled leaving stale kmem.
The list should be iterated over in the reverse order when prefetching.
Make the yield within kprefetchd stronger through the use of cond_resched.
Check that the pos entry hasn't been removed while unlocked.
Signed-off-by: Con Kolivas <kernel@kolivas.org>
---
mm/swap_prefetch.c | 19 ++++++++++---------
1 file changed, 10 insertions(+), 9 deletions(-)
Index: linux-2.6.21-ck1/mm/swap_prefetch.c
===================================================================
--- linux-2.6.21-ck1.orig/mm/swap_prefetch.c 2007-05-14 09:39:37.000000000 +1000
+++ linux-2.6.21-ck1/mm/swap_prefetch.c 2007-05-14 10:21:47.000000000 +1000
@@ -117,7 +117,8 @@ void add_to_swapped_list(struct page *pa
if (likely(!radix_tree_insert(&swapped.swap_tree, index, entry))) {
list_add(&entry->swapped_list, &swapped.list);
swapped.count++;
- }
+ } else
+ kmem_cache_free(swapped.cache, entry);
out_locked:
spin_unlock_irqrestore(&swapped.lock, flags);
@@ -427,7 +428,7 @@ out:
static enum trickle_return trickle_swap(void)
{
enum trickle_return ret = TRICKLE_DELAY;
- struct list_head *p, *next;
+ struct swapped_entry *pos, *n;
unsigned long flags;
if (!prefetch_enabled())
@@ -440,19 +441,19 @@ static enum trickle_return trickle_swap(
return TRICKLE_FAILED;
spin_lock_irqsave(&swapped.lock, flags);
- list_for_each_safe(p, next, &swapped.list) {
- struct swapped_entry *entry;
+ list_for_each_entry_safe_reverse(pos, n, &swapped.list, swapped_list) {
swp_entry_t swp_entry;
int node;
spin_unlock_irqrestore(&swapped.lock, flags);
- might_sleep();
- if (!prefetch_suitable())
+ /* Yield to anything else running */
+ if (cond_resched() || !prefetch_suitable())
goto out_unlocked;
spin_lock_irqsave(&swapped.lock, flags);
- entry = list_entry(p, struct swapped_entry, swapped_list);
- node = get_swap_entry_node(entry);
+ if (unlikely(!pos))
+ continue;
+ node = get_swap_entry_node(pos);
if (!node_isset(node, sp_stat.prefetch_nodes)) {
/*
* We found an entry that belongs to a node that is
@@ -460,7 +461,7 @@ static enum trickle_return trickle_swap(
*/
continue;
}
- swp_entry = entry->swp_entry;
+ swp_entry = pos->swp_entry;
spin_unlock_irqrestore(&swapped.lock, flags);
if (trickle_swap_cache_async(swp_entry, node) == TRICKLE_DELAY)
--
-ck
--
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 reply other threads:[~2007-05-14 0:50 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-05-14 0:50 Con Kolivas [this message]
2007-05-14 22:00 ` Andrew Morton
2007-05-14 22:43 ` Con Kolivas
2007-05-14 23:01 ` Andrew Morton
2007-05-14 23:24 ` Con Kolivas
2007-05-14 23:37 ` [ck] " Michael Chang
2007-05-15 9:58 ` Peter Zijlstra
2007-05-15 12:43 ` Con Kolivas
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=200705141050.55038.kernel@kolivas.org \
--to=kernel@kolivas.org \
--cc=akpm@linux-foundation.org \
--cc=ck@vds.kolivas.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.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