Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/netbsd-7]: src/sys/dev/sysmon Pull up following revision(s) (requested b...
details: https://anonhg.NetBSD.org/src/rev/e79e7dbae196
branches: netbsd-7
changeset: 799178:e79e7dbae196
user: snj <snj%NetBSD.org@localhost>
date: Mon Apr 06 18:45:30 2015 +0000
description:
Pull up following revision(s) (requested by hannken in ticket #666):
sys/dev/sysmon/sysmon_envsys.c: revision 1.129
sys/dev/sysmon/sysmon_envsys_events.c: revision 1.114
sys/dev/sysmon/sysmonvar.h: revision 1.46
Add a counter of busy events and stop enqueueing more work if a device =
is busy.
Protect this counter with a new short time lock "sme_work_mtx" and
keep "sme_mtx" as long time lock.
Removes a deadlock where an active event holds "sme_mtx", the callout
"sme_events_check" blocks on "sme_mtx" and callout processing stops.
diffstat:
sys/dev/sysmon/sysmon_envsys.c | 6 ++++--
sys/dev/sysmon/sysmon_envsys_events.c | 21 +++++++++++++++++++--
sys/dev/sysmon/sysmonvar.h | 6 +++++-
3 files changed, 28 insertions(+), 5 deletions(-)
diffs (116 lines):
diff -r 0761fa8fff3d -r e79e7dbae196 sys/dev/sysmon/sysmon_envsys.c
--- a/sys/dev/sysmon/sysmon_envsys.c Mon Apr 06 02:03:15 2015 +0000
+++ b/sys/dev/sysmon/sysmon_envsys.c Mon Apr 06 18:45:30 2015 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: sysmon_envsys.c,v 1.127 2014/08/10 16:44:36 tls Exp $ */
+/* $NetBSD: sysmon_envsys.c,v 1.127.2.1 2015/04/06 18:45:30 snj Exp $ */
/*-
* Copyright (c) 2007, 2008 Juan Romero Pardines.
@@ -64,7 +64,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: sysmon_envsys.c,v 1.127 2014/08/10 16:44:36 tls Exp $");
+__KERNEL_RCSID(0, "$NetBSD: sysmon_envsys.c,v 1.127.2.1 2015/04/06 18:45:30 snj Exp $");
#include <sys/param.h>
#include <sys/types.h>
@@ -485,6 +485,7 @@
TAILQ_INIT(&sme->sme_sensors_list);
LIST_INIT(&sme->sme_events_list);
mutex_init(&sme->sme_mtx, MUTEX_DEFAULT, IPL_NONE);
+ mutex_init(&sme->sme_work_mtx, MUTEX_DEFAULT, IPL_NONE);
cv_init(&sme->sme_condvar, "sme_wait");
return sme;
@@ -508,6 +509,7 @@
TAILQ_REMOVE(&sme->sme_sensors_list, edata, sensors_head);
}
mutex_destroy(&sme->sme_mtx);
+ mutex_destroy(&sme->sme_work_mtx);
cv_destroy(&sme->sme_condvar);
kmem_free(sme, sizeof(*sme));
}
diff -r 0761fa8fff3d -r e79e7dbae196 sys/dev/sysmon/sysmon_envsys_events.c
--- a/sys/dev/sysmon/sysmon_envsys_events.c Mon Apr 06 02:03:15 2015 +0000
+++ b/sys/dev/sysmon/sysmon_envsys_events.c Mon Apr 06 18:45:30 2015 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: sysmon_envsys_events.c,v 1.110.4.1 2014/12/01 11:38:42 martin Exp $ */
+/* $NetBSD: sysmon_envsys_events.c,v 1.110.4.2 2015/04/06 18:45:30 snj Exp $ */
/*-
* Copyright (c) 2007, 2008 Juan Romero Pardines.
@@ -30,7 +30,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: sysmon_envsys_events.c,v 1.110.4.1 2014/12/01 11:38:42 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: sysmon_envsys_events.c,v 1.110.4.2 2015/04/06 18:45:30 snj Exp $");
#include <sys/param.h>
#include <sys/types.h>
@@ -42,6 +42,7 @@
#include <sys/mutex.h>
#include <sys/kmem.h>
#include <sys/callout.h>
+#include <sys/syslog.h>
#include <dev/sysmon/sysmonvar.h>
#include <dev/sysmon/sysmon_envsysvar.h>
@@ -712,11 +713,23 @@
KASSERT(sme != NULL);
+ mutex_enter(&sme->sme_work_mtx);
+ if (sme->sme_busy > 0) {
+ log(LOG_WARNING, "%s: workqueue busy: updates stopped\n",
+ sme->sme_name);
+ mutex_exit(&sme->sme_work_mtx);
+ return;
+ }
+ mutex_exit(&sme->sme_work_mtx);
+
mutex_enter(&sme->sme_mtx);
+ mutex_enter(&sme->sme_work_mtx);
LIST_FOREACH(see, &sme->sme_events_list, see_list) {
workqueue_enqueue(sme->sme_wq, &see->see_wk, NULL);
see->see_edata->flags |= ENVSYS_FNEED_REFRESH;
+ sme->sme_busy++;
}
+ mutex_exit(&sme->sme_work_mtx);
if (!sysmon_low_power)
sme_schedule_callout(sme);
mutex_exit(&sme->sme_mtx);
@@ -796,6 +809,10 @@
out:
see->see_flags &= ~SEE_EVENT_WORKING;
cv_broadcast(&sme->sme_condvar);
+ mutex_enter(&sme->sme_work_mtx);
+ KASSERT(sme->sme_busy > 0);
+ sme->sme_busy--;
+ mutex_exit(&sme->sme_work_mtx);
mutex_exit(&sme->sme_mtx);
}
diff -r 0761fa8fff3d -r e79e7dbae196 sys/dev/sysmon/sysmonvar.h
--- a/sys/dev/sysmon/sysmonvar.h Mon Apr 06 02:03:15 2015 +0000
+++ b/sys/dev/sysmon/sysmonvar.h Mon Apr 06 18:45:30 2015 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: sysmonvar.h,v 1.44.12.1 2014/12/01 11:38:42 martin Exp $ */
+/* $NetBSD: sysmonvar.h,v 1.44.12.2 2015/04/06 18:45:30 snj Exp $ */
/*-
* Copyright (c) 2000 Zembu Labs, Inc.
@@ -207,7 +207,11 @@
/*
* Locking/synchronization.
*/
+ int sme_busy; /* number of items on workqueue,
+ sme_mtx or sme_work_mtx to read,
+ both to write */
kmutex_t sme_mtx;
+ kmutex_t sme_work_mtx;
kcondvar_t sme_condvar;
};
Home |
Main Index |
Thread Index |
Old Index