* [PATCH] dcache statistics race in 2.4
@ 2003-08-28 2:27 Tejun Huh
2003-08-28 13:43 ` Stephan von Krawczynski
0 siblings, 1 reply; 3+ messages in thread
From: Tejun Huh @ 2003-08-28 2:27 UTC (permalink / raw)
To: linux-kernel
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;
}
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] dcache statistics race in 2.4
2003-08-28 2:27 [PATCH] dcache statistics race in 2.4 Tejun Huh
@ 2003-08-28 13:43 ` Stephan von Krawczynski
2003-08-28 13:53 ` Tejun Huh
0 siblings, 1 reply; 3+ messages in thread
From: Stephan von Krawczynski @ 2003-08-28 13:43 UTC (permalink / raw)
To: Tejun Huh; +Cc: linux-kernel
On Thu, 28 Aug 2003 11:27:49 +0900
Tejun Huh <tejun@aratech.co.kr> wrote:
> 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.
Can you shortly describe what user experiences in this case?
Regards,
Stephan
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] dcache statistics race in 2.4
2003-08-28 13:43 ` Stephan von Krawczynski
@ 2003-08-28 13:53 ` Tejun Huh
0 siblings, 0 replies; 3+ messages in thread
From: Tejun Huh @ 2003-08-28 13:53 UTC (permalink / raw)
To: Stephan von Krawczynski; +Cc: Tejun Huh, linux-kernel
On Thu, Aug 28, 2003 at 03:43:50PM +0200, Stephan von Krawczynski wrote:
> On Thu, 28 Aug 2003 11:27:49 +0900
> Tejun Huh <tejun@aratech.co.kr> wrote:
>
> > 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.
>
> Can you shortly describe what user experiences in this case?
>
Hello Stephan,
Not much, just weird numbers in /proc/sys/fs/dentry-state. isag may
show continuously increasing graph. Only statistic is affected.
--
tejun
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2003-08-28 13:51 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2003-08-28 2:27 [PATCH] dcache statistics race in 2.4 Tejun Huh
2003-08-28 13:43 ` Stephan von Krawczynski
2003-08-28 13:53 ` Tejun Huh
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.