public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] dcache 2nd chance replacement
@ 2001-01-03 18:59 Rik van Riel
  2001-01-03 19:05 ` Linus Torvalds
  2001-01-03 19:43 ` Andrea Arcangeli
  0 siblings, 2 replies; 17+ messages in thread
From: Rik van Riel @ 2001-01-03 18:59 UTC (permalink / raw)
  To: Linus Torvalds; +Cc: Alan Cox, linux-kernel

Hi,

I rediffed this trivial patch by Andrea (that went
into 2.2.19-pre5) which adds 2nd chance replacement
to the dentry cache, this should make our dcache
behave a little bit better than the current FIFO.

I know this probably isn't of any help under very low
and very high loads, but it should provide a nice
improvement under medium loads...

regards,

Rik
--
Hollywood goes for world dumbination,
	Trailer at 11.

		http://www.surriel.com/
http://www.conectiva.com/	http://distro.conectiva.com.br/



--- linux-2.4.0-prerelease/include/linux/dcache.h.orig	Wed Jan  3 16:33:43 2001
+++ linux-2.4.0-prerelease/include/linux/dcache.h	Wed Jan  3 16:43:29 2001
@@ -115,6 +115,7 @@
 					 * If this dentry points to a directory, then
 					 * s_nfsd_free_path semaphore will be down
 					 */
+#define DCACHE_REFERENCED	0x0008  /* Recently used, don't discard. */
 
 extern spinlock_t dcache_lock;
 
--- linux-2.4.0-prerelease/fs/dcache.c.orig	Wed Jan  3 16:33:09 2001
+++ linux-2.4.0-prerelease/fs/dcache.c	Wed Jan  3 16:43:10 2001
@@ -339,10 +339,18 @@
 
 		if (tmp == &dentry_unused)
 			break;
-		dentry_stat.nr_unused--;
 		list_del_init(tmp);
 		dentry = list_entry(tmp, struct dentry, d_lru);
 
+		/* If the dentry was recently referenced, don't free it. */
+		if (dentry->d_flags & DCACHE_REFERENCED) {
+			dentry->d_flags &= ~DCACHE_REFERENCED;
+			list_add(&dentry->d_lru, &dentry_unused);
+			count--;
+			continue;
+		}
+		dentry_stat.nr_unused--;
+
 		/* Unused dentry with a count? */
 		if (atomic_read(&dentry->d_count))
 			BUG();
@@ -733,6 +741,7 @@
 		}
 		__dget_locked(dentry);
 		spin_unlock(&dcache_lock);
+		dentry->d_flags |= DCACHE_REFERENCED;
 		return dentry;
 	}
 	spin_unlock(&dcache_lock);

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
Please read the FAQ at http://www.tux.org/lkml/

^ permalink raw reply	[flat|nested] 17+ messages in thread

end of thread, other threads:[~2001-01-05 12:09 UTC | newest]

Thread overview: 17+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2001-01-03 18:59 [PATCH] dcache 2nd chance replacement Rik van Riel
2001-01-03 19:05 ` Linus Torvalds
2001-01-03 19:11   ` Rik van Riel
2001-01-03 19:43 ` Andrea Arcangeli
2001-01-03 19:47   ` Rik van Riel
2001-01-03 21:12     ` Andrea Arcangeli
2001-01-03 23:09       ` Rik van Riel
2001-01-04  0:32         ` Andrea Arcangeli
2001-01-04 15:00           ` Rik van Riel
2001-01-04 16:18             ` Andrea Arcangeli
2001-01-04 16:23               ` Rik van Riel
2001-01-04 16:52                 ` Andrea Arcangeli
2001-01-04 16:59                   ` Rik van Riel
2001-01-04 17:35                     ` Andrea Arcangeli
2001-01-04 17:36                       ` Rik van Riel
2001-01-04 17:47                       ` Alan Cox
2001-01-05 12:08                         ` Chris Evans

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox