aboutsummaryrefslogtreecommitdiffstats
path: root/fs/proc
diff options
context:
space:
mode:
authorNick Piggin <npiggin@kernel.dk>2011-01-07 01:49:55 -0500
committerNick Piggin <npiggin@kernel.dk>2011-01-07 01:50:28 -0500
commitfb045adb99d9b7c562dc7fef834857f78249daa1 (patch)
tree1fd6a4024fffeec568abe100d730589bfdb81c38 /fs/proc
parent5f57cbcc02cf18f6b22ef4066bb10afeb8f930ff (diff)
fs: dcache reduce branches in lookup path
Reduce some branches and memory accesses in dcache lookup by adding dentry flags to indicate common d_ops are set, rather than having to check them. This saves a pointer memory access (dentry->d_op) in common path lookup situations, and saves another pointer load and branch in cases where we have d_op but not the particular operation. Patched with: git grep -E '[.>]([[:space:]])*d_op([[:space:]])*=' | xargs sed -e 's/\([^\t ]*\)->d_op = \(.*\);/d_set_d_op(\1, \2);/' -e 's/\([^\t ]*\)\.d_op = \(.*\);/d_set_d_op(\&\1, \2);/' -i Signed-off-by: Nick Piggin <npiggin@kernel.dk>
Diffstat (limited to 'fs/proc')
-rw-r--r--fs/proc/base.c12
-rw-r--r--fs/proc/generic.c2
-rw-r--r--fs/proc/proc_sysctl.c4
3 files changed, 9 insertions, 9 deletions
diff --git a/fs/proc/base.c b/fs/proc/base.c
index d932fdb6a245..85f0a80912aa 100644
--- a/fs/proc/base.c
+++ b/fs/proc/base.c
@@ -1969,7 +1969,7 @@ static struct dentry *proc_fd_instantiate(struct inode *dir,
1969 inode->i_op = &proc_pid_link_inode_operations; 1969 inode->i_op = &proc_pid_link_inode_operations;
1970 inode->i_size = 64; 1970 inode->i_size = 64;
1971 ei->op.proc_get_link = proc_fd_link; 1971 ei->op.proc_get_link = proc_fd_link;
1972 dentry->d_op = &tid_fd_dentry_operations; 1972 d_set_d_op(dentry, &tid_fd_dentry_operations);
1973 d_add(dentry, inode); 1973 d_add(dentry, inode);
1974 /* Close the race of the process dying before we return the dentry */ 1974 /* Close the race of the process dying before we return the dentry */
1975 if (tid_fd_revalidate(dentry, NULL)) 1975 if (tid_fd_revalidate(dentry, NULL))
@@ -2137,7 +2137,7 @@ static struct dentry *proc_fdinfo_instantiate(struct inode *dir,
2137 ei->fd = fd; 2137 ei->fd = fd;
2138 inode->i_mode = S_IFREG | S_IRUSR; 2138 inode->i_mode = S_IFREG | S_IRUSR;
2139 inode->i_fop = &proc_fdinfo_file_operations; 2139 inode->i_fop = &proc_fdinfo_file_operations;
2140 dentry->d_op = &tid_fd_dentry_operations; 2140 d_set_d_op(dentry, &tid_fd_dentry_operations);
2141 d_add(dentry, inode); 2141 d_add(dentry, inode);
2142 /* Close the race of the process dying before we return the dentry */ 2142 /* Close the race of the process dying before we return the dentry */
2143 if (tid_fd_revalidate(dentry, NULL)) 2143 if (tid_fd_revalidate(dentry, NULL))
@@ -2196,7 +2196,7 @@ static struct dentry *proc_pident_instantiate(struct inode *dir,
2196 if (p->fop) 2196 if (p->fop)
2197 inode->i_fop = p->fop; 2197 inode->i_fop = p->fop;
2198 ei->op = p->op; 2198 ei->op = p->op;
2199 dentry->d_op = &pid_dentry_operations; 2199 d_set_d_op(dentry, &pid_dentry_operations);
2200 d_add(dentry, inode); 2200 d_add(dentry, inode);
2201 /* Close the race of the process dying before we return the dentry */ 2201 /* Close the race of the process dying before we return the dentry */
2202 if (pid_revalidate(dentry, NULL)) 2202 if (pid_revalidate(dentry, NULL))
@@ -2615,7 +2615,7 @@ static struct dentry *proc_base_instantiate(struct inode *dir,
2615 if (p->fop) 2615 if (p->fop)
2616 inode->i_fop = p->fop; 2616 inode->i_fop = p->fop;
2617 ei->op = p->op; 2617 ei->op = p->op;
2618 dentry->d_op = &proc_base_dentry_operations; 2618 d_set_d_op(dentry, &proc_base_dentry_operations);
2619 d_add(dentry, inode); 2619 d_add(dentry, inode);
2620 error = NULL; 2620 error = NULL;
2621out: 2621out:
@@ -2926,7 +2926,7 @@ static struct dentry *proc_pid_instantiate(struct inode *dir,
2926 inode->i_nlink = 2 + pid_entry_count_dirs(tgid_base_stuff, 2926 inode->i_nlink = 2 + pid_entry_count_dirs(tgid_base_stuff,
2927 ARRAY_SIZE(tgid_base_stuff)); 2927 ARRAY_SIZE(tgid_base_stuff));
2928 2928
2929 dentry->d_op = &pid_dentry_operations; 2929 d_set_d_op(dentry, &pid_dentry_operations);
2930 2930
2931 d_add(dentry, inode); 2931 d_add(dentry, inode);
2932 /* Close the race of the process dying before we return the dentry */ 2932 /* Close the race of the process dying before we return the dentry */
@@ -3169,7 +3169,7 @@ static struct dentry *proc_task_instantiate(struct inode *dir,
3169 inode->i_nlink = 2 + pid_entry_count_dirs(tid_base_stuff, 3169 inode->i_nlink = 2 + pid_entry_count_dirs(tid_base_stuff,
3170 ARRAY_SIZE(tid_base_stuff)); 3170 ARRAY_SIZE(tid_base_stuff));
3171 3171
3172 dentry->d_op = &pid_dentry_operations; 3172 d_set_d_op(dentry, &pid_dentry_operations);
3173 3173
3174 d_add(dentry, inode); 3174 d_add(dentry, inode);
3175 /* Close the race of the process dying before we return the dentry */ 3175 /* Close the race of the process dying before we return the dentry */
diff --git a/fs/proc/generic.c b/fs/proc/generic.c
index 1d607be36d95..f766be29d2c7 100644
--- a/fs/proc/generic.c
+++ b/fs/proc/generic.c
@@ -439,7 +439,7 @@ struct dentry *proc_lookup_de(struct proc_dir_entry *de, struct inode *dir,
439out_unlock: 439out_unlock:
440 440
441 if (inode) { 441 if (inode) {
442 dentry->d_op = &proc_dentry_operations; 442 d_set_d_op(dentry, &proc_dentry_operations);
443 d_add(dentry, inode); 443 d_add(dentry, inode);
444 return NULL; 444 return NULL;
445 } 445 }
diff --git a/fs/proc/proc_sysctl.c b/fs/proc/proc_sysctl.c
index 998e3a715bcc..35efd85a4d32 100644
--- a/fs/proc/proc_sysctl.c
+++ b/fs/proc/proc_sysctl.c
@@ -120,7 +120,7 @@ static struct dentry *proc_sys_lookup(struct inode *dir, struct dentry *dentry,
120 goto out; 120 goto out;
121 121
122 err = NULL; 122 err = NULL;
123 dentry->d_op = &proc_sys_dentry_operations; 123 d_set_d_op(dentry, &proc_sys_dentry_operations);
124 d_add(dentry, inode); 124 d_add(dentry, inode);
125 125
126out: 126out:
@@ -201,7 +201,7 @@ static int proc_sys_fill_cache(struct file *filp, void *dirent,
201 dput(child); 201 dput(child);
202 return -ENOMEM; 202 return -ENOMEM;
203 } else { 203 } else {
204 child->d_op = &proc_sys_dentry_operations; 204 d_set_d_op(child, &proc_sys_dentry_operations);
205 d_add(child, inode); 205 d_add(child, inode);
206 } 206 }
207 } else { 207 } else {