Linux Kernel  3.7.1
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Data Structures | Macros | Typedefs | Enumerations | Functions | Variables
workqueue.h File Reference
#include <linux/timer.h>
#include <linux/linkage.h>
#include <linux/bitops.h>
#include <linux/lockdep.h>
#include <linux/threads.h>
#include <linux/atomic.h>

Go to the source code of this file.

Data Structures

struct  work_struct
 
struct  delayed_work
 
struct  execute_work
 

Macros

#define work_data_bits(work)   ((unsigned long *)(&(work)->data))
 
#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)
 
#define __WORK_INIT_LOCKDEP_MAP(n, k)
 
#define __WORK_INITIALIZER(n, f)
 
#define __DELAYED_WORK_INITIALIZER(n, f, tflags)
 
#define DECLARE_WORK(n, f)   struct work_struct n = __WORK_INITIALIZER(n, f)
 
#define DECLARE_DELAYED_WORK(n, f)   struct delayed_work n = __DELAYED_WORK_INITIALIZER(n, f, 0)
 
#define DECLARE_DEFERRABLE_WORK(n, f)   struct delayed_work n = __DELAYED_WORK_INITIALIZER(n, f, TIMER_DEFERRABLE)
 
#define PREPARE_WORK(_work, _func)
 
#define PREPARE_DELAYED_WORK(_work, _func)   PREPARE_WORK(&(_work)->work, (_func))
 
#define __INIT_WORK(_work, _func, _onstack)
 
#define INIT_WORK(_work, _func)
 
#define INIT_WORK_ONSTACK(_work, _func)
 
#define __INIT_DELAYED_WORK(_work, _func, _tflags)
 
#define __INIT_DELAYED_WORK_ONSTACK(_work, _func, _tflags)
 
#define INIT_DELAYED_WORK(_work, _func)   __INIT_DELAYED_WORK(_work, _func, 0)
 
#define INIT_DELAYED_WORK_ONSTACK(_work, _func)   __INIT_DELAYED_WORK_ONSTACK(_work, _func, 0)
 
#define INIT_DEFERRABLE_WORK(_work, _func)   __INIT_DELAYED_WORK(_work, _func, TIMER_DEFERRABLE)
 
#define INIT_DEFERRABLE_WORK_ONSTACK(_work, _func)   __INIT_DELAYED_WORK_ONSTACK(_work, _func, TIMER_DEFERRABLE)
 
#define work_pending(work)   test_bit(WORK_STRUCT_PENDING_BIT, work_data_bits(work))
 
#define delayed_work_pending(w)   work_pending(&(w)->work)
 
#define work_clear_pending(work)   clear_bit(WORK_STRUCT_PENDING_BIT, work_data_bits(work))
 
#define WQ_UNBOUND_MAX_ACTIVE   max_t(int, WQ_MAX_ACTIVE, num_possible_cpus() * WQ_MAX_UNBOUND_PER_CPU)
 
#define system_nrt_wq   __system_nrt_wq()
 
#define system_nrt_freezable_wq   __system_nrt_freezable_wq()
 
#define alloc_workqueue(fmt, flags, max_active, args...)
 
#define alloc_ordered_workqueue(fmt, flags, args...)   alloc_workqueue(fmt, WQ_UNBOUND | (flags), 1, ##args)
 
#define create_workqueue(name)   alloc_workqueue((name), WQ_MEM_RECLAIM, 1)
 
#define create_freezable_workqueue(name)   alloc_workqueue((name), WQ_FREEZABLE | WQ_UNBOUND | WQ_MEM_RECLAIM, 1)
 
#define create_singlethread_workqueue(name)   alloc_workqueue((name), WQ_UNBOUND | WQ_MEM_RECLAIM, 1)
 

Typedefs

typedef void(* work_func_t )(struct work_struct *work)
 

Enumerations

