[DTrace-devel] [PATCH 03/05] agg: report error if aggsize is too small

Eugene Loh eugene.loh at oracle.com
Mon May 8 16:33:38 UTC 2023


Reviewed-by: Eugene Loh <eugene.loh at oracle.com>
but...

On 5/5/23 11:31, Kris Van Hees via DTrace-devel wrote:
> When aggregations are used, ensure that the aggsize value is sufficient
> to hold at least a single aggregation.

This comment does not hold.  In fact, it conflicts with the subject line.

> Signed-off-by: Kris Van Hees <kris.van.hees at oracle.com>
> ---
>   libdtrace/dt_bpf.c                         |  3 +--
>   test/unittest/aggs/err.aggsize-too-small.d | 26 ++++++++++++++++++++++
>   test/unittest/aggs/err.aggsize-too-small.r |  3 +++
>   3 files changed, 30 insertions(+), 2 deletions(-)
>   create mode 100644 test/unittest/aggs/err.aggsize-too-small.d
>   create mode 100644 test/unittest/aggs/err.aggsize-too-small.r
>
> diff --git a/libdtrace/dt_bpf.c b/libdtrace/dt_bpf.c
> index 18aa07af..b553b33f 100644
> --- a/libdtrace/dt_bpf.c
> +++ b/libdtrace/dt_bpf.c
> @@ -520,9 +520,8 @@ gmap_create_aggs(dtrace_hdl_t *dtp)
>   
>   	nelems = dtp->dt_options[DTRACEOPT_AGGSIZE] /
>   		 (dtp->dt_maxtuplesize + dtp->dt_maxaggdsize);
> -
>   	if (nelems == 0)
> -		return 0;
> +		return dt_set_errno(dtp, EDT_BUFTOOSMALL);
>   
>   	dtp->dt_aggmap_fd = create_gmap_of_maps(dtp, "aggs",
>   						BPF_MAP_TYPE_ARRAY_OF_MAPS,
> diff --git a/test/unittest/aggs/err.aggsize-too-small.d b/test/unittest/aggs/err.aggsize-too-small.d
> new file mode 100644
> index 00000000..8bd12381
> --- /dev/null
> +++ b/test/unittest/aggs/err.aggsize-too-small.d
> @@ -0,0 +1,26 @@
> +/*
> + * Oracle Linux DTrace.
> + * Copyright (c) 2023, 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: If aggsize is too small to hold a single aggregation, report an
> + *	      error.
> + *
> + * SECTION: Aggregations/Aggregations
> + */
> +
> +#pragma D option aggsize=8
> +
> +BEGIN
> +{
> +	@ = count();
> +	exit(0);
> +}
> +
> +ERROR
> +{
> +	exit(0);
> +}
> diff --git a/test/unittest/aggs/err.aggsize-too-small.r b/test/unittest/aggs/err.aggsize-too-small.r
> new file mode 100644
> index 00000000..b0a37c5d
> --- /dev/null
> +++ b/test/unittest/aggs/err.aggsize-too-small.r
> @@ -0,0 +1,3 @@
> +-- @@stderr --
> +dtrace: script 'test/unittest/aggs/err.aggsize-too-small.d' matched 2 probes
> +dtrace: could not enable tracing: Enabling exceeds size of buffer



More information about the DTrace-devel mailing list