summaryrefslogtreecommitdiffstats
path: root/debian/patches-rt/0335-locking-rwsem_rt-Add-__down_read_interruptible.patch
blob: 8abcfab7629b5059c981983db575a7b3ad76bdeb (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
From: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Date: Tue, 19 Jan 2021 18:54:33 +0100
Subject: [PATCH 335/353] locking/rwsem_rt: Add __down_read_interruptible()
Origin: https://git.kernel.org/cgit/linux/kernel/git/rt/linux-stable-rt.git/commit?id=b699ea2423faf81990ed0225a37bc40e018a7707

The stable backported a patch which adds __down_read_interruptible() for
the generic rwsem implementation.

Add RT's version __down_read_interruptible().

Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
---
 include/linux/rwsem_rt.h  |  1 +
 kernel/locking/rwsem-rt.c | 11 +++++++++++
 2 files changed, 12 insertions(+)

diff --git a/include/linux/rwsem_rt.h b/include/linux/rwsem_rt.h
index 2018ff77904a..3fb092b7bcc0 100644
--- a/include/linux/rwsem_rt.h
+++ b/include/linux/rwsem_rt.h
@@ -56,6 +56,7 @@ static inline int rwsem_is_contended(struct rw_semaphore *sem)
 }
 
 extern void __down_read(struct rw_semaphore *sem);
+extern int __down_read_interruptible(struct rw_semaphore *sem);
 extern int __down_read_killable(struct rw_semaphore *sem);
 extern int __down_read_trylock(struct rw_semaphore *sem);
 extern void __down_write(struct rw_semaphore *sem);
diff --git a/kernel/locking/rwsem-rt.c b/kernel/locking/rwsem-rt.c
index f518495bd6cc..19ea20be3fd7 100644
--- a/kernel/locking/rwsem-rt.c
+++ b/kernel/locking/rwsem-rt.c
@@ -166,6 +166,17 @@ void __down_read(struct rw_semaphore *sem)
 	WARN_ON_ONCE(ret);
 }
 
+int __down_read_interruptible(struct rw_semaphore *sem)
+{
+	int ret;
+
+	ret = __down_read_common(sem, TASK_INTERRUPTIBLE);
+	if (likely(!ret))
+		return ret;
+	WARN_ONCE(ret != -EINTR, "Unexpected state: %d\n", ret);
+	return -EINTR;
+}
+
 int __down_read_killable(struct rw_semaphore *sem)
 {
 	int ret;