enum  {
  WORK_STRUCT_PENDING_BIT = 0, WORK_STRUCT_DELAYED_BIT = 1, WORK_STRUCT_CWQ_BIT = 2, WORK_STRUCT_LINKED_BIT = 3,
  WORK_STRUCT_COLOR_SHIFT = 4, WORK_STRUCT_COLOR_BITS = 4, WORK_STRUCT_PENDING = 1 << WORK_STRUCT_PENDING_BIT, WORK_STRUCT_DELAYED = 1 << WORK_STRUCT_DELAYED_BIT,
  WORK_STRUCT_CWQ = 1 << WORK_STRUCT_CWQ_BIT, WORK_STRUCT_LINKED = 1 << WORK_STRUCT_LINKED_BIT, WORK_STRUCT_STATIC = 0, WORK_NR_COLORS = (1 << WORK_STRUCT_COLOR_BITS) - 1,
  WORK_NO_COLOR = WORK_NR_COLORS, WORK_CPU_UNBOUND = NR_CPUS, WORK_CPU_NONE = NR_CPUS + 1, WORK_CPU_LAST = WORK_CPU_NONE,
  WORK_STRUCT_FLAG_BITS, WORK_OFFQ_FLAG_BASE = WORK_STRUCT_FLAG_BITS, WORK_OFFQ_CANCELING = (1 << WORK_OFFQ_FLAG_BASE), WORK_OFFQ_FLAG_BITS = 1,
  WORK_OFFQ_CPU_SHIFT = WORK_OFFQ_FLAG_BASE + WORK_OFFQ_FLAG_BITS, WORK_STRUCT_FLAG_MASK = (1UL << WORK_STRUCT_FLAG_BITS) - 1, WORK_STRUCT_WQ_DATA_MASK = ~WORK_STRUCT_FLAG_MASK, WORK_STRUCT_NO_CPU = (unsigned long)WORK_CPU_NONE << WORK_OFFQ_CPU_SHIFT,
  WORK_BUSY_PENDING = 1 << 0, WORK_BUSY_RUNNING = 1 << 1
}
 
enum  {
  WQ_NON_REENTRANT = 1 << 0, WQ_UNBOUND = 1 << 1, WQ_FREEZABLE = 1 << 2, WQ_MEM_RECLAIM = 1 << 3,
  WQ_HIGHPRI = 1 << 4, WQ_CPU_INTENSIVE = 1 << 5, WQ_DRAINING = 1 << 6, WQ_RESCUER = 1 << 7,
  WQ_MAX_ACTIVE = 512, WQ_MAX_UNBOUND_PER_CPU = 4, WQ_DFL_ACTIVE = WQ_MAX_ACTIVE / 2
}
 

Functions

void delayed_work_timer_fn (unsigned long __data)
 
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
 
void destroy_workqueue (struct workqueue_struct *wq)
 
bool queue_work_on (int cpu, struct workqueue_struct *wq, struct work_struct *work)
 
bool queue_work (struct workqueue_struct *wq, struct work_struct *work)
 
bool queue_delayed_work_on (int cpu, struct workqueue_struct *wq, struct delayed_work *work, unsigned long delay)
 
bool queue_delayed_work (struct workqueue_struct *wq, struct delayed_work *work, unsigned long delay)
 
bool mod_delayed_work_on (int cpu, struct workqueue_struct *wq, struct delayed_work *dwork, unsigned long delay)
 
bool mod_delayed_work (struct workqueue_struct *wq, struct delayed_work *dwork, unsigned long delay)
 
void flush_workqueue (struct workqueue_struct *wq)
 
void drain_workqueue (struct workqueue_struct *wq)
 
void flush_scheduled_work (void)
 
bool schedule_work_on (int cpu, struct work_struct *work)
 
bool schedule_work (struct work_struct *work)
 
bool schedule_delayed_work_on (int cpu, struct delayed_work *work, unsigned long delay)
 
bool schedule_delayed_work (struct delayed_work *work, unsigned long delay)
 
int schedule_on_each_cpu (work_func_t func)
 
int keventd_up (void)
 
int execute_in_process_context (work_func_t fn, struct execute_work *)
 
bool flush_work (struct work_struct *work)
 
bool cancel_work_sync (struct work_struct *work)
 
bool flush_delayed_work (struct delayed_work *dwork)
 
