Skip to content

Commit

Permalink
Implementation of the printa() action
Browse files Browse the repository at this point in the history
Given the design for the handling of aggregation data, there is no
further need for cummulative data retrieval using snapshots.  When we
are ready to display aggregation data, we can retrieve the data by
performing a key 0 BPF map lookup on the 'aggs' map.  It gives us all
data for all CPUs in a single buffer.

The consumer processes the per-CPU aggregation data and aggregates it
into its final values.

The retrieval of aggregation data from the kernel does not pose any
concurrent access issues and therefore does not make use of the latch
sequence mechanism that the producer provides.  This is because the
data is currently stored in a regular BPF map that requires the use of
the bpf_map_lookup_elem syscall option.  This copies out the data with
preemption disabled.

Change summary:

  Global
    - General code cleanup
    - Replace dtrace_aggvarid_t by dtrace_aggid_t
    - Replace DTRACEAGG_* constants with DT_AGG_* constants
  cmd/dtrace.c
    - Remove disabling of default agg printing
  include/dtrace/metadesc.h
    struct dtrace_aggdesc
      - Removed dtagd_epid and dtagd_pad
      - Added dtagd_sig (lquantize and llquantize parameters)
      - Replaced dtagd_rec[1] with *dtagd_recs
  libdtrace/dt_aggregate.c
    - Switch from retrieving per-CPU aggregation data using ioctl() to
      retrieving the BPF map value for key 0 from the 'aggs' map.  The
      order of aggregation data blocks is defined by the order of the
      aggregations (by ID) in the dt_aggs idhash.
  libdtrace/dt_cg.c
    - Add support for storing aggregation IDs in dt_cg_store_val()
    - Implement printa()
  libdtrace/dt_consume.c
    - Remove obsolete support for reading parameters from first data value
    - Pass encoded agg function parameters to dt_print_datum()
    - Pass encoded lquantize parameters to dt_print_lquantize()
    - Pass encoded llquantize parameters to dt_print_llquantize()
    - Implement dt_printa()
  libdtrace/dt_map.c
    - Rewrite dt_aggid_add() to not try to retrieve data from the kernel
      using ioctl() calls but instead construct the data description
      based on the aggregation identifier.
  libdtrace/dt_printf.c
    - Adjust pfprint_*() functions to passing agg func parameters
  libdtrace/dt_work.c:
    - Move the call to dt_aggregate_go() to before the BEGIN probe to
      ensure that setting up the consumer side for aggregation handling
      does not affect whatever work is done in the BEGIN probe program.
  libdtrace/dtrace.h
    struct dtrace_aggdata
      - Renamed dtada_handle -> dtada_hdl
      - Removed dtada_ddesc and dtada_pdesc
  Tests
    - Various tests have been renamed to make their meaning more clear
    - Various tests have been adjusted to more accurately test things

Signed-off-by: Kris Van Hees <kris.van.hees@oracle.com>
  • Loading branch information
kvanhees committed Dec 10, 2020
1 parent 3561741 commit ecbe227
Show file tree
Hide file tree
Showing 35 changed files with 1,144 additions and 1,056 deletions.
9 changes: 2 additions & 7 deletions cmd/dtrace.c
Original file line number Diff line number Diff line change
Expand Up @@ -603,13 +603,10 @@ bufhandler(const dtrace_bufdata_t *bufdata, void *arg)
{ NULL }
};

if (bufdata->dtbda_probe != NULL) {
if (bufdata->dtbda_probe != NULL)
pd = bufdata->dtbda_probe->dtpda_pdesc;
} else if (agg != NULL) {
pd = agg->dtada_pdesc;
} else {
else
pd = NULL;
}

BUFDUMPHDR(">>> Called buffer handler");
BUFDUMPHDR("");
Expand Down Expand Up @@ -1556,13 +1553,11 @@ main(int argc, char *argv[])

oprintf("\n");

#if 0
if (!g_impatient) {
if (dtrace_aggregate_print(g_dtp, g_ofp, NULL) == -1 &&
dtrace_errno(g_dtp) != EINTR)
dfatal("failed to print aggregations");
}
#endif

release_procs:
for (i = 0; i < g_psc; i++)
Expand Down
7 changes: 3 additions & 4 deletions include/dtrace/metadesc.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,14 +52,13 @@ typedef struct dtrace_datadesc {

typedef struct dtrace_aggdesc {
DTRACE_PTR(char, dtagd_name); /* not filled in by kernel */
dtrace_aggvarid_t dtagd_varid; /* not filled in by kernel */
dtrace_aggid_t dtagd_varid; /* not filled in by kernel */
int dtagd_flags; /* not filled in by kernel */
dtrace_aggid_t dtagd_id; /* aggregation ID */
dtrace_epid_t dtagd_epid; /* enabled probe ID */
uint64_t dtagd_sig; /* aggregation signature */
uint32_t dtagd_size; /* size in bytes */
int dtagd_nrecs; /* number of records */
uint32_t dtagd_pad; /* explicit padding */
dtrace_recdesc_t dtagd_rec[1]; /* record descriptions */
dtrace_recdesc_t *dtagd_recs; /* record descriptions */
} dtrace_aggdesc_t;

typedef struct dtrace_fmtdesc {
Expand Down
1 change: 0 additions & 1 deletion include/dtrace/universal.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ typedef uint32_t dtrace_epid_t; /* enabled probe identifier */
typedef uint32_t dtrace_optid_t; /* option identifier */
typedef uint32_t dtrace_specid_t; /* speculation identifier */

typedef uint64_t dtrace_aggvarid_t; /* aggregation variable id */
typedef uint64_t dtrace_genid_t; /* generation identifier */
typedef uint64_t dtrace_optval_t; /* option value */

Expand Down

0 comments on commit ecbe227

Please sign in to comment.