Back to home page

LXR

 
 

    


0001 /*
0002  * kernel/workqueue_internal.h
0003  *
0004  * Workqueue internal header file.  Only to be included by workqueue and
0005  * core kernel subsystems.
0006  */
0007 #ifndef _KERNEL_WORKQUEUE_INTERNAL_H
0008 #define _KERNEL_WORKQUEUE_INTERNAL_H
0009 
0010 #include <linux/workqueue.h>
0011 #include <linux/kthread.h>
0012 
0013 struct worker_pool;
0014 
0015 /*
0016  * The poor guys doing the actual heavy lifting.  All on-duty workers are
0017  * either serving the manager role, on idle list or on busy hash.  For
0018  * details on the locking annotation (L, I, X...), refer to workqueue.c.
0019  *
0020  * Only to be used in workqueue and async.
0021  */
0022 struct worker {
0023     /* on idle list while idle, on busy hash table while busy */
0024     union {
0025         struct list_head    entry;  /* L: while idle */
0026         struct hlist_node   hentry; /* L: while busy */
0027     };
0028 
0029     struct work_struct  *current_work;  /* L: work being processed */
0030     work_func_t     current_func;   /* L: current_work's fn */
0031     struct pool_workqueue   *current_pwq; /* L: current_work's pwq */
0032     bool            desc_valid; /* ->desc is valid */
0033     struct list_head    scheduled;  /* L: scheduled works */
0034 
0035     /* 64 bytes boundary on 64bit, 32 on 32bit */
0036 
0037     struct task_struct  *task;      /* I: worker task */
0038     struct worker_pool  *pool;      /* I: the associated pool */
0039                         /* L: for rescuers */
0040     struct list_head    node;       /* A: anchored at pool->workers */
0041                         /* A: runs through worker->node */
0042 
0043     unsigned long       last_active;    /* L: last active timestamp */
0044     unsigned int        flags;      /* X: flags */
0045     int         id;     /* I: worker id */
0046 
0047     /*
0048      * Opaque string set with work_set_desc().  Printed out with task
0049      * dump for debugging - WARN, BUG, panic or sysrq.
0050      */
0051     char            desc[WORKER_DESC_LEN];
0052 
0053     /* used only by rescuers to point to the target workqueue */
0054     struct workqueue_struct *rescue_wq; /* I: the workqueue to rescue */
0055 };
0056 
0057 /**
0058  * current_wq_worker - return struct worker if %current is a workqueue worker
0059  */
0060 static inline struct worker *current_wq_worker(void)
0061 {
0062     if (current->flags & PF_WQ_WORKER)
0063         return kthread_data(current);
0064     return NULL;
0065 }
0066 
0067 /*
0068  * Scheduler hooks for concurrency managed workqueue.  Only to be used from
0069  * sched/core.c and workqueue.c.
0070  */
0071 void wq_worker_waking_up(struct task_struct *task, int cpu);
0072 struct task_struct *wq_worker_sleeping(struct task_struct *task);
0073 
0074 #endif /* _KERNEL_WORKQUEUE_INTERNAL_H */