bool cancel_delayed_work (struct delayed_work *dwork)
 
bool cancel_delayed_work_sync (struct delayed_work *dwork)
 
void workqueue_set_max_active (struct workqueue_struct *wq, int max_active)
 
bool workqueue_congested (unsigned int cpu, struct workqueue_struct *wq)
 
unsigned int work_cpu (struct work_struct *work)
 
unsigned int work_busy (struct work_struct *work)
 

Variables

struct workqueue_structsystem_wq
 
struct workqueue_structsystem_long_wq
 
struct workqueue_structsystem_unbound_wq
 
struct workqueue_structsystem_freezable_wq
 

Macro Definition Documentation

#define __DELAYED_WORK_INITIALIZER (   n,
  f,
  tflags 
)
Value:
{ \
.work = __WORK_INITIALIZER((n).work, (f)), \
0, (unsigned long)&(n), \
(tflags) | TIMER_IRQSAFE), \
}

Definition at line 136 of file workqueue.h.

#define __INIT_DELAYED_WORK (   _work,
  _func,
  _tflags 
)
Value:
do { \
INIT_WORK(&(_work)->work, (_func)); \
__setup_timer(&(_work)->timer, delayed_work_timer_fn, \
(unsigned long)(_work), \
(_tflags) | TIMER_IRQSAFE); \
} while (0)

Definition at line 214 of file workqueue.h.

#define __INIT_DELAYED_WORK_ONSTACK (   _work,
  _func,
  _tflags 
)
Value:
do { \
INIT_WORK_ONSTACK(&(_work)->work, (_func)); \
__setup_timer_on_stack(&(_work)->timer, \
(unsigned long)(_work), \
(_tflags) | TIMER_IRQSAFE); \
} while (0)

Definition at line 222 of file workqueue.h.

#define __INIT_WORK (   _work,
  _func,
  _onstack 
)
Value:
do { \
__init_work((_work), _onstack); \
(_work)->data = (atomic_long_t) WORK_DATA_INIT(); \
INIT_LIST_HEAD(&(_work)->entry); \
PREPARE_WORK((_work), (_func)); \
} while (0)

Definition at line 195 of file workqueue.h.

#define __WORK_INIT_LOCKDEP_MAP (   n,
  k 
)

Definition at line 126 of file workqueue.h.

#define __WORK_INITIALIZER (   n,
  f 
)
Value:
{ \
.data = WORK_DATA_STATIC_INIT(), \
.entry = { &(n).entry, &(n).entry }, \
.func = (f), \
}

Definition at line 129 of file workqueue.h.

#define alloc_ordered_workqueue (   fmt,
  flags,
  args... 
)    alloc_workqueue(fmt, WQ_UNBOUND | (flags), 1, ##args)

alloc_ordered_workqueue - allocate an ordered workqueue : printf format for the name of the workqueue : WQ_* flags (only WQ_FREEZABLE and WQ_MEM_RECLAIM are meaningful) : args for

Allocate an ordered workqueue. An ordered workqueue executes at most one work item at any given time in the queued order. They are implemented as unbound workqueues with of one.

RETURNS: Pointer to the allocated workqueue on success, NULL on failure.

Definition at line 380 of file workqueue.h.

#define alloc_workqueue (   fmt,
  flags,
  max_active,
  args... 
)
Value:
__alloc_workqueue_key((fmt), (flags), (max_active), \
NULL, NULL, ##args)

alloc_workqueue - allocate a workqueue : printf format for the name of the workqueue : WQ_* flags : max in-flight work items, 0 for default : args for

Allocate a workqueue with the specified parameters. For detailed information on WQ_* flags, please refer to Documentation/workqueue.txt.

The __lock_name macro dance is to guarantee that single lock_class_key doesn't end up with different namesm, which isn't allowed by lockdep.

RETURNS: Pointer to the allocated workqueue on success, NULL on failure.

Definition at line 362 of file workqueue.h.

#define create_freezable_workqueue (   name)    alloc_workqueue((name), WQ_FREEZABLE | WQ_UNBOUND | WQ_MEM_RECLAIM, 1)

Definition at line 385 of file workqueue.h.

#define create_singlethread_workqueue (   name)    alloc_workqueue((name), WQ_UNBOUND | WQ_MEM_RECLAIM, 1)

Definition at line 387 of file workqueue.h.

#define create_workqueue (   name)    alloc_workqueue((name), WQ_MEM_RECLAIM, 1)

Definition at line 383 of file workqueue.h.

#define DECLARE_DEFERRABLE_WORK (   n,
  f 
)    struct delayed_work n = __DELAYED_WORK_INITIALIZER(n, f, TIMER_DEFERRABLE)

