Commit fa3536cc authored by Eric Dumazet's avatar Eric Dumazet Committed by Linus Torvalds
Browse files

[PATCH] Use __read_mostly on some hot fs variables



I discovered on oprofile hunting on a SMP platform that dentry lookups were
slowed down because d_hash_mask, d_hash_shift and dentry_hashtable were in
a cache line that contained inodes_stat.  So each time inodes_stats is
changed by a cpu, other cpus have to refill their cache line.

This patch moves some variables to the __read_mostly section, in order to
avoid false sharing.  RCU dentry lookups can go full speed.

Signed-off-by: default avatarEric Dumazet <dada1@cosmosbay.com>
Signed-off-by: default avatarAndrew Morton <akpm@osdl.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@osdl.org>
parent 878a9f30
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -30,7 +30,7 @@

#define BIO_POOL_SIZE 256

static kmem_cache_t *bio_slab;
static kmem_cache_t *bio_slab __read_mostly;

#define BIOVEC_NR_POOLS 6

@@ -39,7 +39,7 @@ static kmem_cache_t *bio_slab;
 * basically we just need to survive
 */
#define BIO_SPLIT_ENTRIES 8	
mempool_t *bio_split_pool;
mempool_t *bio_split_pool __read_mostly;

struct biovec_slab {
	int nr_vecs;
+2 −2
Original line number Diff line number Diff line
@@ -234,7 +234,7 @@ static int block_fsync(struct file *filp, struct dentry *dentry, int datasync)
 */

static  __cacheline_aligned_in_smp DEFINE_SPINLOCK(bdev_lock);
static kmem_cache_t * bdev_cachep;
static kmem_cache_t * bdev_cachep __read_mostly;

static struct inode *bdev_alloc_inode(struct super_block *sb)
{
@@ -308,7 +308,7 @@ static struct file_system_type bd_type = {
	.kill_sb	= kill_anon_super,
};

static struct vfsmount *bd_mnt;
static struct vfsmount *bd_mnt __read_mostly;
struct super_block *blockdev_superblock;

void __init bdev_cache_init(void)
+7 −7
Original line number Diff line number Diff line
@@ -36,7 +36,7 @@

/* #define DCACHE_DEBUG 1 */

int sysctl_vfs_cache_pressure = 100;
int sysctl_vfs_cache_pressure __read_mostly = 100;
EXPORT_SYMBOL_GPL(sysctl_vfs_cache_pressure);

 __cacheline_aligned_in_smp DEFINE_SPINLOCK(dcache_lock);
@@ -44,7 +44,7 @@ static seqlock_t rename_lock __cacheline_aligned_in_smp = SEQLOCK_UNLOCKED;

EXPORT_SYMBOL(dcache_lock);

static kmem_cache_t *dentry_cache; 
static kmem_cache_t *dentry_cache __read_mostly;

#define DNAME_INLINE_LEN (sizeof(struct dentry)-offsetof(struct dentry,d_iname))

@@ -59,9 +59,9 @@ static kmem_cache_t *dentry_cache;
#define D_HASHBITS     d_hash_shift
#define D_HASHMASK     d_hash_mask

static unsigned int d_hash_mask;
static unsigned int d_hash_shift;
static struct hlist_head *dentry_hashtable;
static unsigned int d_hash_mask __read_mostly;
static unsigned int d_hash_shift __read_mostly;
static struct hlist_head *dentry_hashtable __read_mostly;
static LIST_HEAD(dentry_unused);

/* Statistics gathering. */
@@ -1719,10 +1719,10 @@ static void __init dcache_init(unsigned long mempages)
}

/* SLAB cache for __getname() consumers */
kmem_cache_t *names_cachep;
kmem_cache_t *names_cachep __read_mostly;

/* SLAB cache for file structures */
kmem_cache_t *filp_cachep;
kmem_cache_t *filp_cachep __read_mostly;

EXPORT_SYMBOL(d_genocide);

+3 −3
Original line number Diff line number Diff line
@@ -38,9 +38,9 @@ struct dcookie_struct {

static LIST_HEAD(dcookie_users);
static DEFINE_MUTEX(dcookie_mutex);
static kmem_cache_t * dcookie_cache;
static struct list_head * dcookie_hashtable;
static size_t hash_size;
static kmem_cache_t *dcookie_cache __read_mostly;
static struct list_head *dcookie_hashtable __read_mostly;
static size_t hash_size __read_mostly;

static inline int is_live(void)
{
+2 −2
Original line number Diff line number Diff line
@@ -21,9 +21,9 @@
#include <linux/spinlock.h>
#include <linux/slab.h>

int dir_notify_enable = 1;
int dir_notify_enable __read_mostly = 1;

static kmem_cache_t *dn_cache;
static kmem_cache_t *dn_cache __read_mostly;

static void redo_inode_mask(struct inode *inode)
{
Loading