mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "Thomas Weißschuh" <thomas.weissschuh@linutronix.de>
To: Gabriele Monaco <gmonaco@redhat.com>, Nam Cao <namcao@linutronix.de>
Cc: linux-kernel@vger.kernel.org, linux-trace-kernel@vger.kernel.org,
	Steven Rostedt <rostedt@goodmis.org>,
	Masami Hiramatsu <mhiramat@kernel.org>,
	Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Subject: Re: [PATCH] rv: Add signal reactor
Date: Thu, 25 Sep 2025 16:39:18 +0200 (GMT+02:00)	[thread overview]
Message-ID: <6a5fde33-b3e3-44e2-8ea5-5f4cf350cf35@linutronix.de> (raw)
In-Reply-To: <ced1cdde298d105ba2d789e4e4704caac8dec518.camel@redhat.com>

Hi Gabriele and Nam,

Sep 23, 2025 09:43:05 Gabriele Monaco <gmonaco@redhat.com>:

> On Mon, 2025-09-22 at 18:29 +0200, Nam Cao wrote:
>> On Fri, Sep 19, 2025 at 02:26:12PM +0200, Gabriele Monaco wrote:
>>> On Fri, 2025-09-19 at 12:49 +0200, Thomas Weißschuh wrote:
>>>> +static void rv_reaction_signal(int signal, const char *fmt, va_list args)
>>>> +{
>>>> +   struct rv_signal_work *work;
>>>> +   char message[256];
>>>> +
>>>> +   work = mempool_alloc_preallocated(rv_signal_task_work_pool);
>>>> +   if (!work) {
>>>> +       pr_warn_ratelimited("Unable to signal through task_work,
>>>> sending directly\n");
>>>> +       vsnprintf(message, sizeof(message), fmt, args);
>>>> +       rv_signal_force_sig(signal, message);
>>>> +       return;
>>>> +   }
>>>
>>> Why do you use the task_work at all instead of signalling directly?
>>> If that's something not safe from a (any) tracepoint because it can sleep
>>
>> If I remember correctly, sending signals requires a spinlock and therefore
>> may sleep on PREEMPT_RT.
>
> Yeah that's what I quickly glanced at. Which seems to be the case also for
> mempool_alloc_preallocated by the way, so I'm not sure that's safer than
> signalling directly on PREEMPT_RT.
>
> Thomas, did you test your reactor on PREEMPT_RT? I'd expect a few fat warnings
> when this is called from sched tracepoints. Unless you're lucky and never get
> contention. Lockdep (CONFIG_PROVE_LOCKING) may help here.

I trusted the documentation, which promised not to sleep.
I'll rework it for v2.

> Thanks,
> Gabriele
>
>>
>>> you should definitely not call it if allocation fails.
>>
>> Yep.

Ack.

>>
>> We probably can get away with not reacting at all if allocation fails, by
>> crafting our tests such that only one reaction happens at a time, and
>> allocation won't fail.

Ack.


I am wondering if it would make sense to add a new tracepoint that fires in addition of the reactors.
That would allow multiple simultaneous consumers and also bespoke handlers in userspace.


Thomas

  reply	other threads:[~2025-09-25 14:39 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-09-19 10:49 Thomas Weißschuh
2025-09-19 12:26 ` Gabriele Monaco
2025-09-22 16:29   ` Nam Cao
2025-09-23  7:42     ` Gabriele Monaco
2025-09-25 14:39       ` Thomas Weißschuh [this message]
2025-10-02 14:56         ` Nam Cao
2025-10-03  6:30           ` Gabriele Monaco
2025-10-06 10:10             ` Thomas Weißschuh
2025-10-06 15:19               ` Gabriele Monaco
2025-10-10 11:02                 ` Thomas Weißschuh
2025-10-10 13:02                   ` Gabriele Monaco
2025-10-10 12:12                 ` Nam Cao
2025-09-30 14:18     ` Thomas Weißschuh

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=6a5fde33-b3e3-44e2-8ea5-5f4cf350cf35@linutronix.de \
    --to=thomas.weissschuh@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=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

all inboxes | Powered by JetHome®