mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Nam Cao <namcao@linutronix.de>
To: "Thomas Weißschuh" <thomas.weissschuh@linutronix.de>,
	"Steven Rostedt" <rostedt@goodmis.org>,
	"Gabriele Monaco" <gmonaco@redhat.com>,
	"Masami Hiramatsu" <mhiramat@kernel.org>,
	"Mathieu Desnoyers" <mathieu.desnoyers@efficios.com>
Cc: linux-trace-kernel@vger.kernel.org, linux-kernel@vger.kernel.org,
	"Thomas Weißschuh" <thomas.weissschuh@linutronix.de>
Subject: Re: [PATCH 3/3] rv: Add explicit lockdep context for reactors
Date: Tue, 14 Oct 2025 09:38:09 +0200	[thread overview]
Message-ID: <87qzv6szku.fsf@yellow.woof> (raw)
In-Reply-To: <20251014-rv-lockdep-v1-3-0b9e51919ea8@linutronix.de>

Thomas Weißschuh <thomas.weissschuh@linutronix.de> writes:
> Reactors can be called from any context through tracepoints.
> When developing reactors care needs to be taken to only call APIs which
> are safe. As the tracepoints used during testing may not actually be
> called from restrictive contexts lockdep may not be helpful.
>
> Add explicit overrides to help lockdep find invalid code patterns.
>
> The usage of LD_WAIT_FREE will trigger lockdep warnings in the panic
> reactor. These are indeed valid warnings but they are out of scope for
> RV and will instead be fixed by the printk subsystem.
>
> Signed-off-by: Thomas Weißschuh <thomas.weissschuh@linutronix.de>
> ---
...
>  void rv_react(struct rv_monitor *monitor, const char *msg, ...)
>  {
> +	static DEFINE_WAIT_OVERRIDE_MAP(rv_react_map, LD_WAIT_FREE);
>  	va_list args;
>  
>  	if (!rv_reacting_on() || !monitor->react)
> @@ -487,7 +489,9 @@ void rv_react(struct rv_monitor *monitor, const char *msg, ...)
>  
>  	va_start(args, msg);
>  
> +	lock_map_acquire_try(&rv_react_map);
>  	monitor->react(msg, args);
> +	lock_map_release(&rv_react_map);
>  
>  	va_end(args);
>  }

The reactors are invoked in tracepoints' handlers, thus they must not
trigger another tracepoint, otherwise we may be stuck in an infinite loop.
(this is why preempt_enable_notrace() exists alongside preempt_enable()).

I'm not familiar with the internal lockdep. But I think these would
trigger trace_lock_acquire() and trace_lock_release().

Nam

  parent reply	other threads:[~2025-10-14  7:38 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-10-14  5:51 [PATCH 0/3] " Thomas Weißschuh
2025-10-14  5:51 ` [PATCH 1/3] rv: Pass va_list to reactors Thomas Weißschuh
2025-10-14  7:08   ` Gabriele Monaco
2025-10-14  5:51 ` [PATCH 2/3] rv: Make rv_reacting_on() static Thomas Weißschuh
2025-10-14  5:51 ` [PATCH 3/3] rv: Add explicit lockdep context for reactors Thomas Weißschuh
2025-10-14  6:55   ` Gabriele Monaco
2025-10-14  7:13     ` Thomas Weißschuh
2025-10-14  7:38   ` Nam Cao [this message]
2025-10-14  9:46     ` Thomas Weißschuh
2025-10-14 10:22       ` Gabriele Monaco
2025-10-14 12:51         ` Thomas Weißschuh
2025-10-14 13:45           ` Gabriele Monaco
2025-10-14 14:18             ` Thomas Weißschuh
2025-10-14 14:50               ` Gabriele Monaco
2025-10-15 10:07                 ` Thomas Weißschuh
2025-11-10 10:53                   ` 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=87qzv6szku.fsf@yellow.woof \
    --to=namcao@linutronix.de \
    --cc=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=rostedt@goodmis.org \
    --cc=thomas.weissschuh@linutronix.de \
    /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®