aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPeter Zijlstra <peterz@infradead.org>2016-05-30 10:48:35 -0400
committerIngo Molnar <mingo@kernel.org>2016-09-22 09:25:54 -0400
commit87709e28dc7c669af1126aa7352ff6f7b035412d (patch)
tree64c951adb2bf364a6652517f2f1b6da0943bbbf6
parent259d69b7f056bc9a543c7d184e791ef6c2775081 (diff)
fs/locks: Use percpu_down_read_preempt_disable()
Avoid spurious preemption. Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org> Cc: Al Viro <viro@ZenIV.linux.org.uk> Cc: Linus Torvalds <torvalds@linux-foundation.org> Cc: Oleg Nesterov <oleg@redhat.com> Cc: Peter Zijlstra <peterz@infradead.org> Cc: Thomas Gleixner <tglx@linutronix.de> Cc: dave@stgolabs.net Cc: der.herr@hofr.at Cc: paulmck@linux.vnet.ibm.com Cc: riel@redhat.com Cc: tj@kernel.org Cc: linux-kernel@vger.kernel.org Signed-off-by: Ingo Molnar <mingo@kernel.org>
-rw-r--r--fs/locks.c24
1 files changed, 12 insertions, 12 deletions
diff --git a/fs/locks.c b/fs/locks.c
index c33aa77fada2..133fb2543d21 100644
--- a/fs/locks.c
+++ b/fs/locks.c
@@ -930,7 +930,7 @@ static int flock_lock_inode(struct inode *inode, struct file_lock *request)
930 return -ENOMEM; 930 return -ENOMEM;
931 } 931 }
932 932
933 percpu_down_read(&file_rwsem); 933 percpu_down_read_preempt_disable(&file_rwsem);
934 spin_lock(&ctx->flc_lock); 934 spin_lock(&ctx->flc_lock);
935 if (request->fl_flags & FL_ACCESS) 935 if (request->fl_flags & FL_ACCESS)
936 goto find_conflict; 936 goto find_conflict;
@@ -971,7 +971,7 @@ find_conflict:
971 971
972out: 972out:
973 spin_unlock(&ctx->flc_lock); 973 spin_unlock(&ctx->flc_lock);
974 percpu_up_read(&file_rwsem); 974 percpu_up_read_preempt_enable(&file_rwsem);
975 if (new_fl) 975 if (new_fl)
976 locks_free_lock(new_fl); 976 locks_free_lock(new_fl);
977 locks_dispose_list(&dispose); 977 locks_dispose_list(&dispose);
@@ -1008,7 +1008,7 @@ static int posix_lock_inode(struct inode *inode, struct file_lock *request,
1008 new_fl2 = locks_alloc_lock(); 1008 new_fl2 = locks_alloc_lock();
1009 } 1009 }
1010 1010
1011 percpu_down_read(&file_rwsem); 1011 percpu_down_read_preempt_disable(&file_rwsem);
1012 spin_lock(&ctx->flc_lock); 1012 spin_lock(&ctx->flc_lock);
1013 /* 1013 /*
1014 * New lock request. Walk all POSIX locks and look for conflicts. If 1014 * New lock request. Walk all POSIX locks and look for conflicts. If
@@ -1180,7 +1180,7 @@ static int posix_lock_inode(struct inode *inode, struct file_lock *request,
1180 } 1180 }
1181 out: 1181 out:
1182 spin_unlock(&ctx->flc_lock); 1182 spin_unlock(&ctx->flc_lock);
1183 percpu_up_read(&file_rwsem); 1183 percpu_up_read_preempt_enable(&file_rwsem);
1184 /* 1184 /*
1185 * Free any unused locks. 1185 * Free any unused locks.
1186 */ 1186 */
@@ -1455,7 +1455,7 @@ int __break_lease(struct inode *inode, unsigned int mode, unsigned int type)
1455 return error; 1455 return error;
1456 } 1456 }
1457 1457
1458 percpu_down_read(&file_rwsem); 1458 percpu_down_read_preempt_disable(&file_rwsem);
1459 spin_lock(&ctx->flc_lock); 1459 spin_lock(&ctx->flc_lock);
1460 1460
1461 time_out_leases(inode, &dispose); 1461 time_out_leases(inode, &dispose);
@@ -1507,13 +1507,13 @@ restart:
1507 locks_insert_block(fl, new_fl); 1507 locks_insert_block(fl, new_fl);
1508 trace_break_lease_block(inode, new_fl); 1508 trace_break_lease_block(inode, new_fl);
1509 spin_unlock(&ctx->flc_lock); 1509 spin_unlock(&ctx->flc_lock);
1510 percpu_up_read(&file_rwsem); 1510 percpu_up_read_preempt_enable(&file_rwsem);
1511 1511
1512 locks_dispose_list(&dispose); 1512 locks_dispose_list(&dispose);
1513 error = wait_event_interruptible_timeout(new_fl->fl_wait, 1513 error = wait_event_interruptible_timeout(new_fl->fl_wait,
1514 !new_fl->fl_next, break_time); 1514 !new_fl->fl_next, break_time);
1515 1515
1516 percpu_down_read(&file_rwsem); 1516 percpu_down_read_preempt_disable(&file_rwsem);
1517 spin_lock(&ctx->flc_lock); 1517 spin_lock(&ctx->flc_lock);
1518 trace_break_lease_unblock(inode, new_fl); 1518 trace_break_lease_unblock(inode, new_fl);
1519 locks_delete_block(new_fl); 1519 locks_delete_block(new_fl);
@@ -1530,7 +1530,7 @@ restart:
1530 } 1530 }
1531out: 1531out:
1532 spin_unlock(&ctx->flc_lock); 1532 spin_unlock(&ctx->flc_lock);
1533 percpu_up_read(&file_rwsem); 1533 percpu_up_read_preempt_enable(&file_rwsem);
1534 locks_dispose_list(&dispose); 1534 locks_dispose_list(&dispose);
1535 locks_free_lock(new_fl); 1535 locks_free_lock(new_fl);
1536 return error; 1536 return error;
@@ -1685,7 +1685,7 @@ generic_add_lease(struct file *filp, long arg, struct file_lock **flp, void **pr
1685 return -EINVAL; 1685 return -EINVAL;
1686 } 1686 }
1687 1687
1688 percpu_down_read(&file_rwsem); 1688 percpu_down_read_preempt_disable(&file_rwsem);
1689 spin_lock(&ctx->flc_lock); 1689 spin_lock(&ctx->flc_lock);
1690 time_out_leases(inode, &dispose); 1690 time_out_leases(inode, &dispose);
1691 error = check_conflicting_open(dentry, arg, lease->fl_flags); 1691 error = check_conflicting_open(dentry, arg, lease->fl_flags);
@@ -1756,7 +1756,7 @@ out_setup:
1756 lease->fl_lmops->lm_setup(lease, priv); 1756 lease->fl_lmops->lm_setup(lease, priv);
1757out: 1757out:
1758 spin_unlock(&ctx->flc_lock); 1758 spin_unlock(&ctx->flc_lock);
1759 percpu_up_read(&file_rwsem); 1759 percpu_up_read_preempt_enable(&file_rwsem);
1760 locks_dispose_list(&dispose); 1760 locks_dispose_list(&dispose);
1761 if (is_deleg) 1761 if (is_deleg)
1762 inode_unlock(inode); 1762 inode_unlock(inode);
@@ -1779,7 +1779,7 @@ static int generic_delete_lease(struct file *filp, void *owner)
1779 return error; 1779 return error;
1780 } 1780 }
1781 1781
1782 percpu_down_read(&file_rwsem); 1782 percpu_down_read_preempt_disable(&file_rwsem);
1783 spin_lock(&ctx->flc_lock); 1783 spin_lock(&ctx->flc_lock);
1784 list_for_each_entry(fl, &ctx->flc_lease, fl_list) { 1784 list_for_each_entry(fl, &ctx->flc_lease, fl_list) {
1785 if (fl->fl_file == filp && 1785 if (fl->fl_file == filp &&
@@ -1792,7 +1792,7 @@ static int generic_delete_lease(struct file *filp, void *owner)
1792 if (victim) 1792 if (victim)
1793 error = fl->fl_lmops->lm_change(victim, F_UNLCK, &dispose); 1793 error = fl->fl_lmops->lm_change(victim, F_UNLCK, &dispose);
1794 spin_unlock(&ctx->flc_lock); 1794 spin_unlock(&ctx->flc_lock);
1795 percpu_up_read(&file_rwsem); 1795 percpu_up_read_preempt_enable(&file_rwsem);
1796 locks_dispose_list(&dispose); 1796 locks_dispose_list(&dispose);
1797 return error; 1797 return error;
1798} 1798}