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 Implement return value of flus...



details:   https://anonhg.NetBSD.org/src/rev/9747a96bb3e8
branches:  trunk
changeset: 1027884:9747a96bb3e8
user:      riastradh <riastradh%NetBSD.org@localhost>
date:      Sun Dec 19 01:03:57 2021 +0000

description:
Implement return value of flush_work, flush_delayed_work.

diffstat:

 sys/external/bsd/common/include/linux/workqueue.h |   6 +++---
 sys/external/bsd/common/linux/linux_work.c        |  21 +++++++++++++++------
 2 files changed, 18 insertions(+), 9 deletions(-)

diffs (105 lines):

diff -r c6c258cce659 -r 9747a96bb3e8 sys/external/bsd/common/include/linux/workqueue.h
--- a/sys/external/bsd/common/include/linux/workqueue.h Sun Dec 19 01:03:50 2021 +0000
+++ b/sys/external/bsd/common/include/linux/workqueue.h Sun Dec 19 01:03:57 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: workqueue.h,v 1.15 2021/12/19 01:03:50 riastradh Exp $ */
+/*     $NetBSD: workqueue.h,v 1.16 2021/12/19 01:03:57 riastradh Exp $ */
 
 /*-
  * Copyright (c) 2013, 2018 The NetBSD Foundation, Inc.
@@ -110,7 +110,7 @@
 bool   queue_work(struct workqueue_struct *, struct work_struct *);
 bool   cancel_work(struct work_struct *);
 bool   cancel_work_sync(struct work_struct *);
-void   flush_work(struct work_struct *);
+bool   flush_work(struct work_struct *);
 
 void   INIT_DELAYED_WORK(struct delayed_work *,
            void (*)(struct work_struct *));
@@ -121,7 +121,7 @@
            unsigned long ticks);
 bool   cancel_delayed_work(struct delayed_work *);
 bool   cancel_delayed_work_sync(struct delayed_work *);
-void   flush_delayed_work(struct delayed_work *);
+bool   flush_delayed_work(struct delayed_work *);
 
 struct work_struct *
        current_work(void);
diff -r c6c258cce659 -r 9747a96bb3e8 sys/external/bsd/common/linux/linux_work.c
--- a/sys/external/bsd/common/linux/linux_work.c        Sun Dec 19 01:03:50 2021 +0000
+++ b/sys/external/bsd/common/linux/linux_work.c        Sun Dec 19 01:03:57 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: linux_work.c,v 1.47 2021/12/19 00:49:00 riastradh Exp $        */
+/*     $NetBSD: linux_work.c,v 1.48 2021/12/19 01:03:57 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.47 2021/12/19 00:49:00 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: linux_work.c,v 1.48 2021/12/19 01:03:57 riastradh Exp $");
 
 #include <sys/types.h>
 #include <sys/atomic.h>
@@ -1430,17 +1430,21 @@
  *
  *     If work is queued or currently executing, wait for it to
  *     complete.
+ *
+ *     Return true if we waited to flush it, false if it was already
+ *     idle.
  */
-void
+bool
 flush_work(struct work_struct *work)
 {
        struct workqueue_struct *wq;
 
        /* If there's no workqueue, nothing to flush.  */
        if ((wq = work_queue(work)) == NULL)
-               return;
+               return false;
 
        flush_workqueue(wq);
+       return true;
 }
 
 /*
@@ -1450,14 +1454,15 @@
  *     instead.  Then, if dw is queued or currently executing, wait
  *     for it to complete.
  */
-void
+bool
 flush_delayed_work(struct delayed_work *dw)
 {
        struct workqueue_struct *wq;
+       bool waited = false;
 
        /* If there's no workqueue, nothing to flush.  */
        if ((wq = work_queue(&dw->work)) == NULL)
-               return;
+               return false;
 
        mutex_enter(&wq->wq_lock);
        if (__predict_false(work_queue(&dw->work) != wq)) {
@@ -1466,6 +1471,7 @@
                 * queue, though that would be ill-advised), so it must
                 * have completed, and we have nothing more to do.
                 */
+               waited = false;
        } else {
                switch (dw->dw_state) {
                case DELAYED_WORK_IDLE:
@@ -1514,6 +1520,9 @@
                 * but doesn't hurt.
                 */
                flush_workqueue_locked(wq);
+               waited = true;
        }
        mutex_exit(&wq->wq_lock);
+
+       return waited;
 }



Home | Main Index | Thread Index | Old Index