2020-04-21 20:13:52 +00:00
|
|
|
From 9c36e91215b7ab35c244cc03986637031183c797 Mon Sep 17 00:00:00 2001
|
2018-08-27 14:32:32 +00:00
|
|
|
From: Peter Zijlstra <peterz@infradead.org>
|
2019-04-08 23:49:20 +00:00
|
|
|
Date: Wed, 23 Nov 2016 16:29:32 +0100
|
2020-04-21 20:13:52 +00:00
|
|
|
Subject: [PATCH 169/325] locking/percpu-rwsem: Remove preempt_disable variants
|
|
|
|
Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/4.19/older/patches-4.19.115-rt48.tar.xz
|
2018-08-27 14:32:32 +00:00
|
|
|
|
|
|
|
Effective revert commit:
|
|
|
|
|
|
|
|
87709e28dc7c ("fs/locks: Use percpu_down_read_preempt_disable()")
|
|
|
|
|
|
|
|
This is causing major pain for PREEMPT_RT and is only a very small
|
|
|
|
performance issue for PREEMPT=y.
|
|
|
|
|
|
|
|
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
|
|
|
|
---
|
2019-04-08 23:49:20 +00:00
|
|
|
fs/locks.c | 32 ++++++++++++++++----------------
|
|
|
|
include/linux/percpu-rwsem.h | 24 ++++--------------------
|
2018-08-27 14:32:32 +00:00
|
|
|
2 files changed, 20 insertions(+), 36 deletions(-)
|
|
|
|
|
2019-04-08 23:49:20 +00:00
|
|
|
diff --git a/fs/locks.c b/fs/locks.c
|
2020-01-19 00:54:59 +00:00
|
|
|
index 28270e74be34..552476d6f6bb 100644
|
2018-08-27 14:32:32 +00:00
|
|
|
--- a/fs/locks.c
|
|
|
|
+++ b/fs/locks.c
|
2019-04-08 23:49:20 +00:00
|
|
|
@@ -936,7 +936,7 @@ static int flock_lock_inode(struct inode *inode, struct file_lock *request)
|
2018-08-27 14:32:32 +00:00
|
|
|
return -ENOMEM;
|
|
|
|
}
|
|
|
|
|
|
|
|
- percpu_down_read_preempt_disable(&file_rwsem);
|
|
|
|
+ percpu_down_read(&file_rwsem);
|
|
|
|
spin_lock(&ctx->flc_lock);
|
|
|
|
if (request->fl_flags & FL_ACCESS)
|
|
|
|
goto find_conflict;
|
2019-04-08 23:49:20 +00:00
|
|
|
@@ -977,7 +977,7 @@ static int flock_lock_inode(struct inode *inode, struct file_lock *request)
|
2018-08-27 14:32:32 +00:00
|
|
|
|
|
|
|
out:
|
|
|
|
spin_unlock(&ctx->flc_lock);
|
|
|
|
- percpu_up_read_preempt_enable(&file_rwsem);
|
|
|
|
+ percpu_up_read(&file_rwsem);
|
|
|
|
if (new_fl)
|
|
|
|
locks_free_lock(new_fl);
|
|
|
|
locks_dispose_list(&dispose);
|
2019-04-08 23:49:20 +00:00
|
|
|
@@ -1015,7 +1015,7 @@ static int posix_lock_inode(struct inode *inode, struct file_lock *request,
|
2018-08-27 14:32:32 +00:00
|
|
|
new_fl2 = locks_alloc_lock();
|
|
|
|
}
|
|
|
|
|
|
|
|
- percpu_down_read_preempt_disable(&file_rwsem);
|
|
|
|
+ percpu_down_read(&file_rwsem);
|
|
|
|
spin_lock(&ctx->flc_lock);
|
|
|
|
/*
|
|
|
|
* New lock request. Walk all POSIX locks and look for conflicts. If
|
2019-04-08 23:49:20 +00:00
|
|
|
@@ -1187,7 +1187,7 @@ static int posix_lock_inode(struct inode *inode, struct file_lock *request,
|
2018-08-27 14:32:32 +00:00
|
|
|
}
|
|
|
|
out:
|
|
|
|
spin_unlock(&ctx->flc_lock);
|
|
|
|
- percpu_up_read_preempt_enable(&file_rwsem);
|
|
|
|
+ percpu_up_read(&file_rwsem);
|
|
|
|
/*
|
|
|
|
* Free any unused locks.
|
|
|
|
*/
|
2019-04-08 23:49:20 +00:00
|
|
|
@@ -1462,7 +1462,7 @@ int __break_lease(struct inode *inode, unsigned int mode, unsigned int type)
|
2018-08-27 14:32:32 +00:00
|
|
|
return error;
|
|
|
|
}
|
|
|
|
|
|
|
|
- percpu_down_read_preempt_disable(&file_rwsem);
|
|
|
|
+ percpu_down_read(&file_rwsem);
|
|
|
|
spin_lock(&ctx->flc_lock);
|
|
|
|
|
|
|
|
time_out_leases(inode, &dispose);
|
2019-04-08 23:49:20 +00:00
|
|
|
@@ -1514,13 +1514,13 @@ int __break_lease(struct inode *inode, unsigned int mode, unsigned int type)
|
2018-08-27 14:32:32 +00:00
|
|
|
locks_insert_block(fl, new_fl);
|
|
|
|
trace_break_lease_block(inode, new_fl);
|
|
|
|
spin_unlock(&ctx->flc_lock);
|
|
|
|
- percpu_up_read_preempt_enable(&file_rwsem);
|
|
|
|
+ percpu_up_read(&file_rwsem);
|
|
|
|
|
|
|
|
locks_dispose_list(&dispose);
|
|
|
|
error = wait_event_interruptible_timeout(new_fl->fl_wait,
|
|
|
|
!new_fl->fl_next, break_time);
|
|
|
|
|
|
|
|
- percpu_down_read_preempt_disable(&file_rwsem);
|
|
|
|
+ percpu_down_read(&file_rwsem);
|
|
|
|
spin_lock(&ctx->flc_lock);
|
|
|
|
trace_break_lease_unblock(inode, new_fl);
|
|
|
|
locks_delete_block(new_fl);
|
2019-04-08 23:49:20 +00:00
|
|
|
@@ -1537,7 +1537,7 @@ int __break_lease(struct inode *inode, unsigned int mode, unsigned int type)
|
2018-08-27 14:32:32 +00:00
|
|
|
}
|
|
|
|
out:
|
|
|
|
spin_unlock(&ctx->flc_lock);
|
|
|
|
- percpu_up_read_preempt_enable(&file_rwsem);
|
|
|
|
+ percpu_up_read(&file_rwsem);
|
|
|
|
locks_dispose_list(&dispose);
|
|
|
|
locks_free_lock(new_fl);
|
|
|
|
return error;
|
2018-10-30 12:40:05 +00:00
|
|
|
@@ -1609,7 +1609,7 @@ int fcntl_getlease(struct file *filp)
|
2018-08-27 14:32:32 +00:00
|
|
|
|
|
|
|
ctx = smp_load_acquire(&inode->i_flctx);
|
|
|
|
if (ctx && !list_empty_careful(&ctx->flc_lease)) {
|
|
|
|
- percpu_down_read_preempt_disable(&file_rwsem);
|
|
|
|
+ percpu_down_read(&file_rwsem);
|
|
|
|
spin_lock(&ctx->flc_lock);
|
|
|
|
time_out_leases(inode, &dispose);
|
|
|
|
list_for_each_entry(fl, &ctx->flc_lease, fl_list) {
|
2018-10-30 12:40:05 +00:00
|
|
|
@@ -1619,7 +1619,7 @@ int fcntl_getlease(struct file *filp)
|
2018-08-27 14:32:32 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
spin_unlock(&ctx->flc_lock);
|
|
|
|
- percpu_up_read_preempt_enable(&file_rwsem);
|
|
|
|
+ percpu_up_read(&file_rwsem);
|
|
|
|
|
|
|
|
locks_dispose_list(&dispose);
|
|
|
|
}
|
2019-04-08 23:49:20 +00:00
|
|
|
@@ -1693,7 +1693,7 @@ generic_add_lease(struct file *filp, long arg, struct file_lock **flp, void **pr
|
2018-08-27 14:32:32 +00:00
|
|
|
return -EINVAL;
|
|
|
|
}
|
|
|
|
|
|
|
|
- percpu_down_read_preempt_disable(&file_rwsem);
|
|
|
|
+ percpu_down_read(&file_rwsem);
|
|
|
|
spin_lock(&ctx->flc_lock);
|
|
|
|
time_out_leases(inode, &dispose);
|
|
|
|
error = check_conflicting_open(dentry, arg, lease->fl_flags);
|
2019-04-08 23:49:20 +00:00
|
|
|
@@ -1764,7 +1764,7 @@ generic_add_lease(struct file *filp, long arg, struct file_lock **flp, void **pr
|
2018-08-27 14:32:32 +00:00
|
|
|
lease->fl_lmops->lm_setup(lease, priv);
|
|
|
|
out:
|
|
|
|
spin_unlock(&ctx->flc_lock);
|
|
|
|
- percpu_up_read_preempt_enable(&file_rwsem);
|
|
|
|
+ percpu_up_read(&file_rwsem);
|
|
|
|
locks_dispose_list(&dispose);
|
|
|
|
if (is_deleg)
|
|
|
|
inode_unlock(inode);
|
2019-04-08 23:49:20 +00:00
|
|
|
@@ -1787,7 +1787,7 @@ static int generic_delete_lease(struct file *filp, void *owner)
|
2018-08-27 14:32:32 +00:00
|
|
|
return error;
|
|
|
|
}
|
|
|
|
|
|
|
|
- percpu_down_read_preempt_disable(&file_rwsem);
|
|
|
|
+ percpu_down_read(&file_rwsem);
|
|
|
|
spin_lock(&ctx->flc_lock);
|
|
|
|
list_for_each_entry(fl, &ctx->flc_lease, fl_list) {
|
|
|
|
if (fl->fl_file == filp &&
|
2019-04-08 23:49:20 +00:00
|
|
|
@@ -1800,7 +1800,7 @@ static int generic_delete_lease(struct file *filp, void *owner)
|
2018-08-27 14:32:32 +00:00
|
|
|
if (victim)
|
|
|
|
error = fl->fl_lmops->lm_change(victim, F_UNLCK, &dispose);
|
|
|
|
spin_unlock(&ctx->flc_lock);
|
|
|
|
- percpu_up_read_preempt_enable(&file_rwsem);
|
|
|
|
+ percpu_up_read(&file_rwsem);
|
|
|
|
locks_dispose_list(&dispose);
|
|
|
|
return error;
|
|
|
|
}
|
2019-04-08 23:49:20 +00:00
|
|
|
@@ -2531,13 +2531,13 @@ locks_remove_lease(struct file *filp, struct file_lock_context *ctx)
|
2018-08-27 14:32:32 +00:00
|
|
|
if (list_empty(&ctx->flc_lease))
|
|
|
|
return;
|
|
|
|
|
|
|
|
- percpu_down_read_preempt_disable(&file_rwsem);
|
|
|
|
+ percpu_down_read(&file_rwsem);
|
|
|
|
spin_lock(&ctx->flc_lock);
|
|
|
|
list_for_each_entry_safe(fl, tmp, &ctx->flc_lease, fl_list)
|
|
|
|
if (filp == fl->fl_file)
|
|
|
|
lease_modify(fl, F_UNLCK, &dispose);
|
|
|
|
spin_unlock(&ctx->flc_lock);
|
|
|
|
- percpu_up_read_preempt_enable(&file_rwsem);
|
|
|
|
+ percpu_up_read(&file_rwsem);
|
|
|
|
|
|
|
|
locks_dispose_list(&dispose);
|
|
|
|
}
|
2019-04-08 23:49:20 +00:00
|
|
|
diff --git a/include/linux/percpu-rwsem.h b/include/linux/percpu-rwsem.h
|
|
|
|
index 79b99d653e03..fb44e237316d 100644
|
2018-08-27 14:32:32 +00:00
|
|
|
--- a/include/linux/percpu-rwsem.h
|
|
|
|
+++ b/include/linux/percpu-rwsem.h
|
2019-04-08 23:49:20 +00:00
|
|
|
@@ -29,7 +29,7 @@ static struct percpu_rw_semaphore name = { \
|
2018-08-27 14:32:32 +00:00
|
|
|
extern int __percpu_down_read(struct percpu_rw_semaphore *, int);
|
|
|
|
extern void __percpu_up_read(struct percpu_rw_semaphore *);
|
|
|
|
|
|
|
|
-static inline void percpu_down_read_preempt_disable(struct percpu_rw_semaphore *sem)
|
|
|
|
+static inline void percpu_down_read(struct percpu_rw_semaphore *sem)
|
|
|
|
{
|
|
|
|
might_sleep();
|
|
|
|
|
2019-04-08 23:49:20 +00:00
|
|
|
@@ -47,16 +47,10 @@ static inline void percpu_down_read_preempt_disable(struct percpu_rw_semaphore *
|
2018-08-27 14:32:32 +00:00
|
|
|
__this_cpu_inc(*sem->read_count);
|
|
|
|
if (unlikely(!rcu_sync_is_idle(&sem->rss)))
|
|
|
|
__percpu_down_read(sem, false); /* Unconditional memory barrier */
|
|
|
|
- barrier();
|
|
|
|
/*
|
|
|
|
- * The barrier() prevents the compiler from
|
|
|
|
+ * The preempt_enable() prevents the compiler from
|
|
|
|
* bleeding the critical section out.
|
|
|
|
*/
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
-static inline void percpu_down_read(struct percpu_rw_semaphore *sem)
|
|
|
|
-{
|
|
|
|
- percpu_down_read_preempt_disable(sem);
|
|
|
|
preempt_enable();
|
|
|
|
}
|
|
|
|
|
2019-04-08 23:49:20 +00:00
|
|
|
@@ -83,13 +77,9 @@ static inline int percpu_down_read_trylock(struct percpu_rw_semaphore *sem)
|
2018-08-27 14:32:32 +00:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
-static inline void percpu_up_read_preempt_enable(struct percpu_rw_semaphore *sem)
|
|
|
|
+static inline void percpu_up_read(struct percpu_rw_semaphore *sem)
|
|
|
|
{
|
|
|
|
- /*
|
|
|
|
- * The barrier() prevents the compiler from
|
|
|
|
- * bleeding the critical section out.
|
|
|
|
- */
|
|
|
|
- barrier();
|
|
|
|
+ preempt_disable();
|
|
|
|
/*
|
|
|
|
* Same as in percpu_down_read().
|
|
|
|
*/
|
2019-04-08 23:49:20 +00:00
|
|
|
@@ -102,12 +92,6 @@ static inline void percpu_up_read_preempt_enable(struct percpu_rw_semaphore *sem
|
2018-08-27 14:32:32 +00:00
|
|
|
rwsem_release(&sem->rw_sem.dep_map, 1, _RET_IP_);
|
|
|
|
}
|
|
|
|
|
|
|
|
-static inline void percpu_up_read(struct percpu_rw_semaphore *sem)
|
|
|
|
-{
|
|
|
|
- preempt_disable();
|
|
|
|
- percpu_up_read_preempt_enable(sem);
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
extern void percpu_down_write(struct percpu_rw_semaphore *);
|
|
|
|
extern void percpu_up_write(struct percpu_rw_semaphore *);
|
|
|
|
|
2020-01-03 23:36:11 +00:00
|
|
|
--
|
2020-04-09 19:44:24 +00:00
|
|
|
2.25.1
|
2020-01-03 23:36:11 +00:00
|
|
|
|