NetBSD-Bugs archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: kern/55948: threadpool_job_cancelthrash test randomly fails



Try the attached patch?
diff -r 859d0e5ac5a2 sys/kern/kern_threadpool.c
--- a/sys/kern/kern_threadpool.c	Sun Jan 17 22:02:46 2021 +0000
+++ b/sys/kern/kern_threadpool.c	Sat Jan 23 15:40:39 2021 +0000
@@ -1041,7 +1041,7 @@ threadpool_dispatcher_thread(void *arg)
 
 		/* There are idle threads, so try giving one a job.  */
 		struct threadpool_job *const job = TAILQ_FIRST(&pool->tp_jobs);
-		TAILQ_REMOVE(&pool->tp_jobs, job, job_entry);
+
 		/*
 		 * Take an extra reference on the job temporarily so that
 		 * it won't disappear on us while we have both locks dropped.
@@ -1053,6 +1053,7 @@ threadpool_dispatcher_thread(void *arg)
 		/* If the job was cancelled, we'll no longer be its thread.  */
 		if (__predict_true(job->job_thread == dispatcher)) {
 			mutex_spin_enter(&pool->tp_lock);
+			TAILQ_REMOVE(&pool->tp_jobs, job, job_entry);
 			if (__predict_false(
 				    TAILQ_EMPTY(&pool->tp_idle_threads))) {
 				/*


Home | Main Index | Thread Index | Old Index