All of lore.kernel.org
 help / color / mirror / Atom feed
From: Tejun Huh <tejun@aratech.co.kr>
To: linux-kernel@vger.kernel.org
Subject: [PATCH] dcache statistics race in 2.4
Date: Thu, 28 Aug 2003 11:27:49 +0900	[thread overview]
Message-ID: <20030828022748.GA20792@atj.dyndns.org> (raw)

 Hello,

 In fs/dcache.c, dentry_stat.nr_dentry is not protected by anything
and on a busy SMP machine, after a while, the count goes wild.  I'm
attaching a patch which puts nr_dentry accounting inside dcache_lock.
One spin_lock/unlock pair is added to d_alloc on NULL parent path but
I think NULL parent is used only occasionally when allocating root
dentry so this patch shouldn't cause any performance impact.

 If anything is wrong, please point out.  If there's no comment in a
few days, I'll submit this to Marcelo.

 TIA.

-- 
tejun

# This is a BitKeeper generated patch for the following project:
# Project Name: Linux kernel tree
# This patch format is intended for GNU patch command version 2.5 or higher.
# This patch includes the following deltas:
#	           ChangeSet	1.1085  -> 1.1086 
#	         fs/dcache.c	1.24    -> 1.25   
#
# The following is the BitKeeper ChangeSet Log
# --------------------------------------------
# 03/08/28	tj@atj.dyndns.org	1.1086
# - dentry_stat.nr_dentry race fix.
# --------------------------------------------
#
diff -Nru a/fs/dcache.c b/fs/dcache.c
--- a/fs/dcache.c	Thu Aug 28 11:07:51 2003
+++ b/fs/dcache.c	Thu Aug 28 11:07:51 2003
@@ -63,7 +63,6 @@
 	if (dname_external(dentry)) 
 		kfree(dentry->d_name.name);
 	kmem_cache_free(dentry_cache, dentry); 
-	dentry_stat.nr_dentry--;
 }
 
 /*
@@ -148,6 +147,7 @@
 kill_it: {
 		struct dentry *parent;
 		list_del(&dentry->d_child);
+		dentry_stat.nr_dentry--;
 		/* drops the lock, at that point nobody can reach this dentry */
 		dentry_iput(dentry);
 		parent = dentry->d_parent;
@@ -297,6 +297,7 @@
 
 	list_del_init(&dentry->d_hash);
 	list_del(&dentry->d_child);
+	dentry_stat.nr_dentry--;
 	dentry_iput(dentry);
 	parent = dentry->d_parent;
 	d_free(dentry);
@@ -625,11 +626,15 @@
 		dentry->d_sb = parent->d_sb;
 		spin_lock(&dcache_lock);
 		list_add(&dentry->d_child, &parent->d_subdirs);
+		dentry_stat.nr_dentry++;
 		spin_unlock(&dcache_lock);
-	} else
+	} else {
 		INIT_LIST_HEAD(&dentry->d_child);
+		spin_lock(&dcache_lock);
+		dentry_stat.nr_dentry++;
+		spin_unlock(&dcache_lock);
+	}
 
-	dentry_stat.nr_dentry++;
 	return dentry;
 }
 

             reply	other threads:[~2003-08-28  2:25 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-08-28  2:27 Tejun Huh [this message]
2003-08-28 13:43 ` [PATCH] dcache statistics race in 2.4 Stephan von Krawczynski
2003-08-28 13:53   ` Tejun Huh

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=20030828022748.GA20792@atj.dyndns.org \
    --to=tejun@aratech.co.kr \
    --cc=linux-kernel@vger.kernel.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.