From: Nam Cao <namcao@linutronix.de>
To: John Ogness <john.ogness@linutronix.de>
Cc: Gabriele Monaco <gmonaco@redhat.com>,
Steven Rostedt <rostedt@goodmis.org>,
linux-trace-kernel@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v4 20/22] rv: Add rtapp_sleep monitor
Date: Fri, 25 Apr 2025 11:23:09 +0200 [thread overview]
Message-ID: <20250425092309.nuWnAPa3@linutronix.de> (raw)
In-Reply-To: <84a584isvo.fsf@jogness.linutronix.de>
On Fri, Apr 25, 2025 at 09:54:27AM +0206, John Ogness wrote:
> On 2025-04-25, John Ogness <john.ogness@linutronix.de> wrote:
> > If I understand this correctly, trace_sched_switch() is reporting
> > accurate state transition information, but by the time it is reported
> > that state may have already changed (in which case another
> > trace_sched_switch() occurs later).
> >
> > So in this example, the task did go to sleep. Why do you think it was
> > preempted instead?
You are right, the task did go to sleep. Scratch what I said earlier.
The monitor checks that if an RT task going to sleep, it will be woken by a
"RT-friendly" source. The problem is that trace_sched_switch() may appear
after trace_sched_waking(). The monitor sees the task sleeps, and waits
until the task is woken and checks the waker. But the monitor doesn't see
the task being woken, because it has already happened before the task
sleeps.
For correct ordering, we could:
- Use trace_sched_wakeup() instead of trace_sched_waking(). This would
have correct order, but information about the waker is gone at
trace_sched_wakeup(), so it doesn't work.
- Use trace_set_current_state() instead of trace_sched_switch() to
determine task going to sleep.
The latter option works, but then "sleep" would be defined as task doing
set_current_state(TASK_INTERRUPTIBLE). This new definition is probably not
precise? But for the monitor, it's fine.
Btw, while testing this, I discovered another bug. Real-time thread may
"legally" sleep by a 'restart' syscall after 'nanosleep'. The monitor
doesn't recognize this syscall as valid sleep reason and flags it :(
> On 2025-04-25, Gabriele Monaco <gmonaco@redhat.com> wrote:
> > Peter's fix [1] landed on next recently, I guess in a couple of days
> > you'll get it on the upstream tree and you may not see the problem.
This patch fixes stale prev_state due to signaling. It doesn't fix this
case.
Best regards,
Nam
next prev parent reply other threads:[~2025-04-25 9:23 UTC|newest]
Thread overview: 33+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-04-23 6:49 [PATCH v4 00/22] RV: Linear temporal logic monitors for RT application Nam Cao
2025-04-23 6:49 ` [PATCH v4 01/22] rv: Add #undef TRACE_INCLUDE_FILE Nam Cao
2025-04-23 6:49 ` [PATCH v4 02/22] printk: Make vprintk_deferred() public Nam Cao
2025-04-23 6:49 ` [PATCH v4 03/22] panic: Add vpanic() Nam Cao
2025-04-23 6:49 ` [PATCH v4 04/22] rv: Let the reactors take care of buffers Nam Cao
2025-04-23 6:50 ` [PATCH v4 05/22] verification/dot2k: Make a separate dot2k_templates/Kconfig_container Nam Cao
2025-04-23 6:50 ` [PATCH v4 06/22] verification/dot2k: Remove __buff_to_string() Nam Cao
2025-04-23 6:50 ` [PATCH v4 07/22] verification/dot2k: Replace is_container() hack with subparsers Nam Cao
2025-04-23 6:50 ` [PATCH v4 08/22] rv: rename CONFIG_DA_MON_EVENTS to CONFIG_RV_MON_EVENTS Nam Cao
2025-04-23 6:50 ` [PATCH v4 09/22] verification/dot2k: Prepare the frontend for LTL inclusion Nam Cao
2025-04-23 6:50 ` [PATCH v4 10/22] Documentation/rv: Prepare monitor synthesis document " Nam Cao
2025-04-23 6:50 ` [PATCH v4 11/22] verification/rvgen: Restructure the templates files Nam Cao
2025-04-23 6:50 ` [PATCH v4 12/22] verification/rvgen: Restructure the classes to prepare for LTL inclusion Nam Cao
2025-04-23 6:50 ` [PATCH v4 13/22] rv: Add support for LTL monitors Nam Cao
2025-04-23 6:50 ` [PATCH v4 14/22] rv: Add rtapp container monitor Nam Cao
2025-04-23 6:50 ` [PATCH v4 15/22] x86/tracing: Remove redundant trace_pagefault_key Nam Cao
2025-04-23 6:50 ` [PATCH v4 16/22] x86/tracing: Move page fault trace points to generic Nam Cao
2025-04-23 6:50 ` [PATCH v4 17/22] arm64: mm: Add page fault trace points Nam Cao
2025-04-23 6:50 ` [PATCH v4 18/22] riscv: " Nam Cao
2025-04-23 6:50 ` [PATCH v4 19/22] rv: Add rtapp_pagefault monitor Nam Cao
2025-04-23 10:37 ` Gabriele Monaco
2025-04-24 3:40 ` Nam Cao
2025-04-23 6:50 ` [PATCH v4 20/22] rv: Add rtapp_sleep monitor Nam Cao
2025-04-24 13:55 ` Gabriele Monaco
2025-04-25 6:34 ` Nam Cao
2025-04-25 7:35 ` Gabriele Monaco
2025-04-25 9:33 ` Nam Cao
2025-04-25 7:45 ` John Ogness
2025-04-25 7:48 ` John Ogness
2025-04-25 9:23 ` Nam Cao [this message]
2025-04-23 6:50 ` [PATCH v4 21/22] rv: Add documentation for rtapp monitor Nam Cao
2025-04-23 6:50 ` [PATCH v4 22/22] rv: Allow to configure the number of per-task monitor Nam Cao
2025-08-10 21:12 ` [PATCH v4 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=20250425092309.nuWnAPa3@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