workqueue: increase max_active of keventd and kill current_is_keventd()
[deliverable/linux.git] / include / linux / workqueue.h
index 8762f62103d8eb832e835d000b6c0dfc70c598e8..33e24e734d503d130e8ed0600a15ade79ec76b9c 100644 (file)
@@ -9,6 +9,7 @@
 #include <linux/linkage.h>
 #include <linux/bitops.h>
 #include <linux/lockdep.h>
+#include <linux/threads.h>
 #include <asm/atomic.h>
 
 struct workqueue_struct;
@@ -24,8 +25,9 @@ typedef void (*work_func_t)(struct work_struct *work);
 
 enum {
        WORK_STRUCT_PENDING_BIT = 0,    /* work item is pending execution */
+       WORK_STRUCT_LINKED_BIT  = 1,    /* next work is linked to this one */
 #ifdef CONFIG_DEBUG_OBJECTS_WORK
-       WORK_STRUCT_STATIC_BIT  = 1,    /* static initializer (debugobjects) */
+       WORK_STRUCT_STATIC_BIT  = 2,    /* static initializer (debugobjects) */
        WORK_STRUCT_COLOR_SHIFT = 3,    /* color for workqueue flushing */
 #else
        WORK_STRUCT_COLOR_SHIFT = 2,    /* color for workqueue flushing */
@@ -34,6 +36,7 @@ enum {
        WORK_STRUCT_COLOR_BITS  = 4,
 
        WORK_STRUCT_PENDING     = 1 << WORK_STRUCT_PENDING_BIT,
+       WORK_STRUCT_LINKED      = 1 << WORK_STRUCT_LINKED_BIT,
 #ifdef CONFIG_DEBUG_OBJECTS_WORK
        WORK_STRUCT_STATIC      = 1 << WORK_STRUCT_STATIC_BIT,
 #else
@@ -57,6 +60,7 @@ enum {
 
        WORK_STRUCT_FLAG_MASK   = (1UL << WORK_STRUCT_FLAG_BITS) - 1,
        WORK_STRUCT_WQ_DATA_MASK = ~WORK_STRUCT_FLAG_MASK,
+       WORK_STRUCT_NO_CPU      = NR_CPUS << WORK_STRUCT_FLAG_BITS,
 };
 
 struct work_struct {
@@ -68,8 +72,9 @@ struct work_struct {
 #endif
 };
 
-#define WORK_DATA_INIT()       ATOMIC_LONG_INIT(0)
-#define WORK_DATA_STATIC_INIT()        ATOMIC_LONG_INIT(WORK_STRUCT_STATIC)
+#define WORK_DATA_INIT()       ATOMIC_LONG_INIT(WORK_STRUCT_NO_CPU)
+#define WORK_DATA_STATIC_INIT()        \
+       ATOMIC_LONG_INIT(WORK_STRUCT_NO_CPU | WORK_STRUCT_STATIC)
 
 struct delayed_work {
        struct work_struct work;
@@ -219,15 +224,20 @@ static inline unsigned int work_static(struct work_struct *work) { return 0; }
 
 enum {
        WQ_FREEZEABLE           = 1 << 0, /* freeze during suspend */
-       WQ_SINGLE_THREAD        = 1 << 1, /* no per-cpu worker */
+       WQ_SINGLE_CPU           = 1 << 1, /* only single cpu at a time */
+       WQ_NON_REENTRANT        = 1 << 2, /* guarantee non-reentrance */
+       WQ_RESCUER              = 1 << 3, /* has an rescue worker */
+
+       WQ_MAX_ACTIVE           = 512,    /* I like 512, better ideas? */
+       WQ_DFL_ACTIVE           = WQ_MAX_ACTIVE / 2,
 };
 
 extern struct workqueue_struct *
-__create_workqueue_key(const char *name, unsigned int flags,
+__create_workqueue_key(const char *name, unsigned int flags, int max_active,
                       struct lock_class_key *key, const char *lock_name);
 
 #ifdef CONFIG_LOCKDEP
-#define __create_workqueue(name, flags)                                \
+#define __create_workqueue(name, flags, max_active)            \
 ({                                                             \
        static struct lock_class_key __key;                     \
        const char *__lock_name;                                \
@@ -237,20 +247,21 @@ __create_workqueue_key(const char *name, unsigned int flags,
        else                                                    \
                __lock_name = #name;                            \
                                                                \
-       __create_workqueue_key((name), (flags), &__key,         \
-                              __lock_name);                    \
+       __create_workqueue_key((name), (flags), (max_active),   \
+                               &__key, __lock_name);           \
 })
 #else
-#define __create_workqueue(name, flags)                                \
-       __create_workqueue_key((name), (flags), NULL, NULL)
+#define __create_workqueue(name, flags, max_active)            \
+       __create_workqueue_key((name), (flags), (max_active), NULL, NULL)
 #endif
 
 #define create_workqueue(name)                                 \
-       __create_workqueue((name), 0)
+       __create_workqueue((name), WQ_RESCUER, 1)
 #define create_freezeable_workqueue(name)                      \
-       __create_workqueue((name), WQ_FREEZEABLE | WQ_SINGLE_THREAD)
+       __create_workqueue((name),                              \
+                          WQ_FREEZEABLE | WQ_SINGLE_CPU | WQ_RESCUER, 1)
 #define create_singlethread_workqueue(name)                    \
-       __create_workqueue((name), WQ_SINGLE_THREAD)
+       __create_workqueue((name), WQ_SINGLE_CPU | WQ_RESCUER, 1)
 
 extern void destroy_workqueue(struct workqueue_struct *wq);
 
@@ -272,7 +283,6 @@ extern int schedule_delayed_work(struct delayed_work *work, unsigned long delay)
 extern int schedule_delayed_work_on(int cpu, struct delayed_work *work,
                                        unsigned long delay);
 extern int schedule_on_each_cpu(work_func_t func);
-extern int current_is_keventd(void);
 extern int keventd_up(void);
 
 extern void init_workqueues(void);
@@ -338,4 +348,11 @@ static inline long work_on_cpu(unsigned int cpu, long (*fn)(void *), void *arg)
 #else
 long work_on_cpu(unsigned int cpu, long (*fn)(void *), void *arg);
 #endif /* CONFIG_SMP */
+
+#ifdef CONFIG_FREEZER
+extern void freeze_workqueues_begin(void);
+extern bool freeze_workqueues_busy(void);
+extern void thaw_workqueues(void);
+#endif /* CONFIG_FREEZER */
+
 #endif
This page took 0.028138 seconds and 5 git commands to generate.