Definition at line 149 of file workqueue.h.

#define DECLARE_DELAYED_WORK (   n,
  f 
)    struct delayed_work n = __DELAYED_WORK_INITIALIZER(n, f, 0)

Definition at line 146 of file workqueue.h.

#define DECLARE_WORK (   n,
  f 
)    struct work_struct n = __WORK_INITIALIZER(n, f)

Definition at line 143 of file workqueue.h.

#define delayed_work_pending (   w)    work_pending(&(w)->work)

delayed_work_pending - Find out whether a delayable work item is currently pending : The work item in question

Definition at line 255 of file workqueue.h.

#define INIT_DEFERRABLE_WORK (   _work,
  _func 
)    __INIT_DELAYED_WORK(_work, _func, TIMER_DEFERRABLE)

Definition at line 237 of file workqueue.h.

#define INIT_DEFERRABLE_WORK_ONSTACK (   _work,
  _func 
)    __INIT_DELAYED_WORK_ONSTACK(_work, _func, TIMER_DEFERRABLE)

Definition at line 240 of file workqueue.h.

#define INIT_DELAYED_WORK (   _work,
  _func 
)    __INIT_DELAYED_WORK(_work, _func, 0)

Definition at line 231 of file workqueue.h.

#define INIT_DELAYED_WORK_ONSTACK (   _work,
  _func 
)    __INIT_DELAYED_WORK_ONSTACK(_work, _func, 0)

Definition at line 234 of file workqueue.h.

#define INIT_WORK (   _work,
  _func 
)
Value:
do { \
__INIT_WORK((_work), (_func), 0); \
} while (0)

Definition at line 204 of file workqueue.h.

#define INIT_WORK_ONSTACK (   _work,
  _func 
)
Value:
do { \
__INIT_WORK((_work), (_func), 1); \
} while (0)

Definition at line 209 of file workqueue.h.

#define PREPARE_DELAYED_WORK (   _work,
  _func 
)    PREPARE_WORK(&(_work)->work, (_func))

Definition at line 160 of file workqueue.h.

#define PREPARE_WORK (   _work,
  _func 
)
Value:
do { \
(_work)->func = (_func); \
} while (0)

Definition at line 155 of file workqueue.h.

#define system_nrt_freezable_wq   __system_nrt_freezable_wq()

Definition at line 325 of file workqueue.h.

#define system_nrt_wq   __system_nrt_wq()

Definition at line 324 of file workqueue.h.

#define work_clear_pending (   work)    clear_bit(WORK_STRUCT_PENDING_BIT, work_data_bits(work))

work_clear_pending - for internal use only, mark a work item as not pending : The work item in question

Definition at line 262 of file workqueue.h.

#define work_data_bits (   work)    ((unsigned long *)(&(work)->data))

Definition at line 25 of file workqueue.h.

#define WORK_DATA_INIT ( )    ATOMIC_LONG_INIT(WORK_STRUCT_NO_CPU)

Definition at line 98 of file workqueue.h.

#define WORK_DATA_STATIC_INIT ( )    ATOMIC_LONG_INIT(WORK_STRUCT_NO_CPU | WORK_STRUCT_STATIC)

Definition at line 99 of file workqueue.h.

#define work_pending (   work)    test_bit(WORK_STRUCT_PENDING_BIT, work_data_bits(work))

work_pending - Find out whether a work item is currently pending : The work item in question

Definition at line 247 of file workqueue.h.

