Module Name:    src
Committed By:   riastradh
Date:           Wed Aug  9 08:23:35 UTC 2023

Modified Files:
        src/sys/kern: subr_workqueue.c

Log Message:
workqueue(9): Stop violating queue(3) internals.


To generate a diff of this commit:
cvs rdiff -u -r1.43 -r1.44 src/sys/kern/subr_workqueue.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/kern/subr_workqueue.c
diff -u src/sys/kern/subr_workqueue.c:1.43 src/sys/kern/subr_workqueue.c:1.44
--- src/sys/kern/subr_workqueue.c:1.43	Wed Aug  9 08:23:25 2023
+++ src/sys/kern/subr_workqueue.c	Wed Aug  9 08:23:35 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: subr_workqueue.c,v 1.43 2023/08/09 08:23:25 riastradh Exp $	*/
+/*	$NetBSD: subr_workqueue.c,v 1.44 2023/08/09 08:23:35 riastradh Exp $	*/
 
 /*-
  * Copyright (c)2002, 2005, 2006, 2007 YAMAMOTO Takashi,
@@ -27,7 +27,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: subr_workqueue.c,v 1.43 2023/08/09 08:23:25 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: subr_workqueue.c,v 1.44 2023/08/09 08:23:35 riastradh Exp $");
 
 #include <sys/param.h>
 #include <sys/cpu.h>
@@ -140,10 +140,6 @@ workqueue_runlist(struct workqueue *wq, 
 	work_impl_t *wk;
 	work_impl_t *next;
 
-	/*
-	 * note that "list" is not a complete SIMPLEQ.
-	 */
-
 	for (wk = SIMPLEQ_FIRST(list); wk != NULL; wk = next) {
 		next = SIMPLEQ_NEXT(wk, wk_entry);
 		SDT_PROBE4(sdt, kernel, workqueue, entry,
@@ -169,14 +165,12 @@ workqueue_worker(void *cookie)
 	for (;;) {
 		struct workqhead tmp;
 
-		/*
-		 * we violate abstraction of SIMPLEQ.
-		 */
+		SIMPLEQ_INIT(&tmp);
 
 		mutex_enter(&q->q_mutex);
 		while (SIMPLEQ_EMPTY(&q->q_queue_pending))
 			cv_wait(&q->q_cv, &q->q_mutex);
-		tmp.sqh_first = q->q_queue_pending.sqh_first; /* XXX */
+		SIMPLEQ_CONCAT(&tmp, &q->q_queue_pending);
 		SIMPLEQ_INIT(&q->q_queue_pending);
 
 		/*

Reply via email to