Source-Changes-HG archive

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

[src/trunk]: src/sys/external/bsd/common/linux Fully initialize workqueue str...



details:   https://anonhg.NetBSD.org/src/rev/1b9bfe1f932c
branches:  trunk
changeset: 993054:1b9bfe1f932c
user:      riastradh <riastradh%NetBSD.org@localhost>
date:      Mon Aug 27 15:02:38 2018 +0000

description:
Fully initialize workqueue struct. Zalloc for paranoia.

diffstat:

 sys/external/bsd/common/linux/linux_work.c |  14 +++++++++++---
 1 files changed, 11 insertions(+), 3 deletions(-)

diffs (48 lines):

diff -r 19b8f6143fb8 -r 1b9bfe1f932c sys/external/bsd/common/linux/linux_work.c
--- a/sys/external/bsd/common/linux/linux_work.c        Mon Aug 27 15:02:19 2018 +0000
+++ b/sys/external/bsd/common/linux/linux_work.c        Mon Aug 27 15:02:38 2018 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: linux_work.c,v 1.24 2018/08/27 15:02:19 riastradh Exp $        */
+/*     $NetBSD: linux_work.c,v 1.25 2018/08/27 15:02:38 riastradh Exp $        */
 
 /*-
  * Copyright (c) 2018 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: linux_work.c,v 1.24 2018/08/27 15:02:19 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: linux_work.c,v 1.25 2018/08/27 15:02:38 riastradh Exp $");
 
 #include <sys/types.h>
 #include <sys/atomic.h>
@@ -136,13 +136,18 @@
 
        KASSERT(flags == 0);
 
-       wq = kmem_alloc(sizeof(*wq), KM_SLEEP);
+       wq = kmem_zalloc(sizeof(*wq), KM_SLEEP);
 
        mutex_init(&wq->wq_lock, MUTEX_DEFAULT, IPL_NONE);
        cv_init(&wq->wq_cv, name);
        TAILQ_INIT(&wq->wq_delayed);
        TAILQ_INIT(&wq->wq_queue);
        wq->wq_current_work = NULL;
+       wq->wq_flags = 0;
+       wq->wq_lwp = NULL;
+       wq->wq_gen = 0;
+       wq->wq_requeued = false;
+       wq->wq_dying = false;
 
        error = kthread_create(PRI_NONE,
            KTHREAD_MPSAFE|KTHREAD_TS|KTHREAD_MUSTJOIN, NULL,
@@ -194,6 +199,9 @@
        /* Wait for it to exit.  */
        (void)kthread_join(wq->wq_lwp);
 
+       KASSERT(wq->wq_dying);
+       KASSERT(!wq->wq_requeued);
+       KASSERT(wq->wq_flags == 0);
        KASSERT(wq->wq_current_work == NULL);
        KASSERT(TAILQ_EMPTY(&wq->wq_queue));
        KASSERT(TAILQ_EMPTY(&wq->wq_delayed));



Home | Main Index | Thread Index | Old Index