Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 226691
b: refs/heads/master
c: 3e880fb
h: refs/heads/master
i:
  226689: de884c0
  226687: 9759ab0
v: v3
  • Loading branch information
Nick Piggin committed Jan 7, 2011
1 parent b0e3dee commit 5aebeff
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 14 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 86c8749ede0c59e590de9267066932a26f1ce796
refs/heads/master: 3e880fb5e4bb6a012035e3edd0586ee2817c2e24
19 changes: 13 additions & 6 deletions trunk/fs/dcache.c
Original file line number Diff line number Diff line change
Expand Up @@ -67,13 +67,22 @@ struct dentry_stat_t dentry_stat = {
.age_limit = 45,
};

static struct percpu_counter nr_dentry __cacheline_aligned_in_smp;
static DEFINE_PER_CPU(unsigned int, nr_dentry);

#if defined(CONFIG_SYSCTL) && defined(CONFIG_PROC_FS)
static int get_nr_dentry(void)
{
int i;
int sum = 0;
for_each_possible_cpu(i)
sum += per_cpu(nr_dentry, i);
return sum < 0 ? 0 : sum;
}

int proc_nr_dentry(ctl_table *table, int write, void __user *buffer,
size_t *lenp, loff_t *ppos)
{
dentry_stat.nr_dentry = percpu_counter_sum_positive(&nr_dentry);
dentry_stat.nr_dentry = get_nr_dentry();
return proc_dointvec(table, write, buffer, lenp, ppos);
}
#endif
Expand All @@ -93,7 +102,7 @@ static void __d_free(struct rcu_head *head)
*/
static void d_free(struct dentry *dentry)
{
percpu_counter_dec(&nr_dentry);
this_cpu_dec(nr_dentry);
if (dentry->d_op && dentry->d_op->d_release)
dentry->d_op->d_release(dentry);

Expand Down Expand Up @@ -981,7 +990,7 @@ struct dentry *d_alloc(struct dentry * parent, const struct qstr *name)
list_add(&dentry->d_u.d_child, &parent->d_subdirs);
spin_unlock(&dcache_lock);

percpu_counter_inc(&nr_dentry);
this_cpu_inc(nr_dentry);

return dentry;
}
Expand Down Expand Up @@ -2418,8 +2427,6 @@ static void __init dcache_init(void)
{
int loop;

percpu_counter_init(&nr_dentry, 0);

/*
* A constructor could be added for stable state like the lists,
* but it is probably not worth it because of the cache nature
Expand Down
17 changes: 10 additions & 7 deletions trunk/fs/inode.c
Original file line number Diff line number Diff line change
Expand Up @@ -102,13 +102,17 @@ static DECLARE_RWSEM(iprune_sem);
*/
struct inodes_stat_t inodes_stat;

static struct percpu_counter nr_inodes __cacheline_aligned_in_smp;
static DEFINE_PER_CPU(unsigned int, nr_inodes);

static struct kmem_cache *inode_cachep __read_mostly;

static inline int get_nr_inodes(void)
static int get_nr_inodes(void)
{
return percpu_counter_sum_positive(&nr_inodes);
int i;
int sum = 0;
for_each_possible_cpu(i)
sum += per_cpu(nr_inodes, i);
return sum < 0 ? 0 : sum;
}

static inline int get_nr_inodes_unused(void)
Expand All @@ -118,9 +122,9 @@ static inline int get_nr_inodes_unused(void)

int get_nr_dirty_inodes(void)
{
/* not actually dirty inodes, but a wild approximation */
int nr_dirty = get_nr_inodes() - get_nr_inodes_unused();
return nr_dirty > 0 ? nr_dirty : 0;

}

/*
Expand Down Expand Up @@ -222,7 +226,7 @@ int inode_init_always(struct super_block *sb, struct inode *inode)
inode->i_fsnotify_mask = 0;
#endif

percpu_counter_inc(&nr_inodes);
this_cpu_inc(nr_inodes);

return 0;
out:
Expand Down Expand Up @@ -264,7 +268,7 @@ void __destroy_inode(struct inode *inode)
if (inode->i_default_acl && inode->i_default_acl != ACL_NOT_CACHED)
posix_acl_release(inode->i_default_acl);
#endif
percpu_counter_dec(&nr_inodes);
this_cpu_dec(nr_inodes);
}
EXPORT_SYMBOL(__destroy_inode);

Expand Down Expand Up @@ -1646,7 +1650,6 @@ void __init inode_init(void)
SLAB_MEM_SPREAD),
init_once);
register_shrinker(&icache_shrinker);
percpu_counter_init(&nr_inodes, 0);

/* Hash may have been set up in inode_init_early */
if (!hashdist)
Expand Down

0 comments on commit 5aebeff

Please sign in to comment.