[DTrace-devel] [PATCH 42/61] Fix dtrace_aggregate_clear() for min() and max()
Kris Van Hees
kris.van.hees at oracle.com
Sat Aug 6 06:30:50 UTC 2022
Combine this with the next patch in the series, since that is the one that
actually makes use of dtrace_aggregate_clear(), i.e. it needs it. No need to
do this in two patches.
On Fri, Jul 08, 2022 at 10:45:26AM -0400, eugene.loh--- via DTrace-devel wrote:
> From: Eugene Loh <eugene.loh at oracle.com>
>
> NB: This function is apparently unused in both legacy DTrace as well
> as the port to BPF, but we will be able to make use of it in up-coming
> patches.
>
> Signed-off-by: Eugene Loh <eugene.loh at oracle.com>
> ---
> libdtrace/dt_aggregate.c | 26 ++++++++++++++++++++------
> 1 file changed, 20 insertions(+), 6 deletions(-)
>
> diff --git a/libdtrace/dt_aggregate.c b/libdtrace/dt_aggregate.c
> index f2501ad4..84b79207 100644
> --- a/libdtrace/dt_aggregate.c
> +++ b/libdtrace/dt_aggregate.c
> @@ -1800,13 +1800,27 @@ dtrace_aggregate_clear(dtrace_hdl_t *dtp)
> rec = &aggdesc->dtagd_recs[aggdesc->dtagd_nrecs - 1];
> data = &h->dtahe_data;
>
> - memset(&data->dtada_data[rec->dtrd_offset], 0, rec->dtrd_size);
> -
> - if (data->dtada_percpu == NULL)
> - continue;
> + switch (rec->dtrd_action) {
> + case DT_AGG_MIN:
> + *((uint64_t*)(&data->dtada_data[rec->dtrd_offset])) = INT64_MAX;
> + if (data->dtada_percpu)
> + for (i = 0; i < max_cpus; i++)
> + *((uint64_t*)data->dtada_percpu[i]) = INT64_MAX;
> + break;
> + case DT_AGG_MAX:
> + *((uint64_t*)(&data->dtada_data[rec->dtrd_offset])) = INT64_MIN;
> + if (data->dtada_percpu)
> + for (i = 0; i < max_cpus; i++)
> + *((uint64_t*)data->dtada_percpu[i]) = INT64_MIN;
> + break;
> + default:
> + memset(&data->dtada_data[rec->dtrd_offset], 0, rec->dtrd_size);
> + if (data->dtada_percpu)
> + for (i = 0; i < max_cpus; i++)
> + memset(data->dtada_percpu[i], 0, rec->dtrd_size);
> + break;
> + }
>
> - for (i = 0; i < max_cpus; i++)
> - memset(data->dtada_percpu[i], 0, rec->dtrd_size);
> }
> }
>
> --
> 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