#define WQ_UNBOUND_MAX_ACTIVE   max_t(int, WQ_MAX_ACTIVE, num_possible_cpus() * WQ_MAX_UNBOUND_PER_CPU)

Definition at line 286 of file workqueue.h.

Typedef Documentation

typedef void(* work_func_t)(struct work_struct *work)

Definition at line 18 of file workqueue.h.

Enumeration Type Documentation

anonymous enum
Enumerator:
WORK_STRUCT_PENDING_BIT 
WORK_STRUCT_DELAYED_BIT 
WORK_STRUCT_CWQ_BIT 
WORK_STRUCT_LINKED_BIT 
WORK_STRUCT_COLOR_SHIFT 
WORK_STRUCT_COLOR_BITS 
WORK_STRUCT_PENDING 
WORK_STRUCT_DELAYED 
WORK_STRUCT_CWQ 
WORK_STRUCT_LINKED 
WORK_STRUCT_STATIC 
WORK_NR_COLORS 
WORK_NO_COLOR 
WORK_CPU_UNBOUND 
WORK_CPU_NONE 
WORK_CPU_LAST 
WORK_STRUCT_FLAG_BITS 
WORK_OFFQ_FLAG_BASE 
WORK_OFFQ_CANCELING 
WORK_OFFQ_FLAG_BITS 
WORK_OFFQ_CPU_SHIFT 
WORK_STRUCT_FLAG_MASK 
WORK_STRUCT_WQ_DATA_MASK 
WORK_STRUCT_NO_CPU 
WORK_BUSY_PENDING 
WORK_BUSY_RUNNING 

Definition at line 27 of file workqueue.h.

anonymous enum
Enumerator:
WQ_NON_REENTRANT 
WQ_UNBOUND 
WQ_FREEZABLE 
WQ_MEM_RECLAIM 
WQ_HIGHPRI 
WQ_CPU_INTENSIVE 
WQ_DRAINING 
WQ_RESCUER 
WQ_MAX_ACTIVE 
WQ_MAX_UNBOUND_PER_CPU 
WQ_DFL_ACTIVE 

Definition at line 269 of file workqueue.h.

Function Documentation

struct workqueue_struct* __alloc_workqueue_key ( const char fmt,
unsigned int  flags,
int  max_active,
struct lock_class_key key,
const char lock_name,
  ... 
)
read
bool cancel_delayed_work ( struct delayed_work dwork)

cancel_delayed_work - cancel a delayed work : delayed_work to cancel

Kill off a pending delayed_work. Returns true if was pending and canceled; false if wasn't pending. Note that the work callback function may still be running on return, unless it returns true and the work doesn't re-arm itself. Explicitly flush or use cancel_delayed_work_sync() to wait on it.

This function is safe to call from any context including IRQ handler.

Definition at line 2981 of file workqueue.c.

bool cancel_delayed_work_sync ( struct delayed_work dwork)

cancel_delayed_work_sync - cancel a delayed work and wait for it to finish : the delayed work cancel

This is cancel_work_sync() for delayed works.

RETURNS: true if was pending, false otherwise.

Definition at line 3008 of file workqueue.c.

bool cancel_work_sync ( struct work_struct work)

cancel_work_sync - cancel a work and wait for it to finish : the work to cancel

Cancel and wait for its execution to finish. This function can be used even if the work re-queues itself or migrates to another workqueue. On return from this function, is guaranteed to be not pending or executing on any CPU.

cancel_work_sync(&delayed_work->work) must not be used for delayed_work's. Use cancel_delayed_work_sync() instead.

The caller must ensure that the workqueue on which was last queued can't be destroyed before this function returns.

RETURNS: true if was pending, false otherwise.

Definition at line 2940 of file workqueue.c.

void delayed_work_timer_fn ( unsigned long  __data)

Definition at line 1345 of file workqueue.c.

void destroy_workqueue ( struct workqueue_struct wq)

destroy_workqueue - safely terminate a workqueue : target workqueue

Safely destroy a workqueue. All work currently pending will be done first.

Definition at line 3340 of file workqueue.c.

void drain_workqueue ( struct workqueue_struct wq)

drain_workqueue - drain a workqueue : workqueue to drain

