Re: [PATCH v2 5/5] perf metric: Don't compute unused events.

From: Jiri Olsa
Date: Thu Nov 19 2020 - 16:00:06 EST


On Tue, Nov 17, 2020 at 09:03:35PM -0800, Ian Rogers wrote:

SNIP

> + ids__free($1.ids);
> + ids__free($3.ids);
> + }
> + } else {
> + $$.val = NAN;
> + $$.ids = ids__union($1.ids, $3.ids);
> + }
> +}
> +| expr '*' expr
> +{
> + if (!compute_ids || (isfinite($1.val) && isfinite($3.val))) {
> + $$.val = $1.val * $3.val;
> + $$.ids = NULL;
> + if (compute_ids) {
> + ids__free($1.ids);
> + ids__free($3.ids);
> + }
> + } else {
> + $$.val = NAN;
> + $$.ids = ids__union($1.ids, $3.ids);
> + }
> +}
> +| expr '/' expr
> +{
> + if (fpclassify($3.val) == FP_ZERO) {
> + pr_debug("division by zero\n");
> + YYABORT;
> + } else if (!compute_ids || (isfinite($1.val) && isfinite($3.val))) {
> + $$.val = $1.val / $3.val;
> + $$.ids = NULL;

hum, I'm confused with this.. compute_ids with finite values?
why do we erase ids then? also val should be NAN then, no?
could you please put in some comment with reasoning?

thanks,
jirka