summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKent Overstreet <kent.overstreet@gmail.com>2016-03-14 15:33:57 -0800
committerKent Overstreet <kent.overstreet@gmail.com>2016-08-28 19:15:19 -0800
commit3939d5b7321dcd548d093126bbc568318bb9ee10 (patch)
tree02a4050b8927ebdbb3df427ed3fc043afa85089b
parent26031fdf96022ec685b53daf4c1fc3981f8f0d25 (diff)
workqueue: context_is_freezable()
-rw-r--r--include/linux/workqueue.h3
-rw-r--r--kernel/workqueue.c22
2 files changed, 25 insertions, 0 deletions
diff --git a/include/linux/workqueue.h b/include/linux/workqueue.h
index ca73c503b92a..b853f6d1a458 100644
--- a/include/linux/workqueue.h
+++ b/include/linux/workqueue.h
@@ -358,6 +358,9 @@ extern struct workqueue_struct *system_freezable_wq;
extern struct workqueue_struct *system_power_efficient_wq;
extern struct workqueue_struct *system_freezable_power_efficient_wq;
+bool context_is_freezable(void);
+const char *context_name(void);
+
extern struct workqueue_struct *
__alloc_workqueue_key(const char *fmt, unsigned int flags, int max_active,
struct lock_class_key *key, const char *lock_name, ...) __printf(1, 6);
diff --git a/kernel/workqueue.c b/kernel/workqueue.c
index 2db41ecca2c4..8e6a3a44d088 100644
--- a/kernel/workqueue.c
+++ b/kernel/workqueue.c
@@ -521,6 +521,28 @@ static inline void debug_work_activate(struct work_struct *work) { }
static inline void debug_work_deactivate(struct work_struct *work) { }
#endif
+bool context_is_freezable(void)
+{
+ struct worker *worker;
+
+ worker = current_wq_worker();
+ if (worker)
+ return worker->current_pwq->wq->flags & WQ_FREEZABLE;
+ else
+ return !(current->flags & PF_NOFREEZE);
+}
+
+const char *context_name(void)
+{
+ struct worker *worker;
+
+ worker = current_wq_worker();
+ if (worker)
+ return worker->current_pwq->wq->name;
+ else
+ return current->comm;
+}
+
/**
* worker_pool_assign_id - allocate ID and assing it to @pool
* @pool: the pool pointer of interest