Index: head/sys/kern/dtio_kdtrace.c =================================================================== --- head/sys/kern/dtio_kdtrace.c (revision 257036) +++ head/sys/kern/dtio_kdtrace.c (nonexistent) @@ -1,232 +0,0 @@ -/*- - * Copyright (c) 2012 Advanced Computing Technologies LLC - * Written by George Neville-Neil gnn@freebsd.org - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#include -__FBSDID("$FreeBSD$"); - -#include -#include -#include -#include -#include -#include - -#include -#include "../sys/dtrace_bsd.h" - - -static int dtio_unload(void); -static void dtio_getargdesc(void *, dtrace_id_t, void *, - dtrace_argdesc_t *); -static void dtio_provide(void *, dtrace_probedesc_t *); -static void dtio_destroy(void *, dtrace_id_t, void *); -static void dtio_enable(void *, dtrace_id_t, void *); -static void dtio_disable(void *, dtrace_id_t, void *); -static void dtio_load(void *); - -static dtrace_pattr_t dtio_attr = { -{ DTRACE_STABILITY_STABLE, DTRACE_STABILITY_STABLE, DTRACE_CLASS_COMMON }, -{ DTRACE_STABILITY_PRIVATE, DTRACE_STABILITY_PRIVATE, DTRACE_CLASS_UNKNOWN }, -{ DTRACE_STABILITY_PRIVATE, DTRACE_STABILITY_PRIVATE, DTRACE_CLASS_UNKNOWN }, -{ DTRACE_STABILITY_STABLE, DTRACE_STABILITY_STABLE, DTRACE_CLASS_COMMON }, -{ DTRACE_STABILITY_STABLE, DTRACE_STABILITY_STABLE, DTRACE_CLASS_COMMON }, -}; - -static char *kernel = "kernel"; - -/* - * Name strings. - */ -static char *dtio_start_str = "start"; -static char *dtio_done_str = "done"; -static char *dtio_wait_start_str = "wait-start"; -static char *dtio_wait_done_str = "wait-done"; - -static dtrace_pops_t dtio_pops = { - dtio_provide, - NULL, - dtio_enable, - dtio_disable, - NULL, - NULL, - dtio_getargdesc, - NULL, - NULL, - dtio_destroy -}; - -static dtrace_provider_id_t dtio_id; - -extern uint32_t dtio_start_id; -extern uint32_t dtio_done_id; -extern uint32_t dtio_wait_start_id; -extern uint32_t dtio_wait_done_id; - -static void -dtio_getargdesc(void *arg, dtrace_id_t id, void *parg, - dtrace_argdesc_t *desc) -{ - const char *p = NULL; - - switch (desc->dtargd_ndx) { - case 0: - p = "struct bio *"; - break; - case 1: - p = "struct devstat *"; - break; - default: - desc->dtargd_ndx = DTRACE_ARGNONE; - } - - if (p != NULL) - strlcpy(desc->dtargd_native, p, sizeof(desc->dtargd_native)); -} - -static void -dtio_provide(void *arg, dtrace_probedesc_t *desc) -{ - if (desc != NULL) - return; - - if (dtrace_probe_lookup(dtio_id, kernel, NULL, - dtio_start_str) == 0) { - dtio_start_id = dtrace_probe_create(dtio_id, kernel, NULL, - dtio_start_str, 0, NULL); - } - if (dtrace_probe_lookup(dtio_id, kernel, NULL, dtio_done_str) == 0) { - dtio_done_id = dtrace_probe_create(dtio_id, kernel, NULL, - dtio_done_str, 0, NULL); - } - if (dtrace_probe_lookup(dtio_id, kernel, NULL, - dtio_wait_start_str) == 0) { - dtio_wait_start_id = dtrace_probe_create(dtio_id, kernel, - NULL, - dtio_wait_start_str, - 0, NULL); - } - if (dtrace_probe_lookup(dtio_id, kernel, NULL, - dtio_wait_done_str) == 0) { - dtio_wait_done_id = dtrace_probe_create(dtio_id, kernel, NULL, - dtio_wait_done_str, 0, NULL); - } - -} - -static void -dtio_destroy(void *arg, dtrace_id_t id, void *parg) -{ -} - -static void -dtio_enable(void *arg, dtrace_id_t id, void *parg) -{ - if (id == dtio_start_id) - dtrace_io_start_probe = - (dtrace_io_start_probe_func_t)dtrace_probe; - else if (id == dtio_done_id) - dtrace_io_done_probe = - (dtrace_io_done_probe_func_t)dtrace_probe; - else if (id == dtio_wait_start_id) - dtrace_io_wait_start_probe = - (dtrace_io_wait_start_probe_func_t)dtrace_probe; - else if (id == dtio_wait_done_id) - dtrace_io_wait_done_probe = - (dtrace_io_wait_done_probe_func_t)dtrace_probe; - else - printf("dtrace io provider: unknown ID\n"); - -} - -static void -dtio_disable(void *arg, dtrace_id_t id, void *parg) -{ - if (id == dtio_start_id) - dtrace_io_start_probe = NULL; - else if (id == dtio_done_id) - dtrace_io_done_probe = NULL; - else if (id == dtio_wait_start_id) - dtrace_io_wait_start_probe = NULL; - else if (id == dtio_wait_done_id) - dtrace_io_wait_done_probe = NULL; - else - printf("dtrace io provider: unknown ID\n"); - -} - -static void -dtio_load(void *dummy) -{ - if (dtrace_register("io", &dtio_attr, DTRACE_PRIV_USER, NULL, - &dtio_pops, NULL, &dtio_id) != 0) - return; -} - - -static int -dtio_unload() -{ - dtrace_io_start_probe = NULL; - dtrace_io_done_probe = NULL; - dtrace_io_wait_start_probe = NULL; - dtrace_io_wait_done_probe = NULL; - - return (dtrace_unregister(dtio_id)); -} - -static int -dtio_modevent(module_t mod __unused, int type, void *data __unused) -{ - int error = 0; - - switch (type) { - case MOD_LOAD: - break; - - case MOD_UNLOAD: - break; - - case MOD_SHUTDOWN: - break; - - default: - error = EOPNOTSUPP; - break; - } - - return (error); -} - -SYSINIT(dtio_load, SI_SUB_DTRACE_PROVIDER, SI_ORDER_ANY, - dtio_load, NULL); -SYSUNINIT(dtio_unload, SI_SUB_DTRACE_PROVIDER, SI_ORDER_ANY, - dtio_unload, NULL); - -DEV_MODULE(dtio, dtio_modevent, NULL); -MODULE_VERSION(dtio, 1); -MODULE_DEPEND(dtio, dtrace, 1, 1, 1); -MODULE_DEPEND(dtio, opensolaris, 1, 1, 1); Property changes on: head/sys/kern/dtio_kdtrace.c ___________________________________________________________________ Deleted: svn:eol-style ## -1 +0,0 ## -native \ No newline at end of property Deleted: svn:keywords ## -1 +0,0 ## -FreeBSD=%H \ No newline at end of property Deleted: svn:mime-type ## -1 +0,0 ## -text/plain \ No newline at end of property Index: head/sys/kern/subr_devstat.c =================================================================== --- head/sys/kern/subr_devstat.c (revision 257036) +++ head/sys/kern/subr_devstat.c (revision 257037) @@ -1,613 +1,578 @@ /*- * Copyright (c) 1997, 1998, 1999 Kenneth D. Merry. * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. The name of the author may not be used to endorse or promote products * derived from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. */ #include __FBSDID("$FreeBSD$"); #include "opt_kdtrace.h" #include #include #include #include #include +#include #include #include #include #include #include #include #include #include -#ifdef KDTRACE_HOOKS -#include +SDT_PROVIDER_DEFINE(io); -dtrace_io_start_probe_func_t dtrace_io_start_probe; -dtrace_io_done_probe_func_t dtrace_io_done_probe; -dtrace_io_wait_start_probe_func_t dtrace_io_wait_start_probe; -dtrace_io_wait_done_probe_func_t dtrace_io_wait_done_probe; +SDT_PROBE_DEFINE2(io, , , start, start, "struct bio *", "struct devstat *"); +SDT_PROBE_DEFINE2(io, , , done, done, "struct bio *", "struct devstat *"); +SDT_PROBE_DEFINE2(io, , , wait_start, wait-start, "struct bio *", + "struct devstat *"); +SDT_PROBE_DEFINE2(io, , , wait_done, wait-done, "struct bio *", + "struct devstat *"); -uint32_t dtio_start_id; -uint32_t dtio_done_id; -uint32_t dtio_wait_start_id; -uint32_t dtio_wait_done_id; - -#define DTRACE_DEVSTAT_START() \ - if (dtrace_io_start_probe != NULL) \ - (*dtrace_io_start_probe)(dtio_start_id, NULL, ds); - -#define DTRACE_DEVSTAT_BIO_START() \ - if (dtrace_io_start_probe != NULL) \ - (*dtrace_io_start_probe)(dtio_start_id, bp, ds); - -#define DTRACE_DEVSTAT_DONE() \ - if (dtrace_io_done_probe != NULL) \ - (*dtrace_io_done_probe)(dtio_done_id, NULL, ds); - -#define DTRACE_DEVSTAT_BIO_DONE() \ - if (dtrace_io_done_probe != NULL) \ - (*dtrace_io_done_probe)(dtio_done_id, bp, ds); - -#define DTRACE_DEVSTAT_WAIT_START() \ - if (dtrace_io_wait_start_probe != NULL) \ - (*dtrace_io_wait_start_probe)(dtio_wait_start_id, NULL, ds); - -#define DTRACE_DEVSTAT_WAIT_DONE() \ - if (dtrace_io_wait_done_probe != NULL) \ - (*dtrace_io_wait_done_probe)(dtio_wait_done_id, NULL, ds); - -#else /* ! KDTRACE_HOOKS */ - -#define DTRACE_DEVSTAT_START() - -#define DTRACE_DEVSTAT_BIO_START() - -#define DTRACE_DEVSTAT_DONE() - -#define DTRACE_DEVSTAT_BIO_DONE() - -#define DTRACE_DEVSTAT_WAIT_START() - -#define DTRACE_DEVSTAT_WAIT_DONE() -#endif /* KDTRACE_HOOKS */ +#define DTRACE_DEVSTAT_START() SDT_PROBE2(io, , , start, NULL, ds) +#define DTRACE_DEVSTAT_BIO_START() SDT_PROBE2(io, , , start, bp, ds) +#define DTRACE_DEVSTAT_DONE() SDT_PROBE2(io, , , done, NULL, ds) +#define DTRACE_DEVSTAT_BIO_DONE() SDT_PROBE2(io, , , done, bp, ds) +#define DTRACE_DEVSTAT_WAIT_START() SDT_PROBE2(io, , , wait_start, NULL, ds) +#define DTRACE_DEVSTAT_WAIT_DONE() SDT_PROBE2(io, , , wait_done, NULL, ds) static int devstat_num_devs; static long devstat_generation = 1; static int devstat_version = DEVSTAT_VERSION; static int devstat_current_devnumber; static struct mtx devstat_mutex; MTX_SYSINIT(devstat_mutex, &devstat_mutex, "devstat", MTX_DEF); static struct devstatlist device_statq = STAILQ_HEAD_INITIALIZER(device_statq); static struct devstat *devstat_alloc(void); static void devstat_free(struct devstat *); static void devstat_add_entry(struct devstat *ds, const void *dev_name, int unit_number, uint32_t block_size, devstat_support_flags flags, devstat_type_flags device_type, devstat_priority priority); /* * Allocate a devstat and initialize it */ struct devstat * devstat_new_entry(const void *dev_name, int unit_number, uint32_t block_size, devstat_support_flags flags, devstat_type_flags device_type, devstat_priority priority) { struct devstat *ds; mtx_assert(&devstat_mutex, MA_NOTOWNED); ds = devstat_alloc(); mtx_lock(&devstat_mutex); if (unit_number == -1) { ds->unit_number = unit_number; ds->id = dev_name; binuptime(&ds->creation_time); devstat_generation++; } else { devstat_add_entry(ds, dev_name, unit_number, block_size, flags, device_type, priority); } mtx_unlock(&devstat_mutex); return (ds); } /* * Take a malloced and zeroed devstat structure given to us, fill it in * and add it to the queue of devices. */ static void devstat_add_entry(struct devstat *ds, const void *dev_name, int unit_number, uint32_t block_size, devstat_support_flags flags, devstat_type_flags device_type, devstat_priority priority) { struct devstatlist *devstat_head; struct devstat *ds_tmp; mtx_assert(&devstat_mutex, MA_OWNED); devstat_num_devs++; devstat_head = &device_statq; /* * Priority sort. Each driver passes in its priority when it adds * its devstat entry. Drivers are sorted first by priority, and * then by probe order. * * For the first device, we just insert it, since the priority * doesn't really matter yet. Subsequent devices are inserted into * the list using the order outlined above. */ if (devstat_num_devs == 1) STAILQ_INSERT_TAIL(devstat_head, ds, dev_links); else { STAILQ_FOREACH(ds_tmp, devstat_head, dev_links) { struct devstat *ds_next; ds_next = STAILQ_NEXT(ds_tmp, dev_links); /* * If we find a break between higher and lower * priority items, and if this item fits in the * break, insert it. This also applies if the * "lower priority item" is the end of the list. */ if ((priority <= ds_tmp->priority) && ((ds_next == NULL) || (priority > ds_next->priority))) { STAILQ_INSERT_AFTER(devstat_head, ds_tmp, ds, dev_links); break; } else if (priority > ds_tmp->priority) { /* * If this is the case, we should be able * to insert ourselves at the head of the * list. If we can't, something is wrong. */ if (ds_tmp == STAILQ_FIRST(devstat_head)) { STAILQ_INSERT_HEAD(devstat_head, ds, dev_links); break; } else { STAILQ_INSERT_TAIL(devstat_head, ds, dev_links); printf("devstat_add_entry: HELP! " "sorting problem detected " "for name %p unit %d\n", dev_name, unit_number); break; } } } } ds->device_number = devstat_current_devnumber++; ds->unit_number = unit_number; strlcpy(ds->device_name, dev_name, DEVSTAT_NAME_LEN); ds->block_size = block_size; ds->flags = flags; ds->device_type = device_type; ds->priority = priority; binuptime(&ds->creation_time); devstat_generation++; } /* * Remove a devstat structure from the list of devices. */ void devstat_remove_entry(struct devstat *ds) { struct devstatlist *devstat_head; mtx_assert(&devstat_mutex, MA_NOTOWNED); if (ds == NULL) return; mtx_lock(&devstat_mutex); devstat_head = &device_statq; /* Remove this entry from the devstat queue */ atomic_add_acq_int(&ds->sequence1, 1); if (ds->unit_number != -1) { devstat_num_devs--; STAILQ_REMOVE(devstat_head, ds, devstat, dev_links); } devstat_free(ds); devstat_generation++; mtx_unlock(&devstat_mutex); } /* * Record a transaction start. * * See comments for devstat_end_transaction(). Ordering is very important * here. */ void devstat_start_transaction(struct devstat *ds, struct bintime *now) { mtx_assert(&devstat_mutex, MA_NOTOWNED); /* sanity check */ if (ds == NULL) return; atomic_add_acq_int(&ds->sequence1, 1); /* * We only want to set the start time when we are going from idle * to busy. The start time is really the start of the latest busy * period. */ if (ds->start_count == ds->end_count) { if (now != NULL) ds->busy_from = *now; else binuptime(&ds->busy_from); } ds->start_count++; atomic_add_rel_int(&ds->sequence0, 1); DTRACE_DEVSTAT_START(); } void devstat_start_transaction_bio(struct devstat *ds, struct bio *bp) { mtx_assert(&devstat_mutex, MA_NOTOWNED); /* sanity check */ if (ds == NULL) return; binuptime(&bp->bio_t0); devstat_start_transaction(ds, &bp->bio_t0); DTRACE_DEVSTAT_BIO_START(); } /* * Record the ending of a transaction, and incrment the various counters. * * Ordering in this function, and in devstat_start_transaction() is VERY * important. The idea here is to run without locks, so we are very * careful to only modify some fields on the way "down" (i.e. at * transaction start) and some fields on the way "up" (i.e. at transaction * completion). One exception is busy_from, which we only modify in * devstat_start_transaction() when there are no outstanding transactions, * and thus it can't be modified in devstat_end_transaction() * simultaneously. * * The sequence0 and sequence1 fields are provided to enable an application * spying on the structures with mmap(2) to tell when a structure is in a * consistent state or not. * * For this to work 100% reliably, it is important that the two fields * are at opposite ends of the structure and that they are incremented * in the opposite order of how a memcpy(3) in userland would copy them. * We assume that the copying happens front to back, but there is actually * no way short of writing your own memcpy(3) replacement to guarantee * this will be the case. * * In addition to this, being a kind of locks, they must be updated with * atomic instructions using appropriate memory barriers. */ void devstat_end_transaction(struct devstat *ds, uint32_t bytes, devstat_tag_type tag_type, devstat_trans_flags flags, struct bintime *now, struct bintime *then) { struct bintime dt, lnow; /* sanity check */ if (ds == NULL) return; if (now == NULL) { now = &lnow; binuptime(now); } atomic_add_acq_int(&ds->sequence1, 1); /* Update byte and operations counts */ ds->bytes[flags] += bytes; ds->operations[flags]++; /* * Keep a count of the various tag types sent. */ if ((ds->flags & DEVSTAT_NO_ORDERED_TAGS) == 0 && tag_type != DEVSTAT_TAG_NONE) ds->tag_types[tag_type]++; if (then != NULL) { /* Update duration of operations */ dt = *now; bintime_sub(&dt, then); bintime_add(&ds->duration[flags], &dt); } /* Accumulate busy time */ dt = *now; bintime_sub(&dt, &ds->busy_from); bintime_add(&ds->busy_time, &dt); ds->busy_from = *now; ds->end_count++; atomic_add_rel_int(&ds->sequence0, 1); DTRACE_DEVSTAT_DONE(); } void devstat_end_transaction_bio(struct devstat *ds, struct bio *bp) { devstat_end_transaction_bio_bt(ds, bp, NULL); } void devstat_end_transaction_bio_bt(struct devstat *ds, struct bio *bp, struct bintime *now) { devstat_trans_flags flg; /* sanity check */ if (ds == NULL) return; if (bp->bio_cmd == BIO_DELETE) flg = DEVSTAT_FREE; else if (bp->bio_cmd == BIO_READ) flg = DEVSTAT_READ; else if (bp->bio_cmd == BIO_WRITE) flg = DEVSTAT_WRITE; else flg = DEVSTAT_NO_DATA; devstat_end_transaction(ds, bp->bio_bcount - bp->bio_resid, DEVSTAT_TAG_SIMPLE, flg, now, &bp->bio_t0); DTRACE_DEVSTAT_BIO_DONE(); } /* * This is the sysctl handler for the devstat package. The data pushed out * on the kern.devstat.all sysctl variable consists of the current devstat * generation number, and then an array of devstat structures, one for each * device in the system. * * This is more cryptic that obvious, but basically we neither can nor * want to hold the devstat_mutex for any amount of time, so we grab it * only when we need to and keep an eye on devstat_generation all the time. */ static int sysctl_devstat(SYSCTL_HANDLER_ARGS) { int error; long mygen; struct devstat *nds; mtx_assert(&devstat_mutex, MA_NOTOWNED); /* * XXX devstat_generation should really be "volatile" but that * XXX freaks out the sysctl macro below. The places where we * XXX change it and inspect it are bracketed in the mutex which * XXX guarantees us proper write barriers. I don't belive the * XXX compiler is allowed to optimize mygen away across calls * XXX to other functions, so the following is belived to be safe. */ mygen = devstat_generation; error = SYSCTL_OUT(req, &mygen, sizeof(mygen)); if (devstat_num_devs == 0) return(0); if (error != 0) return (error); mtx_lock(&devstat_mutex); nds = STAILQ_FIRST(&device_statq); if (mygen != devstat_generation) error = EBUSY; mtx_unlock(&devstat_mutex); if (error != 0) return (error); for (;nds != NULL;) { error = SYSCTL_OUT(req, nds, sizeof(struct devstat)); if (error != 0) return (error); mtx_lock(&devstat_mutex); if (mygen != devstat_generation) error = EBUSY; else nds = STAILQ_NEXT(nds, dev_links); mtx_unlock(&devstat_mutex); if (error != 0) return (error); } return(error); } /* * Sysctl entries for devstat. The first one is a node that all the rest * hang off of. */ static SYSCTL_NODE(_kern, OID_AUTO, devstat, CTLFLAG_RD, NULL, "Device Statistics"); SYSCTL_PROC(_kern_devstat, OID_AUTO, all, CTLFLAG_RD|CTLTYPE_OPAQUE, NULL, 0, sysctl_devstat, "S,devstat", "All devices in the devstat list"); /* * Export the number of devices in the system so that userland utilities * can determine how much memory to allocate to hold all the devices. */ SYSCTL_INT(_kern_devstat, OID_AUTO, numdevs, CTLFLAG_RD, &devstat_num_devs, 0, "Number of devices in the devstat list"); SYSCTL_LONG(_kern_devstat, OID_AUTO, generation, CTLFLAG_RD, &devstat_generation, 0, "Devstat list generation"); SYSCTL_INT(_kern_devstat, OID_AUTO, version, CTLFLAG_RD, &devstat_version, 0, "Devstat list version number"); /* * Allocator for struct devstat structures. We sub-allocate these from pages * which we get from malloc. These pages are exported for mmap(2)'ing through * a miniature device driver */ #define statsperpage (PAGE_SIZE / sizeof(struct devstat)) static d_mmap_t devstat_mmap; static struct cdevsw devstat_cdevsw = { .d_version = D_VERSION, .d_flags = D_NEEDGIANT, .d_mmap = devstat_mmap, .d_name = "devstat", }; struct statspage { TAILQ_ENTRY(statspage) list; struct devstat *stat; u_int nfree; }; static TAILQ_HEAD(, statspage) pagelist = TAILQ_HEAD_INITIALIZER(pagelist); static MALLOC_DEFINE(M_DEVSTAT, "devstat", "Device statistics"); static int devstat_mmap(struct cdev *dev, vm_ooffset_t offset, vm_paddr_t *paddr, int nprot, vm_memattr_t *memattr) { struct statspage *spp; if (nprot != VM_PROT_READ) return (-1); TAILQ_FOREACH(spp, &pagelist, list) { if (offset == 0) { *paddr = vtophys(spp->stat); return (0); } offset -= PAGE_SIZE; } return (-1); } static struct devstat * devstat_alloc(void) { struct devstat *dsp; struct statspage *spp, *spp2; u_int u; static int once; mtx_assert(&devstat_mutex, MA_NOTOWNED); if (!once) { make_dev_credf(MAKEDEV_ETERNAL | MAKEDEV_CHECKNAME, &devstat_cdevsw, 0, NULL, UID_ROOT, GID_WHEEL, 0400, DEVSTAT_DEVICE_NAME); once = 1; } spp2 = NULL; mtx_lock(&devstat_mutex); for (;;) { TAILQ_FOREACH(spp, &pagelist, list) { if (spp->nfree > 0) break; } if (spp != NULL) break; mtx_unlock(&devstat_mutex); spp2 = malloc(sizeof *spp, M_DEVSTAT, M_ZERO | M_WAITOK); spp2->stat = malloc(PAGE_SIZE, M_DEVSTAT, M_ZERO | M_WAITOK); spp2->nfree = statsperpage; /* * If free statspages were added while the lock was released * just reuse them. */ mtx_lock(&devstat_mutex); TAILQ_FOREACH(spp, &pagelist, list) if (spp->nfree > 0) break; if (spp == NULL) { spp = spp2; /* * It would make more sense to add the new page at the * head but the order on the list determine the * sequence of the mapping so we can't do that. */ TAILQ_INSERT_TAIL(&pagelist, spp, list); } else break; } dsp = spp->stat; for (u = 0; u < statsperpage; u++) { if (dsp->allocated == 0) break; dsp++; } spp->nfree--; dsp->allocated = 1; mtx_unlock(&devstat_mutex); if (spp2 != NULL && spp2 != spp) { free(spp2->stat, M_DEVSTAT); free(spp2, M_DEVSTAT); } return (dsp); } static void devstat_free(struct devstat *dsp) { struct statspage *spp; mtx_assert(&devstat_mutex, MA_OWNED); bzero(dsp, sizeof *dsp); TAILQ_FOREACH(spp, &pagelist, list) { if (dsp >= spp->stat && dsp < (spp->stat + statsperpage)) { spp->nfree++; return; } } } SYSCTL_INT(_debug_sizeof, OID_AUTO, devstat, CTLFLAG_RD, NULL, sizeof(struct devstat), "sizeof(struct devstat)"); Index: head/sys/modules/dtrace/dtio/Makefile =================================================================== --- head/sys/modules/dtrace/dtio/Makefile (revision 257036) +++ head/sys/modules/dtrace/dtio/Makefile (nonexistent) @@ -1,15 +0,0 @@ -# $FreeBSD$ - -.PATH: ${.CURDIR}/../../../kern - -KMOD= dtio -SRCS= dtio_kdtrace.c \ - vnode_if.h - -CFLAGS+= -I${.CURDIR}/../../../cddl/compat/opensolaris \ - -I${.CURDIR}/../../../cddl/contrib/opensolaris/uts/common \ - -I${.CURDIR}/../../.. - -.include - -CFLAGS+= -include ${.CURDIR}/../../../cddl/compat/opensolaris/sys/debug_compat.h Property changes on: head/sys/modules/dtrace/dtio/Makefile ___________________________________________________________________ Deleted: svn:eol-style ## -1 +0,0 ## -native \ No newline at end of property Deleted: svn:keywords ## -1 +0,0 ## -FreeBSD=%H \ No newline at end of property Deleted: svn:mime-type ## -1 +0,0 ## -text/plain \ No newline at end of property Index: head/sys/modules/dtrace/Makefile =================================================================== --- head/sys/modules/dtrace/Makefile (revision 257036) +++ head/sys/modules/dtrace/Makefile (revision 257037) @@ -1,29 +1,28 @@ # $FreeBSD$ .include .include "Makefile.inc" SUBDIR= dtmalloc \ dtnfscl \ dtnfsclient \ dtrace \ dtraceall \ dtrace_test \ - dtio \ lockstat \ profile \ prototype \ sdt \ systrace .if ${MACHINE_CPUARCH} == "amd64" || ${MACHINE_CPUARCH} == "i386" SUBDIR+= fasttrap fbt systrace_linux32 .endif .if ${MACHINE_CPUARCH} == "powerpc" SUBDIR+= fbt fasttrap .endif .if ${MACHINE_CPUARCH} == "amd64" || ${MACHINE_ARCH} == "powerpc64" SUBDIR+= systrace_freebsd32 .endif .include Index: head/sys/modules/dtrace/dtraceall/dtraceall.c =================================================================== --- head/sys/modules/dtrace/dtraceall/dtraceall.c (revision 257036) +++ head/sys/modules/dtrace/dtraceall/dtraceall.c (revision 257037) @@ -1,87 +1,86 @@ /* * Copyright (C) 2008 John Birrell * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY AUTHOR AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * * $FreeBSD$ */ #include #include #include #include #include #include #include #include "opt_compat.h" #include "opt_nfs.h" static int dtraceall_modevent(module_t mod __unused, int type, void *data __unused) { int error = 0; switch (type) { case MOD_LOAD: break; case MOD_UNLOAD: break; case MOD_SHUTDOWN: break; default: error = EOPNOTSUPP; break; } return (error); } DEV_MODULE(dtraceall, dtraceall_modevent, NULL); MODULE_VERSION(dtraceall, 1); /* All the DTrace modules should be dependencies here: */ MODULE_DEPEND(dtraceall, cyclic, 1, 1, 1); MODULE_DEPEND(dtraceall, opensolaris, 1, 1, 1); MODULE_DEPEND(dtraceall, dtrace, 1, 1, 1); -MODULE_DEPEND(dtraceall, dtio, 1, 1, 1); MODULE_DEPEND(dtraceall, dtmalloc, 1, 1, 1); MODULE_DEPEND(dtraceall, dtnfscl, 1, 1, 1); #if defined(NFSCLIENT) MODULE_DEPEND(dtraceall, dtnfsclient, 1, 1, 1); #endif #if defined(__amd64__) || defined(__i386__) || defined(__powerpc__) MODULE_DEPEND(dtraceall, fbt, 1, 1, 1); #endif #if defined(__amd64__) || defined(__i386__) MODULE_DEPEND(dtraceall, fasttrap, 1, 1, 1); #endif MODULE_DEPEND(dtraceall, lockstat, 1, 1, 1); MODULE_DEPEND(dtraceall, sdt, 1, 1, 1); MODULE_DEPEND(dtraceall, systrace, 1, 1, 1); #if defined(COMPAT_FREEBSD32) MODULE_DEPEND(dtraceall, systrace_freebsd32, 1, 1, 1); #endif MODULE_DEPEND(dtraceall, profile, 1, 1, 1);