[patch V3 11/20] rcuwait: Add @state argument to rcuwait_wait_event()
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
- To: LKML <linux-kernel@xxxxxxxxxxxxxxx>
- Subject: [patch V3 11/20] rcuwait: Add @state argument to rcuwait_wait_event()
- From: Thomas Gleixner <tglx@xxxxxxxxxxxxx>
- Date: Sat, 21 Mar 2020 12:25:55 +0100
- Cc: Peter Zijlstra <peterz@xxxxxxxxxxxxx>, Ingo Molnar <mingo@xxxxxxxxxx>, Sebastian Siewior <bigeasy@xxxxxxxxxxxxx>, Linus Torvalds <torvalds@xxxxxxxxxxxxxxxxxxxx>, Joel Fernandes <joel@xxxxxxxxxxxxxxxxx>, Oleg Nesterov <oleg@xxxxxxxxxx>, Davidlohr Bueso <dave@xxxxxxxxxxxx>, Logan Gunthorpe <logang@xxxxxxxxxxxx>, Bjorn Helgaas <bhelgaas@xxxxxxxxxx>, Kurt Schwemmer <kurt.schwemmer@xxxxxxxxxxxxx>, linux-pci@xxxxxxxxxxxxxxx, Greg Kroah-Hartman <gregkh@xxxxxxxxxxxxxxxxxxx>, Felipe Balbi <balbi@xxxxxxxxxx>, linux-usb@xxxxxxxxxxxxxxx, Kalle Valo <kvalo@xxxxxxxxxxxxxx>, "David S. Miller" <davem@xxxxxxxxxxxxx>, linux-wireless@xxxxxxxxxxxxxxx, netdev@xxxxxxxxxxxxxxx, Darren Hart <dvhart@xxxxxxxxxxxxx>, Andy Shevchenko <andy@xxxxxxxxxxxxx>, platform-driver-x86@xxxxxxxxxxxxxxx, Zhang Rui <rui.zhang@xxxxxxxxx>, "Rafael J. Wysocki" <rafael.j.wysocki@xxxxxxxxx>, linux-pm@xxxxxxxxxxxxxxx, Len Brown <lenb@xxxxxxxxxx>, linux-acpi@xxxxxxxxxxxxxxx, kbuild test robot <lkp@xxxxxxxxx>, Nick Hu <nickhu@xxxxxxxxxxxxx>, Greentime Hu <green.hu@xxxxxxxxx>, Vincent Chen <deanbo422@xxxxxxxxx>, Guo Ren <guoren@xxxxxxxxxx>, linux-csky@xxxxxxxxxxxxxxx, Brian Cain <bcain@xxxxxxxxxxxxxx>, linux-hexagon@xxxxxxxxxxxxxxx, Tony Luck <tony.luck@xxxxxxxxx>, Fenghua Yu <fenghua.yu@xxxxxxxxx>, linux-ia64@xxxxxxxxxxxxxxx, Michal Simek <monstr@xxxxxxxxx>, Michael Ellerman <mpe@xxxxxxxxxxxxxx>, Arnd Bergmann <arnd@xxxxxxxx>, Geoff Levand <geoff@xxxxxxxxxxxxx>, linuxppc-dev@xxxxxxxxxxxxxxxx, "Paul E . McKenney" <paulmck@xxxxxxxxxx>, Jonathan Corbet <corbet@xxxxxxx>, Randy Dunlap <rdunlap@xxxxxxxxxxxxx>, Davidlohr Bueso <dbueso@xxxxxxx>
- References: <20200321112544.878032781@linutronix.de>
- User-agent: quilt/0.65
From: Peter Zijlstra (Intel) <peterz@xxxxxxxxxxxxx>
Extend rcuwait_wait_event() with a state variable so that it is not
restricted to UNINTERRUPTIBLE waits.
Signed-off-by: Peter Zijlstra (Intel) <peterz@xxxxxxxxxxxxx>
Signed-off-by: Thomas Gleixner <tglx@xxxxxxxxxxxxx>
Cc: Linus Torvalds <torvalds@xxxxxxxxxxxxxxxxxxxx>
Cc: Davidlohr Bueso <dave@xxxxxxxxxxxx>
---
include/linux/rcuwait.h | 12 ++++++++++--
kernel/locking/percpu-rwsem.c | 2 +-
2 files changed, 11 insertions(+), 3 deletions(-)
--- a/include/linux/rcuwait.h
+++ b/include/linux/rcuwait.h
@@ -3,6 +3,7 @@
#define _LINUX_RCUWAIT_H_
#include <linux/rcupdate.h>
+#include <linux/sched/signal.h>
/*
* rcuwait provides a way of blocking and waking up a single
@@ -30,23 +31,30 @@ extern void rcuwait_wake_up(struct rcuwa
* The caller is responsible for locking around rcuwait_wait_event(),
* such that writes to @task are properly serialized.
*/
-#define rcuwait_wait_event(w, condition) \
+#define rcuwait_wait_event(w, condition, state) \
({ \
+ int __ret = 0; \
rcu_assign_pointer((w)->task, current); \
for (;;) { \
/* \
* Implicit barrier (A) pairs with (B) in \
* rcuwait_wake_up(). \
*/ \
- set_current_state(TASK_UNINTERRUPTIBLE); \
+ set_current_state(state); \
if (condition) \
break; \
\
+ if (signal_pending_state(state, current)) { \
+ __ret = -EINTR; \
+ break; \
+ } \
+ \
schedule(); \
} \
\
WRITE_ONCE((w)->task, NULL); \
__set_current_state(TASK_RUNNING); \
+ __ret; \
})
#endif /* _LINUX_RCUWAIT_H_ */
--- a/kernel/locking/percpu-rwsem.c
+++ b/kernel/locking/percpu-rwsem.c
@@ -162,7 +162,7 @@ void percpu_down_write(struct percpu_rw_
*/
/* Wait for all now active readers to complete. */
- rcuwait_wait_event(&sem->writer, readers_active_check(sem));
+ rcuwait_wait_event(&sem->writer, readers_active_check(sem), TASK_UNINTERRUPTIBLE);
}
EXPORT_SYMBOL_GPL(percpu_down_write);
[Index of Archives]
[Linux Kernel]
[Sparc Linux]
[DCCP]
[Linux ARM]
[Yosemite News]
[Linux SCSI]
[Linux x86_64]
[Linux for Ham Radio]