All of lore.kernel.org
 help / color / mirror / Atom feed
From: John Kacur <jkacur@gmail.com>
To: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Cc: linux-rt-users@vger.kernel.org, John Kacur <jkacur@redhat.com>
Subject: Re: [PATCH 5/5] cyclictest: Add a timestamp of the last update
Date: Fri, 28 Aug 2026 10:26:59 -0400 (EDT)	[thread overview]
Message-ID: <f6692168-cc78-d625-f750-bf979be73dfe@gmail.com> (raw)
In-Reply-To: <20260826132153.2476006-6-bigeasy@linutronix.de>



On Wed, 26 Aug 2026, Sebastian Andrzej Siewior wrote:

> Add a timestamp once the the MAX value is updated. This is useful to
> figure out when a certain value was updated and if an update occurred on
> multiple CPUs at same. The output is seconds accurate, the ns are
> stripped for now.
> 
> I'm limiting this to the the -M switch, which I am using, but there
> should be nothing wrong with using it unconditionally.
> 
> Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
> ---
>  src/cyclictest/cyclictest.c | 17 ++++++++++++++++-
>  1 file changed, 16 insertions(+), 1 deletion(-)
> 
> diff --git a/src/cyclictest/cyclictest.c b/src/cyclictest/cyclictest.c
> index 1cad1bf6b929e..1c14d13b7cd80 100644
> --- a/src/cyclictest/cyclictest.c
> +++ b/src/cyclictest/cyclictest.c
> @@ -145,6 +145,7 @@ struct thread_stat {
>  	long redmax;
>  	long cycleofmax;
>  	unsigned long smi_count;
> +	struct timespec max_update_ts;
>  };
>  
>  static pthread_mutex_t trigger_lock;
> @@ -834,8 +835,10 @@ static void *timerthread(void *param)
>  			stat->min = diff;
>  		if (diff > stat->max) {
>  			stat->max = diff;
> -			if (refresh_on_max)
> +			if (refresh_on_max) {
>  				need_refresh_max = true;
> +				clock_gettime(CLOCK_REALTIME, &stat->max_update_ts);
> +			}
>  		}
>  		if (need_refresh_max) {
>  			if (!pthread_mutex_trylock(&refresh_on_max_lock)) {
> @@ -1599,6 +1602,18 @@ static void print_stat(FILE *fp, struct thread_param *par, int index, int verbos
>  				stat->act, stat->cycles ?
>  				(long)(stat->avg/stat->cycles) : 0, stat->max);
>  
> +			if (refresh_on_max) {
> +				char ts_str[64];
> +				struct tm tm;
> +				time_t ts;
> +
> +				ts = stat->max_update_ts.tv_sec;
> +				localtime_r(&ts, &tm);
> +				/* RFC 2822-compliant date format */
> +				strftime(ts_str, sizeof(ts_str), "%a, %d %b %Y %T %z", &tm);

This creates a really long line with redundant information, for example

T: 0 (36716) P: 0 I:1000 C:   1331 Min:      1 Act:    2 Avg:   12 Max:      
71 Fri, 28 Aug 2026 10:18:32 -0400
T: 1 (36717) P: 0 I:1500 C:    887 Min:      1 Act:    2 Avg:   10 Max:      
62 Fri, 28 Aug 2026 10:18:32 -0400
T: 2 (36718) P: 0 I:2000 C:    665 Min:      1 Act:    2 Avg:   28 Max:      
56 Fri, 28 Aug 2026 10:18:32 -0400
T: 3 (36719) P: 0 I:2500 C:    532 Min:      1 Act:   52 Avg:   36 Max:      
57 Fri, 28 Aug 2026 10:18:32 -0400
T: 4 (36720) P: 0 I:3000 C:    443 Min:      1 Act:   51 Avg:   21 Max:      
55 Fri, 28 Aug 2026 10:18:32 -0400
T: 5 (36721) P: 0 I:3500 C:    380 Min:      1 Act:    2 Avg:    1 Max:      
12 Fri, 28 Aug 2026 10:18:32 -0400
T: 6 (36722) P: 0 I:4000 C:    332 Min:      1 Act:   52 Avg:   49 Max:      
62 Fri, 28 Aug 2026 10:18:32 -0400

Why not strftime(ts_str, sizeof(ts_str), "%T", &tm);
This will still go over 80 char, but it's more succinct.


T: 0 (40468) P: 0 I:1000 C:    282 Min:      1 Act:   52 Avg:   17 Max:      
65 10:25:32
T: 1 (40469) P: 0 I:1500 C:    188 Min:      1 Act:   51 Avg:   22 Max:      
56 10:25:31
T: 2 (40470) P: 0 I:2000 C:    141 Min:      1 Act:    2 Avg:    7 Max:      
55 10:25:31
T: 3 (40471) P: 0 I:2500 C:    113 Min:      1 Act:   63 Avg:   19 Max:      
63 10:25:32
T: 4 (40472) P: 0 I:3000 C:     94 Min:      1 Act:   52 Avg:   27 Max:      
54 10:25:31
T: 5 (40473) P: 0 I:3500 C:     80 Min:      1 Act:    5 Avg:   43 Max:      
56 10:25:32
T: 6 (40474) P: 0 I:4000 C:     70 Min:      1 Act:   51 Avg:   27 Max:      
55 10:25:32

The other patches in this series look fine.

John

  reply	other threads:[~2026-08-28 14:27 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-08-26 13:21 [PATCH 0/5] cyclictest: Little tweaks here and there Sebastian Andrzej Siewior
2026-08-26 13:21 ` [PATCH 1/5] rt-tests: cyclicdeadline: Remove unused `alloverflows' Sebastian Andrzej Siewior
2026-08-31 16:40   ` John Kacur
2026-08-26 13:21 ` [PATCH 2/5] cyclictest: Acquire a lock before invoking pthread_cond_signal() Sebastian Andrzej Siewior
2026-08-31 16:41   ` John Kacur
2026-09-01  8:19   ` D, Suneeth
2026-09-01  8:34     ` Tomas Glozar
2026-09-01  8:39     ` Sebastian Andrzej Siewior
2026-08-26 13:21 ` [PATCH 3/5] cyclictest: Make break_thread_id_lock a PI lock Sebastian Andrzej Siewior
2026-08-31 16:42   ` John Kacur
2026-08-26 13:21 ` [PATCH 4/5] cyclictest: Make trigger_lock " Sebastian Andrzej Siewior
2026-08-31 16:43   ` John Kacur
2026-08-26 13:21 ` [PATCH 5/5] cyclictest: Add a timestamp of the last update Sebastian Andrzej Siewior
2026-08-28 14:26   ` John Kacur [this message]
2026-08-28 16:10     ` Sebastian Andrzej Siewior

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=f6692168-cc78-d625-f750-bf979be73dfe@gmail.com \
    --to=jkacur@gmail.com \
    --cc=bigeasy@linutronix.de \
    --cc=jkacur@redhat.com \
    --cc=linux-rt-users@vger.kernel.org \
    /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.