linux-trace-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Gabriele Monaco <gmonaco@redhat.com>
To: Nam Cao <namcao@linutronix.de>
Cc: Steven Rostedt <rostedt@goodmis.org>,
	Masami Hiramatsu <mhiramat@kernel.org>,
	 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>,
	linux-trace-kernel@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v2 2/5] rv/ltl: Support per-cpu monitors
Date: Thu, 07 Aug 2025 15:28:46 +0200	[thread overview]
Message-ID: <918e887ec5f0832623b9fb7b8a23559aaa66e3db.camel@redhat.com> (raw)
In-Reply-To: <8e2b9d37f0543b1c0f78119d459d2294d99c8d4d.1754466623.git.namcao@linutronix.de>

On Wed, 2025-08-06 at 10:01 +0200, Nam Cao wrote:
> Add support for per-cpu run-time verification linear temporal logic
> monitors. This is analogous to deterministic automaton per-cpu
> monitors.
> 
> Signed-off-by: Nam Cao <namcao@linutronix.de>
> ---
> v2: Rename "implicit" to "cpu"

Looks good to me.

Reviewed-by: Gabriele Monaco <gmonaco@redhat.com>

Thanks,
Gabriele

> ---
>  include/rv/ltl_monitor.h   | 32 ++++++++++++++++++++++++++
>  kernel/trace/rv/Kconfig    |  4 ++++
>  kernel/trace/rv/rv_trace.h | 46
> ++++++++++++++++++++++++++++++++++++++
>  3 files changed, 82 insertions(+)
> 
> diff --git a/include/rv/ltl_monitor.h b/include/rv/ltl_monitor.h
> index 9dabc5b133a3..4ad08b5b9f2d 100644
> --- a/include/rv/ltl_monitor.h
> +++ b/include/rv/ltl_monitor.h
> @@ -23,12 +23,21 @@
>  
>  typedef struct task_struct *monitor_target;
>  
> +#elif LTL_MONITOR_TYPE == RV_MON_PER_CPU
> +
> +#define TARGET_PRINT_FORMAT "%u"
> +#define TARGET_PRINT_ARGS(cpu) cpu
> +
> +typedef unsigned int monitor_target;
> +
>  #endif
>  
>  #ifdef CONFIG_RV_REACTORS
>  #define RV_MONITOR_NAME CONCATENATE(rv_, MONITOR_NAME)
>  static struct rv_monitor RV_MONITOR_NAME;
>  
> +static struct ltl_monitor *ltl_get_monitor(monitor_target target);
> +
>  static void rv_cond_react(monitor_target target)
>  {
>  	if (!rv_reacting_on() || !RV_MONITOR_NAME.react)
> @@ -54,6 +63,13 @@ static struct ltl_monitor
> *ltl_get_monitor(monitor_target target)
>  {
>  	return &target->rv[ltl_monitor_slot].ltl_mon;
>  }
> +#elif LTL_MONITOR_TYPE == RV_MON_PER_CPU
> +static struct ltl_monitor *ltl_get_monitor(unsigned int cpu)
> +{
> +	static DEFINE_PER_CPU(struct ltl_monitor, ltl_monitor);
> +
> +	return per_cpu_ptr(&ltl_monitor, cpu);
> +}
>  #endif
>  
>  static void ltl_target_init(monitor_target target, bool
> target_creation)
> @@ -108,6 +124,22 @@ static void ltl_monitor_destroy(void)
>  	rv_put_task_monitor_slot(ltl_monitor_slot);
>  	ltl_monitor_slot = RV_PER_TASK_MONITOR_INIT;
>  }
> +
> +#elif LTL_MONITOR_TYPE == RV_MON_PER_CPU
> +
> +static int ltl_monitor_init(void)
> +{
> +	unsigned int cpu;
> +
> +	for_each_possible_cpu(cpu)
> +		ltl_target_init(cpu, false);
> +	return 0;
> +}
> +
> +static void ltl_monitor_destroy(void)
> +{
> +}
> +
>  #endif
>  
>  static void ltl_illegal_state(monitor_target target, struct
> ltl_monitor *mon)
> diff --git a/kernel/trace/rv/Kconfig b/kernel/trace/rv/Kconfig
> index 5b4be87ba59d..7ef89006ed50 100644
> --- a/kernel/trace/rv/Kconfig
> +++ b/kernel/trace/rv/Kconfig
> @@ -16,6 +16,10 @@ config DA_MON_EVENTS_ID
>  	select RV_MON_MAINTENANCE_EVENTS
>  	bool
>  
> +config LTL_MON_EVENTS_CPU
> +	select RV_MON_EVENTS
> +	bool
> +
>  config LTL_MON_EVENTS_ID
>  	select RV_MON_EVENTS
>  	bool
> diff --git a/kernel/trace/rv/rv_trace.h b/kernel/trace/rv/rv_trace.h
> index 4a6faddac614..bf7cca6579ec 100644
> --- a/kernel/trace/rv/rv_trace.h
> +++ b/kernel/trace/rv/rv_trace.h
> @@ -177,8 +177,54 @@ DECLARE_EVENT_CLASS(error_ltl_monitor_id,
>  #include <monitors/pagefault/pagefault_trace.h>
>  #include <monitors/sleep/sleep_trace.h>
>  // Add new monitors based on CONFIG_LTL_MON_EVENTS_ID here
> +
>  #endif /* CONFIG_LTL_MON_EVENTS_ID */
>  
> +#ifdef CONFIG_LTL_MON_EVENTS_CPU
> +DECLARE_EVENT_CLASS(event_ltl_monitor_cpu,
> +
> +	TP_PROTO(unsigned int cpu, char *states, char *atoms, char
> *next),
> +
> +	TP_ARGS(cpu, states, atoms, next),
> +
> +	TP_STRUCT__entry(
> +		__field(unsigned int, cpu)
> +		__string(states, states)
> +		__string(atoms, atoms)
> +		__string(next, next)
> +	),
> +
> +	TP_fast_assign(
> +		__entry->cpu = cpu;
> +		__assign_str(states);
> +		__assign_str(atoms);
> +		__assign_str(next);
> +	),
> +
> +	TP_printk("cpu%u: (%s) x (%s) -> (%s)", __entry->cpu,
> +		  __get_str(states), __get_str(atoms),
> __get_str(next))
> +);
> +
> +DECLARE_EVENT_CLASS(error_ltl_monitor_cpu,
> +
> +	TP_PROTO(unsigned int cpu),
> +
> +	TP_ARGS(cpu),
> +
> +	TP_STRUCT__entry(
> +		__field(unsigned int, cpu)
> +	),
> +
> +	TP_fast_assign(
> +		__entry->cpu = cpu;
> +	),
> +
> +	TP_printk("cpu%u: violation detected", __entry->cpu)
> +);
> +// Add new monitors based on CONFIG_LTL_MON_EVENTS_CPU here
> +
> +#endif /* CONFIG_LTL_MON_EVENTS_CPU */
> +
>  #ifdef CONFIG_RV_MON_MAINTENANCE_EVENTS
>  /* Tracepoint useful for monitors development, currenly only used in
> DA */
>  TRACE_EVENT(rv_retries_error,


  reply	other threads:[~2025-08-07 13:28 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-08-06  8:01 [PATCH v2 0/5] rv: LTL per-cpu monitor type and real-time scheduling monitor Nam Cao
2025-08-06  8:01 ` [PATCH v2 1/5] rv/ltl: Prepare for other monitor types Nam Cao
2025-08-06  8:01 ` [PATCH v2 2/5] rv/ltl: Support per-cpu monitors Nam Cao
2025-08-07 13:28   ` Gabriele Monaco [this message]
2025-08-06  8:01 ` [PATCH v2 3/5] verification/rvgen/ltl: Support per-cpu monitor generation Nam Cao
2025-08-07 13:06   ` Gabriele Monaco
2025-08-08  5:12     ` Nam Cao
2025-08-08  6:21       ` Gabriele Monaco
2025-08-08  6:30         ` Nam Cao
2025-08-06  8:01 ` [PATCH v2 4/5] sched: Add task enqueue/dequeue trace points Nam Cao
2025-08-15 13:40   ` Peter Zijlstra
2025-08-15 13:52     ` Peter Zijlstra
2025-08-21  7:05       ` Nam Cao
2025-08-21  8:43         ` K Prateek Nayak
2025-08-19  7:49     ` Nam Cao
2025-08-19  8:24       ` Peter Zijlstra
2025-08-06  8:01 ` [PATCH v2 5/5] rv: Add rts monitor Nam Cao
2025-08-06 20:28   ` kernel test robot
2025-08-07 13:33   ` Gabriele Monaco
2025-08-08  5:13     ` Nam Cao
2025-08-07 14:34   ` Gabriele Monaco
2025-08-08  5:29     ` Nam Cao
2025-08-08  7:30       ` Gabriele Monaco
2025-08-15 13:48   ` Peter Zijlstra
2025-08-19  7:54     ` Nam Cao

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=918e887ec5f0832623b9fb7b8a23559aaa66e3db.camel@redhat.com \
    --to=gmonaco@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-trace-kernel@vger.kernel.org \
    --cc=mathieu.desnoyers@efficios.com \
    --cc=mhiramat@kernel.org \
    --cc=namcao@linutronix.de \
    --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).