From: Nam Cao <namcao@linutronix.de>
To: Gabriele Monaco <gmonaco@redhat.com>
Cc: Steven Rostedt <rostedt@goodmis.org>,
john.ogness@linutronix.de, linux-trace-kernel@vger.kernel.org,
linux-kernel@vger.kernel.org, Petr Mladek <pmladek@suse.com>,
Sergey Senozhatsky <senozhatsky@chromium.org>
Subject: Re: [PATCH 02/10] rv: Let the reactors take care of buffers
Date: Thu, 13 Mar 2025 09:16:59 +0100 [thread overview]
Message-ID: <20250313081659.N-X57_b_@linutronix.de> (raw)
In-Reply-To: <e3f6e9a2e859e2c65ab960942543b8660f86edbc.camel@redhat.com>
Hi Gabriele,
On Wed, Mar 12, 2025 at 08:58:56AM +0100, Gabriele Monaco wrote:
> On Tue, 2025-03-11 at 18:05 +0100, Nam Cao wrote:
> > diff --git a/include/rv/da_monitor.h b/include/rv/da_monitor.h
> > index 510c88bfabd4..c55d45544a16 100644
> > --- a/include/rv/da_monitor.h
> > +++ b/include/rv/da_monitor.h
> > @@ -16,58 +16,11 @@
> > #include <linux/bug.h>
> > #include <linux/sched.h>
> >
> > -#ifdef CONFIG_RV_REACTORS
> > -
> > -#define DECLARE_RV_REACTING_HELPERS(name,
> > type) \
> > -static char
> > REACT_MSG_##name[1024]; \
> > -
> > \
> > -static inline char *format_react_msg_##name(type curr_state, type
> > event) \
> > -
> > { \
> > - snprintf(REACT_MSG_##name,
> > 1024, \
> > - "rv: monitor %s does not allow event %s on state
> > %s\n", \
> > -
> > #name, \
> > -
> > model_get_event_name_##name(event), \
> > -
> > model_get_state_name_##name(curr_state)); \
> > - return
> > REACT_MSG_##name; \
> > -
> > } \
> > -
> > \
> > -static void cond_react_##name(char
> > *msg) \
> > -
> > { \
> > - if
> > (rv_##name.react) \
> > -
> > rv_##name.react(msg); \
> > -
> > } \
> > -
> > \
> > -static bool
> > rv_reacting_on_##name(void) \
> > -
> > { \
> > - return
> > rv_reacting_on(); \
> > -}
> > -
> > -#else /* CONFIG_RV_REACTOR */
> > -
> > -#define DECLARE_RV_REACTING_HELPERS(name,
> > type) \
> > -static inline char *format_react_msg_##name(type curr_state, type
> > event) \
> > -
> > { \
> > - return
> > NULL; \
> > -
> > } \
> > -
> > \
> > -static void cond_react_##name(char
> > *msg) \
> > -
> > { \
> > -
> > return; \
> > -
> > } \
> > -
> > \
> > -static bool
> > rv_reacting_on_##name(void) \
> > -
> > { \
> > - return
> > 0; \
> > -}
> > -#endif
> > -
>
> I don't think you need to remove those helper functions, why not just
> having format_react_msg_ prepare the arguments for react?
I'm not sure what you mean. Making format_react_msg_* a macro that is
preprocessed into arguments? Then make cond_react_*() a variadic function,
so that we can "pass" format_react_msg_* to it?
Going that way would also need a vreact() variant, as cond_react_*() cannot
pass on the variadic arguments to react().
Instead, is it cleaner to do the below?
diff --git a/include/rv/da_monitor.h b/include/rv/da_monitor.h
index 510c88bfabd4..e185ebf894a4 100644
--- a/include/rv/da_monitor.h
+++ b/include/rv/da_monitor.h
@@ -19,22 +19,14 @@
#ifdef CONFIG_RV_REACTORS
#define DECLARE_RV_REACTING_HELPERS(name, type) \
-static char REACT_MSG_##name[1024]; \
- \
-static inline char *format_react_msg_##name(type curr_state, type event) \
-{ \
- snprintf(REACT_MSG_##name, 1024, \
- "rv: monitor %s does not allow event %s on state %s\n", \
- #name, \
- model_get_event_name_##name(event), \
- model_get_state_name_##name(curr_state)); \
- return REACT_MSG_##name; \
-} \
- \
-static void cond_react_##name(char *msg) \
+static void cond_react_##name(type curr_state, type event) \
{ \
- if (rv_##name.react) \
- rv_##name.react(msg); \
+ if (!rv_##name.react) \
+ return; \
+ rv_##name.react("rv: monitor %s does not allow event %s on state %s\n", \
+ #name, \
+ model_get_event_name_##name(event), \
+ model_get_state_name_##name(curr_state)); \
} \
\
static bool rv_reacting_on_##name(void) \
@@ -45,12 +37,7 @@ static bool rv_reacting_on_##name(void) \
#else /* CONFIG_RV_REACTOR */
#define DECLARE_RV_REACTING_HELPERS(name, type) \
-static inline char *format_react_msg_##name(type curr_state, type event) \
-{ \
- return NULL; \
-} \
- \
-static void cond_react_##name(char *msg) \
+static void cond_react_##name(type curr_state, type event) \
{ \
return; \
} \
@@ -171,7 +158,7 @@ da_event_##name(struct da_monitor *da_mon, enum events_##name event) \
} \
\
if (rv_reacting_on_##name()) \
- cond_react_##name(format_react_msg_##name(curr_state, event)); \
+ cond_react_##name(curr_state, event); \
\
trace_error_##name(model_get_state_name_##name(curr_state), \
model_get_event_name_##name(event)); \
@@ -203,7 +190,7 @@ static inline bool da_event_##name(struct da_monitor *da_mon, struct task_struct
} \
\
if (rv_reacting_on_##name()) \
- cond_react_##name(format_react_msg_##name(curr_state, event)); \
+ cond_react_##name(curr_state, event); \
\
trace_error_##name(tsk->pid, \
model_get_state_name_##name(curr_state), \
Best regards,
Nam
next prev parent reply other threads:[~2025-03-13 8:17 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-03-11 17:05 [PATCH 00/10] RV: Linear temporal logic monitors for RT application Nam Cao
2025-03-11 17:05 ` [PATCH 01/10] rv: Add #undef TRACE_INCLUDE_FILE Nam Cao
2025-03-11 17:05 ` [PATCH 02/10] rv: Let the reactors take care of buffers Nam Cao
2025-03-12 7:58 ` Gabriele Monaco
2025-03-13 8:16 ` Nam Cao [this message]
2025-03-13 11:39 ` Gabriele Monaco
2025-03-13 16:07 ` kernel test robot
2025-03-13 16:07 ` kernel test robot
2025-03-11 17:05 ` [PATCH 03/10] rv: Add infrastructure for linear temporal logic monitor Nam Cao
2025-03-12 6:47 ` Gabriele Monaco
2025-03-12 9:56 ` Steven Rostedt
2025-03-12 14:29 ` Nam Cao
2025-03-11 17:05 ` [PATCH 04/10] rv: Add rtapp_block monitor Nam Cao
2025-03-12 7:34 ` Gabriele Monaco
2025-03-13 15:15 ` kernel test robot
2025-03-11 17:05 ` [PATCH 05/10] x86/tracing: Remove redundant trace_pagefault_key Nam Cao
2025-03-11 17:05 ` [PATCH 06/10] x86/tracing: Move page fault trace points to generic Nam Cao
2025-03-11 17:05 ` [PATCH 07/10] arm64: mm: Add page fault trace points Nam Cao
2025-03-11 17:05 ` [PATCH 08/10] riscv: " Nam Cao
2025-04-02 7:35 ` Alexandre Ghiti
2025-03-11 17:05 ` [PATCH 09/10] rv: Add rtapp_pagefault monitor Nam Cao
2025-03-11 17:05 ` [PATCH 10/10] rv: raise the number of per-task monitor to 2 Nam Cao
2025-03-12 6:57 ` Gabriele Monaco
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=20250313081659.N-X57_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=pmladek@suse.com \
--cc=rostedt@goodmis.org \
--cc=senozhatsky@chromium.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
all inboxes | Powered by JetHome®