aboutsummaryrefslogtreecommitdiff
path: root/include/linux/fdtable.h
diff options
context:
space:
mode:
authorEric Dumazet <edumazet@google.com>2015-06-30 15:54:08 +0200
committerMister Oyster <oysterized@gmail.com>2017-12-31 03:25:06 +0100
commitea776cc85615113b780fc6126aa0c7601209cf50 (patch)
tree78448894bbb7a1d1c32621ca83a3b6c7dce64f38 /include/linux/fdtable.h
parente5983e9c4e1c61b347aeda7243266bee387a40e1 (diff)
fs/file.c: don't acquire files->file_lock in fd_install()
Mateusz Guzik reported : Currently obtaining a new file descriptor results in locking fdtable twice - once in order to reserve a slot and second time to fill it. Holding the spinlock in __fd_install() is needed in case a resize is done, or to prevent a resize. Mateusz provided an RFC patch and a micro benchmark : http://people.redhat.com/~mguzik/pipebench.c A resize is an unlikely operation in a process lifetime, as table size is at least doubled at every resize. We can use RCU instead of the spinlock. __fd_install() must wait if a resize is in progress. The resize must block new __fd_install() callers from starting, and wait that ongoing install are finished (synchronize_sched()) resize should be attempted by a single thread to not waste resources. rcu_sched variant is used, as __fd_install() and expand_fdtable() run from process context. It gives us a ~30% speedup using pipebench on a dual Intel(R) Xeon(R) CPU E5-2696 v2 @ 2.50GHz Signed-off-by: Eric Dumazet <edumazet@google.com> Reported-by: Mateusz Guzik <mguzik@redhat.com> Acked-by: Mateusz Guzik <mguzik@redhat.com> Tested-by: Mateusz Guzik <mguzik@redhat.com> Signed-off-by: Al Viro <viro@zeniv.linux.org.uk> [@nathanchance: Leave out documentation, https://github.com/torvalds/linux/commit/8a81252b774b53e628a8a0fe18e2b8fc236d92cc] Signed-off-by: Nathan Chancellor <natechancellor@gmail.com> Signed-off-by: Joe Maples <joe@frap129.org>
Diffstat (limited to 'include/linux/fdtable.h')
-rw-r--r--include/linux/fdtable.h3
1 files changed, 3 insertions, 0 deletions
diff --git a/include/linux/fdtable.h b/include/linux/fdtable.h
index 9bf15b13f..cb674d6d6 100644
--- a/include/linux/fdtable.h
+++ b/include/linux/fdtable.h
@@ -48,6 +48,9 @@ struct files_struct {
* read mostly part
*/
atomic_t count;
+ bool resize_in_progress;
+ wait_queue_head_t resize_wait;
+
struct fdtable __rcu *fdt;
struct fdtable fdtab;
/*