Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 206207
b: refs/heads/master
c: 97e37d7
h: refs/heads/master
i:
  206205: e207019
  206203: 3e90c68
  206199: 405331d
  206191: 29ffbe4
  206175: 7b20ee9
  206143: 765b1db
  206079: e87a735
v: v3
  • Loading branch information
Tejun Heo committed Jun 29, 2010
1 parent 409fbed commit 935629f
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 21 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 4690c4ab56c71919893ca25252f2dd65b58188c7
refs/heads/master: 97e37d7b9e65a6ac939f796f91081135b7a08acc
25 changes: 15 additions & 10 deletions trunk/include/linux/workqueue.h
Original file line number Diff line number Diff line change
Expand Up @@ -184,13 +184,17 @@ static inline unsigned int work_static(struct work_struct *work) { return 0; }
#define work_clear_pending(work) \
clear_bit(WORK_STRUCT_PENDING, work_data_bits(work))

enum {
WQ_FREEZEABLE = 1 << 0, /* freeze during suspend */
WQ_SINGLE_THREAD = 1 << 1, /* no per-cpu worker */
};

extern struct workqueue_struct *
__create_workqueue_key(const char *name, int singlethread, int freezeable,
__create_workqueue_key(const char *name, unsigned int flags,
struct lock_class_key *key, const char *lock_name);

#ifdef CONFIG_LOCKDEP
#define __create_workqueue(name, singlethread, freezeable) \
#define __create_workqueue(name, flags) \
({ \
static struct lock_class_key __key; \
const char *__lock_name; \
Expand All @@ -200,19 +204,20 @@ __create_workqueue_key(const char *name, int singlethread, int freezeable,
else \
__lock_name = #name; \
\
__create_workqueue_key((name), (singlethread), \
(freezeable), &__key, \
__create_workqueue_key((name), (flags), &__key, \
__lock_name); \
})
#else
#define __create_workqueue(name, singlethread, freezeable) \
__create_workqueue_key((name), (singlethread), (freezeable), \
NULL, NULL)
#define __create_workqueue(name, flags) \
__create_workqueue_key((name), (flags), NULL, NULL)
#endif

#define create_workqueue(name) __create_workqueue((name), 0, 0)
#define create_freezeable_workqueue(name) __create_workqueue((name), 1, 1)
#define create_singlethread_workqueue(name) __create_workqueue((name), 1, 0)
#define create_workqueue(name) \
__create_workqueue((name), 0)
#define create_freezeable_workqueue(name) \
__create_workqueue((name), WQ_FREEZEABLE | WQ_SINGLE_THREAD)
#define create_singlethread_workqueue(name) \
__create_workqueue((name), WQ_SINGLE_THREAD)

extern void destroy_workqueue(struct workqueue_struct *wq);

Expand Down
17 changes: 7 additions & 10 deletions trunk/kernel/workqueue.c
Original file line number Diff line number Diff line change
Expand Up @@ -67,11 +67,10 @@ struct cpu_workqueue_struct {
* per-CPU workqueues:
*/
struct workqueue_struct {
unsigned int flags; /* I: WQ_* flags */
struct cpu_workqueue_struct *cpu_wq; /* I: cwq's */
struct list_head list; /* W: list of all workqueues */
const char *name; /* I: workqueue name */
int singlethread;
int freezeable; /* Freeze threads during suspend */
#ifdef CONFIG_LOCKDEP
struct lockdep_map lockdep_map;
#endif
Expand Down Expand Up @@ -203,9 +202,9 @@ static const struct cpumask *cpu_singlethread_map __read_mostly;
static cpumask_var_t cpu_populated_map __read_mostly;

/* If it's single threaded, it isn't in the list of workqueues. */
static inline int is_wq_single_threaded(struct workqueue_struct *wq)
static inline bool is_wq_single_threaded(struct workqueue_struct *wq)
{
return wq->singlethread;
return wq->flags & WQ_SINGLE_THREAD;
}

static const struct cpumask *wq_cpu_map(struct workqueue_struct *wq)
Expand Down Expand Up @@ -463,7 +462,7 @@ static int worker_thread(void *__cwq)
struct cpu_workqueue_struct *cwq = __cwq;
DEFINE_WAIT(wait);

if (cwq->wq->freezeable)
if (cwq->wq->flags & WQ_FREEZEABLE)
set_freezable();

for (;;) {
Expand Down Expand Up @@ -1013,8 +1012,7 @@ static void start_workqueue_thread(struct cpu_workqueue_struct *cwq, int cpu)
}

struct workqueue_struct *__create_workqueue_key(const char *name,
int singlethread,
int freezeable,
unsigned int flags,
struct lock_class_key *key,
const char *lock_name)
{
Expand All @@ -1030,13 +1028,12 @@ struct workqueue_struct *__create_workqueue_key(const char *name,
if (!wq->cpu_wq)
goto err;

wq->flags = flags;
wq->name = name;
lockdep_init_map(&wq->lockdep_map, lock_name, key, 0);
wq->singlethread = singlethread;
wq->freezeable = freezeable;
INIT_LIST_HEAD(&wq->list);

if (singlethread) {
if (flags & WQ_SINGLE_THREAD) {
cwq = init_cpu_workqueue(wq, singlethread_cpu);
err = create_workqueue_thread(cwq, singlethread_cpu);
start_workqueue_thread(cwq, -1);
Expand Down

0 comments on commit 935629f

Please sign in to comment.