io-wq: make io_wq_fork_thread() available to other users
We want to use this in io_uring proper as well, for the SQPOLL thread. Rename it from fork_thread() to io_wq_fork_thread(), and make it available through the io-wq.h header. Signed-off-by: Jens Axboe <axboe@kernel.dk>
This commit is contained in:
parent
bf1daa4bfc
commit
843bbfd49f
@ -592,7 +592,7 @@ static int task_thread_unbound(void *data)
|
|||||||
return task_thread(data, IO_WQ_ACCT_UNBOUND);
|
return task_thread(data, IO_WQ_ACCT_UNBOUND);
|
||||||
}
|
}
|
||||||
|
|
||||||
static pid_t fork_thread(int (*fn)(void *), void *arg)
|
pid_t io_wq_fork_thread(int (*fn)(void *), void *arg)
|
||||||
{
|
{
|
||||||
unsigned long flags = CLONE_FS|CLONE_FILES|CLONE_SIGHAND|CLONE_THREAD|
|
unsigned long flags = CLONE_FS|CLONE_FILES|CLONE_SIGHAND|CLONE_THREAD|
|
||||||
CLONE_IO|SIGCHLD;
|
CLONE_IO|SIGCHLD;
|
||||||
@ -622,9 +622,9 @@ static bool create_io_worker(struct io_wq *wq, struct io_wqe *wqe, int index)
|
|||||||
spin_lock_init(&worker->lock);
|
spin_lock_init(&worker->lock);
|
||||||
|
|
||||||
if (index == IO_WQ_ACCT_BOUND)
|
if (index == IO_WQ_ACCT_BOUND)
|
||||||
pid = fork_thread(task_thread_bound, worker);
|
pid = io_wq_fork_thread(task_thread_bound, worker);
|
||||||
else
|
else
|
||||||
pid = fork_thread(task_thread_unbound, worker);
|
pid = io_wq_fork_thread(task_thread_unbound, worker);
|
||||||
if (pid < 0) {
|
if (pid < 0) {
|
||||||
kfree(worker);
|
kfree(worker);
|
||||||
return false;
|
return false;
|
||||||
@ -1012,7 +1012,7 @@ struct io_wq *io_wq_create(unsigned bounded, struct io_wq_data *data)
|
|||||||
refcount_set(&wq->refs, 1);
|
refcount_set(&wq->refs, 1);
|
||||||
|
|
||||||
current->flags |= PF_IO_WORKER;
|
current->flags |= PF_IO_WORKER;
|
||||||
ret = fork_thread(io_wq_manager, wq);
|
ret = io_wq_fork_thread(io_wq_manager, wq);
|
||||||
current->flags &= ~PF_IO_WORKER;
|
current->flags &= ~PF_IO_WORKER;
|
||||||
if (ret >= 0) {
|
if (ret >= 0) {
|
||||||
wait_for_completion(&wq->done);
|
wait_for_completion(&wq->done);
|
||||||
|
@ -106,6 +106,8 @@ void io_wq_destroy(struct io_wq *wq);
|
|||||||
void io_wq_enqueue(struct io_wq *wq, struct io_wq_work *work);
|
void io_wq_enqueue(struct io_wq *wq, struct io_wq_work *work);
|
||||||
void io_wq_hash_work(struct io_wq_work *work, void *val);
|
void io_wq_hash_work(struct io_wq_work *work, void *val);
|
||||||
|
|
||||||
|
pid_t io_wq_fork_thread(int (*fn)(void *), void *arg);
|
||||||
|
|
||||||
static inline bool io_wq_is_hashed(struct io_wq_work *work)
|
static inline bool io_wq_is_hashed(struct io_wq_work *work)
|
||||||
{
|
{
|
||||||
return work->flags & IO_WQ_WORK_HASHED;
|
return work->flags & IO_WQ_WORK_HASHED;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user