aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--include/linux/kthread.h1
-rw-r--r--include/linux/sched/signal.h9
-rw-r--r--kernel/kthread.c6
3 files changed, 16 insertions, 0 deletions
diff --git a/include/linux/kthread.h b/include/linux/kthread.h
index 30e5bec81d2b..7061dde23237 100644
--- a/include/linux/kthread.h
+++ b/include/linux/kthread.h
@@ -87,6 +87,7 @@ void kthread_bind(struct task_struct *k, unsigned int cpu);
void kthread_bind_mask(struct task_struct *k, const struct cpumask *mask);
int kthread_stop(struct task_struct *k);
bool kthread_should_stop(void);
+bool __kthread_should_stop(struct task_struct *k);
bool kthread_should_park(void);
bool __kthread_should_park(struct task_struct *k);
bool kthread_freezable_should_stop(bool *was_frozen);
diff --git a/include/linux/sched/signal.h b/include/linux/sched/signal.h
index cafbe03eed01..08700c65b806 100644
--- a/include/linux/sched/signal.h
+++ b/include/linux/sched/signal.h
@@ -11,6 +11,7 @@
#include <linux/refcount.h>
#include <linux/posix-timers.h>
#include <linux/mm_types.h>
+#include <linux/kthread.h>
#include <asm/ptrace.h>
/*
@@ -397,6 +398,14 @@ static inline int signal_pending(struct task_struct *p)
*/
if (unlikely(test_tsk_thread_flag(p, TIF_NOTIFY_SIGNAL)))
return 1;
+
+ /*
+ * Likewise, KTHREAD_SHOULD_STOP isn't really a signal, but it also
+ * requires the same behavior, lest wait loops go forever.
+ */
+ if (unlikely(__kthread_should_stop(p)))
+ return 1;
+
return task_sigpending(p);
}
diff --git a/kernel/kthread.c b/kernel/kthread.c
index 3c677918d8f2..7e0743330cd4 100644
--- a/kernel/kthread.c
+++ b/kernel/kthread.c
@@ -145,6 +145,12 @@ void free_kthread_struct(struct task_struct *k)
kfree(kthread);
}
+bool __kthread_should_stop(struct task_struct *k)
+{
+ return (k->flags & PF_KTHREAD) &&
+ test_bit(KTHREAD_SHOULD_STOP, &to_kthread(k)->flags);
+}
+
/**
* kthread_should_stop - should this kthread return now?
*