linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Rik van Riel <riel@conectiva.com.br>
To: Linus Torvalds <torvalds@transmeta.com>
Cc: Alan Cox <alan@lxorguk.ukuu.org.uk>, linux-kernel@vger.kernel.org
Subject: [PATCH] dcache 2nd chance replacement
Date: Wed, 3 Jan 2001 16:59:16 -0200 (BRDT)	[thread overview]
Message-ID: <Pine.LNX.4.21.0101031653100.1403-100000@duckman.distro.conectiva> (raw)

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/

             reply	other threads:[~2001-01-03 19:31 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2001-01-03 18:59 Rik van Riel [this message]
2001-01-03 19:05 ` [PATCH] dcache 2nd chance replacement 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

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=Pine.LNX.4.21.0101031653100.1403-100000@duckman.distro.conectiva \
    --to=riel@conectiva.com.br \
    --cc=alan@lxorguk.ukuu.org.uk \
    --cc=linux-kernel@vger.kernel.org \
    --cc=torvalds@transmeta.com \
    /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;
as well as URLs for NNTP newsgroup(s).