[patch] sched, vfs: fix scheduling latencies in prune_dcache() and select_parent()

Ingo Molnar
2004-09-14T10:17:55Z

[-- Attachment #1: Type: text/plain, Size: 390 bytes --]

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.

Ingo

[-- Attachment #2: fix-latency-dcache.patch --]
[-- Type: text/plain, Size: 1249 bytes --]

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 <mingo@elte.hu>

--- linux/fs/dcache.c.orig
+++ linux/fs/dcache.c
@@ -381,6 +381,8 @@ static void prune_dcache(int count)
struct dentry *dentry;
struct list_head *tmp;

+ cond_resched_lock(&dcache_lock);
+
tmp = dentry_unused.prev;
if (tmp == &dentry_unused)
break;
@@ -553,6 +555,14 @@ resume:
struct dentry *dentry = list_entry(tmp, struct dentry, d_child);
next = tmp->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(&dentry->d_lru)) {
dentry_stat.nr_unused--;
list_del_init(&dentry->d_lru);
@@ -590,6 +600,7 @@ this_parent->d_parent->d_name.name, this
#endif
goto resume;
}
+out:
spin_unlock(&dcache_lock);
return found;
}