Wait until the workqueue becomes empty. While draining is in progress, only chain queueing is allowed. IOW, only currently pending or running work items on can queue further work items on it. is flushed repeatedly until it becomes empty. The number of flushing is detemined by the depth of chaining and should be relatively short. Whine if it takes too long.

Definition at line 2778 of file workqueue.c.

int execute_in_process_context ( work_func_t  fn,
struct execute_work  
)

Definition at line 3153 of file workqueue.c.

bool flush_delayed_work ( struct delayed_work dwork)

flush_delayed_work - wait for a dwork to finish executing the last queueing : the delayed work to flush

Delayed timer is cancelled and the pending work is queued for immediate execution. Like flush_work(), this function only considers the last queueing instance of .

RETURNS: true if flush_work() waited for the work to finish execution, false if it was already idle.

Definition at line 2958 of file workqueue.c.

void flush_scheduled_work ( void  )

flush_scheduled_work - ensure that any scheduled work has run to completion.

Forces execution of the kernel-global workqueue and blocks until its completion.

Think twice before calling this function! It's very easy to get into trouble if you don't take great care. Either of the following situations will lead to deadlock:

One of the work items currently on the workqueue needs to acquire a lock held by your code or its caller.

Your code is running in the context of a work routine.

They will be detected by lockdep when they occur, but the first might not occur very often. It depends on what work items are on the workqueue and what locks they need, which you have no control over.

In most situations flushing the entire workqueue is overkill; you merely need to know that a particular work item isn't queued and isn't running. In such cases you should use cancel_delayed_work_sync() or cancel_work_sync() instead.

Definition at line 3135 of file workqueue.c.

bool flush_work ( struct work_struct work)

flush_work - wait for a work to finish executing the last queueing instance : the work to flush

Wait until has finished execution. is guaranteed to be idle on return if it hasn't been requeued since flush started.

RETURNS: true if flush_work() waited for the work to finish execution, false if it was already idle.

Definition at line 2881 of file workqueue.c.

void flush_workqueue ( struct workqueue_struct wq)

flush_workqueue - ensure that any scheduled work has run to completion. : workqueue to flush

Forces execution of the workqueue and blocks until its completion. This is typically used in driver shutdown handlers.

We sleep until all works which were queued on entry have been handled, but we are not livelocked by new incoming ones.

Definition at line 2621 of file workqueue.c.

int keventd_up ( void  )

Definition at line 3167 of file workqueue.c.

bool mod_delayed_work ( struct workqueue_struct wq,
struct delayed_work dwork,
unsigned long  delay 
)

mod_delayed_work - modify delay of or queue a delayed work : workqueue to use : work to queue : number of jiffies to wait before queueing

mod_delayed_work_on() on local CPU.

Definition at line 1505 of file workqueue.c.

bool mod_delayed_work_on ( int  cpu,
struct workqueue_struct wq,
struct delayed_work dwork,
unsigned long  delay 
)

mod_delayed_work_on - modify delay of or queue a delayed work on specific CPU : CPU number to execute work on : workqueue to use : work to queue : number of jiffies to wait before queueing

If is idle, equivalent to queue_delayed_work_on(); otherwise, modify 's timer so that it expires after . If is zero, is guaranteed to be scheduled immediately regardless of its current state.

Returns false if was idle and queued, true if was pending and its timer was modified.

This function is safe to call from any context including IRQ handler. See try_to_grab_pending() for details.

Definition at line 1477 of file workqueue.c.

bool queue_delayed_work ( struct workqueue_struct wq,
struct delayed_work dwork,
unsigned long  delay 
)

queue_delayed_work - queue work on a workqueue after delay : workqueue to use : delayable work to queue : number of jiffies to wait before queueing

Equivalent to queue_delayed_work_on() but tries to use the local CPU.

Definition at line 1452 of file workqueue.c.

bool queue_delayed_work_on ( int  cpu,
struct workqueue_struct wq,
struct delayed_work dwork,
unsigned long  delay 
)

queue_delayed_work_on - queue work on specific CPU after delay : CPU number to execute work on : workqueue to use : work to queue : number of jiffies to wait before queueing

