MCPcopy Create free account
hub / github.com/F-Stack/f-stack / taskq_thread

Function taskq_thread

freebsd/contrib/openzfs/module/os/linux/spl/spl-taskq.c:855–1000  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

853}
854
855static int
856taskq_thread(void *args)
857{
858 DECLARE_WAITQUEUE(wait, current);
859 sigset_t blocked;
860 taskq_thread_t *tqt = args;
861 taskq_t *tq;
862 taskq_ent_t *t;
863 int seq_tasks = 0;
864 unsigned long flags;
865 taskq_ent_t dup_task = {};
866
867 ASSERT(tqt);
868 ASSERT(tqt->tqt_tq);
869 tq = tqt->tqt_tq;
870 current->flags |= PF_NOFREEZE;
871
872 (void) spl_fstrans_mark();
873
874 sigfillset(&blocked);
875 sigprocmask(SIG_BLOCK, &blocked, NULL);
876 flush_signals(current);
877
878 tsd_set(taskq_tsd, tq);
879 spin_lock_irqsave_nested(&tq->tq_lock, flags, tq->tq_lock_class);
880 /*
881 * If we are dynamically spawned, decrease spawning count. Note that
882 * we could be created during taskq_create, in which case we shouldn't
883 * do the decrement. But it's fine because taskq_create will reset
884 * tq_nspawn later.
885 */
886 if (tq->tq_flags & TASKQ_DYNAMIC)
887 tq->tq_nspawn--;
888
889 /* Immediately exit if more threads than allowed were created. */
890 if (tq->tq_nthreads >= tq->tq_maxthreads)
891 goto error;
892
893 tq->tq_nthreads++;
894 list_add_tail(&tqt->tqt_thread_list, &tq->tq_thread_list);
895 wake_up(&tq->tq_wait_waitq);
896 set_current_state(TASK_INTERRUPTIBLE);
897
898 while (!kthread_should_stop()) {
899
900 if (list_empty(&tq->tq_pend_list) &&
901 list_empty(&tq->tq_prio_list)) {
902
903 if (taskq_thread_should_stop(tq, tqt)) {
904 wake_up_all(&tq->tq_wait_waitq);
905 break;
906 }
907
908 add_wait_queue_exclusive(&tq->tq_work_waitq, &wait);
909 spin_unlock_irqrestore(&tq->tq_lock, flags);
910
911 schedule();
912 seq_tasks = 0;

Callers

nothing calls this directly

Calls 13

flush_signalsFunction · 0.85
list_emptyFunction · 0.85
taskq_thread_should_stopFunction · 0.85
taskq_next_entFunction · 0.85
list_del_initFunction · 0.85
taskq_insert_in_orderFunction · 0.85
task_doneFunction · 0.85
taskq_lowest_idFunction · 0.85
taskq_thread_spawnFunction · 0.85
tsd_setFunction · 0.70
spl_fstrans_markFunction · 0.50
list_add_tailFunction · 0.50

Tested by

no test coverage detected