mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/herbert/cryptodev-2.6.git
synced 2026-04-27 03:49:57 -04:00
treewide: Introduce kthread_run_worker[_on_cpu]()
kthread_create() creates a kthread without running it yet. kthread_run() creates a kthread and runs it. On the other hand, kthread_create_worker() creates a kthread worker and runs it. This difference in behaviours is confusing. Also there is no way to create a kthread worker and affine it using kthread_bind_mask() or kthread_affine_preferred() before starting it. Consolidate the behaviours and introduce kthread_run_worker[_on_cpu]() that behaves just like kthread_run(). kthread_create_worker[_on_cpu]() will now only create a kthread worker without starting it. Signed-off-by: Frederic Weisbecker <frederic@kernel.org> Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org>
This commit is contained in:
@@ -193,19 +193,53 @@ struct kthread_worker *kthread_create_worker_on_node(unsigned int flags,
|
||||
const char namefmt[], ...);
|
||||
|
||||
#define kthread_create_worker(flags, namefmt, ...) \
|
||||
({ \
|
||||
struct kthread_worker *__kw \
|
||||
= kthread_create_worker_on_node(flags, NUMA_NO_NODE, \
|
||||
namefmt, ## __VA_ARGS__); \
|
||||
if (!IS_ERR(__kw)) \
|
||||
wake_up_process(__kw->task); \
|
||||
__kw; \
|
||||
kthread_create_worker_on_node(flags, NUMA_NO_NODE, namefmt, ## __VA_ARGS__);
|
||||
|
||||
/**
|
||||
* kthread_run_worker - create and wake a kthread worker.
|
||||
* @flags: flags modifying the default behavior of the worker
|
||||
* @namefmt: printf-style name for the thread.
|
||||
*
|
||||
* Description: Convenient wrapper for kthread_create_worker() followed by
|
||||
* wake_up_process(). Returns the kthread_worker or ERR_PTR(-ENOMEM).
|
||||
*/
|
||||
#define kthread_run_worker(flags, namefmt, ...) \
|
||||
({ \
|
||||
struct kthread_worker *__kw \
|
||||
= kthread_create_worker(flags, namefmt, ## __VA_ARGS__); \
|
||||
if (!IS_ERR(__kw)) \
|
||||
wake_up_process(__kw->task); \
|
||||
__kw; \
|
||||
})
|
||||
|
||||
struct kthread_worker *
|
||||
kthread_create_worker_on_cpu(int cpu, unsigned int flags,
|
||||
const char namefmt[]);
|
||||
|
||||
/**
|
||||
* kthread_run_worker_on_cpu - create and wake a cpu bound kthread worker.
|
||||
* @cpu: CPU number
|
||||
* @flags: flags modifying the default behavior of the worker
|
||||
* @namefmt: printf-style name for the thread. Format is restricted
|
||||
* to "name.*%u". Code fills in cpu number.
|
||||
*
|
||||
* Description: Convenient wrapper for kthread_create_worker_on_cpu()
|
||||
* followed by wake_up_process(). Returns the kthread_worker or
|
||||
* ERR_PTR(-ENOMEM).
|
||||
*/
|
||||
static inline struct kthread_worker *
|
||||
kthread_run_worker_on_cpu(int cpu, unsigned int flags,
|
||||
const char namefmt[])
|
||||
{
|
||||
struct kthread_worker *kw;
|
||||
|
||||
kw = kthread_create_worker_on_cpu(cpu, flags, namefmt);
|
||||
if (!IS_ERR(kw))
|
||||
wake_up_process(kw->task);
|
||||
|
||||
return kw;
|
||||
}
|
||||
|
||||
bool kthread_queue_work(struct kthread_worker *worker,
|
||||
struct kthread_work *work);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user