Module Name:    src
Committed By:   ozaki-r
Date:           Tue Jan 30 11:03:06 UTC 2018

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

Log Message:
Check if a queued work is tried to be enqueued again, which is not allowed


To generate a diff of this commit:
cvs rdiff -u -r1.34 -r1.35 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.34 src/sys/kern/subr_workqueue.c:1.35
--- src/sys/kern/subr_workqueue.c:1.34	Thu Dec 28 07:00:52 2017
+++ src/sys/kern/subr_workqueue.c	Tue Jan 30 11:03:06 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: subr_workqueue.c,v 1.34 2017/12/28 07:00:52 ozaki-r Exp $	*/
+/*	$NetBSD: subr_workqueue.c,v 1.35 2018/01/30 11:03:06 ozaki-r 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.34 2017/12/28 07:00:52 ozaki-r Exp $");
+__KERNEL_RCSID(0, "$NetBSD: subr_workqueue.c,v 1.35 2018/01/30 11:03:06 ozaki-r Exp $");
 
 #include <sys/param.h>
 #include <sys/cpu.h>
@@ -354,6 +354,19 @@ workqueue_destroy(struct workqueue *wq)
 	kmem_free(wq->wq_ptr, workqueue_size(wq->wq_flags));
 }
 
+#ifdef DEBUG
+static void
+workqueue_check_duplication(struct workqueue_queue *q, work_impl_t *wk)
+{
+	work_impl_t *_wk;
+
+	SIMPLEQ_FOREACH(_wk, &q->q_queue_pending, wk_entry) {
+		if (_wk == wk)
+			panic("%s: tried to enqueue a queued work", __func__);
+	}
+}
+#endif
+
 void
 workqueue_enqueue(struct workqueue *wq, struct work *wk0, struct cpu_info *ci)
 {
@@ -365,6 +378,9 @@ workqueue_enqueue(struct workqueue *wq, 
 
 	mutex_enter(&q->q_mutex);
 	KASSERT(q->q_waiter == NULL);
+#ifdef DEBUG
+	workqueue_check_duplication(q, wk);
+#endif
 	SIMPLEQ_INSERT_TAIL(&q->q_queue_pending, wk, wk_entry);
 	cv_signal(&q->q_cv);
 	mutex_exit(&q->q_mutex);

Reply via email to