diff options
author | jkoshy <jkoshy@FreeBSD.org> | 2005-07-09 17:29:36 +0000 |
---|---|---|
committer | jkoshy <jkoshy@FreeBSD.org> | 2005-07-09 17:29:36 +0000 |
commit | 5347c3345e3e5d6903a225ccf0da3c83800f49ec (patch) | |
tree | 9f3f9763bb2a5ec73a7aafb28592beedb2767211 /sys/dev/hwpmc/hwpmc_logging.c | |
parent | a9a2668bf2dea09c72c2e42e5d504e3230c15ce3 (diff) | |
download | FreeBSD-src-5347c3345e3e5d6903a225ccf0da3c83800f49ec.zip FreeBSD-src-5347c3345e3e5d6903a225ccf0da3c83800f49ec.tar.gz |
sys/dev/hwpmc/hwpmc_{amd,piv,ppro}.c:
- Update driver interrupt statistics correctly.
sys/sys/pmc.h, sys/dev/hwpmc/hwpmc_mod.c:
- Fix a bug affecting debug printfs.
- Move the 'stalled' flag from being in a bit in the
'pm_flags' field of a 'struct pmc' to a field of its own in the
same structure. This flag is updated from the NMI handler and
keeping it separate makes it easier to avoid races with other
parts of the code.
sys/dev/hwpmc/hwpmc_logging.c:
- Do arithmetic with 'uintptr_t' types rather that casting
to and from 'char *'.
Approved by: re (scottl)
Diffstat (limited to 'sys/dev/hwpmc/hwpmc_logging.c')
-rw-r--r-- | sys/dev/hwpmc/hwpmc_logging.c | 34 |
1 files changed, 20 insertions, 14 deletions
diff --git a/sys/dev/hwpmc/hwpmc_logging.c b/sys/dev/hwpmc/hwpmc_logging.c index bca14bd..8b6f376 100644 --- a/sys/dev/hwpmc/hwpmc_logging.c +++ b/sys/dev/hwpmc/hwpmc_logging.c @@ -97,6 +97,11 @@ static struct mtx pmc_kthread_mtx; /* sleep lock */ * Log file record constructors. */ +#define _PMCLOG_TO_HEADER(T,L) \ + ((PMCLOG_HEADER_MAGIC << 24) | \ + (PMCLOG_TYPE_ ## T << 16) | \ + ((L) & 0xFFFF)) + /* reserve LEN bytes of space and initialize the entry header */ #define _PMCLOG_RESERVE(PO,TYPE,LEN,ACTION) do { \ uint32_t *_le; \ @@ -104,9 +109,7 @@ static struct mtx pmc_kthread_mtx; /* sleep lock */ if ((_le = pmclog_reserve((PO), _len)) == NULL) { \ ACTION; \ } \ - *_le = (PMCLOG_HEADER_MAGIC << 24) | \ - (PMCLOG_TYPE_ ## TYPE << 16) | \ - (_len & 0xFFFF); \ + *_le = _PMCLOG_TO_HEADER(TYPE,_len); \ _le += 3 /* skip over timestamp */ #define PMCLOG_RESERVE(P,T,L) _PMCLOG_RESERVE(P,T,L,return) @@ -397,7 +400,7 @@ pmclog_release(struct pmc_owner *po) static uint32_t * pmclog_reserve(struct pmc_owner *po, int length) { - char *newptr, *oldptr; + uintptr_t newptr, oldptr; uint32_t *lh; struct timespec ts; @@ -423,22 +426,25 @@ pmclog_reserve(struct pmc_owner *po, int length) __LINE__, po, po->po_curbuf->plb_ptr, po->po_curbuf->plb_base, po->po_curbuf->plb_fence)); - oldptr = po->po_curbuf->plb_ptr; + oldptr = (uintptr_t) po->po_curbuf->plb_ptr; newptr = oldptr + length; - KASSERT(oldptr != NULL, + KASSERT(oldptr != (uintptr_t) NULL, ("[pmc,%d] po=%p Null log buffer pointer", __LINE__, po)); /* * If we have space in the current buffer, return a pointer to * available space with the PO structure locked. */ - if (newptr <= po->po_curbuf->plb_fence) { - po->po_curbuf->plb_ptr = newptr; + if (newptr <= (uintptr_t) po->po_curbuf->plb_fence) { + po->po_curbuf->plb_ptr = (char *) newptr; goto done; } - /* otherwise, schedule the current buffer and get a fresh buffer */ + /* + * Otherwise, schedule the current buffer for output and get a + * fresh buffer. + */ pmclog_schedule_io(po); if (pmclog_get_buffer(po) != 0) { @@ -458,12 +464,12 @@ pmclog_reserve(struct pmc_owner *po, int length) __LINE__, po, po->po_curbuf->plb_ptr, po->po_curbuf->plb_base, po->po_curbuf->plb_fence)); - oldptr = po->po_curbuf->plb_ptr; + oldptr = (uintptr_t) po->po_curbuf->plb_ptr; done: - lh = (uint32_t *) oldptr; lh++; - /* fill in the timestamp */ - getnanotime(&ts); + lh = (uint32_t *) oldptr; + lh++; /* skip header */ + getnanotime(&ts); /* fill in the timestamp */ *lh++ = ts.tv_sec & 0xFFFFFFFF; *lh++ = ts.tv_nsec & 0xFFFFFFF; return (uint32_t *) oldptr; @@ -517,7 +523,7 @@ pmclog_stop_kthread(struct pmc_owner *po) po->po_flags &= ~PMC_PO_OWNS_LOGFILE; wakeup_one(po); if (po->po_kthread) - msleep(po->po_kthread, &pmc_kthread_mtx, PPAUSE, "pmcdcl", 0); + msleep(po->po_kthread, &pmc_kthread_mtx, PPAUSE, "pmckstp", 0); } /* |