linux-trace-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Nam Cao <namcao@linutronix.de>
To: Gabriele Monaco <gmonaco@redhat.com>
Cc: Steven Rostedt <rostedt@goodmis.org>,
	linux-trace-kernel@vger.kernel.org, linux-kernel@vger.kernel.org,
	john.ogness@linutronix.de
Subject: Re: [PATCH v3 13/22] rv: Add support for LTL monitors
Date: Wed, 16 Apr 2025 13:56:58 +0200	[thread overview]
Message-ID: <20250416115658.AkFAts-B@linutronix.de> (raw)
In-Reply-To: <4edad1940b2d05f1997895d4bbc11f02a921e8e5.camel@redhat.com>

On Wed, Apr 16, 2025 at 11:34:53AM +0200, Gabriele Monaco wrote:
> On Wed, 2025-04-16 at 08:51 +0200, Nam Cao wrote:
> >  #endif /* CONFIG_DA_MON_EVENTS_ID */
> > +#if CONFIG_LTL_MON_EVENTS_ID
> > +TRACE_EVENT(event_ltl_monitor_id,
> > +
> > +	TP_PROTO(struct task_struct *task, char *states, char
> > *atoms, char *next),
> > +
> > +	TP_ARGS(task, states, atoms, next),
> > +
> > +	TP_STRUCT__entry(
> > +		__string(comm, task->comm)
> > +		__field(pid_t, pid)
> > +		__string(states, states)
> > +		__string(atoms, atoms)
> > +		__string(next, next)
> > +	),
> > +
> > +	TP_fast_assign(
> > +		__assign_str(comm);
> > +		__entry->pid = task->pid;
> > +		__assign_str(states);
> > +		__assign_str(atoms);
> > +		__assign_str(next);
> > +	),
> > +
> > +	TP_printk("%s[%d]: (%s) x (%s) -> (%s)", __get_str(comm),
> > __entry->pid, __get_str(states),
> > +		  __get_str(atoms), __get_str(next))
> > +);
> > +
> > +TRACE_EVENT(error_ltl_monitor_id,
> > +
> > +	TP_PROTO(struct task_struct *task),
> > +
> > +	TP_ARGS(task),
> > +
> > +	TP_STRUCT__entry(
> > +		__string(comm, task->comm)
> > +		__field(pid_t, pid)
> > +	),
> > +
> > +	TP_fast_assign(
> > +		__assign_str(comm);
> > +		__entry->pid = task->pid;
> > +	),
> > +
> > +	TP_printk("%s[%d]: violation detected", __get_str(comm),
> 
> In your workflow you're probably using events and errors together, but
> wouldn't it help printing the atoms together with the violation
> detected?
> At least to give a clue on the error in case the user doesn't want to
> see the entire trace (which might be needed for a full debug though).
> 
> The same could be said from reactors, the user doesn't have much
> information to infer what went wrong.

Actually my intention for the "event" tracepoints are only for debugging
the monitor itself. I don't want to bother users with the Büchi automaton,
because that's implementation details.

The "error" tracepoints should be enough for identifying problems with
realtime applications. Because errors from the monitors are unambiguous:

  - pagefault monitor: error means an RT task is raising pagefault
  - sleep monitor: error means an RT task is delayed unboundedly

That and a stacktrace (e.g. from perf) is enough to understand the problem.
That was all I need to identifying problems with pipewire using the
monitors.

In the future, we can have other monitors whose warnings are ambiguous, and
a more detailed error message will be necessary. But for now, I think we
can keep it simple.

> > +def abbreviate_atoms(atoms: list[str]) -> list[str]:
> > +    abbrs = list()
> > +    for atom in atoms:
> > +        size = 1
> > +        while True:
> > +            abbr = atom[:size]
> > +            if sum(a.startswith(abbr) for a in atoms) == 1:
> > +                break
> > +            size += 1
> > +        abbrs.append(abbr.lower())
> > +    return abbrs
> 
> I get this is just a matter of preference, so feel free to ignore my
> suggestion.
> This abbreviation algorithm doesn't work too well with atoms starting
> with the same substring and can produce some unexpected result:
> 
> LTL_BLOCK_ON_RT_MUTEX:                b,
> LTL_KERNEL_THREAD:                    ke,
> LTL_KTHREAD_SHOULD_STOP:              kt,
> LTL_NANOSLEEP:                        n,
> LTL_PI_FUTEX:                         p,
> LTL_RT:                               r,
> LTL_SLEEP:                            s,
> LTL_TASK_IS_MIGRATION:                task_is_m,
> LTL_TASK_IS_RCU:                      task_is_r,
> LTL_WAKE:                             wa,
> LTL_WOKEN_BY_EQUAL_OR_HIGHER_PRIO:    woken_by_e,
> LTL_WOKEN_BY_HARDIRQ:                 woken_by_h,
> LTL_WOKEN_BY_NMI:                     woken_by_n,
> 
> "woken_by_*" and "task_is_*" atom can get unnecessarily long and
> while reading "kt" I might think about kernel_thread.
> 
> I was thinking about something like:
> 
> LTL_BLOCK_ON_RT_MUTEX:                b_o_r_m
> LTL_KERNEL_THREAD:                    k_t
> LTL_KTHREAD_SHOULD_STOP:              k_s_s
> LTL_NANOSLEEP:                        n
> LTL_PI_FUTEX:                         p_f
> LTL_RT:                               r
> LTL_SLEEP:                            s
> LTL_TASK_IS_MIGRATION:                t_i_m
> LTL_TASK_IS_RCU:                      t_i_r
> LTL_WAKE:                             w
> LTL_WOKEN_BY_EQUAL_OR_HIGHER_PRIO:    w_b_e_o_h_p
> LTL_WOKEN_BY_HARDIRQ:                 w_b_h
> LTL_WOKEN_BY_NMI:                     w_b_n
> 
> or even
> 
> LTL_BLOCK_ON_RT_MUTEX:                b_m
> LTL_KERNEL_THREAD:                    k_t
> LTL_KTHREAD_SHOULD_STOP:              k_s_s
> LTL_NANOSLEEP:                        n
> LTL_PI_FUTEX:                         p_f
> LTL_RT:                               r
> LTL_SLEEP:                            s
> LTL_TASK_IS_MIGRATION:                t_m
> LTL_TASK_IS_RCU:                      t_r
> LTL_WAKE:                             w
> LTL_WOKEN_BY_EQUAL_OR_HIGHER_PRIO:    w_e_h_p
> LTL_WOKEN_BY_HARDIRQ:                 w_h
> LTL_WOKEN_BY_NMI:                     w_n
> 
> I used the following code to come up with this:
> 
> def abbreviate_atoms(atoms: list[str]) -> list[str]:
>     # completely arbitrary..
>     skip = [ "is", "by", "or", "and" ]
>     def abbr (n, s):
>         return '_'.join(word[:n] for word in s.lower().split('_') if word not in skip)
>     for n in range(1, 32):
>         abbrs = [abbr(n, a) for a in atoms]
>         if len(abbrs) == len(set(abbrs)):
>             return abbrs
> 
> Which could even be tuned to use 2 letters per block instead of 1
> (improving readability by a lot actually)..
> 'bl_on_rt_mu', 'ke_th', 'kt_sh_st', 'na', 'pi_fu', 'rt', 'sl', 'ta_mi',
> 'ta_rc', 'wa', 'wo_eq_hi_pr', 'wo_ha', 'wo_nm'
> 
> What do you think?

Yes, this would be very nice. But as mentioned, this is mainly for
debugging the monitors, not for end users. Therefore I don't want to spend
too much energy on it.

Let me see how "nice" we can make it without spending too many hours.
Thanks for the suggestion!

Best regards,
Nam

  reply	other threads:[~2025-04-16 11:57 UTC|newest]

Thread overview: 34+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-04-16  6:51 [PATCH v3 00/22] RV: Linear temporal logic monitors for RT application Nam Cao
2025-04-16  6:51 ` [PATCH v3 01/22] rv: Add #undef TRACE_INCLUDE_FILE Nam Cao
2025-04-16  6:51 ` [PATCH v3 02/22] printk: Make vprintk_deferred() public Nam Cao
2025-04-16  6:51 ` [PATCH v3 03/22] panic: Add vpanic() Nam Cao
2025-04-16  6:51 ` [PATCH v3 04/22] rv: Let the reactors take care of buffers Nam Cao
2025-04-16  6:51 ` [PATCH v3 05/22] verification/dot2k: Make a separate dot2k_templates/Kconfig_container Nam Cao
2025-04-16  6:51 ` [PATCH v3 06/22] verification/dot2k: Remove __buff_to_string() Nam Cao
2025-04-16  6:51 ` [PATCH v3 07/22] verification/dot2k: Replace is_container() hack with subparsers Nam Cao
2025-04-16  6:51 ` [PATCH v3 08/22] rv: rename CONFIG_DA_MON_EVENTS to CONFIG_RV_MON_EVENTS Nam Cao
2025-04-16  6:51 ` [PATCH v3 09/22] verification/dot2k: Prepare the frontend for LTL inclusion Nam Cao
2025-04-16 13:21   ` Gabriele Monaco
2025-04-16  6:51 ` [PATCH v3 10/22] Documentation/rv: Prepare monitor synthesis document " Nam Cao
2025-04-16  6:51 ` [PATCH v3 11/22] verification/rvgen: Restructure the templates files Nam Cao
2025-04-16  6:51 ` [PATCH v3 12/22] verification/rvgen: Restructure the classes to prepare for LTL inclusion Nam Cao
2025-04-16  6:51 ` [PATCH v3 13/22] rv: Add support for LTL monitors Nam Cao
2025-04-16  9:34   ` Gabriele Monaco
2025-04-16 11:56     ` Nam Cao [this message]
2025-04-16 13:05       ` Gabriele Monaco
2025-04-16 14:13       ` Gabriele Monaco
2025-04-16 14:15         ` Nam Cao
2025-04-16 14:29   ` Gabriele Monaco
2025-04-16  6:51 ` [PATCH v3 14/22] rv: Add rtapp container monitor Nam Cao
2025-04-16  7:32   ` Gabriele Monaco
2025-04-17  5:42     ` Nam Cao
2025-04-16  6:51 ` [PATCH v3 15/22] x86/tracing: Remove redundant trace_pagefault_key Nam Cao
2025-04-16  6:51 ` [PATCH v3 16/22] x86/tracing: Move page fault trace points to generic Nam Cao
2025-04-16  6:51 ` [PATCH v3 17/22] arm64: mm: Add page fault trace points Nam Cao
2025-04-16  6:51 ` [PATCH v3 18/22] riscv: " Nam Cao
2025-04-16  6:51 ` [PATCH v3 19/22] rv: Add rtapp_pagefault monitor Nam Cao
2025-04-16  6:51 ` [PATCH v3 20/22] rv: Add rtapp_sleep monitor Nam Cao
2025-04-16  6:51 ` [PATCH v3 21/22] rv: Add documentation for rtapp monitor Nam Cao
2025-04-16  8:56   ` Gabriele Monaco
2025-04-16  6:51 ` [PATCH v3 22/22] rv: Allow to configure the number of per-task monitor Nam Cao
2025-08-10 21:12 ` [PATCH v3 00/22] RV: Linear temporal logic monitors for RT application patchwork-bot+linux-riscv

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=20250416115658.AkFAts-B@linutronix.de \
    --to=namcao@linutronix.de \
    --cc=gmonaco@redhat.com \
    --cc=john.ogness@linutronix.de \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-trace-kernel@vger.kernel.org \
    --cc=rostedt@goodmis.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 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).