Skip to content

Commit 8c74392

Browse files
Kirill TkhaiIngo Molnar
authored andcommitted
locking/arch, alpha: Add __down_read_killable()
Similar to __down_write_killable(), and read killable primitive. Signed-off-by: Kirill Tkhai <[email protected]> Signed-off-by: Peter Zijlstra (Intel) <[email protected]> Cc: Linus Torvalds <[email protected]> Cc: Peter Zijlstra <[email protected]> Cc: Thomas Gleixner <[email protected]> Cc: [email protected] Cc: [email protected] Cc: [email protected] Cc: [email protected] Cc: [email protected] Cc: [email protected] Cc: [email protected] Cc: [email protected] Cc: [email protected] Cc: [email protected] Cc: [email protected] Cc: [email protected] Cc: [email protected] Cc: [email protected] Link: http://lkml.kernel.org/r/150670115677.23930.5711263025537758463.stgit@localhost.localdomain Signed-off-by: Ingo Molnar <[email protected]>
1 parent e6fd28e commit 8c74392

File tree

1 file changed

+18
-3
lines changed

1 file changed

+18
-3
lines changed

arch/alpha/include/asm/rwsem.h

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
#define RWSEM_ACTIVE_READ_BIAS RWSEM_ACTIVE_BIAS
2222
#define RWSEM_ACTIVE_WRITE_BIAS (RWSEM_WAITING_BIAS + RWSEM_ACTIVE_BIAS)
2323

24-
static inline void __down_read(struct rw_semaphore *sem)
24+
static inline int ___down_read(struct rw_semaphore *sem)
2525
{
2626
long oldcount;
2727
#ifndef CONFIG_SMP
@@ -41,10 +41,24 @@ static inline void __down_read(struct rw_semaphore *sem)
4141
:"=&r" (oldcount), "=m" (sem->count), "=&r" (temp)
4242
:"Ir" (RWSEM_ACTIVE_READ_BIAS), "m" (sem->count) : "memory");
4343
#endif
44-
if (unlikely(oldcount < 0))
44+
return (oldcount < 0);
45+
}
46+
47+
static inline void __down_read(struct rw_semaphore *sem)
48+
{
49+
if (unlikely(___down_read(sem)))
4550
rwsem_down_read_failed(sem);
4651
}
4752

53+
static inline int __down_read_killable(struct rw_semaphore *sem)
54+
{
55+
if (unlikely(___down_read(sem)))
56+
if (IS_ERR(rwsem_down_read_failed_killable(sem)))
57+
return -EINTR;
58+
59+
return 0;
60+
}
61+
4862
/*
4963
* trylock for reading -- returns 1 if successful, 0 if contention
5064
*/
@@ -94,9 +108,10 @@ static inline void __down_write(struct rw_semaphore *sem)
94108

95109
static inline int __down_write_killable(struct rw_semaphore *sem)
96110
{
97-
if (unlikely(___down_write(sem)))
111+
if (unlikely(___down_write(sem))) {
98112
if (IS_ERR(rwsem_down_write_failed_killable(sem)))
99113
return -EINTR;
114+
}
100115

101116
return 0;
102117
}

0 commit comments

Comments
 (0)