All of lore.kernel.org
 help / color / mirror / Atom feed
From: Kris Van Hees <kris.van.hees@oracle.com>
To: eugene.loh@oracle.com
Cc: dtrace@lists.linux.dev, dtrace-devel@oss.oracle.com
Subject: Re: [PATCH 1/8] test: Allow aggpercpu test to omit some CPUs
Date: Mon, 19 Aug 2024 19:11:57 -0400	[thread overview]
Message-ID: <ZsPRPUXZkD8RRWGf@oracle.com> (raw)
In-Reply-To: <20240604180008.11331-1-eugene.loh@oracle.com>

On Tue, Jun 04, 2024 at 02:00:01PM -0400, eugene.loh@oracle.com wrote:
> From: Eugene Loh <eugene.loh@oracle.com>
> 
> The aggpercpu test uses profile-* to fire aggregations on every CPU.
> But whether for good (offline CPUs) or bad (unreliable probe) reasons,
> a CPU might not aggregate any values.
> 
> Allow this test to skip over such CPUs.  That is, while a BPF agg map
> might have the correct default value for the aggregation function, it
> may not see any anticipated data.  The quality of profile-* probes
> should be checked by a different test.
> 
> Also, when computing avg() and stddev() in the awk check program,
> truncate results to ints more often to mimic the algorithms in DTrace
> for more robust checks.
> 
> Signed-off-by: Eugene Loh <eugene.loh@oracle.com>

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

> ---
>  test/unittest/aggs/tst.aggpercpu.sh | 62 +++++++++++++++++++++--------
>  1 file changed, 45 insertions(+), 17 deletions(-)
> 
> diff --git a/test/unittest/aggs/tst.aggpercpu.sh b/test/unittest/aggs/tst.aggpercpu.sh
> index be74890a..6092bd17 100755
> --- a/test/unittest/aggs/tst.aggpercpu.sh
> +++ b/test/unittest/aggs/tst.aggpercpu.sh
> @@ -46,7 +46,8 @@ fi
>  awk '
>      # The expected value for the aggregation is aggval.
>      # The expected value on a CPU is (m * cpu + b).
> -    function check(label, aggval, m, b) {
> +    # The default value on a CPU that did not fire is defval.
> +    function check(label, aggval, m, b, defval) {
>          # Check the aggregation over all CPUs.
>          getline;
>          print "check:", $0;
> @@ -54,12 +55,38 @@ awk '
>  
>          # Check the per-CPU values.
>          for (i = 1; i <= ncpu; i++) {
> -            getline;
> -            print "check:", $0;
> -            if (match($0, "^    \\[CPU ") != 1 ||
> -                strtonum($2) != cpu[i] ||
> -                strtonum($3) != m * cpu[i] + b)
> -                printf("ERROR: %s, agg per cpu %d, line: %s\n", label, cpu[i], $0);
> +            do {
> +                getline;
> +                print "check:", $0;
> +
> +                # pass is +1 for pass, -1 for error, 0 for skip CPU
> +                pass = 0;
> +
> +                if (match($0, "^    \\[CPU ") != 1) {
> +                    print "ERROR: no CPU to read"
> +                    pass = -1;
> +                } else if (strtonum($2) > cpu[i]) {
> +                    print "ERROR: skipped over expected CPU"
> +                    pass = -1;
> +                } else if (strtonum($2) == cpu[i]) {
> +                    if (strtonum($3) != m * cpu[i] + b) {
> +                        print "ERROR: wrong value"
> +                        pass = -1;
> +                    } else {
> +                        # right value
> +                        pass = +1;
> +                    }
> +                } else if ($3 != defval) {
> +                    print "ERROR: wrong default value"
> +                    pass = -1;
> +                } else {
> +                    # skip over CPU that apparently did not fire
> +                    pass = 0;
> +                }
> +
> +                if (pass == -1)
> +                    printf("ERROR: %s, agg per cpu %d, line: %s\n", label, cpu[i], $0);
> +            } while (pass == 0);
>          }
>      }
>  
> @@ -99,13 +126,14 @@ awk '
>      {
>          # First we finish computing our estimates for avg and stddev.
>          # (The other results require no further action.)
> +        # (We keep truncating to ints to mimic DTrace algorithms.)
>  
> -        xavg /= xcnt;
> +        xavg /= xcnt;             xavg = int(xavg);
>  
> -        xstm /= xcnt;
> -        xstd /= xcnt;
> +        xstm /= xcnt;             xstm = int(xstm);
> +        xstd /= xcnt;             xstd = int(xstd);
>          xstd -= xstm * xstm;
> -        xstd = int(sqrt(xstd));
> +        xstd = sqrt(xstd);        xstd = int(xstd);
>  
>          # Sort the cpus.
>  
> @@ -113,12 +141,12 @@ awk '
>  
>          # Now read the results and compare.
>  
> -        check("cnt", xcnt,  0,   1);
> -        check("avg", xavg, 10,   3);
> -        check("std", xstd,  0,   0);
> -        check("min", xmin, 30, -10);
> -        check("max", xmax, 40, -15);
> -        check("sum", xsum, 50,   0);
> +        check("cnt", xcnt,  0,   1, "0");
> +        check("avg", xavg, 10,   3, "0");
> +        check("std", xstd,  0,   0, "0");
> +        check("min", xmin, 30, -10,  "9223372036854775807");
> +        check("max", xmax, 40, -15, "-9223372036854775808");
> +        check("sum", xsum, 50,   0, "0");
>  
>          printf("done\n");
>      }
> -- 
> 2.18.4
> 

      parent reply	other threads:[~2024-08-19 23:12 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-06-04 18:00 [PATCH 1/8] test: Allow aggpercpu test to omit some CPUs eugene.loh
2024-06-04 18:00 ` [PATCH 2/8] Reduce stack depth if kernel returns NULL frames eugene.loh
2024-08-19 23:30   ` [DTrace-devel] " Kris Van Hees
2024-08-28 20:11     ` Eugene Loh
2024-08-28 20:17       ` Kris Van Hees
2024-08-28 20:23         ` Eugene Loh
2024-08-28 20:37           ` Kris Van Hees
2025-08-13  5:12             ` Eugene Loh
2024-06-04 18:00 ` [PATCH 3/8] test: Fix nonexistent @@sort option eugene.loh
2024-08-19 23:15   ` [DTrace-devel] " Kris Van Hees
2024-06-04 18:00 ` [PATCH 4/8] test: Remove unneeded -w option eugene.loh
2024-08-19 23:12   ` [DTrace-devel] " Kris Van Hees
2024-06-04 18:00 ` [PATCH 5/8] Fix stddev() carryover computation eugene.loh
2024-08-19 23:13   ` [DTrace-devel] " Kris Van Hees
2024-06-04 18:00 ` [PATCH 6/8] test: Check dtrace return status eugene.loh
2024-06-04 18:00 ` [PATCH 7/8] Clean up double semicolons eugene.loh
2024-08-19 23:34   ` [DTrace-devel] " Kris Van Hees
2024-06-04 18:00 ` [PATCH 8/8] Turn some leading spaces into tabs eugene.loh
2024-08-19 23:34   ` [DTrace-devel] " Kris Van Hees
2024-08-19 23:11 ` Kris Van Hees [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=ZsPRPUXZkD8RRWGf@oracle.com \
    --to=kris.van.hees@oracle.com \
    --cc=dtrace-devel@oss.oracle.com \
    --cc=dtrace@lists.linux.dev \
    --cc=eugene.loh@oracle.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.