/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License (the "License").
* You may not use this file except in compliance with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright 2009 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
/*
* Copyright (c) 2011, Joyent, Inc. All rights reserved.
*/
/*
* Regardless of platform, the stack frames look like this in the case of the
* profile provider:
*
* profile_fire
* cyclic_expire
* cyclic_fire
* [ cbe ]
* [ interrupt code ]
*
* On x86, there are five frames from the generic interrupt code; further, the
* interrupted instruction appears as its own stack frame, giving us a total of
* 10.
*
* On SPARC, the picture is further complicated because the compiler
* optimizes away tail-calls -- so the following frames are optimized away:
*
* profile_fire
* cyclic_expire
*
* This gives three frames. However, on DEBUG kernels, the cyclic_expire
* frame cannot be tail-call eliminated, yielding four frames in this case.
*
* All of the above constraints lead to the mess below. Yes, the profile
* provider should ideally figure this out on-the-fly by hitting one of its own
* probes and then walking its own stack trace. This is complicated, however,
* and the static definition doesn't seem to be overly brittle. Still, we
* allow for a manual override in case we get it completely wrong.
*/
#ifdef __x86
#else
#ifdef __sparc
#ifdef DEBUG
#else
#endif
#endif
#endif
#define PROF_PROFILE 0
typedef struct profile_probe {
int prof_kind;
typedef struct profile_probe_percpu {
static int profile_rates[] = {
97, 199, 499, 997, 1999,
4001, 4999, 0, 0, 0,
0, 0, 0, 0, 0,
0, 0, 0, 0, 0
};
static int profile_ticks[] = {
1, 10, 100, 500, 1000,
5000, 0, 0, 0, 0,
0, 0, 0, 0, 0
};
/*
* profile_max defines the upper bound on the number of profile probes that
* can exist (this is to prevent malicious or clumsy users from exhausing
* system resources by creating a slew of profile probes). At mod load time,
* this gets its value from PROFILE_MAX_DEFAULT or profile-max-probes if it's
* present in the profile.conf file.
*/
static void
{
}
static void
{
CPU->cpu_profile_upc, 0, 0, 0);
}
static void
{
if (profile_aframes)
if (interval < profile_interval_min)
return;
return;
if (profile_total > profile_max) {
return;
}
}
/*ARGSUSED*/
static void
{
const struct {
char *prefix;
int kind;
} types[] = {
{ PROF_PREFIX_TICK, PROF_TICK },
};
const struct {
char *name;
} suffixes[] = {
{ "hz", 0 },
{ NULL }
};
char n[PROF_NAMELEN];
/*
* If no description was provided, provide all of our probes.
*/
for (i = 0; i < sizeof (profile_rates) / sizeof (int); i++) {
if ((rate = profile_rates[i]) == 0)
continue;
}
for (i = 0; i < sizeof (profile_ticks) / sizeof (int); i++) {
if ((rate = profile_ticks[i]) == 0)
continue;
}
return;
}
continue;
break;
}
return;
/*
* We need to start before any time suffix.
*/
break;
}
/*
* Now determine the numerical value present in the probe name.
*/
for (; j >= len; j--) {
return;
}
if (val == 0)
return;
/*
* Look-up the suffix to determine the multiplier.
*/
break;
}
}
return;
if (mult == 0) {
/*
* The default is frequency-per-second.
*/
} else {
}
}
/*ARGSUSED*/
static void
{
}
/*ARGSUSED*/
static void
{
}
/*ARGSUSED*/
static void
{
}
/*ARGSUSED*/
static int
{
} else {
}
} else {
}
return (0);
}
/*ARGSUSED*/
static void
{
}
/*ARGSUSED*/
static int
{
int mode;
if (CPU->cpu_profile_pc != 0) {
} else {
}
} else {
}
return (mode);
}
};
NULL,
NULL,
NULL,
NULL,
NULL,
};
static int
{
switch (cmd) {
case DDI_ATTACH:
break;
case DDI_RESUME:
return (DDI_SUCCESS);
default:
return (DDI_FAILURE);
}
return (DDI_FAILURE);
}
"profile-max-probes", PROFILE_MAX_DEFAULT);
profile_devi = devi;
return (DDI_SUCCESS);
}
static int
{
switch (cmd) {
case DDI_DETACH:
break;
case DDI_SUSPEND:
return (DDI_SUCCESS);
default:
return (DDI_FAILURE);
}
if (dtrace_unregister(profile_id) != 0)
return (DDI_FAILURE);
return (DDI_SUCCESS);
}
/*ARGSUSED*/
static int
{
int error;
switch (infocmd) {
case DDI_INFO_DEVT2DEVINFO:
*result = (void *)profile_devi;
error = DDI_SUCCESS;
break;
case DDI_INFO_DEVT2INSTANCE:
*result = (void *)0;
error = DDI_SUCCESS;
break;
default:
error = DDI_FAILURE;
}
return (error);
}
/*ARGSUSED*/
static int
{
return (0);
}
profile_open, /* open */
nodev, /* close */
nulldev, /* strategy */
nulldev, /* print */
nodev, /* dump */
nodev, /* read */
nodev, /* write */
nodev, /* ioctl */
nodev, /* devmap */
nodev, /* mmap */
nodev, /* segmap */
nochpoll, /* poll */
ddi_prop_op, /* cb_prop_op */
0, /* streamtab */
};
DEVO_REV, /* devo_rev, */
0, /* refcnt */
profile_info, /* get_dev_info */
nulldev, /* identify */
nulldev, /* probe */
profile_attach, /* attach */
profile_detach, /* detach */
nodev, /* reset */
&profile_cb_ops, /* driver operations */
NULL, /* bus operations */
nodev, /* dev power */
ddi_quiesce_not_needed, /* quiesce */
};
/*
* Module linkage information for the kernel.
*/
&mod_driverops, /* module type (this is a pseudo driver) */
"Profile Interrupt Tracing", /* name of module */
&profile_ops, /* driver ops */
};
(void *)&modldrv,
};
int
_init(void)
{
return (mod_install(&modlinkage));
}
int
{
}
int
_fini(void)
{
return (mod_remove(&modlinkage));
}