/*
* 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
*/
/*
*/
#include <stdlib.h>
#include <strings.h>
#include <errno.h>
#include <unistd.h>
#include <dt_impl.h>
#include <assert.h>
#include <alloca.h>
#include <limits.h>
32779,
500009,
2104987,
4000037,
7954979
};
#define DTRACE_NUM_AHASHSIZE \
(sizeof (dtrace_ahashsize) / sizeof (dtrace_ahashsize[0]))
/*
* Rotate the hash by LSHIFT bits, then XOR the next word.
* hashval must be an unsigned type.
*/
{ \
}
/*
* Because qsort(3C) does not allow an argument to be passed to a comparison
* function, the variables that affect comparison must regrettably be global;
* they are protected by a global static lock, dt_qsort_lock.
*/
static int dt_revsort;
static int dt_keysort;
static int dt_keypos;
static void
{
int i;
}
static int
{
return (DT_LESSTHAN);
return (DT_GREATERTHAN);
return (0);
}
/*ARGSUSED*/
static void
{
}
/*ARGSUSED*/
static void
{
}
static int
{
return (DT_LESSTHAN);
return (DT_GREATERTHAN);
return (0);
}
static int
{
return (DT_LESSTHAN);
return (DT_GREATERTHAN);
return (0);
}
/*ARGSUSED*/
static void
{
int i;
for (i = 0; i <= levels + 1; i++)
}
static long double
{
(long double)(base + 1));
}
static int64_t
{
if (base - 1 == 0)
return (lquanta[0]);
if (base != 0)
continue;
return (lquanta[i + 1]);
}
if (base + 1 == 0)
return (0);
}
static int
{
return (DT_LESSTHAN);
return (DT_GREATERTHAN);
/*
* If they're both equal, then we will compare based on the weights at
* zero. If the weights at zero are equal (or if zero is not within
* the range of the linear quantization), then this will be judged a
* tie and will be resolved based on the key comparison.
*/
return (DT_LESSTHAN);
return (DT_GREATERTHAN);
return (0);
}
static int
{
for (i = 0; i < nbuckets; i++) {
if (bucketval == 0) {
}
}
return (DT_LESSTHAN);
return (DT_GREATERTHAN);
/*
* If they're both equal, then we will compare based on the weights at
* zero. If the weights at zero are equal, then this will be judged a
* tie and will be resolved based on the key comparison.
*/
return (DT_LESSTHAN);
return (DT_GREATERTHAN);
return (0);
}
static void
{
struct ps_prochandle *P;
return;
return;
dt_proc_lock(dtp, P);
dt_proc_unlock(dtp, P);
dt_proc_release(dtp, P);
}
static void
{
struct ps_prochandle *P;
return;
return;
dt_proc_lock(dtp, P);
dt_proc_unlock(dtp, P);
dt_proc_release(dtp, P);
}
static void
{
}
static void
{
/*
* We don't have a way of just getting the module for a
* vectored open, and it doesn't seem to be worth defining
* one. This means that use of mod() won't get true
* aggregation in the postmortem case (some modules may
* appear more than once in aggregation output). It seems
* unlikely that anyone will ever notice or care...
*/
return;
}
return;
}
}
}
static dtrace_aggvarid_t
{
/*
* First, we'll check the variable ID in the aggdesc. If it's valid,
* we'll return it. If not, we'll use the compiler-generated ID
* present as the first record.
*/
return (agg->dtagd_varid);
rec->dtrd_offset));
return (agg->dtagd_varid);
}
static void
{
int i;
/* Check to see if we're at the maximum size */
*allocation_failed = 1;
return;
}
/* First, allocate the new array; if we fail, we will not resize. */
hash->dtah_sizendx++;
hash->dtah_sizendx--;
*allocation_failed = 1;
return;
}
for (i = 0; i < old_size; i++) {
moving = h;
h = h->dtahe_next;
}
}
/*
* All moved, now update hash info.
*/
}
static int
{
int i, j, rval;
dt_ahashent_t *h;
int allocation_failed = 0;
/*
* If that failed with ENOENT, it may be because the
* CPU was unconfigured. This is okay; we'll just
* do nothing but return success.
*/
return (0);
}
}
if (buf->dtbd_drops != 0) {
return (-1);
}
return (0);
}
/*
* We're guaranteed to have an ID.
*/
if (id == DTRACE_AGGIDNONE) {
/*
* This is filler to assure proper alignment of the
* next record; we simply ignore it.
*/
continue;
}
return (rval);
hashval = 0;
switch (rec->dtrd_action) {
case DTRACEACT_USYM:
/* LINTED - alignment */
break;
case DTRACEACT_UMOD:
/* LINTED - alignment */
break;
case DTRACEACT_SYM:
/* LINTED - alignment */
break;
case DTRACEACT_MOD:
/* LINTED - alignment */
break;
default:
break;
}
}
}
/*
* For locks (lockstat) things are int aligned, so we
* are not using the entire hash.
*/
if (h->dtahe_hashval != hashval)
continue;
if (h->dtahe_size != size)
continue;
aggdata = &h->dtahe_data;
goto hashnext;
}
}
/*
* We found it. Now we need to apply the aggregating
* action on the data here.
*/
/* LINTED - alignment */
/* LINTED - alignment */
/*
* If we're keeping per CPU data, apply the aggregating
* action there as well.
*/
/* LINTED - alignment */
/* LINTED - alignment */
}
goto bufnext;
continue;
}
/*
* No entry for this record -- allocate a new one. Before doing
* so, see if we should grow the hash. (If it cannot be grown,
* just add the entry to the existing hash.)
*/
bzero(h, sizeof (dt_ahashent_t));
aggdata = &h->dtahe_data;
free(h);
}
h->dtahe_hashval = hashval;
h->dtahe_size = size;
(void) dt_aggregate_aggvarid(h);
if (flags & DTRACE_A_PERCPU) {
free(h);
}
for (j = 0; j < max_cpus; j++) {
while (--j >= 0)
free(h);
}
if (j == cpu) {
} else {
}
}
}
switch (rec->dtrd_action) {
case DTRACEAGG_MIN:
break;
case DTRACEAGG_MAX:
break;
case DTRACEAGG_LQUANTIZE:
break;
case DTRACEAGG_COUNT:
case DTRACEAGG_SUM:
case DTRACEAGG_AVG:
case DTRACEAGG_STDDEV:
case DTRACEAGG_QUANTIZE:
break;
default:
}
}
return (0);
}
int
{
int i, rval;
if (dtp->dt_lastagg != 0) {
return (0);
} else {
}
return (0);
for (i = 0; i < agp->dtat_ncpus; i++) {
return (rval);
}
return (0);
}
static int
{
return (DT_LESSTHAN);
return (DT_GREATERTHAN);
return (0);
}
static int
{
return (DT_LESSTHAN);
return (DT_GREATERTHAN);
return (0);
}
static int
{
return (rval);
for (i = 1; i < nrecs; i++) {
return (DT_LESSTHAN);
return (DT_GREATERTHAN);
case sizeof (uint64_t):
/* LINTED - alignment */
/* LINTED - alignment */
break;
case sizeof (uint32_t):
/* LINTED - alignment */
/* LINTED - alignment */
break;
case sizeof (uint16_t):
/* LINTED - alignment */
/* LINTED - alignment */
break;
case sizeof (uint8_t):
break;
default:
switch (lrec->dtrd_action) {
case DTRACEACT_UMOD:
case DTRACEACT_UADDR:
case DTRACEACT_USYM:
for (j = 0; j < 2; j++) {
/* LINTED - alignment */
/* LINTED - alignment */
return (DT_LESSTHAN);
return (DT_GREATERTHAN);
}
break;
default:
return (DT_LESSTHAN);
return (DT_GREATERTHAN);
}
}
continue;
}
return (DT_LESSTHAN);
return (DT_GREATERTHAN);
}
return (0);
}
static int
{
int rval, i;
return (rval);
return (DT_GREATERTHAN);
return (DT_LESSTHAN);
for (i = 0; i < lagg->dtagd_nrecs; i++) {
return (DT_LESSTHAN);
return (DT_GREATERTHAN);
return (DT_LESSTHAN);
return (DT_GREATERTHAN);
}
switch (lrec->dtrd_action) {
case DTRACEAGG_AVG:
break;
case DTRACEAGG_STDDEV:
break;
case DTRACEAGG_QUANTIZE:
break;
case DTRACEAGG_LQUANTIZE:
break;
case DTRACEAGG_COUNT:
case DTRACEAGG_SUM:
case DTRACEAGG_MIN:
case DTRACEAGG_MAX:
break;
default:
assert(0);
}
return (rval);
}
static int
{
int rval;
return (rval);
/*
* If we're here, the values for the two aggregation elements are
* equal. We already know that the key layout is the same for the two
* elements; we must now compare the keys themselves as a tie-breaker.
*/
}
static int
{
int rval;
return (rval);
}
static int
{
int rval;
return (rval);
}
static int
{
int rval;
return (rval);
}
static int
{
int rval;
return (rval);
}
static int
{
}
static int
{
}
static int
{
}
static int
{
}
static int
{
int i, rval;
if (dt_keysort) {
/*
* If we're sorting on keys, we need to scan until we find the
* last entry -- that's the representative key. (The order of
* the bundle is values followed by key to accommodate the
* default behavior of sorting by value.) If the keys are
* equal, we'll fall into the value comparison loop, below.
*/
continue;
assert(i != 0);
return (rval);
}
for (i = 0; ; i++) {
/*
* All of the values are equal; if we're sorting on
* keys, then we're only here because the keys were
* found to be equal and these records are therefore
* equal. If we're not sorting on keys, we'll use the
* key comparison from the representative key as the
* tie-breaker.
*/
if (dt_keysort)
return (0);
assert(i != 0);
} else {
return (rval);
}
}
}
int
{
int rval, i;
/*
* Use the aggregation buffer size as reloaded from the kernel.
*/
return (0);
/*
* Now query for the CPUs enabled.
*/
if (cpu != DTRACE_CPUALL) {
return (0);
}
agp->dtat_ncpus = 0;
for (i = 0; i < agp->dtat_maxcpu; i++) {
continue;
}
return (0);
}
static int
{
int i;
switch (rval) {
case DTRACE_AGGWALK_NEXT:
break;
case DTRACE_AGGWALK_CLEAR: {
data = &h->dtahe_data;
}
break;
break;
}
case DTRACE_AGGWALK_ERROR:
/*
* We assume that errno is already set in this case.
*/
case DTRACE_AGGWALK_ABORT:
return (0);
case DTRACE_AGGWALK_NORMALIZE:
if (h->dtahe_data.dtada_normal == 0) {
}
return (0);
case DTRACE_AGGWALK_REMOVE: {
/*
* First, remove this hash entry from its hash chain.
*/
if (h->dtahe_prev != NULL) {
} else {
}
if (h->dtahe_next != NULL)
/*
* Now remove it from the list of all hash entries.
*/
if (h->dtahe_prevall != NULL) {
} else {
}
if (h->dtahe_nextall != NULL)
/*
* We're unlinked. We can safely destroy the data.
*/
for (i = 0; i < max_cpus; i++)
}
free(h);
return (0);
}
default:
}
return (0);
}
void
int (*compar)(const void *, const void *))
{
} else {
dt_keypos = 0;
}
if (!dt_keysort) {
} else {
}
}
dt_revsort = rev;
dt_keysort = key;
}
int
{
/*
* dt_aggwalk_rval() can potentially remove the current hash
* entry; we need to load the next hash entry before calling
* into it.
*/
next = h->dtahe_nextall;
return (-1);
}
return (0);
}
static int
int (*sfunc)(const void *, const void *))
{
nentries++;
return (-1);
sorted[i++] = h;
(void) pthread_mutex_lock(&dt_qsort_lock);
sizeof (dt_ahashent_t *), NULL);
} else {
/*
* If we've been explicitly passed a sorting function,
* we'll use that -- ignoring the values of the "aggsortrev",
* "aggsortkey" and "aggsortkeypos" options.
*/
}
(void) pthread_mutex_unlock(&dt_qsort_lock);
for (i = 0; i < nentries; i++) {
h = sorted[i];
return (-1);
}
}
return (0);
}
int
{
}
int
{
}
int
{
}
int
{
}
int
{
}
int
{
}
int
{
}
int
{
}
int
{
}
int
{
int i, j;
/*
* If the sorting position is greater than the number of aggregation
* variable IDs, we silently set it to 0.
*/
sortpos = 0;
/*
* First we need to translate the specified aggregation variable IDs
* into a linear map that will allow us to translate an aggregation
* variable ID into its position in the specified aggvars.
*/
for (i = 0; i < naggvars; i++) {
}
return (-1);
goto out;
for (i = 0; i < naggvars; i++) {
/*
* We have an aggregation variable that is present
* more than once in the array of aggregation
* variables. While it's unclear why one might want
* to do this, it's legal. To support this construct,
* we will allocate a remap that will indicate the
* position from which this aggregation variable
* should be pulled. (That is, where the remap will
* map from one position to another.)
*/
goto out;
}
/*
* Given that the variable is already present, assert
* that following through the mapping and adjusting
* for the sort position yields the same aggregation
* variable ID.
*/
continue;
}
}
/*
* We need to take two passes over the data to size our allocation, so
* we'll use the first pass to also fill in the zero-filled data to be
* used to properly format a zero-valued aggregation.
*/
int ndx;
continue;
}
nentries++;
}
if (nentries == 0) {
/*
* We couldn't find any entries; there is nothing else to do.
*/
rval = 0;
goto out;
}
/*
* Before we sort the data, we're going to look for any holes in our
* zero-filled data. This will occur if an aggregation variable that
* we are being asked to print has not yet been assigned the result of
* any aggregating action for _any_ tuple. The issue becomes that we
* would like a zero value to be printed for all columns for this
* aggregation, but without any record description, we don't know the
* aggregating action that corresponds to the aggregation variable. To
* try to find a match, we're simply going to lookup aggregation IDs
* (which are guaranteed to be contiguous and to start from 1), looking
* for the specified aggregation variable ID. If we find a match,
* we'll use that. If we iterate over all aggregation IDs and don't
* find a match, then we must be an anonymous enabling. (Anonymous
* enablings can't currently derive either aggregation variable IDs or
* aggregation variable names given only an aggregation ID.) In this
* obscure case (anonymous enabling, multiple aggregation printa() with
* some aggregations not represented for any tuple), our defined
* behavior is that the zero will be printed in the format of the first
* aggregation variable that contains any non-zero value.
*/
for (i = 0; i < naggvars; i++) {
if (zaggdata[i].dtahe_size == 0) {
for (j = DTRACE_AGGIDNONE + 1; ; j++) {
break;
continue;
/*
* We have our description -- now we need to
* cons up the zaggdata entry for it.
*/
&aggdata->dtada_pdesc);
zaggdata[i].dtahe_hashval = 0;
break;
}
if (zaggdata[i].dtahe_size == 0) {
/*
* We couldn't find this aggregation, meaning
* that we have never seen it before for any
* tuple _and_ this is an anonymous enabling.
* That is, we're in the obscure case outlined
* above. In this case, our defined behavior
* is to format the data in the format of the
* first non-zero aggregation -- of which, of
* course, we know there to be at least one
* (or nentries would have been zero).
*/
for (j = 0; j < naggvars; j++) {
if (zaggdata[j].dtahe_size != 0)
break;
}
}
}
}
/*
* Now we need to allocate our zero-filled data for use for
* aggregations that don't have a value corresponding to a given key.
*/
for (i = 0; i < naggvars; i++) {
/*
* If we failed to allocated some zero-filled data, we
* need to zero out the remaining dtada_data pointers
* to prevent the wrong data from being freed below.
*/
for (j = i; j < naggvars; j++)
goto out;
}
/*
* First, the easy bit. To maintain compatibility with
* consumers that pull the compiler-generated ID out of the
* data, we put that ID at the top of the zero-filled data.
*/
/* LINTED - alignment */
/*
* Now for the more complicated part. If (and only if) this
* is an lquantize() aggregating action, zero-filled data is
* not equivalent to an empty record: we must also get the
* parameters for the lquantize().
*/
/*
* The easier case here is if we actually have
* some prototype data -- in which case we
* manually dig it out of the aggregation
* record.
*/
/* LINTED - alignment */
rec->dtrd_offset));
} else {
/*
* We don't have any prototype data. As a
* result, we know that we _do_ have the
* compiler-generated information. (If this
* were an anonymous enabling, all of our
* zero-filled data would have prototype data
* -- either directly or indirectly.) So as
* gross as it is, we'll grovel around in the
* compiler-generated information to find the
* lquantize() parameters.
*/
}
/* LINTED - alignment */
}
}
/*
* Now that we've dealt with setting up our zero-filled data, we can
* allocate our sorted array, and take another pass over the data to
* fill it.
*/
goto out;
continue;
sorted[i++] = h;
}
/*
* We've loaded our array; now we need to sort by value to allow us
* to create bundles of like value. We're going to acquire the
* dt_qsort_lock here, and hold it across all of our subsequent
* comparison and sorting.
*/
(void) pthread_mutex_lock(&dt_qsort_lock);
/*
* Now we need to go through and create bundles. Because the number
* of bundles is bounded by the size of the sorted array, we're going
* to reuse the underlying storage. And note that "bundle" is an
* array of pointers to arrays of pointers to dt_ahashent_t -- making
* its type (regrettably) "dt_ahashent_t ***". (Regrettable because
* '*' -- like '_' and 'X' -- should never appear in triplicate in
* an ideal world.)
*/
if (i < nentries &&
continue;
/*
* We have a bundle boundary. Everything from start to
* (i - 1) belongs in one bundle.
*/
(void) pthread_mutex_unlock(&dt_qsort_lock);
goto out;
}
for (j = start; j < i; j++) {
}
for (j = 0; j < naggvars; j++) {
continue;
/*
* Before we assume that this aggregation variable
* isn't present (and fall back to using the
* zero-filled data allocated earlier), check the
* remap. If we have a remapping, we'll drop it in
* here. Note that we might be remapping an
* aggregation variable that isn't present for this
* key; in this case, the aggregation data that we
* copy will point to the zeroed data.
*/
} else {
}
}
start = i;
}
/*
* Now we need to re-sort based on the first value.
*/
(void) pthread_mutex_unlock(&dt_qsort_lock);
/*
* We're done! Now we just need to go back over the sorted bundles,
* calling the function.
*/
for (i = 0; i < nbundles; i++) {
for (j = 0; j < naggvars; j++)
for (j = 0; j < naggvars; j++) {
if (ndx < 0)
}
for (j = 0; j < naggvars; j++)
/*
* The representative key is the last element in the bundle.
* Assert that we have one, and then set it to be the first
* element of data.
*/
goto out;
}
rval = 0;
out:
for (i = 0; i < nbundles; i++)
for (i = 0; i < naggvars; i++)
}
return (rval);
}
int
{
return (0);
}
void
{
dt_ahashent_t *h;
data = &h->dtahe_data;
continue;
for (i = 0; i < max_cpus; i++)
}
}
void
{
} else {
next = h->dtahe_nextall;
aggdata = &h->dtahe_data;
for (i = 0; i < max_cpus; i++)
}
free(h);
}
}
}