[Devel] [PATCH RHEL7 COMMIT] locking/rwsem: Add down_read_killable()
Konstantin Khorenko
khorenko at virtuozzo.com
Mon May 25 17:56:01 MSK 2020
The commit is pushed to "branch-rh7-3.10.0-1127.8.2.vz7.161.x-ovz" and will appear at https://src.openvz.org/scm/ovz/vzkernel.git
after rh7-3.10.0-1127.8.2.vz7.161.1
------>
commit 47c6116485df34b5caa5d322b0cb519c483045e8
Author: Kirill Tkhai <ktkhai at virtuozzo.com>
Date: Mon May 25 17:56:00 2020 +0300
locking/rwsem: Add down_read_killable()
ms commit 76f8507f7a64
Similar to down_read() and down_write_killable(),
add killable version of down_read(), based on
__down_read_killable() function, added in previous
patches.
Signed-off-by: Kirill Tkhai <ktkhai at virtuozzo.com>
Signed-off-by: Peter Zijlstra (Intel) <peterz at infradead.org>
Cc: Linus Torvalds <torvalds at linux-foundation.org>
Cc: Peter Zijlstra <peterz at infradead.org>
Cc: Thomas Gleixner <tglx at linutronix.de>
Cc: arnd at arndb.de
Cc: avagin at virtuozzo.com
Cc: davem at davemloft.net
Cc: fenghua.yu at intel.com
Cc: gorcunov at virtuozzo.com
Cc: heiko.carstens at de.ibm.com
Cc: hpa at zytor.com
Cc: ink at jurassic.park.msu.ru
Cc: mattst88 at gmail.com
Cc: rientjes at google.com
Cc: rth at twiddle.net
Cc: schwidefsky at de.ibm.com
Cc: tony.luck at intel.com
Cc: viro at zeniv.linux.org.uk
Link: http://lkml.kernel.org/r/150670119884.23930.2585570605960763239.stgit@localhost.localdomain
Signed-off-by: Ingo Molnar <mingo at kernel.org>
=====================
Patchset description:
This ports support for down_read_killable(),
which is a prerequisite for pernet_ops_rwsem.
https://jira.sw.ru/browse/PSBM-104158
---
include/linux/rwsem.h | 1 +
kernel/rwsem.c | 16 ++++++++++++++++
2 files changed, 17 insertions(+)
diff --git a/include/linux/rwsem.h b/include/linux/rwsem.h
index 56c930b825c7f..151d65e4b897d 100644
--- a/include/linux/rwsem.h
+++ b/include/linux/rwsem.h
@@ -133,6 +133,7 @@ static inline int rwsem_is_contended(struct rw_semaphore *sem)
* lock for reading
*/
extern void down_read(struct rw_semaphore *sem);
+extern int __must_check down_read_killable(struct rw_semaphore *sem);
/*
* trylock for reading -- returns 1 if successful, 0 if contention
diff --git a/kernel/rwsem.c b/kernel/rwsem.c
index e35f38a86a216..e6c66e527453a 100644
--- a/kernel/rwsem.c
+++ b/kernel/rwsem.c
@@ -27,6 +27,22 @@ void __sched down_read(struct rw_semaphore *sem)
EXPORT_SYMBOL(down_read);
+int __sched down_read_killable(struct rw_semaphore *sem)
+{
+ might_sleep();
+ rwsem_acquire_read(&sem->dep_map, 0, 0, _RET_IP_);
+
+ if (LOCK_CONTENDED_RETURN(sem, __down_read_trylock, __down_read_killable)) {
+ rwsem_release(&sem->dep_map, 1, _RET_IP_);
+ return -EINTR;
+ }
+
+ rwsem_set_reader_owned(sem);
+ return 0;
+}
+
+EXPORT_SYMBOL(down_read_killable);
+
/*
* trylock for reading -- returns 1 if successful, 0 if contention
*/
More information about the Devel
mailing list