Fastwalk
Subsystems (4)
Marcelo,
Here is the dcache fastwalk patch to reduce cacheline bouncing of the d_count reference counter while traversing paths that are already in the dcache. The testing I have done this year shows a small increase in throughput on a 2-way system. I expect the benefit to be greatest on slower SMP systems which could suffer from cacheline problems.
Please consider it for inclusion.
Thanks.
Hanna
-----
fs/dcache.c | 17 +- fs/intermezzo/journal.c | 3 fs/intermezzo/presto.c | 3 fs/intermezzo/vfs.c | 31 +--- fs/namei.c | 330 ++++++++++++++++++++++++++++++---------------- fs/namespace.c | 1 fs/nfsd/export.c | 6 include/linux/dcache.h | 1 include/linux/fs.h | 5 include/linux/fs_struct.h | 4 kernel/ksyms.c | 2 net/unix/af_unix.c | 8 - 12 files changed, 258 insertions(+), 153 deletions(-)
fs/dcache.c +13 -4
@@ -702,13 +702,25 @@ static inline struct list_head * d_hash(struct dentry *d_lookup (struct dentry * parent,struct qstr * name) { +struct dentry *dentry =NULL ; + +spin_lock (&dcache_lock); + dentry =__d_lookup (parent,name); +if (dentry) +__dget_locked (dentry); +spin_unlock (&dcache_lock); +return dentry; +} + +struct dentry *__d_lookup (struct dentry * parent,struct qstr * name) +{ +unsigned int len = name->len;unsigned int hash = name->hash;const unsigned char *str = name->name;struct list_head *head =d_hash (parent,hash);struct list_head *tmp; -spin_lock (&dcache_lock); tmp = head->next;for (;;) { struct dentry * dentry = list_entry(tmp, struct dentry, d_hash);
@@ -728,12 +740,9 @@ struct dentry * d_lookup(struct dentry *if (memcmp (dentry->d_name.name, str, len))continue ; } -__dget_locked (dentry); dentry->d_vfs_flags |=DCACHE_REFERENCED ; -spin_unlock (&dcache_lock);return dentry; } -spin_unlock (&dcache_lock);return NULL ; }
fs/intermezzo/journal.c +1 -2
@@ -617,8 +617,7 @@ int izo_lookup_file(struct presto_file_sCDEBUG (D_CACHE ,"looking up: %s\n" , path); -if (path_init (path,LOOKUP_PARENT , nd)) - error =path_walk (path, nd); + error =path_lookup (path,LOOKUP_PARENT , nd);if (error) {EXIT ;return error;
fs/intermezzo/presto.c +1 -2
@@ -53,8 +53,7 @@ int presto_walk(const char *name, structENTRY ; err =0 ; -if (path_init (name, flags, nd)) - err =path_walk (name, nd); + err =path_lookup (name, flags, nd);return err; }
fs/intermezzo/vfs.c +10 -21
@@ -702,8 +702,7 @@ int lento_create(const char *name, int m/* this looks up the parent */ // if (path_init(pathname, LOOKUP_FOLLOW | LOOKUP_POSITIVE, &nd)) -if (path_init (pathname,LOOKUP_PARENT , &nd)) - error =path_walk (pathname, &nd); + error =path_lookup (pathname,LOOKUP_PARENT , &nd);if (error) {EXIT ; goto exit;
@@ -855,12 +854,10 @@ int lento_link(const char * oldname, construct nameidata nd, old_nd; error =0 ; -if (path_init (from,LOOKUP_POSITIVE , &old_nd)) - error =path_walk (from, &old_nd); + error =path_lookup (from,LOOKUP_POSITIVE , &old_nd);if (error) goto exit; -if (path_init (to,LOOKUP_PARENT , &nd)) - error =path_walk (to, &nd); + error =path_lookup (to,LOOKUP_PARENT , &nd);if (error) goto out; error = -EXDEV ;
@@ -1062,8 +1059,7 @@ int lento_unlink(const char *pathname, sif (IS_ERR (name))return PTR_ERR (name); -if (path_init (name,LOOKUP_PARENT , &nd)) - error =path_walk (name, &nd); + error =path_lookup (name,LOOKUP_PARENT , &nd);if (error) goto exit; error = -EISDIR ;
@@ -1223,8 +1219,7 @@ int lento_symlink(const char *oldname, c goto exit_from; } -if (path_init (to,LOOKUP_PARENT , &nd)) - error =path_walk (to, &nd); + error =path_lookup (to,LOOKUP_PARENT , &nd);if (error) {EXIT ; goto exit_to;
@@ -1381,8 +1376,7 @@ int lento_mkdir(const char *name, int moreturn error; } -if (path_init (pathname,LOOKUP_PARENT , &nd)) - error =path_walk (pathname, &nd); + error =path_lookup (pathname,LOOKUP_PARENT , &nd);if (error) goto out_name;
@@ -1527,8 +1521,7 @@ int lento_rmdir(const char *pathname, streturn PTR_ERR (name); } -if (path_init (name,LOOKUP_PARENT , &nd)) - error =path_walk (name, &nd); + error =path_lookup (name,LOOKUP_PARENT , &nd);if (error) {EXIT ; goto exit;
@@ -1693,8 +1686,7 @@ int lento_mknod(const char *filename, inif (IS_ERR (tmp))return PTR_ERR (tmp); -if (path_init (tmp,LOOKUP_PARENT , &nd)) - error =path_walk (tmp, &nd); + error =path_lookup (tmp,LOOKUP_PARENT , &nd);if (error) goto out; dentry =lookup_create (&nd,0 );
@@ -1973,14 +1965,11 @@ int lento_do_rename(const char *oldname,ENTRY ; -if (path_init (oldname,LOOKUP_PARENT , &oldnd)) - error =path_walk (oldname, &oldnd); - + error =path_lookup (oldname,LOOKUP_PARENT , &oldnd);if (error) goto exit; -if (path_init (newname,LOOKUP_PARENT , &newnd)) - error =path_walk (newname, &newnd); + error =path_lookup (newname,LOOKUP_PARENT , &newnd);if (error) goto exit1;
fs/namei.c +217 -113
486 lines not on this page · raw message
fs/namespace.c +1 -0
@@ -23,6 +23,7 @@struct vfsmount *do_kern_mount (const char *type,int flags,char *name,void *data);int do_remount_sb (struct super_block *sb,int flags,void * data); +int __init init_rootfs (void );void kill_super (struct super_block *sb);extern int __init init_rootfs (void );
fs/nfsd/export.c +2 -4
@@ -214,8 +214,7 @@ exp_export(struct nfsctl_export *nxp)/* Look up the dentry */ err =0 ; -if (path_init (nxp->ex_path,LOOKUP_POSITIVE , &nd)) - err =path_walk (nxp->ex_path, &nd); + err =path_lookup (nxp->ex_path,LOOKUP_POSITIVE , &nd);if (err) goto out_unlock;
@@ -411,8 +410,7 @@ exp_rootfh(struct svc_client *clp, kdev_ err = -EPERM ;if (path) { -if (path_init (path,LOOKUP_POSITIVE , &nd) && -path_walk (path, &nd)) { +if (path_lookup (path,LOOKUP_POSITIVE , &nd)) {printk ("nfsd: exp_rootfh path not found %s" , path);return err; }
include/linux/dcache.h +1 -0
@@ -219,6 +219,7 @@ extern void d_move(struct dentry *, stru/* appendix may either be NULL or be used for transname suffixes */ extern struct dentry *d_lookup (struct dentry *,struct qstr *); +extern struct dentry *__d_lookup (struct dentry *,struct qstr *);/* validate "insecure" dentry pointer */ extern int d_validate (struct dentry *,struct dentry *);
include/linux/fs.h +4 -1
@@ -659,6 +659,8 @@ struct nameidata {struct qstr last;unsigned int flags;int last_type; +struct dentry *old_dentry; +struct vfsmount *old_mnt; };#define DQUOT_USR_ENABLED 0x01/* User diskquotas enabled */
@@ -1328,6 +1330,7 @@ static inline long IS_ERR(const void *pt* - require a directory * - ending slashes ok even for nonexistent files * - internal "there are more path compnents" flag +* - locked when lookup done with dcache_lock held */ #define LOOKUP_FOLLOW (1)#define LOOKUP_DIRECTORY (2)
@@ -1335,6 +1338,7 @@ static inline long IS_ERR(const void *pt#define LOOKUP_POSITIVE (8)#define LOOKUP_PARENT (16)#define LOOKUP_NOALT (32) +/* * Type of the last component on LOOKUP_PARENT */
@@ -1362,7 +1366,6 @@ typedef int (*read_actor_t)(read_descripextern loff_t default_llseek (struct file *file,loff_t offset,int origin);extern int FASTCALL (__user_walk (const char *,unsigned ,struct nameidata *)); -extern int FASTCALL (path_init (const char *,unsigned ,struct nameidata *));extern int FASTCALL (path_walk (const char *,struct nameidata *));extern int FASTCALL (path_lookup (const char *,unsigned ,struct nameidata *));extern int FASTCALL (link_path_walk (const char *,struct nameidata *));
include/linux/fs_struct.h +4 -0
@@ -32,10 +32,12 @@ static inline void set_fs_root(struct fsstruct dentry *old_root;struct vfsmount *old_rootmnt;write_lock (&fs->lock); +spin_lock (&dcache_lock); old_root = fs->root; old_rootmnt = fs->rootmnt; fs->rootmnt =mntget (mnt); fs->root =dget (dentry); +spin_unlock (&dcache_lock);write_unlock (&fs->lock);if (old_root) {dput (old_root);
@@ -55,10 +57,12 @@ static inline void set_fs_pwd(struct fs_struct dentry *old_pwd;struct vfsmount *old_pwdmnt;write_lock (&fs->lock); +spin_lock (&dcache_lock); old_pwd = fs->pwd; old_pwdmnt = fs->pwdmnt; fs->pwdmnt =mntget (mnt); fs->pwd =dget (dentry); +spin_unlock (&dcache_lock);write_unlock (&fs->lock);if (old_pwd) {dput (old_pwd);
kernel/ksyms.c +1 -1
@@ -149,8 +149,8 @@ EXPORT_SYMBOL(force_delete);EXPORT_SYMBOL (follow_up);EXPORT_SYMBOL (follow_down);EXPORT_SYMBOL (lookup_mnt); -EXPORT_SYMBOL (path_init);EXPORT_SYMBOL (path_walk); +EXPORT_SYMBOL (path_lookup);EXPORT_SYMBOL (path_release);EXPORT_SYMBOL (__user_walk);EXPORT_SYMBOL (lookup_one_len);
net/unix/af_unix.c +3 -5
@@ -590,9 +590,8 @@ static unix_socket *unix_find_other(struint err =0 ;if (sunname->sun_path[0 ]) { -if (path_init (sunname->sun_path, -LOOKUP_POSITIVE |LOOKUP_FOLLOW , &nd)) - err =path_walk (sunname->sun_path, &nd); + err =path_lookup (sunname->sun_path, +LOOKUP_POSITIVE |LOOKUP_FOLLOW , &nd);if (err) goto fail; err =permission (nd.dentry->d_inode,MAY_WRITE );
@@ -685,8 +684,7 @@ static int unix_bind(struct socket *sock* Get the parent directory, calculate the hash for last * component. */ -if (path_init (sunaddr->sun_path,LOOKUP_PARENT , &nd)) - err =path_walk (sunaddr->sun_path, &nd); + err =path_lookup (sunaddr->sun_path,LOOKUP_PARENT , &nd);if (err) goto out_mknod_parent;/*