From: John Kacur <jkacur@redhat.com>
To: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Cc: linux-rt-users@vger.kernel.org,
Clark Williams <williams@redhat.com>,
Steven Rostedt <rostedt@goodmis.org>
Subject: Re: [PATCH 07/10] rt-utils: Decouple writting trace-marks with trace stopping
Date: Fri, 19 Sep 2025 14:49:16 -0400 (EDT) [thread overview]
Message-ID: <c2fa419a-75bd-ca4c-db95-eb09035d0287@redhat.com> (raw)
In-Reply-To: <20250903111717.1391196-8-bigeasy@linutronix.de>
On Wed, 3 Sep 2025, Sebastian Andrzej Siewior wrote:
> Most users write a trace mark and expect that the trace stops afterwads.
> Decoupling writting and stopping the trace so it can be used in context
> where trace stopping is not needed.
>
> Make tracemark() writting just to the tracemark file.
> Add tracing_stop() which stops tracing and let current users of
> tracemark() use it.
>
> Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
> ---
> src/cyclictest/cyclictest.c | 1 +
> src/include/rt-utils.h | 1 +
> src/lib/rt-utils.c | 8 ++++++--
> src/oslat/oslat.c | 1 +
> src/sched_deadline/cyclicdeadline.c | 1 +
> 5 files changed, 10 insertions(+), 2 deletions(-)
>
> diff --git a/src/cyclictest/cyclictest.c b/src/cyclictest/cyclictest.c
> index 890da5d869c92..b4bce8915b432 100644
> --- a/src/cyclictest/cyclictest.c
> +++ b/src/cyclictest/cyclictest.c
> @@ -852,6 +852,7 @@ static void *timerthread(void *param)
> break_thread_id = stat->tid;
> tracemark("hit latency threshold (%llu > %d)",
> (unsigned long long) diff, tracelimit);
> + tracing_stop();
> break_thread_value = diff;
> }
> pthread_mutex_unlock(&break_thread_id_lock);
> diff --git a/src/include/rt-utils.h b/src/include/rt-utils.h
> index 569023c5d3051..e148dd77fd7d8 100644
> --- a/src/include/rt-utils.h
> +++ b/src/include/rt-utils.h
> @@ -31,6 +31,7 @@ int parse_mem_string(char *str, uint64_t *val);
>
> void enable_trace_mark(void);
> void tracemark(char *fmt, ...) __attribute__((format(printf, 1, 2)));
> +void tracing_stop(void);
> void disable_trace_mark(void);
>
> #define MSEC_PER_SEC 1000
> diff --git a/src/lib/rt-utils.c b/src/lib/rt-utils.c
> index 294fc9683a122..e504b17738411 100644
> --- a/src/lib/rt-utils.c
> +++ b/src/lib/rt-utils.c
> @@ -427,7 +427,7 @@ void tracemark(char *fmt, ...)
>
> /* bail out if we're not tracing */
> /* or if the kernel doesn't support trace_mark */
> - if (tracemark_fd < 0 || trace_fd < 0)
> + if (tracemark_fd < 0)
> return;
>
> va_start(ap, fmt);
> @@ -436,8 +436,12 @@ void tracemark(char *fmt, ...)
>
> /* write the tracemark message */
> write(tracemark_fd, tracebuf, len);
> +}
>
> - /* now stop any trace */
> +void tracing_stop(void)
> +{
> + if (trace_fd < 0)
> + return;
> write(trace_fd, "0\n", 2);
> }
>
> diff --git a/src/oslat/oslat.c b/src/oslat/oslat.c
> index 9e5a08a2fbd92..4291221dc6521 100644
> --- a/src/oslat/oslat.c
> +++ b/src/oslat/oslat.c
> @@ -340,6 +340,7 @@ static void insert_bucket(struct thread *t, stamp_t value)
> char *line = "%s: Trace threshold (%d us) triggered on cpu %d with %.*f us!\n";
> tracemark(line, g.app_name, g.trace_threshold, t->core_i,
> g.precision, us);
> + tracing_stop();
> err_quit(line, g.app_name, g.trace_threshold, t->core_i,
> g.precision, us);
> }
> diff --git a/src/sched_deadline/cyclicdeadline.c b/src/sched_deadline/cyclicdeadline.c
> index 04e61edc68d83..e2f827deb275a 100644
> --- a/src/sched_deadline/cyclicdeadline.c
> +++ b/src/sched_deadline/cyclicdeadline.c
> @@ -885,6 +885,7 @@ void *run_deadline(void *data)
> break_thread_value = stat->max;
> tracemark("hit latency threshold (%lld > %d)",
> (unsigned long long) stat->max, tracelimit);
> + tracing_stop();
> }
> pthread_mutex_unlock(&break_thread_id_lock);
> break;
> --
> 2.51.0
>
>
- Fixed spelling of "writing" and "afterwards"
Signed-off-by: John Kacur <jkacur@redhat.com>
next prev parent reply other threads:[~2025-09-19 18:49 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-09-03 11:17 [PATCH 00/10] rt-tests: Remove debugfs usage Sebastian Andrzej Siewior
2025-09-03 11:17 ` [PATCH 01/10] README: Drop "debug" from the tracing path Sebastian Andrzej Siewior
2025-09-19 18:18 ` John Kacur
2025-09-03 11:17 ` [PATCH 02/10] rt-utils: Remove mount_debugfs() Sebastian Andrzej Siewior
2025-09-19 18:20 ` John Kacur
2025-09-03 11:17 ` [PATCH 03/10] rt-utils: Rename get_debugfileprefix() and let it look for tracefs Sebastian Andrzej Siewior
2025-09-19 18:29 ` John Kacur
2025-09-03 11:17 ` [PATCH 04/10] queuelat, rt-migrate-test: Use tracefs for tracing Sebastian Andrzej Siewior
2025-09-19 18:39 ` John Kacur
2025-09-03 11:17 ` [PATCH 05/10] rt-utils: Remove fileprefix Sebastian Andrzej Siewior
2025-09-19 18:41 ` John Kacur
2025-09-03 11:17 ` [PATCH 06/10] rt-utils: Simplify trace_file_exists() Sebastian Andrzej Siewior
2025-09-19 18:42 ` John Kacur
2025-09-03 11:17 ` [PATCH 07/10] rt-utils: Decouple writting trace-marks with trace stopping Sebastian Andrzej Siewior
2025-09-19 18:49 ` John Kacur [this message]
2025-09-03 11:17 ` [PATCH 08/10] sched_deadline: Use tracemark() from rt-utils instead cusstom implementation Sebastian Andrzej Siewior
2025-09-19 18:52 ` John Kacur
2025-09-03 11:17 ` [PATCH 09/10] sched_deadline: Check the resulting size returned from snprintf() Sebastian Andrzej Siewior
2025-09-19 18:54 ` John Kacur
2025-09-03 11:17 ` [PATCH 10/10] cyclicdeadline: Don't test for /sys/kernel/debug/sched_features Sebastian Andrzej Siewior
2025-09-19 18:55 ` John Kacur
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=c2fa419a-75bd-ca4c-db95-eb09035d0287@redhat.com \
--to=jkacur@redhat.com \
--cc=bigeasy@linutronix.de \
--cc=linux-rt-users@vger.kernel.org \
--cc=rostedt@goodmis.org \
--cc=williams@redhat.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).