Skip to content

Commit 80fbaf1

Browse files
author
Peter Zijlstra (Intel)
committed
rcuwait: Add @State argument to rcuwait_wait_event()
Extend rcuwait_wait_event() with a state variable so that it is not restricted to UNINTERRUPTIBLE waits. Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org> Signed-off-by: Thomas Gleixner <tglx@linutronix.de> Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org> Link: https://lkml.kernel.org/r/20200321113241.824030968@linutronix.de
1 parent d964ea7 commit 80fbaf1

2 files changed

Lines changed: 11 additions & 3 deletions

File tree

‎include/linux/rcuwait.h‎

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
#define _LINUX_RCUWAIT_H_
44

55
#include <linux/rcupdate.h>
6+
#include <linux/sched/signal.h>
67

78
/*
89
* rcuwait provides a way of blocking and waking up a single
@@ -30,23 +31,30 @@ extern void rcuwait_wake_up(struct rcuwait *w);
3031
* The caller is responsible for locking around rcuwait_wait_event(),
3132
* such that writes to @task are properly serialized.
3233
*/
33-
#define rcuwait_wait_event(w, condition) \
34+
#define rcuwait_wait_event(w, condition, state) \
3435
({ \
36+
int __ret = 0; \
3537
rcu_assign_pointer((w)->task, current); \
3638
for (;;) { \
3739
/* \
3840
* Implicit barrier (A) pairs with (B) in \
3941
* rcuwait_wake_up(). \
4042
*/ \
41-
set_current_state(TASK_UNINTERRUPTIBLE); \
43+
set_current_state(state); \
4244
if (condition) \
4345
break; \
4446
\
47+
if (signal_pending_state(state, current)) { \
48+
__ret = -EINTR; \
49+
break; \
50+
} \
51+
\
4552
schedule(); \
4653
} \
4754
\
4855
WRITE_ONCE((w)->task, NULL); \
4956
__set_current_state(TASK_RUNNING); \
57+
__ret; \
5058
})
5159

5260
#endif /* _LINUX_RCUWAIT_H_ */

‎kernel/locking/percpu-rwsem.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,7 @@ void percpu_down_write(struct percpu_rw_semaphore *sem)
234234
*/
235235

236236
/* Wait for all active readers to complete. */
237-
rcuwait_wait_event(&sem->writer, readers_active_check(sem));
237+
rcuwait_wait_event(&sem->writer, readers_active_check(sem), TASK_UNINTERRUPTIBLE);
238238
}
239239
EXPORT_SYMBOL_GPL(percpu_down_write);
240240

0 commit comments

Comments
 (0)