Merge tag 'core-entry-notify-signal' of git://git.kernel.org/pub/scm/linux/kernel...
[sfrench/cifs-2.6.git] / include / linux / tracehook.h
index b480e1a07ed85198e4d43dde761ae9420734dc95..f7d82e4fafd6c78fd6a628e6a77068140c0faf94 100644 (file)
@@ -198,4 +198,31 @@ static inline void tracehook_notify_resume(struct pt_regs *regs)
        blkcg_maybe_throttle_current();
 }
 
+/*
+ * called by exit_to_user_mode_loop() if ti_work & _TIF_NOTIFY_SIGNAL. This
+ * is currently used by TWA_SIGNAL based task_work, which requires breaking
+ * wait loops to ensure that task_work is noticed and run.
+ */
+static inline void tracehook_notify_signal(void)
+{
+#if defined(TIF_NOTIFY_SIGNAL)
+       clear_thread_flag(TIF_NOTIFY_SIGNAL);
+       smp_mb__after_atomic();
+       if (current->task_works)
+               task_work_run();
+#endif
+}
+
+/*
+ * Called when we have work to process from exit_to_user_mode_loop()
+ */
+static inline void set_notify_signal(struct task_struct *task)
+{
+#if defined(TIF_NOTIFY_SIGNAL)
+       if (!test_and_set_tsk_thread_flag(task, TIF_NOTIFY_SIGNAL) &&
+           !wake_up_state(task, TASK_INTERRUPTIBLE))
+               kick_process(task);
+#endif
+}
+
 #endif /* <linux/tracehook.h> */