Re: [PATCH] rt-tests: cyclics: Omit empty histogram buckets

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 




On Wed, 1 May 2024, Crystal Wood wrote:

> This makes the output more palatable for human readers, at the expense
> of requiring other consumers of the data to be able to handle the missing
> lines.
> 
> Signed-off-by: Crystal Wood <crwood@xxxxxxxxxx>
> ---
> Don't apply until the below patch has been merged in rteval:
> https://lore.kernel.org/linux-rt-users/20240501200922.226347-1-crwood@xxxxxxxxxx/
> ---
>  src/cyclictest/cyclictest.c         |  6 +++---
>  src/include/histogram.h             |  4 ++--
>  src/lib/histogram.c                 | 15 ++++++++++++---
>  src/sched_deadline/cyclicdeadline.c |  7 +++----
>  4 files changed, 20 insertions(+), 12 deletions(-)
> 
> diff --git a/src/cyclictest/cyclictest.c b/src/cyclictest/cyclictest.c
> index 8a963392e639..c5c33898c63c 100644
> --- a/src/cyclictest/cyclictest.c
> +++ b/src/cyclictest/cyclictest.c
> @@ -1340,13 +1340,13 @@ static void print_hist(struct thread_param *par[], int nthreads)
>  	fprintf(fd, "# Histogram\n");
>  	for (i = 0; i < histogram; i++) {
>  		unsigned long flags = 0;
> +		char buf[64];
>  
> -		fprintf(fd, "%06d ", i);
> +		snprintf(buf, sizeof(buf), "%06d ", i);
>  
>  		if (histofall)
>  			flags |= HSET_PRINT_SUM;
> -		hset_print_bucket(&hset, fd, i, flags);
> -		fprintf(fd, "\n");
> +		hset_print_bucket(&hset, fd, buf, i, flags);
>  	}
>  	fprintf(fd, "# Min Latencies:");
>  	for (j = 0; j < nthreads; j++)
> diff --git a/src/include/histogram.h b/src/include/histogram.h
> index c7aba68ffb99..31fe2a08eda0 100644
> --- a/src/include/histogram.h
> +++ b/src/include/histogram.h
> @@ -36,7 +36,7 @@ int hist_sample(struct histogram *h, uint64_t sample);
>  int hset_init(struct histoset *hs, unsigned long histos, unsigned long bucket_width,
>  	      unsigned long num_buckets, unsigned long overflow);
>  void hset_destroy(struct histoset *hs);
> -void hset_print_bucket(struct histoset *hs, FILE *f, unsigned long bucket,
> -		       unsigned long flags);
> +void hset_print_bucket(struct histoset *hs, FILE *f, const char *pre,
> +		       unsigned long bucket, unsigned long flags);
>  void hist_print_json(struct histogram *h, FILE *f);
>  void hist_print_oflows(struct histogram *h, FILE *f);
> diff --git a/src/lib/histogram.c b/src/lib/histogram.c
> index 35a9d604da86..c21fc49c0a6c 100644
> --- a/src/lib/histogram.c
> +++ b/src/lib/histogram.c
> @@ -114,8 +114,8 @@ void hset_destroy(struct histoset *hs)
>  	hs->histos = NULL;
>  }
>  
> -void hset_print_bucket(struct histoset *hs, FILE *f, unsigned long bucket,
> -		       unsigned long flags)
> +void hset_print_bucket(struct histoset *hs, FILE *f, const char *pre,
> +		       unsigned long bucket, unsigned long flags)
>  {
>  	unsigned long long sum = 0;
>  	unsigned long i;
> @@ -123,10 +123,17 @@ void hset_print_bucket(struct histoset *hs, FILE *f, unsigned long bucket,
>  	if (bucket >= hs->num_buckets)
>  		return;
>  
> +	for (i = 0; i < hs->num_histos; i++)
> +		sum += hs->histos[i].buckets[bucket];
> +
> +	if (sum == 0)
> +		return;
> +	if (pre)
> +		fprintf(f, "%s", pre);
> +
>  	for (i = 0; i < hs->num_histos; i++) {
>  		unsigned long val = hs->histos[i].buckets[bucket];
>  
> -		sum += val;
>  		if (i != 0)
>  			fprintf(f, "\t");
>  		fprintf(f, "%06lu", val);
> @@ -134,6 +141,8 @@ void hset_print_bucket(struct histoset *hs, FILE *f, unsigned long bucket,
>  
>  	if (flags & HSET_PRINT_SUM)
>  		fprintf(f, "\t%06llu", sum);
> +
> +	fprintf(f, "\n");
>  }
>  
>  void hist_print_json(struct histogram *h, FILE *f)
> diff --git a/src/sched_deadline/cyclicdeadline.c b/src/sched_deadline/cyclicdeadline.c
> index 7525ad136d2c..631d57ee885e 100644
> --- a/src/sched_deadline/cyclicdeadline.c
> +++ b/src/sched_deadline/cyclicdeadline.c
> @@ -731,11 +731,10 @@ static void print_hist(FILE *fp, struct sched_data *sd, int nthreads)
>  	fprintf(fp, "# Histogram\n");
>  	for (i = 0; i < histogram; i++) {
>  		unsigned long flags = 0;
> +		char buf[64];
>  
> -		fprintf(fp, "%06d ", i);
> -
> -		hset_print_bucket(&hset, fp, i, flags);
> -		fprintf(fp, "\n");
> +		snprintf(buf, sizeof(buf), "%06d ", i);
> +		hset_print_bucket(&hset, fp, buf, i, flags);
>  	}
>  	fprintf(fp, "# Min Latencies:");
>  	for (i = 0; i < nthreads; i++)
> -- 
Fixed title to say: rt-tests: cyclictest: Omit empty histogram buckets
Signed-off-by: John Kacur <jkacur@xxxxxxxxxx>





[Index of Archives]     [RT Stable]     [Kernel Newbies]     [IDE]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux ATA RAID]     [Samba]     [Video 4 Linux]     [Device Mapper]

  Powered by Linux