Returns false if was already on a queue, true otherwise. If is zero and is idle, it will be scheduled for immediate execution.

Definition at line 1424 of file workqueue.c.

bool queue_work ( struct workqueue_struct wq,
struct work_struct work 
)

queue_work - queue work on a workqueue : workqueue to use : work to queue

Returns false if was already on a queue, true otherwise.

We queue the work to the CPU on which it was submitted, but if the CPU dies it can be processed by another CPU.

Definition at line 1339 of file workqueue.c.

bool queue_work_on ( int  cpu,
struct workqueue_struct wq,
struct work_struct work 
)

queue_work_on - queue work on specific cpu : CPU number to execute work on : workqueue to use : work to queue

Returns false if was already on a queue, true otherwise.

We queue the work to a specific CPU, the caller must ensure it can't go away.

Definition at line 1311 of file workqueue.c.

bool schedule_delayed_work ( struct delayed_work dwork,
unsigned long  delay 
)

schedule_delayed_work - put work task in global workqueue after delay : job to be done : number of jiffies to wait or 0 for immediate execution

After waiting for a given time this puts a job in the kernel-global workqueue.

Definition at line 3068 of file workqueue.c.

bool schedule_delayed_work_on ( int  cpu,
struct delayed_work dwork,
unsigned long  delay 
)

schedule_delayed_work_on - queue work in global workqueue on CPU after delay : cpu to use : job to be done : number of jiffies to wait

After waiting for a given time this puts a job in the kernel-global workqueue on the specified CPU.

Definition at line 3053 of file workqueue.c.

int schedule_on_each_cpu ( work_func_t  func)

schedule_on_each_cpu - execute a function synchronously on each online CPU : the function to call

schedule_on_each_cpu() executes on each online CPU using the system workqueue and blocks until all CPUs have completed. schedule_on_each_cpu() is very slow.

RETURNS: 0 on success, -errno on failure.

Definition at line 3085 of file workqueue.c.

bool schedule_work ( struct work_struct work)

schedule_work - put work task in global workqueue : job to be done

Returns false if was already on the kernel-global workqueue and true otherwise.

This puts a job in the kernel-global workqueue if it was not already queued and leaves it in the same position on the kernel-global workqueue otherwise.

Definition at line 3038 of file workqueue.c.

bool schedule_work_on ( int  cpu,
struct work_struct work 
)

schedule_work_on - put work task on a specific cpu : cpu to put the work task on : job to be done

This puts a job on a specific cpu

Definition at line 3021 of file workqueue.c.

unsigned int work_busy ( struct work_struct work)

work_busy - test whether a work is currently pending or running : the work to be tested

Test whether is currently pending or running. There is no synchronization around this function and the test result is unreliable and only useful as advisory hints or for debugging. Especially for reentrant wqs, the pending state might hide the running state.

RETURNS: OR'd bitmask of WORK_BUSY_* bits.

Definition at line 3481 of file workqueue.c.

unsigned int work_cpu ( struct work_struct work)

work_cpu - return the last known associated cpu for : the work of interest

RETURNS: CPU number if was ever queued. WORK_CPU_NONE otherwise.

Definition at line 3460 of file workqueue.c.

bool workqueue_congested ( unsigned int  cpu,
struct workqueue_struct wq 
)

workqueue_congested - test whether a workqueue is congested : CPU in question : target workqueue

Test whether 's cpu workqueue for is congested. There is no synchronization around this function and the test result is unreliable and only useful as advisory hints or for debugging.

RETURNS: true if congested, false otherwise.

Definition at line 3445 of file workqueue.c.

void workqueue_set_max_active ( struct workqueue_struct wq,
int  max_active 
)

workqueue_set_max_active - adjust max_active of a workqueue : target workqueue : new max_active value.

Set max_active of to .

CONTEXT: Don't call from IRQ context.

Definition at line 3407 of file workqueue.c.

Variable Documentation

struct workqueue_struct* system_freezable_wq
struct workqueue_struct* system_long_wq
struct workqueue_struct* system_unbound_wq