summaryrefslogtreecommitdiff
path: root/include/linux/file.h
diff options
context:
space:
mode:
authorAndrew Morton <akpm@digeo.com>2003-05-07 08:19:50 -0700
committerLinus Torvalds <torvalds@home.transmeta.com>2003-05-07 08:19:50 -0700
commit6a414e64bd6ffda2cbfe3505fcd67a66cf374cc9 (patch)
tree588d6e251bcce2dc320d4543e1649147576c1a73 /include/linux/file.h
parent09f9576108939bb7028f479b23b0314e7ae3a0cb (diff)
[PATCH] reduced overheads in fget/fput
From: Dipankar Sarma <dipankar@in.ibm.com> fget() shows up on profiles, especially on SMP. Dipankar's patch special-cases the situation wherein there are no sharers of current->files. In this situation we know that no other process can close this file, so it is not necessary to increment the file's refcount. It's ugly as sin, but makes a substantial difference. The test is dd if=/dev/zero of=foo bs=1 count=1M On 4CPU P3 xeon with 1MB L2 cache and 512MB ram: kernel sys time std-dev ------------ -------- ------- UP - vanilla 2.104 0.028 UP - file 1.867 0.019 SMP - vanilla 2.976 0.023 SMP - file 2.719 0.026
Diffstat (limited to 'include/linux/file.h')
-rw-r--r--include/linux/file.h8
1 files changed, 8 insertions, 0 deletions
diff --git a/include/linux/file.h b/include/linux/file.h
index 6fbd27f755d5..a488f738f9f0 100644
--- a/include/linux/file.h
+++ b/include/linux/file.h
@@ -35,7 +35,15 @@ struct files_struct {
extern void FASTCALL(__fput(struct file *));
extern void FASTCALL(fput(struct file *));
+
+static inline void fput_light(struct file *file, int fput_needed)
+{
+ if (unlikely(fput_needed))
+ fput(file);
+}
+
extern struct file * FASTCALL(fget(unsigned int fd));
+extern struct file * FASTCALL(fget_light(unsigned int fd, int *fput_needed));
extern void FASTCALL(set_close_on_exec(unsigned int fd, int flag));
extern void put_filp(struct file *);
extern int get_unused_fd(void);