<html><head><meta name="color-scheme" content="light dark"></head><body><pre style="word-wrap: break-word; white-space: pre-wrap;">
From: Ingo Molnar &lt;mingo@elte.hu&gt;

The attached patch fixes long scheduling latencies in select_parent() and
prune_dcache().  The prune_dcache() lock-break is easy, but for
select_parent() the only viable solution i found was to break out if
there's a resched necessary - the reordering is not necessary and the
dcache scanning/shrinking will later on do it anyway.

This patch has been in the -VP patchset for weeks.

Signed-off-by: Ingo Molnar &lt;mingo@elte.hu&gt;
Signed-off-by: Andrew Morton &lt;akpm@osdl.org&gt;
---

 25-akpm/fs/dcache.c |   11 +++++++++++
 1 files changed, 11 insertions(+)

diff -puN fs/dcache.c~sched-vfs-fix-scheduling-latencies-in-prune_dcache-and-select_parent fs/dcache.c
--- 25/fs/dcache.c~sched-vfs-fix-scheduling-latencies-in-prune_dcache-and-select_parent	2004-09-21 01:53:30.382304552 -0700
+++ 25-akpm/fs/dcache.c	2004-09-21 01:53:30.387303792 -0700
@@ -382,6 +382,8 @@ static void prune_dcache(int count)
 		struct dentry *dentry;
 		struct list_head *tmp;
 
+		cond_resched_lock(&amp;dcache_lock);
+
 		tmp = dentry_unused.prev;
 		if (tmp == &amp;dentry_unused)
 			break;
@@ -554,6 +556,14 @@ resume:
 		struct dentry *dentry = list_entry(tmp, struct dentry, d_child);
 		next = tmp-&gt;next;
 
+		/*
+		 * select_parent() is a performance optimization, it is
+		 * not necessary to complete it. Abort if a reschedule is
+		 * pending:
+		 */
+		if (need_resched())
+			goto out;
+
 		if (!list_empty(&amp;dentry-&gt;d_lru)) {
 			dentry_stat.nr_unused--;
 			list_del_init(&amp;dentry-&gt;d_lru);
@@ -591,6 +601,7 @@ this_parent-&gt;d_parent-&gt;d_name.name, this
 #endif
 		goto resume;
 	}
+out:
 	spin_unlock(&amp;dcache_lock);
 	return found;
 }
_
</pre></body></html>