From: Gabriele Monaco <gmonaco@redhat.com>
To: Nam Cao <namcao@linutronix.de>,
Steven Rostedt <rostedt@goodmis.org>,
linux-trace-kernel@vger.kernel.org,
linux-kernel@vger.kernel.org
Cc: john.ogness@linutronix.de
Subject: Re: [PATCH v4 19/22] rv: Add rtapp_pagefault monitor
Date: Wed, 23 Apr 2025 12:37:53 +0200 [thread overview]
Message-ID: <02f047788f369cd0387d2934fa99fe3e8e1913c2.camel@redhat.com> (raw)
In-Reply-To: <2eff7190ba245eb157f95ae461fef54183d07665.1745390829.git.namcao@linutronix.de>
On Wed, 2025-04-23 at 08:50 +0200, Nam Cao wrote:
> Userspace real-time applications may have design flaws that they
> raise
> page faults in real-time threads, and thus have unexpected latencies.
>
> Add an linear temporal logic monitor to detect this scenario.
>
> Signed-off-by: Nam Cao <namcao@linutronix.de>
> ---
> kernel/trace/rv/Kconfig | 1 +
> kernel/trace/rv/Makefile | 1 +
> kernel/trace/rv/monitors/pagefault/Kconfig | 11 +++
> .../trace/rv/monitors/pagefault/pagefault.c | 82
> +++++++++++++++++++
> .../trace/rv/monitors/pagefault/pagefault.h | 57 +++++++++++++
> .../rv/monitors/pagefault/pagefault_trace.h | 14 ++++
> kernel/trace/rv/rv_trace.h | 1 +
> tools/verification/models/rtapp/pagefault.ltl | 1 +
> 8 files changed, 168 insertions(+)
> create mode 100644 kernel/trace/rv/monitors/pagefault/Kconfig
> create mode 100644 kernel/trace/rv/monitors/pagefault/pagefault.c
> create mode 100644 kernel/trace/rv/monitors/pagefault/pagefault.h
> create mode 100644
> kernel/trace/rv/monitors/pagefault/pagefault_trace.h
> create mode 100644 tools/verification/models/rtapp/pagefault.ltl
>
> diff --git a/kernel/trace/rv/Kconfig b/kernel/trace/rv/Kconfig
> index 5c407d291661..6f86d8501e87 100644
> --- a/kernel/trace/rv/Kconfig
> +++ b/kernel/trace/rv/Kconfig
> @@ -42,6 +42,7 @@ source "kernel/trace/rv/monitors/scpd/Kconfig"
> source "kernel/trace/rv/monitors/snep/Kconfig"
> source "kernel/trace/rv/monitors/sncid/Kconfig"
> source "kernel/trace/rv/monitors/rtapp/Kconfig"
> +source "kernel/trace/rv/monitors/pagefault/Kconfig"
> # Add new monitors here
>
> config RV_REACTORS
> diff --git a/kernel/trace/rv/Makefile b/kernel/trace/rv/Makefile
> index 9b28c2419995..353ecf939d0e 100644
> --- a/kernel/trace/rv/Makefile
> +++ b/kernel/trace/rv/Makefile
> @@ -13,6 +13,7 @@ obj-$(CONFIG_RV_MON_SCPD) += monitors/scpd/scpd.o
> obj-$(CONFIG_RV_MON_SNEP) += monitors/snep/snep.o
> obj-$(CONFIG_RV_MON_SNCID) += monitors/sncid/sncid.o
> obj-$(CONFIG_RV_MON_RTAPP) += monitors/rtapp/rtapp.o
> +obj-$(CONFIG_RV_MON_PAGEFAULT) += monitors/pagefault/pagefault.o
> # Add new monitors here
> obj-$(CONFIG_RV_REACTORS) += rv_reactors.o
> obj-$(CONFIG_RV_REACT_PRINTK) += reactor_printk.o
> diff --git a/kernel/trace/rv/monitors/pagefault/Kconfig
> b/kernel/trace/rv/monitors/pagefault/Kconfig
> new file mode 100644
> index 000000000000..b31dee208459
> --- /dev/null
> +++ b/kernel/trace/rv/monitors/pagefault/Kconfig
> @@ -0,0 +1,11 @@
> +# SPDX-License-Identifier: GPL-2.0-only
> +#
> +config RV_MON_PAGEFAULT
> + depends on RV
> + select RV_LTL_MONITOR
> + depends on RV_MON_RTAPP
> + default y
> + select LTL_MON_EVENTS_ID
> + bool "pagefault monitor"
> + help
> + Monitor that real-time tasks do not raise page faults
> diff --git a/kernel/trace/rv/monitors/pagefault/pagefault.c
> b/kernel/trace/rv/monitors/pagefault/pagefault.c
> new file mode 100644
> index 000000000000..ff7df49871b2
> --- /dev/null
> +++ b/kernel/trace/rv/monitors/pagefault/pagefault.c
> @@ -0,0 +1,82 @@
> +// SPDX-License-Identifier: GPL-2.0
> +#include <linux/ftrace.h>
> +#include <linux/init.h>
> +#include <linux/kernel.h>
> +#include <linux/module.h>
> +#include <linux/rv.h>
> +#include <linux/sched/deadline.h>
> +#include <linux/sched/rt.h>
> +#include <linux/tracepoint.h>
> +#include <rv/instrumentation.h>
> +
> +#define MODULE_NAME "pagefault"
> +
> +#include <rv_trace.h>
> +#include <trace/events/exceptions.h>
> +#include <monitors/rtapp/rtapp.h>
> +
> +#include "pagefault.h"
> +#include <rv/ltl_monitor.h>
> +
> +static void ltl_atoms_fetch(struct task_struct *task, struct
> ltl_monitor *mon)
> +{
> + ltl_atom_set(mon, LTL_RT, rt_or_dl_task(task));
> +}
Mmh, you probably already considered that, so ignore my comment in that case.
I just realised this function would tell you a PI boosted task is an RT task,
is that acceptable in your model?
It's probably a configuration mistake on its own if an RT task following those
rules shares resources with non-RT tasks not following them, but if that's
something allowed, you may see this atom change more often than you'd like, not
sure if that can be something worth noting.
Perhaps you could add a comment saying that this is not a problem and why (e.g.
instead of using rt_or_dl_task_policy for the job).
What do you think?
Besides this detail, the monitor looks good to me
Reviewed-by: Gabriele Monaco <gmonaco@redhat.com>
Thanks,
Gabriele
next prev parent reply other threads:[~2025-04-23 10:37 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 [this message]
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
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=02f047788f369cd0387d2934fa99fe3e8e1913c2.camel@redhat.com \
--to=gmonaco@redhat.com \
--cc=john.ogness@linutronix.de \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-trace-kernel@vger.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®