summaryrefslogtreecommitdiff
path: root/sys/dev/sysmon
diff options
context:
space:
mode:
authorpgoyette <pgoyette@NetBSD.org>2009-07-10 15:27:33 +0000
committerpgoyette <pgoyette@NetBSD.org>2009-07-10 15:27:33 +0000
commitd36ea2afc50cbc23d1aa8f3b3c1ccdd5e8c23648 (patch)
tree7823aed1dacb4b81a1d7367f4bde69c427584502 /sys/dev/sysmon
parent0fab9769e497e05b4b274e01253ff36bc0ecb9be (diff)
Document usage of PROP_DRIVER_LIMITS flag and set it correctly.
Use flag bits to determine validity of limit values, rather than assuming that invalid/not-present values are set to zero.
Diffstat (limited to 'sys/dev/sysmon')
-rw-r--r--sys/dev/sysmon/sysmon_envsys_events.c43
1 files changed, 31 insertions, 12 deletions
diff --git a/sys/dev/sysmon/sysmon_envsys_events.c b/sys/dev/sysmon/sysmon_envsys_events.c
index f5c33eb67cf..28c4f95dce5 100644
--- a/sys/dev/sysmon/sysmon_envsys_events.c
+++ b/sys/dev/sysmon/sysmon_envsys_events.c
@@ -1,4 +1,4 @@
-/* $NetBSD: sysmon_envsys_events.c,v 1.70 2009/07/08 17:28:53 pgoyette Exp $ */
+/* $NetBSD: sysmon_envsys_events.c,v 1.71 2009/07/10 15:27:33 pgoyette 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.70 2009/07/08 17:28:53 pgoyette Exp $");
+__KERNEL_RCSID(0, "$NetBSD: sysmon_envsys_events.c,v 1.71 2009/07/10 15:27:33 pgoyette Exp $");
#include <sys/param.h>
#include <sys/types.h>
@@ -480,15 +480,30 @@ do { \
} \
} while (/* CONSTCOND */ 0)
+ /*
+ * If driver provides method to retrieve its internal limit
+ * values, call it. If it returns any values, set the flag
+ * PROP_DRIVER_LIMITS to indicate that the driver can process
+ * all the limits we have. (If userland limits are specified
+ * later and the driver cannot handle them, this flag will be
+ * cleared.)
+ *
+ * If the driver cannot or does not provide us with limit values
+ * we cannot monitor limits now; we get another chance to create
+ * the FMONLIMITS entry later if userland specifies some limits.
+ */
lims.sel_flags = 0;
- if (sed_t->sed_edata->flags & ENVSYS_FMONLIMITS) {
+ if (sed_t->sed_edata->flags & ENVSYS_FMONLIMITS)
if (sed_t->sed_sme->sme_get_limits)
(*sed_t->sed_sme->sme_get_limits)(sed_t->sed_sme,
sed_t->sed_edata,
&lims);
- else
- sed_t->sed_edata->flags &= ~ENVSYS_FMONLIMITS;
- }
+ if (lims.sel_flags)
+ lims.sel_flags |= PROP_DRIVER_LIMITS;
+ else
+ sed_t->sed_edata->flags &= ~ENVSYS_FMONLIMITS;
+
+ /* Register the events that were specified */
SEE_REGEVENT(ENVSYS_FMONCRITICAL,
PENVSYS_EVENT_CRITICAL,
@@ -645,18 +660,22 @@ sme_events_worker(struct work *wk, void *arg)
*/
case PENVSYS_EVENT_LIMITS:
case PENVSYS_EVENT_CAPACITY:
-#define __EXCEED_LIM(lim, rel) ((lim) && edata->value_cur rel (lim))
+#define __EXCEED_LIM(valid, lim, rel) \
+ ((see->see_lims.sel_flags & (valid)) && \
+ (edata->value_cur rel (see->see_lims.lim)))
+
if ((see->see_lims.sel_flags & PROP_DRIVER_LIMITS) == 0) {
- if __EXCEED_LIM(see->see_lims.sel_critmin, <)
+ if __EXCEED_LIM(PROP_CRITMIN | PROP_BATTCAP,
+ sel_critmin, <)
edata->state = ENVSYS_SCRITUNDER;
- else if __EXCEED_LIM(see->see_lims.sel_warnmin, <)
+ else if __EXCEED_LIM(PROP_WARNMIN | PROP_BATTWARN,
+ sel_warnmin, <)
edata->state = ENVSYS_SWARNUNDER;
- else if __EXCEED_LIM(see->see_lims.sel_warnmax, >)
+ else if __EXCEED_LIM(PROP_WARNMAX, sel_warnmax, >)
edata->state = ENVSYS_SWARNOVER;
- else if __EXCEED_LIM(see->see_lims.sel_critmax, >)
+ else if __EXCEED_LIM(PROP_CRITMAX, sel_critmax, >)
edata->state = ENVSYS_SCRITOVER;
}
- /* FALLTHROUGH */
#undef __EXCEED_LIM
/*