Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id C3798C433DB for ; Wed, 17 Feb 2021 03:52:42 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 8293164DF3 for ; Wed, 17 Feb 2021 03:52:42 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230438AbhBQDwl (ORCPT ); Tue, 16 Feb 2021 22:52:41 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53930 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230417AbhBQDwj (ORCPT ); Tue, 16 Feb 2021 22:52:39 -0500 Received: from mail-qt1-x82a.google.com (mail-qt1-x82a.google.com [IPv6:2607:f8b0:4864:20::82a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D2EE6C06174A for ; Tue, 16 Feb 2021 19:51:59 -0800 (PST) Received: by mail-qt1-x82a.google.com with SMTP id w5so3277105qts.12 for ; Tue, 16 Feb 2021 19:51:59 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:date:from:to:cc:subject:in-reply-to:message-id:references :mime-version; bh=vQkmQfX3MhcQsu+jv5YnlZQ6eikMsM7g4wN7pp0b65E=; b=Bx9VYgRMo6hlKIMwKEE1nDzxJTv1d6tOM9TBTh4c9epFAQdF5hrAzReNJIr/ZpeY3K wSUQq7V1uPzTkQ/kgBOkosmlI78x93eTOTVfhcQgPHSTMuYgu6pqf2wBdspXPyh1NK9c hqaHTt5uiPtwNqdCcrwz1od8NPCUkfFJqvRnwXH66BTbQK216hBaPpAt7kY/oqXk6pKn p0NCwnSMA4KcOIjQA/H9h7AavU441iq+lCh/a2/7fhdhLhpK38YIwYXx/B4tHlKxH0lD PkmQvGK4CLL85v5oco3C2vfSruqD12Mw6IHb9ZTf3aQNyaG1NVZO0pdg0My4ZoYnclnE lZiQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:date:from:to:cc:subject:in-reply-to :message-id:references:mime-version; bh=vQkmQfX3MhcQsu+jv5YnlZQ6eikMsM7g4wN7pp0b65E=; b=lJmnoOKm1P1kaLQZh02TUuzLxa+s5p3yphmgqLKIY3ZlZi5wV9QQ4ZHFzm/ex8OxvK OkDr5v41sloWtQU2XGVQINFJXEvVO9ADQ5MfG+v6IVvT7OtMmo+XT8azwEhm3ViK+Qj5 VhEVKYZWk/WY2t8NIE5D7GbU5DqqRjUX5uInvEevIbogoWr0EUSBbTu9rjd2ffVq/8WW G7EhZ7cSW5W0JI/EsAHAfwnsI8sKjBOFOEDQNTV/LXFxQn15JsPGDyk8yQELb/vrsOR0 cOzCxrB1wxLNkTeBTaurq+C9d6ctJCsahJaRT6DTKg5Lj6ekdJlUYgR/mm4RoUSoTrCo TiLg== X-Gm-Message-State: AOAM533YmL7fRrkvdRUr4sv60WGE/IiLgAKmaGA/0C9fA6BA/5ezzcvH /Hclg135BqCH9W5LvRkhwOI= X-Google-Smtp-Source: ABdhPJwHTbhYa2saPljpKUj4qZApX372HnuFnCQTJ7qa4A/mj9s5RaUJI4aLuuQMmIYznsGMBGZ9LA== X-Received: by 2002:aed:2090:: with SMTP id 16mr22706791qtb.146.1613533919110; Tue, 16 Feb 2021 19:51:59 -0800 (PST) Received: from fionn (bras-base-rdwyon0600w-grc-06-184-147-140-29.dsl.bell.ca. [184.147.140.29]) by smtp.gmail.com with ESMTPSA id u20sm434933qtb.63.2021.02.16.19.51.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 16 Feb 2021 19:51:58 -0800 (PST) Sender: John Kacur Date: Tue, 16 Feb 2021 22:51:58 -0500 (EST) From: John Kacur To: Daniel Wagner cc: Clark Williams , linux-rt-users@vger.kernel.org Subject: Re: [PATCH rt-tests v5 11/13] oslat: Add JSON output feature In-Reply-To: <20210210175118.19709-12-dwagner@suse.de> Message-ID: <9332d197-d46a-e071-d7c2-2c70bfc7ca68@redhat.com> References: <20210210175118.19709-1-dwagner@suse.de> <20210210175118.19709-12-dwagner@suse.de> MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Precedence: bulk List-ID: X-Mailing-List: linux-rt-users@vger.kernel.org On Wed, 10 Feb 2021, Daniel Wagner wrote: > Write the test results as JSON output to a file. This allows to > simplifies any parsing later on. > > Signed-off-by: Daniel Wagner > --- > src/oslat/oslat.c | 97 +++++++++++++++++++++++++++++++++++++++-------- > 1 file changed, 82 insertions(+), 15 deletions(-) > > diff --git a/src/oslat/oslat.c b/src/oslat/oslat.c > index 9e6f70600830..987f2002985d 100644 > --- a/src/oslat/oslat.c > +++ b/src/oslat/oslat.c > @@ -29,7 +29,7 @@ > #include > #include > #include > -#include > +#include > > #include > #include > @@ -41,6 +41,8 @@ > #include > #include > > +#include > + > #include "rt-utils.h" > #include "rt-numa.h" > #include "rt-error.h" > @@ -171,6 +173,7 @@ struct global { > uint64_t bias; > int single_preheat_thread; > int output_omit_zero_buckets; > + char outfile[MAX_PATH]; > > /* Mutable state. */ > volatile enum command cmd; > @@ -479,6 +482,39 @@ static void write_summary(struct thread *t) > printf("\n"); > } > > +static void write_summary_json(FILE *f, void *data) > +{ > + struct thread *t = data; > + int i, j, comma; > + > + fprintf(f, " \"num_threads\": %d,\n", g.n_threads); > + fprintf(f, " \"thread\": {\n"); > + for (i = 0; i < g.n_threads; ++i) { > + fprintf(f, " \"%u\": {\n", i); > + fprintf(f, " \"cpu\": %d,\n", t[i].core_i); > + fprintf(f, " \"freq\": %d,\n", t[i].cpu_mhz); > + fprintf(f, " \"min\": %" PRIu64 ",\n", t[i].minlat); > + fprintf(f, " \"avg\": %3lf,\n", t[i].average); > + fprintf(f, " \"max\": %" PRIu64 ",\n", t[i].maxlat); > + fprintf(f, " \"duration\": %.3f,\n", > + cycles_to_sec(&(t[i]), t[i].runtime)); > + fprintf(f, " \"histogram\": {"); > + for (j = 0, comma = 0; j < g.bucket_size; j++) { > + if (t[i].buckets[j] == 0) > + continue; > + fprintf(f, "%s", comma ? ",\n" : "\n"); > + fprintf(f, " \"%" PRIu64 "\": %" PRIu64, > + g.bias+j+1, t[i].buckets[j]); > + comma = 1; > + } > + if (comma) > + fprintf(f, "\n"); > + fprintf(f, " }\n"); > + fprintf(f, " }%s\n", i == g.n_threads - 1 ? "" : ","); > + } > + fprintf(f, " }\n"); > +} > + > static void run_expt(struct thread *threads, int runtime_secs) > { > int i; > @@ -533,6 +569,7 @@ static void usage(int error) > " NOTE: please make sure the CPU frequency on all testing cores\n" > " are locked before using this parmater. If you don't know how\n" > " to lock the freq then please don't use this parameter.\n" > + " --output=FILENAME write final results into FILENAME, JSON formatted\n" > "-T, --trace-threshold Stop the test when threshold triggered (in us),\n" > " print a marker in ftrace and stop ftrace too.\n" > "-v, --version Display the version of the software.\n" > @@ -557,34 +594,45 @@ static int workload_select(char *name) > return -1; > } > > +enum option_value { > + OPT_BUCKETSIZE=1, OPT_CPU_LIST, OPT_CPU_MAIN_THREAD, > + OPT_DURATION, OPT_RT_PRIO, OPT_HELP, OPT_TRACE_TH, > + OPT_WORKLOAD, OPT_WORKLOAD_MEM, OPT_BIAS, OPT_OUTPUT, > + OPT_SINGLE_PREHEAT, OPT_ZERO_OMIT, OPT_VERSION > + > +}; > + > /* Process commandline options */ > static void parse_options(int argc, char *argv[]) > { > while (1) { > + int option_index = 0; > static struct option options[] = { > - { "bucket-size", required_argument, NULL, 'b' }, > - { "cpu-list", required_argument, NULL, 'c' }, > - { "cpu-main-thread", required_argument, NULL, 'C'}, > - { "duration", required_argument, NULL, 'D' }, > - { "rtprio", required_argument, NULL, 'f' }, > - { "help", no_argument, NULL, 'h' }, > - { "trace-threshold", required_argument, NULL, 'T' }, > - { "workload", required_argument, NULL, 'w'}, > - { "workload-mem", required_argument, NULL, 'm'}, > - { "bias", no_argument, NULL, 'B'}, > - { "single-preheat", no_argument, NULL, 's'}, > - { "zero-omit", no_argument, NULL, 'u'}, > - { "version", no_argument, NULL, 'v'}, > + { "bucket-size",required_argument, NULL, OPT_BUCKETSIZE }, > + { "cpu-list", required_argument, NULL, OPT_CPU_LIST }, > + { "cpu-main-thread", required_argument, NULL, OPT_CPU_MAIN_THREAD}, > + { "duration", required_argument, NULL, OPT_DURATION }, > + { "rtprio", required_argument, NULL, OPT_RT_PRIO }, > + { "help", no_argument, NULL, OPT_HELP }, > + { "trace-threshold", required_argument, NULL, OPT_TRACE_TH }, > + { "workload", required_argument, NULL, OPT_WORKLOAD }, > + { "workload-mem", required_argument, NULL, OPT_WORKLOAD_MEM }, > + { "bias", no_argument, NULL, OPT_BIAS }, > + { "single-preheat", no_argument, NULL, OPT_SINGLE_PREHEAT }, > + { "output", required_argument, NULL, OPT_OUTPUT }, > + { "zero-omit", no_argument, NULL, OPT_ZERO_OMIT }, > + { "version", no_argument, NULL, OPT_VERSION }, > { NULL, 0, NULL, 0 }, > }; > int i, c = getopt_long(argc, argv, "b:Bc:C:D:f:hm:sw:T:vz", > - options, NULL); > + options, &option_index); > long ncores; > > if (c == -1) > break; > > switch (c) { > + case OPT_BUCKETSIZE: > case 'b': > g.bucket_size = strtol(optarg, NULL, 10); > if (g.bucket_size > 1024 || g.bucket_size <= 4) { > @@ -593,12 +641,15 @@ static void parse_options(int argc, char *argv[]) > exit(1); > } > break; > + case OPT_BIAS: > case 'B': > g.enable_bias = 1; > break; > + case OPT_CPU_LIST: > case 'c': > g.cpu_list = strdup(optarg); > break; > + case OPT_CPU_MAIN_THREAD: > case 'C': > ncores = sysconf(_SC_NPROCESSORS_CONF); > g.cpu_main_thread = strtol(optarg, NULL, 10); > @@ -608,6 +659,7 @@ static void parse_options(int argc, char *argv[]) > exit(1); > } > break; > + case OPT_DURATION: > case 'D': > g.runtime = parse_time_string(optarg); > if (!g.runtime) { > @@ -615,6 +667,7 @@ static void parse_options(int argc, char *argv[]) > exit(1); > } > break; > + case OPT_RT_PRIO: > case 'f': > g.rtprio = strtol(optarg, NULL, 10); > if (g.rtprio < 1 || g.rtprio > 99) { > @@ -622,6 +675,10 @@ static void parse_options(int argc, char *argv[]) > exit(1); > } > break; > + case OPT_OUTPUT: > + strncpy(g.outfile, optarg, strnlen(optarg, MAX_PATH-1)); > + break; > + case OPT_TRACE_TH: > case 'T': > g.trace_threshold = strtol(optarg, NULL, 10); > if (g.trace_threshold <= 0) { > @@ -630,6 +687,7 @@ static void parse_options(int argc, char *argv[]) > } > enable_trace_mark(); > break; > + case OPT_WORKLOAD: > case 'w': > if (workload_select(optarg)) { > printf("Unknown workload '%s'. Please choose from: ", optarg); > @@ -642,12 +700,14 @@ static void parse_options(int argc, char *argv[]) > exit(1); > } > break; > + case OPT_WORKLOAD_MEM: > case 'm': > if (parse_mem_string(optarg, &g.workload_mem_size)) { > printf("Unknown workload memory size '%s'.\n\n", optarg); > exit(1); > } > break; > + case OPT_SINGLE_PREHEAT: > case 's': > /* > * Only use one core for pre-heat. Then if --bias is used, the > @@ -655,6 +715,7 @@ static void parse_options(int argc, char *argv[]) > */ > g.single_preheat_thread = true; > break; > + case OPT_VERSION: > case 'v': > /* > * Because we always dump the version even before parsing options, > @@ -662,9 +723,11 @@ static void parse_options(int argc, char *argv[]) > */ > exit(0); > break; > + case OPT_ZERO_OMIT: > case 'z': > g.output_omit_zero_buckets = 1; > break; > + case OPT_HELP: > case 'h': > usage(0); > break; > @@ -781,6 +844,10 @@ int main(int argc, char *argv[]) > > write_summary(threads); > > + if (strlen(g.outfile) != 0) > + rt_write_json(g.outfile, argc, argv, > + write_summary_json, threads); > + > if (g.cpu_list) { > free(g.cpu_list); > g.cpu_list = NULL; > -- > 2.30.0 > > - Added a space after a common parse_options Signed-off-by: John Kacur