[DTrace-devel] [PATCH 04/12] Aggregations are not data-recording actions

Kris Van Hees kris.van.hees at oracle.com
Thu Jun 3 11:17:07 PDT 2021


On Fri, May 28, 2021 at 02:35:08PM -0400, eugene.loh at oracle.com wrote:
> From: Eugene Loh <eugene.loh at oracle.com>
> 
> A clause like { @ = count() } should not be data-recording.  The
> whole point of aggregations is that we should not have to see output
> for every probe firing, even if -q/quiet is turned off.  Nevertheless,
> we still have to vet clauses to make sure that, e.g., a clause does
> not combine aggregations and speculation.
> 
> The reason this problem was not caught earlier is that testing is
> typically done in "quiet" mode.
> 
> Add a new DT_CLSFLAG_AGGREGATION and split this case off of
> DT_CLSFLAG_DATAREC in clause-flag processing.  Add a test for
> aggregations that does not use quiet mode.
> 
> Signed-off-by: Eugene Loh <eugene.loh at oracle.com>

Reviewed-by: Kris Van Hees <kris.van.hees at oracle.com>

> ---
>  libdtrace/dt_cg.c                       |  6 +++---
>  libdtrace/dtrace.h                      |  1 +
>  test/unittest/aggs/tst.count_notquiet.d | 21 +++++++++++++++++++++
>  test/unittest/aggs/tst.count_notquiet.r |  6 ++++++
>  4 files changed, 31 insertions(+), 3 deletions(-)
>  create mode 100644 test/unittest/aggs/tst.count_notquiet.d
>  create mode 100644 test/unittest/aggs/tst.count_notquiet.r
> 
> diff --git a/libdtrace/dt_cg.c b/libdtrace/dt_cg.c
> index db94f8de..f7168ffe 100644
> --- a/libdtrace/dt_cg.c
> +++ b/libdtrace/dt_cg.c
> @@ -833,7 +833,7 @@ dt_cg_clsflags(dt_pcb_t *pcb, dtrace_actkind_t kind, const dt_node_t *dnp)
>  		if (*cfp & DT_CLSFLAG_COMMIT)
>  			dnerror(dnp, D_COMM_COMM,
>  			    "commit( ) may not follow commit( )\n");
> -		if (*cfp & DT_CLSFLAG_DATAREC)
> +		if (*cfp & (DT_CLSFLAG_DATAREC | DT_CLSFLAG_AGGREGATION))
>  			dnerror(dnp, D_COMM_DREC, "commit( ) may "
>  			    "not follow data-recording action(s)\n");
>  
> @@ -850,7 +850,7 @@ dt_cg_clsflags(dt_pcb_t *pcb, dtrace_actkind_t kind, const dt_node_t *dnp)
>  			dnerror(dnp, D_SPEC_COMM,
>  			    "speculate( ) may not follow commit( )\n");
>  
> -		if (*cfp & DT_CLSFLAG_DATAREC)
> +		if (*cfp & (DT_CLSFLAG_DATAREC | DT_CLSFLAG_AGGREGATION))
>  			dnerror(dnp, D_SPEC_DREC, "speculate( ) may "
>  			    "not follow data-recording action(s)\n");
>  
> @@ -866,7 +866,7 @@ dt_cg_clsflags(dt_pcb_t *pcb, dtrace_actkind_t kind, const dt_node_t *dnp)
>  			dnerror(dnp, D_AGG_SPEC, "aggregating actions "
>  			    "may not follow speculate( )\n");
>  
> -		*cfp |= DT_CLSFLAG_DATAREC;
> +		*cfp |= DT_CLSFLAG_AGGREGATION;
>  		return;
>  	}
>  
> diff --git a/libdtrace/dtrace.h b/libdtrace/dtrace.h
> index 88c3eeec..ec3730f1 100644
> --- a/libdtrace/dtrace.h
> +++ b/libdtrace/dtrace.h
> @@ -150,6 +150,7 @@ typedef struct dtrace_stmtdesc {
>  #define DT_CLSFLAG_COMMIT	4	/* commit */
>  #define DT_CLSFLAG_EXIT		8	/* exit */
>  #define DT_CLSFLAG_DESTRUCT	16	/* destructive */
> +#define DT_CLSFLAG_AGGREGATION	32	/* aggregation */
>  
>  typedef int dtrace_stmt_f(dtrace_hdl_t *dtp, dtrace_prog_t *pgp,
>      dtrace_stmtdesc_t *sdp, void *data);
> diff --git a/test/unittest/aggs/tst.count_notquiet.d b/test/unittest/aggs/tst.count_notquiet.d
> new file mode 100644
> index 00000000..a55e3b41
> --- /dev/null
> +++ b/test/unittest/aggs/tst.count_notquiet.d
> @@ -0,0 +1,21 @@
> +/*
> + * Oracle Linux DTrace.
> + * Copyright (c) 2021, Oracle and/or its affiliates. All rights reserved.
> + * Licensed under the Universal Permissive License v 1.0 as shown at
> + * http://oss.oracle.com/licenses/upl.
> + */
> +
> +/*
> + * ASSERTION: Aggregations are not data-recording.
> + *
> + * SECTION: Aggregations/Aggregations
> + */
> +
> +tick-100ms
> +{
> +	@a = count();
> +}
> +tick-1005ms
> +{
> +	exit(0);
> +}
> diff --git a/test/unittest/aggs/tst.count_notquiet.r b/test/unittest/aggs/tst.count_notquiet.r
> new file mode 100644
> index 00000000..b6a14daa
> --- /dev/null
> +++ b/test/unittest/aggs/tst.count_notquiet.r
> @@ -0,0 +1,6 @@
> +                   FUNCTION:NAME
> +                    :tick-1005ms 
> +
> +               10
> +-- @@stderr --
> +dtrace: script 'test/unittest/aggs/tst.count_notquiet.d' matched 2 probes
> -- 
> 2.18.4
> 
> 
> _______________________________________________
> DTrace-devel mailing list
> DTrace-devel at oss.oracle.com
> https://oss.oracle.com/mailman/listinfo/dtrace-devel



More information about the DTrace-devel mailing list