Add scheduler specification monitors
Subsystems (4)
Gabriele Monaco
maintainerv2 cover Add scheduler specification monitors
This patchset starts including adapted scheduler specifications from Daniel's task model [1].
As the model is fairly complicated, it is split in several generators and specifications. The tool used to create the model can output a unified model, but that would be hardly readable (9k states).
RV allows monitors to run and react concurrently. Running the cumulative model is equivalent to running single components using the same reactors, with the advantage that it's easier to point out which specification failed in case of error.
We allow this by introducing nested monitors, in short, the sysfs monitor folder will contain a monitor named sched, which is nothing but an empty container for other monitors. Controlling the sched monitor (enable, disable, set reactors) controls all nested monitors.
The task model proposed by Daniel includes 12 generators and 33 specifications. The generators are good for documentation but are usually implied in some specifications.
Not all monitors work out of the box, mainly because of those reasons:
* need to distinguish if preempt disable leads to schedule
* need to distinguish if irq disable comes from an actual irq
* assumptions not always true on SMP
The original task model was designed for PREEMPT_RT and this patchset is only tested on an upstream kernel with full preemption enabled.
In patch 4-6 are included only some specifications that work without further modifications. Ideally, we would adapt all specifications and add them gradually to the sched monitor.
Patch 1 fixes a macro required for some tracepoints This patch was already sent and reviewed in [2]
Patch 2 adds some additional tracepoints in the scheduler's code to complete the model, the tracepoints were already defined in Daniel's patches but, as far as I understand, were never submitted
Patch 3 adds the empty sched monitor container and the infrastructure for nested monitors
Patch 4 adds 2 per-cpu monitors using the tracepoints defined in 2
Patch 5 adds a per-task monitor using the tracepoints defined in 2
Patch 6 adds 3 more per-cpu monitors using the tracepoints defined in 2 and preemptirq tracepoints
Patch 7 adjusts the rv tool to support nested monitors
Patch 8 adjusts the dot2k tool to support nested monitors
Patch 9 adds some documentation for the sched monitors, including a description of the included specifications
Patch 10 adapts the rv tool to list also filtering by container
Changes since V1:
* skip static_branch_unlikely in function exporting the tracepoint
* rename function and make clear it should not be called directly
* add missing parameter documentation in rv_register_monitor
Changes since RFC:
* use static_branch_unlikely to trace set_state via external function
* allow nested monitors to be disabled via Kconfig
- they are enabled by default if the container is enabled
* remove need_resched tracepoint as it needs a bit more work
- will come in a following patch together with a monitor using it
[1] - https://bristot.me/linux-task-model
[2] - https://lore.kernel.org/linux-trace-kernel/[email protected]
To: Steven Rostedt <[email protected]>
To: Ingo Molnar <[email protected]>
To: Peter Zijlstra <[email protected]>
To: Juri Lelli <[email protected]>
Cc: John Kacur <[email protected]>
Cc: Clark Williams <[email protected]>
Cc: Tomas Glozar <[email protected]>
Cc: [email protected]
Gabriele Monaco (11):
tracing: Fix DECLARE_TRACE_CONDITION
rv: Add license identifiers to monitor files
sched: Add sched tracepoints for RV task model
rv: Add option for nested monitors and include sched
rv: Add sco and tss per-cpu monitors
rv: Add snroc per-task monitor
rv: Add scpd, snep and sncid per-cpu monitors tools/rv: Add support for nested monitors verification/dot2k: Add support for nested monitors Documentation/rv: Add docs for the sched monitors tools/rv: Allow rv list to filter for container
Documentation/tools/rv/rv-mon-sched.rst | 69 +++++ Documentation/trace/rv/monitor_sched.rst | 171 ++++++++++++ include/linux/rv.h | 4 +- include/linux/sched.h | 16 ++ include/trace/define_trace.h | 7 + include/trace/events/sched.h | 13 + kernel/sched/core.c | 26 +- kernel/trace/rv/Kconfig | 7 + kernel/trace/rv/Makefile | 7 + kernel/trace/rv/monitors/sched/Kconfig | 12 + kernel/trace/rv/monitors/sched/sched.c | 38 +++ kernel/trace/rv/monitors/sched/sched.h | 3 + kernel/trace/rv/monitors/sco/Kconfig | 14 + kernel/trace/rv/monitors/sco/sco.c | 88 ++++++ kernel/trace/rv/monitors/sco/sco.h | 47 ++++ kernel/trace/rv/monitors/sco/sco_trace.h | 15 + kernel/trace/rv/monitors/scpd/Kconfig | 15 + kernel/trace/rv/monitors/scpd/scpd.c | 96 +++++++ kernel/trace/rv/monitors/scpd/scpd.h | 49 ++++ kernel/trace/rv/monitors/scpd/scpd_trace.h | 15 + kernel/trace/rv/monitors/sncid/Kconfig | 15 + kernel/trace/rv/monitors/sncid/sncid.c | 96 +++++++ kernel/trace/rv/monitors/sncid/sncid.h | 49 ++++ kernel/trace/rv/monitors/sncid/sncid_trace.h | 15 + kernel/trace/rv/monitors/snep/Kconfig | 15 + kernel/trace/rv/monitors/snep/snep.c | 96 +++++++ kernel/trace/rv/monitors/snep/snep.h | 49 ++++ kernel/trace/rv/monitors/snep/snep_trace.h | 15 + kernel/trace/rv/monitors/snroc/Kconfig | 14 + kernel/trace/rv/monitors/snroc/snroc.c | 87 ++++++ kernel/trace/rv/monitors/snroc/snroc.h | 47 ++++ kernel/trace/rv/monitors/snroc/snroc_trace.h | 15 + kernel/trace/rv/monitors/tss/Kconfig | 14 + kernel/trace/rv/monitors/tss/tss.c | 91 +++++++ kernel/trace/rv/monitors/tss/tss.h | 47 ++++ kernel/trace/rv/monitors/tss/tss_trace.h | 15 + kernel/trace/rv/monitors/wip/Kconfig | 2 + kernel/trace/rv/monitors/wip/wip.c | 2 +- kernel/trace/rv/monitors/wip/wip.h | 1 + kernel/trace/rv/monitors/wwnr/Kconfig | 2 + kernel/trace/rv/monitors/wwnr/wwnr.c | 2 +- kernel/trace/rv/monitors/wwnr/wwnr.h | 1 + kernel/trace/rv/rv.c | 152 +++++++++-- kernel/trace/rv/rv.h | 4 + kernel/trace/rv/rv_reactors.c | 28 +- kernel/trace/rv/rv_trace.h | 6 + tools/verification/dot2/dot2k | 27 +- tools/verification/dot2/dot2k.py | 80 ++++-- .../verification/dot2/dot2k_templates/Kconfig | 3 + .../verification/dot2/dot2k_templates/main.c | 4 +- .../dot2/dot2k_templates/main_container.c | 38 +++ .../dot2/dot2k_templates/main_container.h | 3 + tools/verification/models/sched/sco.dot | 18 ++ tools/verification/models/sched/scpd.dot | 18 ++ tools/verification/models/sched/sncid.dot | 18 ++ tools/verification/models/sched/snep.dot | 18 ++ tools/verification/models/sched/snroc.dot | 18 ++ tools/verification/models/sched/tss.dot | 18 ++ tools/verification/rv/include/in_kernel.h | 2 +- tools/verification/rv/include/rv.h | 3 +- tools/verification/rv/src/in_kernel.c | 256 ++++++++++++++---- tools/verification/rv/src/rv.c | 38 ++- 62 files changed, 2027 insertions(+), 127 deletions(-) create mode 100644 Documentation/tools/rv/rv-mon-sched.rst create mode 100644 Documentation/trace/rv/monitor_sched.rst create mode 100644 kernel/trace/rv/monitors/sched/Kconfig create mode 100644 kernel/trace/rv/monitors/sched/sched.c create mode 100644 kernel/trace/rv/monitors/sched/sched.h create mode 100644 kernel/trace/rv/monitors/sco/Kconfig create mode 100644 kernel/trace/rv/monitors/sco/sco.c create mode 100644 kernel/trace/rv/monitors/sco/sco.h create mode 100644 kernel/trace/rv/monitors/sco/sco_trace.h create mode 100644 kernel/trace/rv/monitors/scpd/Kconfig create mode 100644 kernel/trace/rv/monitors/scpd/scpd.c create mode 100644 kernel/trace/rv/monitors/scpd/scpd.h create mode 100644 kernel/trace/rv/monitors/scpd/scpd_trace.h create mode 100644 kernel/trace/rv/monitors/sncid/Kconfig create mode 100644 kernel/trace/rv/monitors/sncid/sncid.c create mode 100644 kernel/trace/rv/monitors/sncid/sncid.h create mode 100644 kernel/trace/rv/monitors/sncid/sncid_trace.h create mode 100644 kernel/trace/rv/monitors/snep/Kconfig create mode 100644 kernel/trace/rv/monitors/snep/snep.c create mode 100644 kernel/trace/rv/monitors/snep/snep.h create mode 100644 kernel/trace/rv/monitors/snep/snep_trace.h create mode 100644 kernel/trace/rv/monitors/snroc/Kconfig create mode 100644 kernel/trace/rv/monitors/snroc/snroc.c create mode 100644 kernel/trace/rv/monitors/snroc/snroc.h create mode 100644 kernel/trace/rv/monitors/snroc/snroc_trace.h create mode 100644 kernel/trace/rv/monitors/tss/Kconfig create mode 100644 kernel/trace/rv/monitors/tss/tss.c create mode 100644 kernel/trace/rv/monitors/tss/tss.h create mode 100644 kernel/trace/rv/monitors/tss/tss_trace.h create mode 100644 tools/verification/dot2/dot2k_templates/main_container.c create mode 100644 tools/verification/dot2/dot2k_templates/main_container.h create mode 100644 tools/verification/models/sched/sco.dot create mode 100644 tools/verification/models/sched/scpd.dot create mode 100644 tools/verification/models/sched/sncid.dot create mode 100644 tools/verification/models/sched/snep.dot create mode 100644 tools/verification/models/sched/snroc.dot create mode 100644 tools/verification/models/sched/tss.dot
base-commit: 4dc1d1bec89864d8076e5ab314f86f46442bfb02
Signature · 1 line
2.48.1
Gabriele Monaco
maintainerPATCH v2 1/11 tracing: Fix DECLARE_TRACE_CONDITION
Commit 287050d39026 ("tracing: Add TRACE_EVENT_CONDITIONAL()") adds macros to define conditional trace events (TRACE_EVENT_CONDITIONAL) and tracepoints (DECLARE_TRACE_CONDITION), but sets up functionality for direct use only for the former.
Add preprocessor bits in define_trace.h to allow usage of DECLARE_TRACE_CONDITION just like DECLARE_TRACE.
--- include/trace/define_trace.h | 7 +++++++ 1 file changed, 7 insertions(+)
include/trace/define_trace.h +7 -0
@@ -76,6 +76,10 @@#define DECLARE_TRACE (name, proto, args) \ DEFINE_TRACE(name, PARAMS(proto), PARAMS(args)) +#undef DECLARE_TRACE_CONDITION +#define DECLARE_TRACE_CONDITION (name, proto, args, cond) \ + DEFINE_TRACE(name, PARAMS(proto), PARAMS(args)) +/* If requested, create helpers for calling these tracepoints from Rust. */ #ifdef CREATE_RUST_TRACE_POINTS #undef DEFINE_RUST_DO_TRACE
@@ -108,6 +112,8 @@/* Make all open coded DECLARE_TRACE nops */ #undef DECLARE_TRACE#define DECLARE_TRACE (name, proto, args) +#undef DECLARE_TRACE_CONDITION +#define DECLARE_TRACE_CONDITION (name, proto, args, cond)#ifdef TRACEPOINTS_ENABLED #include <trace/trace_events.h>
@@ -129,6 +135,7 @@#undef DEFINE_EVENT_CONDITION#undef TRACE_HEADER_MULTI_READ#undef DECLARE_TRACE +#undef DECLARE_TRACE_CONDITION/* Only undef what we defined in this file */ #ifdef UNDEF_TRACE_INCLUDE_FILE
Signature · 1 line
2.48.1
Gabriele Monaco
maintainerPATCH v2 2/11 Add license identifiers to monitor files
In reply to Gabriele MonacoSome monitor files like the main header and the Kconfig are missing the license identifier.
Add it to those and make sure the automatic generation script includes the line in newly created monitors.
--- kernel/trace/rv/monitors/wip/Kconfig | 2 ++ kernel/trace/rv/monitors/wip/wip.h | 1 + kernel/trace/rv/monitors/wwnr/Kconfig | 2 ++ kernel/trace/rv/monitors/wwnr/wwnr.h | 1 + tools/verification/dot2/dot2k.py | 1 + tools/verification/dot2/dot2k_templates/Kconfig | 2 ++ 6 files changed, 9 insertions(+)
kernel/trace/rv/monitors/wip/Kconfig +2 -0
@@ -1,3 +1,5 @@ +# SPDX-License-Identifier: GPL-2.0-only +# config RV_MON_WIP depends on RV depends on PREEMPT_TRACER
kernel/trace/rv/monitors/wip/wip.h +1 -0
@@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: GPL-2.0 */ /* * Automatically generated C representation of wip automaton * For further information about this format, see kernel documentation:
kernel/trace/rv/monitors/wwnr/Kconfig +2 -0
@@ -1,3 +1,5 @@ +# SPDX-License-Identifier: GPL-2.0-only +# config RV_MON_WWNR depends on RV select DA_MON_EVENTS_ID
kernel/trace/rv/monitors/wwnr/wwnr.h +1 -0
@@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: GPL-2.0 */ /* * Automatically generated C representation of wwnr automaton * For further information about this format, see kernel documentation:
tools/verification/dot2/dot2k.py +1 -0
@@ -160,6 +160,7 @@ class dot2k(Dot2c): def fill_model_h_header(self): buff = [] + buff.append("/* SPDX-License-Identifier: GPL-2.0 */") buff.append("/*") buff.append(" * Automatically generated C representation of %s automaton" % (self.name)) buff.append(" * For further information about this format, see kernel documentation:")
tools/verification/dot2/dot2k_templates/Kconfig +2 -0
@@ -1,3 +1,5 @@ +# SPDX-License-Identifier: GPL-2.0-only +# config RV_MON_%%MODEL_NAME_UP%% depends on RV select %%MONITOR_CLASS_TYPE%%
Signature · 1 line
2.48.1
Gabriele Monaco
maintainerPATCH v2 3/11 sched: Add sched tracepoints for RV task model
In reply to Gabriele MonacoAdd the following tracepoints:
* sched_entry(bool preempt, ip)
Called while entering __schedule
* sched_exit(bool is_switch, ip)
Called while exiting __schedule
* sched_set_state(task, curr_state, state)
Called when a task changes its state (to and from running)
These tracepoints are useful to describe the Linux task model and are adapted from the patches by Daniel Bristot de Oliveira
(https://bristot.me/linux-task-model/).
--- include/linux/rv.h | 2 +- include/linux/sched.h | 16 ++++++++++++++++ include/trace/events/sched.h | 13 +++++++++++++ kernel/sched/core.c | 26 +++++++++++++++++++++++++- tools/verification/rv/include/rv.h | 2 +- 5 files changed, 56 insertions(+), 3 deletions(-)
include/linux/rv.h +1 -1
@@ -7,7 +7,7 @@#ifndef _LINUX_RV_H#define _LINUX_RV_H -#define MAX_DA_NAME_LEN 24 +#define MAX_DA_NAME_LEN 32#ifdef CONFIG_RV /*
include/linux/sched.h +16 -0
@@ -46,6 +46,7 @@#include <linux/rv.h> #include <linux/livepatch_sched.h> #include <linux/uidgid_types.h> +#include <linux/tracepoint-defs.h> #include <asm/kmap_size.h> /* task_struct member predeclarations (sorted alphabetically): */
@@ -186,6 +187,12 @@ struct user_event_mm;# define debug_rtlock_wait_restore_state () do { } while (0)#endif +#define trace_set_current_state (state_value) \ + do { \ + if (tracepoint_enabled(sched_set_state_tp)) \ + __do_trace_set_current_state(state_value); \ + } while (0) +/* * set_current_state() includes a barrier so that the write of current->__state * is correctly serialised wrt the caller's subsequent test of whether to
@@ -226,12 +233,14 @@ struct user_event_mm;#define __set_current_state (state_value) \ do { \ debug_normal_state_change((state_value)); \ + trace_set_current_state(state_value); \ WRITE_ONCE(current->__state, (state_value)); \ } while (0)#define set_current_state (state_value) \ do { \ debug_normal_state_change((state_value)); \ + trace_set_current_state(state_value); \ smp_store_mb(current->__state, (state_value)); \ } while (0)
@@ -247,6 +256,7 @@ struct user_event_mm; \raw_spin_lock_irqsave (¤t->pi_lock, flags); \debug_special_state_change ((state_value)); \ +trace_set_current_state (state_value); \WRITE_ONCE (current->__state, (state_value)); \raw_spin_unlock_irqrestore (¤t->pi_lock, flags); \ }while (0 )
@@ -282,6 +292,7 @@ struct user_event_mm;raw_spin_lock (¤t->pi_lock); \ current->saved_state = current->__state; \debug_rtlock_wait_set_state (); \ +trace_set_current_state (TASK_RTLOCK_WAIT ); \WRITE_ONCE (current->__state,TASK_RTLOCK_WAIT ); \raw_spin_unlock (¤t->pi_lock); \ }while (0 );
@@ -291,6 +302,7 @@ struct user_event_mm;lockdep_assert_irqs_disabled (); \raw_spin_lock (¤t->pi_lock); \debug_rtlock_wait_restore_state (); \ +trace_set_current_state (TASK_RUNNING ); \WRITE_ONCE (current->__state, current->saved_state); \ current->saved_state =TASK_RUNNING ; \raw_spin_unlock (¤t->pi_lock); \
@@ -327,6 +339,10 @@ extern void io_schedule_finish(int token);extern long io_schedule_timeout (long timeout);extern void io_schedule (void ); +/* wrapper function to trace from this header file */ +DECLARE_TRACEPOINT (sched_set_state_tp); +extern void __do_trace_set_current_state (int state_value); +/** * struct prev_cputime - snapshot of system and user cputime * @utime: time spent in user mode
include/trace/events/sched.h +13 -0
@@ -824,6 +824,19 @@ DECLARE_TRACE(sched_compute_energy_tp, unsigned long max_util, unsigned long busy_time), TP_ARGS(p, dst_cpu, energy, max_util, busy_time)); +DECLARE_TRACE (sched_entry_tp, + TP_PROTO(bool preempt, unsigned long ip), +TP_ARGS (preempt, ip)); + +DECLARE_TRACE (sched_exit_tp, + TP_PROTO(bool is_switch, unsigned long ip), +TP_ARGS (is_switch, ip)); + +DECLARE_TRACE_CONDITION (sched_set_state_tp, + TP_PROTO(struct task_struct *tsk, int curr_state, int state), +TP_ARGS (tsk, curr_state, state), +TP_CONDITION (!!curr_state != !!state)); +#endif /* _TRACE_SCHED_H */ /* This part must be outside protection */
kernel/sched/core.c +25 -1
@@ -491,6 +491,19 @@ sched_core_dequeue(struct rq *rq, struct task_struct *p, int flags) { }#endif /* CONFIG_SCHED_CORE */ +/* need a wrapper since we may need to trace from modules */ +EXPORT_TRACEPOINT_SYMBOL (sched_set_state_tp); + +/* +* Do not call this function directly since it won't check if the tp is enabled. +* Call the helper macro trace_set_current_state instead. +*/ +void __do_trace_set_current_state (int state_value) +{ +__do_trace_sched_set_state_tp (current, current->__state, state_value); +} +EXPORT_SYMBOL (__do_trace_set_current_state); +/* * Serialization rules: *
@@ -5306,6 +5319,12 @@ asmlinkage __visible void schedule_tail(struct task_struct *prev)*/ finish_task_switch (prev); +/* +* This is a special case: the newly created task has just +* switched the context for the fist time. It is returning from +* schedule for the first time in this path. +*/ +trace_sched_exit_tp (true,CALLER_ADDR0 );preempt_enable ();if (current->set_child_tid)
@@ -6649,12 +6668,15 @@ static void __sched notrace __schedule(int sched_mode)* as a preemption by schedule_debug() and RCU. */ bool preempt = sched_mode >SM_NONE ; +bool is_switch = false;unsigned long *switch_count;unsigned long prev_state;struct rq_flags rf;struct rq *rq;int cpu; +trace_sched_entry_tp (preempt,CALLER_ADDR0 ); + cpu =smp_processor_id (); rq =cpu_rq (cpu); prev = rq->curr;
@@ -6722,7 +6744,8 @@ static void __sched notrace __schedule(int sched_mode) rq->last_seen_need_resched_ns =0 ;#endif -if (likely (prev != next)) { + is_switch = prev != next; +if (likely (is_switch)) { rq->nr_switches++;/* * RCU users of rcu_dereference(rq->curr) may not see
@@ -6767,6 +6790,7 @@ static void __sched notrace __schedule(int sched_mode)__balance_callbacks (rq);raw_spin_rq_unlock_irq (rq); } +trace_sched_exit_tp (is_switch,CALLER_ADDR0 ); }void __noreturn do_task_dead (void )
tools/verification/rv/include/rv.h +1 -1
@@ -1,7 +1,7 @@// SPDX-License-Identifier: GPL-2.0 #define MAX_DESCRIPTION 1024 -#define MAX_DA_NAME_LEN 24 +#define MAX_DA_NAME_LEN 32struct monitor {char name[MAX_DA_NAME_LEN ];
Signature · 1 line
2.48.1
kernel test robot
build botRe: [PATCH v2 03/11] sched: Add sched tracepoints for RV task model
kernel test robot noticed the following build errors:
Hi Gabriele,
kernel test robot noticed the following build errors:
[auto build test ERROR on 4dc1d1bec89864d8076e5ab314f86f46442bfb02]
url: https://github.com/intel-lab-lkp/linux/commits/Gabriele-Monaco/tracing-Fix-DECLARE_TRACE_CONDITION/20250213-171642 base: 4dc1d1bec89864d8076e5ab314f86f46442bfb02 patch link: https://lore.kernel.org/r/20250213090819.419470-4-gmonaco%40redhat.com patch subject: [PATCH v2 03/11] sched: Add sched tracepoints for RV task model config: i386-buildonly-randconfig-001-20250214 (https://download.01.org/0day-ci/archive/20250214/[email protected]/config) compiler: gcc-12 (Debian 12.2.0-14) 12.2.0 reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20250214/[email protected]/reproduce)
If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/
All errors (new ones prefixed by >>):
kernel/sched/core.c: In function '__do_trace_set_current_state':
>> kernel/sched/core.c:503:9: error: implicit declaration of function '__do_trace_sched_set_state_tp'; did you mean 'trace_sched_set_state_tp'? [-Werror=implicit-function-declaration]
503 | __do_trace_sched_set_state_tp(current, current->__state, state_value);
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
| trace_sched_set_state_tpcc1: some warnings being treated as errors
vim +503 kernel/sched/core.c
496
497 /*
498 * Do not call this function directly since it won't check if the tp is enabled.
499 * Call the helper macro trace_set_current_state instead.
500 */
501 void __do_trace_set_current_state(int state_value)
502 {
> 503 __do_trace_sched_set_state_tp(current, current->__state, state_value);
504 }
505 EXPORT_SYMBOL(__do_trace_set_current_state);
506
Signature · 2 lines
0-DAY CI Kernel Test Service https://github.com/intel/lkp-tests/wiki
Gabriele Monaco
maintainerRe: [PATCH v2 03/11] sched: Add sched tracepoints for RV task model
Quoted 36 lines · kernel test robot
>
kernel/sched/core.c: In function
'__do_trace_set_current_state':Quoted 7 lines
Quoted 5 lines
> > >
kernel/sched/core.c:503:9: error: implicit declaration ofQuoted 3 lines
Quoted 3 lines
Quoted 3 lines
function '
__do_trace_sched_set_state_tp'; did you mean 'trace_sched_set_state_tp'? [-Werror=implicit-function-declaration]> 503 | __do_trace_sched_set_state_tp(current,
Quoted 8 lines
current->__state,state_value);
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|trace_sched_set_state_tp
cc1: some warnings being treated as errorsvim +503
kernel/sched/core.cQuoted 13 lines
496
497 /*
498 * Do not call this function directly since it won't check if the tp is enabled.
499 * Call the helper macrotrace_set_current_stateinstead. 500 */
501 void__do_trace_set_current_state(int state_value)502 {
> 503__do_trace_sched_set_state_tp(current, current->__state, state_value);
504 }
505EXPORT_SYMBOL(__do_trace_set_current_state);
506
Quoted 1 line
I honestly don't get why this build failed. The function __do_trace_ exists since cff6d93eab00ba ("tracepoint: Reduce duplication of __DO_TRACE_CALL"), a while before that it was just a macro and not an inline function, reason why no one so far used it directly.
Both failed builds are based on 4dc1d1bec898 (where my patchset is based) and there __do_trace_ does exist.
Unless there's a strong opinion not to use it although the compiler allows it, I'd consider the two kernel robot results false negatives.
Or am I missing something?
Steven Rostedt
maintainerRe: [PATCH v2 03/11] sched: Add sched tracepoints for RV task model
Quoted 12 lines · On Fri, 14 Feb 2025 12:15:31 +0100 Gabriele Monaco <[email protected]> wrote:
Quoted 6 lines
Quoted 5 lines
> 503
__do_trace_sched_set_state_tp(current, current->__state, state_value);
504 }
505EXPORT_SYMBOL(__do_trace_set_current_state); 506I honestly don't get why this build failed. The function
__do_trace_exists sincecff6d93eab00ba("tracepoint: Reduce duplication of__DO_TRACE_CALL"), a while before that it was just a macro and not an inline function, reason why no one so far used it directly.
Quoted 7 lines
Both failed builds are based on
4dc1d1bec898(where my patchset is based) and there__do_trace_does exist.Unless there's a strong opinion not to use it although the compiler allows it, I'd consider the two kernel robot results false negatives.
Or am I missing something?
It's because you should not be using the internal macros of a tracepoint. Just use the tracepoint itself.
I replied to the patch.
-- Steve
kernel test robot
build botRe: [PATCH v2 03/11] sched: Add sched tracepoints for RV task model
In reply to Gabriele Monacokernel test robot noticed the following build errors:
Hi Gabriele,
kernel test robot noticed the following build errors:
[auto build test ERROR on 4dc1d1bec89864d8076e5ab314f86f46442bfb02]
url: https://github.com/intel-lab-lkp/linux/commits/Gabriele-Monaco/tracing-Fix-DECLARE_TRACE_CONDITION/20250213-171642 base: 4dc1d1bec89864d8076e5ab314f86f46442bfb02 patch link: https://lore.kernel.org/r/20250213090819.419470-4-gmonaco%40redhat.com patch subject: [PATCH v2 03/11] sched: Add sched tracepoints for RV task model config: arm-randconfig-001-20250214 (https://download.01.org/0day-ci/archive/20250214/[email protected]/config) compiler: clang version 16.0.6 (https://github.com/llvm/llvm-project 7cbf1a2591520c2491aa35339f227775f4d3adf6) reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20250214/[email protected]/reproduce)
If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/
All errors (new ones prefixed by >>):
>> kernel/sched/core.c:503:2: error: call to undeclared function '__do_trace_sched_set_state_tp'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]
__do_trace_sched_set_state_tp(current, current->__state, state_value);
^
kernel/sched/core.c:503:2: note: did you mean 'trace_sched_set_state_tp'?
include/trace/events/sched.h:835:1: note: 'trace_sched_set_state_tp' declared here
DECLARE_TRACE_CONDITION(sched_set_state_tp,
^
include/linux/tracepoint.h:472:2: note: expanded from macro 'DECLARE_TRACE_CONDITION'
__DECLARE_TRACE(name, PARAMS(proto), PARAMS(args), \
^
include/linux/tracepoint.h:409:2: note: expanded from macro '__DECLARE_TRACE'
__DECLARE_TRACE_COMMON(name, PARAMS(proto), PARAMS(args), PARAMS(data_proto))
^
include/linux/tracepoint.h:385:21: note: expanded from macro '__DECLARE_TRACE_COMMON'
static inline void trace_##name(proto) \
^ <scratch space>:84:1: note: expanded from here
trace_sched_set_state_tp
^
1 error generated.
vim +/__do_trace_sched_set_state_tp +503 kernel/sched/core.c
496
497 /*
498 * Do not call this function directly since it won't check if the tp is enabled.
499 * Call the helper macro trace_set_current_state instead.
500 */
501 void __do_trace_set_current_state(int state_value)
502 {
> 503 __do_trace_sched_set_state_tp(current, current->__state, state_value);
504 }
505 EXPORT_SYMBOL(__do_trace_set_current_state);
506
Signature · 2 lines
0-DAY CI Kernel Test Service https://github.com/intel/lkp-tests/wiki
Steven Rostedt
maintainerRe: [PATCH v2 03/11] sched: Add sched tracepoints for RV task model
In reply to Gabriele MonacoQuoted 10 lines · On Thu, 13 Feb 2025 10:08:01 +0100 Gabriele Monaco <[email protected]> wrote:
include/trace/events/sched.h +2
-0@@ -824,6 +824,19 @@ DECLARE_TRACE(sched_compute_energy_tp, unsigned long max_util, unsigned long busy_time), TP_ARGS(p, dst_cpu, energy, max_util, busy_time)); +DECLARE_TRACE(sched_entry_tp, + TP_PROTO(bool preempt, unsigned long ip),
include/trace/events/sched.h DECLARE_TRACE(sched_compute_energy_tp, · line 838
Quoted 10 lines
include/trace/events/sched.h +10
-0+ TP_ARGS(preempt, ip)); + +DECLARE_TRACE (sched_exit_tp, + TP_PROTO(bool is_switch, unsigned long ip), +TP_ARGS (is_switch, ip)); + +DECLARE_TRACE_CONDITION (sched_set_state_tp, + TP_PROTO(struct task_struct *tsk, int curr_state, int state), +TP_ARGS (tsk, curr_state, state), +TP_CONDITION (!!curr_state != !!state));
I don't think you need to pass in state. Just have it be:
TP_CONDITION(!!(tsk->__state) != !!state));
Quoted 12 lines
include/trace/events/sched.h +1
-0+#endif /* _TRACE_SCHED_H */ /* This part must be outside protection */ kernel/sched/core.c +0
-0@@ -491,6 +491,19 @@ sched_core_dequeue(struct rq *rq, struct task_struct *p, int flags) { }#endif /* CONFIG_SCHED_CORE */
kernel/sched/core.c sched_core_dequeue(struct rq *rq, struct task_struct *p, int flags) { } · line 503
Quoted 10 lines
kernel/sched/core.c +10
-0+/* need a wrapper since we may need to trace from modules */ +EXPORT_TRACEPOINT_SYMBOL (sched_set_state_tp); + +/* +* Do not call this function directly since it won't check if the tp is enabled. +* Call the helper macro trace_set_current_state instead. +*/ +void __do_trace_set_current_state (int state_value) +{ +__do_trace_sched_set_state_tp (current, current->__state, state_value);
And this should not be using the internal macros of a trace point. It should be:
trace_sched_set_state_tp(current, state_value);
(I removed the current->__state as mentioned above).
kernel/sched/core.c sched_core_dequeue(struct rq *rq, struct task_struct *p, int flags) { } · line 506
Quoted 3 lines
kernel/sched/core.c +3
-0+} +EXPORT_SYMBOL (__do_trace_set_current_state); +
-- Steve
Peter Zijlstra
maintainerRe: [PATCH v2 03/11] sched: Add sched tracepoints for RV task model
Quoted 9 lines · Steven Rostedt
kernel/sched/core.c sched_core_dequeue(struct rq *rq, struct task_struct *p, int flags) { } · line 503
Quoted 3 lines
kernel/sched/core.c +3
-0+void __do_trace_set_current_state (int state_value) +{ +__do_trace_sched_set_state_tp (current, current->__state, state_value);And this should not be using the internal macros of a trace point. It should be:
trace_sched_set_state_tp(current, state_value);(I removed the
current->__stateas mentioned above).
But the static branch is already in the caller, no point duplicating that.
Steven Rostedt
maintainerRe: [PATCH v2 03/11] sched: Add sched tracepoints for RV task model
Quoted 8 lines · On Mon, 17 Feb 2025 17:49:17 +0100 Peter Zijlstra <[email protected]> wrote:
Quoted 6 lines · Steven Rostedt
kernel/sched/core.c sched_core_dequeue(struct rq *rq, struct task_struct *p, int flags) { } · line 503
Quoted 3 lines
kernel/sched/core.c +3
-0+void __do_trace_set_current_state (int state_value) +{ +__do_trace_sched_set_state_tp (current, current->__state, state_value);And this should not be using the internal macros of a trace point. It should be:
Quoted 6 lines
Quoted 3 lines
trace_sched_set_state_tp(current, state_value);(I removed the
current->__stateas mentioned above).But the static branch is already in the caller, no point duplicating that.
Regardless, you should not be using internals of the tracepoints. That can change at any time and is not reliable (as the kernel test robot pointed out).
It's a static branch, who cares if it's added twice? One is used to jump to the function, the other is for the tracepoint logic itself.
There's several places that do this.
Perhaps, in the future we could create a normal API that will always call the tracepoint, but until then, let's not use code that wasn't meant for that purpose.
-- Steve
Gabriele Monaco
maintainerRe: [PATCH v2 03/11] sched: Add sched tracepoints for RV task model
Quoted 32 lines · Steven Rostedt
Quoted 10 lines · On Mon, 17 Feb 2025 17:49:17 +0100 Peter Zijlstra <[email protected]> wrote:
Quoted 8 lines · Steven Rostedt
Quoted 4 lines
kernel/sched/core.c +3
-0+void __do_trace_set_current_state (int state_value) +{ + __do_trace_sched_set_state_tp(current, current-Quoted 1 line
__state,state_value);And this should not be using the internal macros of a trace point. It should be:
Quoted 7 lines
Quoted 3 lines
trace_sched_set_state_tp(current, state_value);(I removed the
current->__stateas mentioned above).But the static branch is already in the caller, no point duplicating
that.Regardless, you should not be using internals of the tracepoints. That can
change at any time and is not reliable (as the kernel test robot pointed out).It's a static branch, who cares if it's added twice? One is used to jump to
the function, the other is for the tracepoint logic itself.There's several places that do this.
Quoted 8 lines
Perhaps, in the future we could create a normal API that will always call
the tracepoint, but until then, let's not use code that wasn't meant for
that purpose.-- Steve
Mmh I get your point. We definitely don't want this piece of code to break whenever something changes in the tracepoint API..
I will revert the change and prepare a V3
Thanks,
Gabriele
Gabriele Monaco
maintainerPATCH v2 4/11 Add option for nested monitors and include sched
In reply to Gabriele MonacoMonitors describing complex systems, such as the scheduler, can easily grow to the point where they are just hard to understand because of the many possible state transitions.
Often it is possible to break such descriptions into smaller monitors, sharing some or all events. Enabling those smaller monitors concurrently is, in fact, testing the system as if we had one single larger monitor. Splitting models into multiple specification is not only easier to understand, but gives some more clues when we see errors.
Add the possibility to create container monitors, whose only purpose is to host other nested monitors. Enabling a container monitor enables all nested ones, but it's still possible to enable nested monitors independently.
Add the sched monitor as first container, for now empty.
--- include/linux/rv.h | 2 +- kernel/trace/rv/Kconfig | 1 + kernel/trace/rv/Makefile | 1 + kernel/trace/rv/monitors/sched/Kconfig | 12 ++ kernel/trace/rv/monitors/sched/sched.c | 38 +++++++ kernel/trace/rv/monitors/sched/sched.h | 3 + kernel/trace/rv/monitors/wip/wip.c | 2 +- kernel/trace/rv/monitors/wwnr/wwnr.c | 2 +- kernel/trace/rv/rv.c | 152 +++++++++++++++++++++---- kernel/trace/rv/rv.h | 4 + kernel/trace/rv/rv_reactors.c | 28 ++++- 11 files changed, 216 insertions(+), 29 deletions(-) create mode 100644 kernel/trace/rv/monitors/sched/Kconfig create mode 100644 kernel/trace/rv/monitors/sched/sched.c create mode 100644 kernel/trace/rv/monitors/sched/sched.h
include/linux/rv.h +1 -1
@@ -56,7 +56,7 @@ struct rv_monitor {bool rv_monitoring_on (void );int rv_unregister_monitor (struct rv_monitor *monitor); -int rv_register_monitor (struct rv_monitor *monitor); +int rv_register_monitor (struct rv_monitor *monitor,struct rv_monitor *parent);int rv_get_task_monitor_slot (void );void rv_put_task_monitor_slot (int slot);
kernel/trace/rv/Kconfig +1 -0
@@ -27,6 +27,7 @@ menuconfig RV source "kernel/trace/rv/monitors/wip/Kconfig" source "kernel/trace/rv/monitors/wwnr/Kconfig" +source "kernel/trace/rv/monitors/sched/Kconfig" # Add new monitors here config RV_REACTORS
kernel/trace/rv/Makefile +1 -0
@@ -5,6 +5,7 @@ ccflags-y += -I $(src) # needed for trace events obj-$(CONFIG_RV) += rv.o obj-$(CONFIG_RV_MON_WIP) += monitors/wip/wip.o obj-$(CONFIG_RV_MON_WWNR) += monitors/wwnr/wwnr.o +obj-$(CONFIG_RV_MON_SCHED) += monitors/sched/sched.o # Add new monitors here obj-$(CONFIG_RV_REACTORS) += rv_reactors.o obj-$(CONFIG_RV_REACT_PRINTK) += reactor_printk.o
kernel/trace/rv/monitors/sched/Kconfig new file +12 -0
@@ -0,0 +1,12 @@ +# SPDX-License-Identifier: GPL-2.0-only +# +config RV_MON_SCHED + depends on RV + select DA_MON_EVENTS_IMPLICIT + bool "sched monitor" + help + Collection of monitors to check the scheduler behaves according to specifications. + Enable this to enable all scheduler specification supported by the current kernel. + + For further information, see: + Documentation/trace/rv/monitor_sched.rst
kernel/trace/rv/monitors/sched/sched.c new file +38 -0
@@ -0,0 +1,38 @@ +// SPDX-License-Identifier: GPL-2.0 +#include <linux/kernel.h> +#include <linux/module.h> +#include <linux/init.h> +#include <linux/rv.h> + +#define MODULE_NAME "sched" + +#include "sched.h" + +struct rv_monitor rv_sched; + +struct rv_monitor rv_sched = { + .name ="sched" , + .description ="container for several scheduler monitor specifications." , + .enable =NULL , + .disable =NULL , + .reset =NULL , + .enabled =0 , +}; + +static int __init register_sched (void ) +{ +rv_register_monitor (&rv_sched,NULL ); +return 0 ; +} + +static void __exit unregister_sched(void) +{ +rv_unregister_monitor (&rv_sched); +} + +module_init (register_sched); +module_exit (unregister_sched); + +MODULE_LICENSE ("GPL" ); +MODULE_AUTHOR ("Gabriele Monaco <[email protected]>" ); +MODULE_DESCRIPTION ("sched: container for several scheduler monitor specifications." );
kernel/trace/rv/monitors/sched/sched.h new file +3 -0
@@ -0,0 +1,3 @@ +/* SPDX-License-Identifier: GPL-2.0 */ + +extern struct rv_monitor rv_sched;
kernel/trace/rv/monitors/wip/wip.c +1 -1
@@ -71,7 +71,7 @@ static struct rv_monitor rv_wip = {static int __init register_wip (void ) { -rv_register_monitor (&rv_wip); +rv_register_monitor (&rv_wip,NULL );return 0 ; }
kernel/trace/rv/monitors/wwnr/wwnr.c +1 -1
@@ -70,7 +70,7 @@ static struct rv_monitor rv_wwnr = {static int __init register_wwnr (void ) { -rv_register_monitor (&rv_wwnr); +rv_register_monitor (&rv_wwnr,NULL );return 0 ; }
kernel/trace/rv/rv.c +129 -23
256 lines not on this page · raw message
kernel/trace/rv/rv.h +4 -0
@@ -21,6 +21,7 @@ struct rv_interface {#define MAX_RV_REACTOR_NAME_SIZE 32extern struct mutex rv_interface_lock; +extern struct list_head rv_monitors_list;#ifdef CONFIG_RV_REACTORS struct rv_reactor_def {
@@ -34,6 +35,7 @@ struct rv_reactor_def {struct rv_monitor_def {struct list_head list;struct rv_monitor *monitor; +struct rv_monitor *parent;struct dentry *root_d;#ifdef CONFIG_RV_REACTORS struct rv_reactor_def *rdef;
@@ -45,6 +47,8 @@ struct rv_monitor_def {struct dentry *get_monitors_root (void );int rv_disable_monitor (struct rv_monitor_def *mdef);int rv_enable_monitor (struct rv_monitor_def *mdef); +bool rv_is_container_monitor (struct rv_monitor_def *mdef); +bool rv_is_nested_monitor (struct rv_monitor_def *mdef);#ifdef CONFIG_RV_REACTORS int reactor_populate_monitor (struct rv_monitor_def *mdef);
kernel/trace/rv/rv_reactors.c +25 -3
@@ -158,8 +158,9 @@ static const struct seq_operations monitor_reactors_seq_ops = { .show = monitor_reactor_show }; -static void monitor_swap_reactors (struct rv_monitor_def *mdef,struct rv_reactor_def *rdef, -bool reacting) +static void monitor_swap_reactors_single (struct rv_monitor_def *mdef, +struct rv_reactor_def *rdef, +bool reacting,bool nested) {bool monitor_enabled;
@@ -179,10 +180,31 @@ static void monitor_swap_reactors(struct rv_monitor_def *mdef, struct rv_reactor mdef->reacting = reacting; mdef->monitor->react = rdef->reactor->react; -if (monitor_enabled) +/* enable only once if iterating through a container */ +if (monitor_enabled && !nested)rv_enable_monitor (mdef); } +static void monitor_swap_reactors (struct rv_monitor_def *mdef, +struct rv_reactor_def *rdef,bool reacting) +{ +struct rv_monitor_def *p = mdef; + +if (rv_is_container_monitor (mdef)) +list_for_each_entry_continue (p, &rv_monitors_list, list) { +if (p->parent != mdef->monitor) +break ; +monitor_swap_reactors_single (p, rdef, reacting, true); + } +/* +* This call enables and disables the monitor if they were active. +* In case of a container, we already disabled all and will enable all. +* All nested monitors are enabled also if they were off, we may refine +* this logic in the future. +*/ +monitor_swap_reactors_single (mdef, rdef, reacting, false); +} +static ssize_t monitor_reactors_write (struct file *file,const char __user *user_buf,size_t count,loff_t *ppos)
Signature · 1 line
2.48.1
kernel test robot
build botRe: [PATCH v2 04/11] rv: Add option for nested monitors and include sched
kernel test robot noticed the following build warnings:
Hi Gabriele,
kernel test robot noticed the following build warnings:
[auto build test WARNING on 4dc1d1bec89864d8076e5ab314f86f46442bfb02]
url: https://github.com/intel-lab-lkp/linux/commits/Gabriele-Monaco/tracing-Fix-DECLARE_TRACE_CONDITION/20250213-171642 base: 4dc1d1bec89864d8076e5ab314f86f46442bfb02 patch link: https://lore.kernel.org/r/20250213090819.419470-5-gmonaco%40redhat.com patch subject: [PATCH v2 04/11] rv: Add option for nested monitors and include sched config: parisc-randconfig-r112-20250217 (https://download.01.org/0day-ci/archive/20250217/[email protected]/config) compiler: hppa-linux-gcc (GCC) 14.2.0 reproduce: (https://download.01.org/0day-ci/archive/20250217/[email protected]/reproduce)
If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/
All warnings (new ones prefixed by >>):
In file included from include/trace/define_trace.h:119,
from kernel/trace/rv/rv_trace.h:130,
from kernel/trace/rv/rv.c:148:
>> include/trace/trace_events.h:477:13: warning: 'print_fmt_error_da_monitor' defined but not used [-Wunused-variable]
477 | static char print_fmt_##call[] = print; \
| ^~~~~~~~~~
kernel/trace/rv/./rv_trace.h:39:1: note: in expansion of macro 'DECLARE_EVENT_CLASS'
39 | DECLARE_EVENT_CLASS(error_da_monitor,
| ^~~~~~~~~~~~~~~~~~~
>> include/trace/trace_events.h:477:13: warning: 'print_fmt_event_da_monitor' defined but not used [-Wunused-variable]
477 | static char print_fmt_##call[] = print; \
| ^~~~~~~~~~
kernel/trace/rv/./rv_trace.h:12:1: note: in expansion of macro 'DECLARE_EVENT_CLASS'
12 | DECLARE_EVENT_CLASS(event_da_monitor,
| ^~~~~~~~~~~~~~~~~~~
>> include/trace/trace_events.h:223:37: warning: 'trace_event_type_funcs_error_da_monitor' defined but not used [-Wunused-variable]
223 | static struct trace_event_functions trace_event_type_funcs_##call = { \
| ^~~~~~~~~~~~~~~~~~~~~~~
kernel/trace/rv/./rv_trace.h:39:1: note: in expansion of macro 'DECLARE_EVENT_CLASS'
39 | DECLARE_EVENT_CLASS(error_da_monitor,
| ^~~~~~~~~~~~~~~~~~~
>> include/trace/trace_events.h:223:37: warning: 'trace_event_type_funcs_event_da_monitor' defined but not used [-Wunused-variable]
223 | static struct trace_event_functions trace_event_type_funcs_##call = { \
| ^~~~~~~~~~~~~~~~~~~~~~~ kernel/trace/rv/./rv_trace.h:12:1: note: in expansion of macro 'DECLARE_EVENT_CLASS'
12 | DECLARE_EVENT_CLASS(event_da_monitor,
| ^~~~~~~~~~~~~~~~~~~
vim +/print_fmt_error_da_monitor +477 include/trace/trace_events.h
46ac51822a6a0b Steven Rostedt (Red Hat 2015-09-23 473)
46ac51822a6a0b Steven Rostedt (Red Hat 2015-09-23 474) #undef DECLARE_EVENT_CLASS
46ac51822a6a0b Steven Rostedt (Red Hat 2015-09-23 475) #define DECLARE_EVENT_CLASS(call, proto, args, tstruct, assign, print) \
46ac51822a6a0b Steven Rostedt (Red Hat 2015-09-23 476) _TRACE_PERF_PROTO(call, PARAMS(proto)); \
46ac51822a6a0b Steven Rostedt (Red Hat 2015-09-23 @477) static char print_fmt_##call[] = print; \
46ac51822a6a0b Steven Rostedt (Red Hat 2015-09-23 478) static struct trace_event_class __used __refdata event_class_##call = { \
46ac51822a6a0b Steven Rostedt (Red Hat 2015-09-23 479) .system = TRACE_SYSTEM_STRING, \
04ae87a52074e2 Peter Zijlstra 2019-10-24 480 .fields_array = trace_event_fields_##call, \
46ac51822a6a0b Steven Rostedt (Red Hat 2015-09-23 481) .fields = LIST_HEAD_INIT(event_class_##call.fields),\
46ac51822a6a0b Steven Rostedt (Red Hat 2015-09-23 482) .raw_init = trace_event_raw_init, \
46ac51822a6a0b Steven Rostedt (Red Hat 2015-09-23 483) .probe = trace_event_raw_event_##call, \
46ac51822a6a0b Steven Rostedt (Red Hat 2015-09-23 484) .reg = trace_event_reg, \
46ac51822a6a0b Steven Rostedt (Red Hat 2015-09-23 485) _TRACE_PERF_INIT(call) \
46ac51822a6a0b Steven Rostedt (Red Hat 2015-09-23 486) };
46ac51822a6a0b Steven Rostedt (Red Hat 2015-09-23 487) Signature · 2 lines
0-DAY CI Kernel Test Service https://github.com/intel/lkp-tests/wiki
Gabriele Monaco
maintainerRe: [PATCH v2 04/11] rv: Add option for nested monitors and include sched
Quoted 67 lines · kernel test robot
Hi Gabriele,
kernel test robot noticed the following build warnings:
[auto build test WARNING on
4dc1d1bec89864d8076e5ab314f86f46442bfb02]url:
https://github.com/intel-lab-lkp/linux/commits/Gabriele-Monaco/tracing-Fix-DECLARE_TRACE_CONDITION/20250213-171642
base:4dc1d1bec89864d8076e5ab314f86f46442bfb02
patch link:
https://lore.kernel.org/r/20250213090819.419470-5-gmonaco%40redhat.com
patch subject: [PATCH v2 04/11] rv: Add option for nested monitors and include sched
config: parisc-randconfig-r112-20250217
(https://download.01.org/0day-ci/archive/20250217/202502170630.xSYE4c
[email protected]/config)
compiler: hppa-linux-gcc (GCC) 14.2.0
reproduce:
(https://download.01.org/0day-ci/archive/20250217/202502170630.xSYE4c
[email protected]/reproduce)If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tagsQuoted 3 lines
Reported-by kernel test robot <[email protected]>Closes:
https://lore.kernel.org/oe-kbuild-all/[email protected]/All warnings (new ones prefixed by >>):
In file included from
include/trace/define_trace.h:119, fromkernel/trace/rv/rv_trace.h:130, fromkernel/trace/rv/rv.c:148:Quoted 3 lines
Quoted 3 lines
include/trace/trace_events.h:477:13: warning:
'print_fmt_error_da_monitor' defined but not used [-Wunused- variable]477 | static char print_fmt_##call[] =
print; \
| ^~~~~~~~~~kernel/trace/rv/./rv_trace.h:39:1: note: in expansion of macro 'DECLARE_EVENT_CLASS'
39 | DECLARE_EVENT_CLASS(error_da_monitor,
| ^~~~~~~~~~~~~~~~~~~Quoted 3 lines
Quoted 3 lines
include/trace/trace_events.h:477:13: warning:
'print_fmt_event_da_monitor' defined but not used [-Wunused- variable]477 | static char print_fmt_##call[] =
print; \
| ^~~~~~~~~~kernel/trace/rv/./rv_trace.h:12:1: note: in expansion of macro 'DECLARE_EVENT_CLASS'
12 | DECLARE_EVENT_CLASS(event_da_monitor,
| ^~~~~~~~~~~~~~~~~~~Quoted 3 lines
Quoted 3 lines
include/trace/trace_events.h:223:37: warning:
'trace_event_type_funcs_error_da_monitor' defined but not used [- Wunused-variable]223 | static struct
trace_event_functionstrace_event_type_funcs_##call = { \
|
^~~~~~~~~~~~~~~~~~~~~~~kernel/trace/rv/./rv_trace.h:39:1: note: in expansion of macro 'DECLARE_EVENT_CLASS'
39 | DECLARE_EVENT_CLASS(error_da_monitor,
| ^~~~~~~~~~~~~~~~~~~Quoted 3 lines
Quoted 3 lines
include/trace/trace_events.h:223:37: warning:
'trace_event_type_funcs_event_da_monitor' defined but not used [- Wunused-variable]
Quoted 9 lines
223 | static struct
trace_event_functionstrace_event_type_funcs_##call = { \
|
^~~~~~~~~~~~~~~~~~~~~~~kernel/trace/rv/./rv_trace.h:12:1: note: in expansion of macro 'DECLARE_EVENT_CLASS'
12 | DECLARE_EVENT_CLASS(event_da_monitor,
| ^~~~~~~~~~~~~~~~~~~
This is something hard to trigger, but I didn't remove the select DA_MON_EVENTS_IMPLICIT in RV_MON_SCHED . As a result if the user enables the sched monitor without any nested monitor (which is already a broken configuration but happens if you apply this commit without the following ones) trace event classes would be created with no event using them.
I will send a V2 with the fix.
Gabriele Monaco
maintainerPATCH v2 5/11 Add sco and tss per-cpu monitors
In reply to Gabriele MonacoAdd 2 per-cpu monitors as part of the sched model:
* sco: scheduling context operations
Monitor to ensure sched_set_state happens only in thread context
* tss: task switch while scheduling
Monitor to ensure sched_switch happens only in scheduling context
To: Ingo Molnar <[email protected]>
To: Peter Zijlstra <[email protected]>
--- kernel/trace/rv/Kconfig | 2 + kernel/trace/rv/Makefile | 2 + kernel/trace/rv/monitors/sco/Kconfig | 14 ++++ kernel/trace/rv/monitors/sco/sco.c | 88 +++++++++++++++++++++++ kernel/trace/rv/monitors/sco/sco.h | 47 ++++++++++++ kernel/trace/rv/monitors/sco/sco_trace.h | 15 ++++ kernel/trace/rv/monitors/tss/Kconfig | 14 ++++ kernel/trace/rv/monitors/tss/tss.c | 91 ++++++++++++++++++++++++ kernel/trace/rv/monitors/tss/tss.h | 47 ++++++++++++ kernel/trace/rv/monitors/tss/tss_trace.h | 15 ++++ kernel/trace/rv/rv_trace.h | 2 + tools/verification/models/sched/sco.dot | 18 +++++ tools/verification/models/sched/tss.dot | 18 +++++ 13 files changed, 373 insertions(+) create mode 100644 kernel/trace/rv/monitors/sco/Kconfig create mode 100644 kernel/trace/rv/monitors/sco/sco.c create mode 100644 kernel/trace/rv/monitors/sco/sco.h create mode 100644 kernel/trace/rv/monitors/sco/sco_trace.h create mode 100644 kernel/trace/rv/monitors/tss/Kconfig create mode 100644 kernel/trace/rv/monitors/tss/tss.c create mode 100644 kernel/trace/rv/monitors/tss/tss.h create mode 100644 kernel/trace/rv/monitors/tss/tss_trace.h create mode 100644 tools/verification/models/sched/sco.dot create mode 100644 tools/verification/models/sched/tss.dot
kernel/trace/rv/Kconfig +2 -0
@@ -28,6 +28,8 @@ menuconfig RV source "kernel/trace/rv/monitors/wip/Kconfig" source "kernel/trace/rv/monitors/wwnr/Kconfig" source "kernel/trace/rv/monitors/sched/Kconfig" +source "kernel/trace/rv/monitors/tss/Kconfig" +source "kernel/trace/rv/monitors/sco/Kconfig" # Add new monitors here config RV_REACTORS
kernel/trace/rv/Makefile +2 -0
@@ -6,6 +6,8 @@ obj-$(CONFIG_RV) += rv.o obj-$(CONFIG_RV_MON_WIP) += monitors/wip/wip.o obj-$(CONFIG_RV_MON_WWNR) += monitors/wwnr/wwnr.o obj-$(CONFIG_RV_MON_SCHED) += monitors/sched/sched.o +obj-$(CONFIG_RV_MON_TSS) += monitors/tss/tss.o +obj-$(CONFIG_RV_MON_SCO) += monitors/sco/sco.o # Add new monitors here obj-$(CONFIG_RV_REACTORS) += rv_reactors.o obj-$(CONFIG_RV_REACT_PRINTK) += reactor_printk.o
kernel/trace/rv/monitors/sco/Kconfig new file +14 -0
@@ -0,0 +1,14 @@ +# SPDX-License-Identifier: GPL-2.0-only +# +config RV_MON_SCO + depends on RV + depends on RV_MON_SCHED + default y + select DA_MON_EVENTS_IMPLICIT + bool "sco monitor" + help + Monitor to ensure sched_set_state happens only in thread context. + This monitor is part of the sched monitors collection. + + For further information, see: + Documentation/trace/rv/monitor_sched.rst
kernel/trace/rv/monitors/sco/sco.c new file +88 -0
88 lines not on this page · raw message
kernel/trace/rv/monitors/sco/sco.h new file +47 -0
47 lines not on this page · raw message
kernel/trace/rv/monitors/sco/sco_trace.h new file +15 -0
@@ -0,0 +1,15 @@ +/* SPDX-License-Identifier: GPL-2.0 */ + +/* +* Snippet to be included in rv_trace.h +*/ + +#ifdef CONFIG_RV_MON_SCO +DEFINE_EVENT (event_da_monitor, event_sco, + TP_PROTO(char *state, char *event, char *next_state, bool final_state), +TP_ARGS (state, event, next_state, final_state)); + +DEFINE_EVENT (error_da_monitor, error_sco, +TP_PROTO (char *state, char *event), +TP_ARGS (state, event)); +#endif /* CONFIG_RV_MON_SCO */
kernel/trace/rv/monitors/tss/Kconfig new file +14 -0
@@ -0,0 +1,14 @@ +# SPDX-License-Identifier: GPL-2.0-only +# +config RV_MON_TSS + depends on RV + depends on RV_MON_SCHED + default y + select DA_MON_EVENTS_IMPLICIT + bool "tss monitor" + help + Monitor to ensure sched_switch happens only in scheduling context. + This monitor is part of the sched monitors collection. + + For further information, see: + Documentation/trace/rv/monitor_sched.rst
kernel/trace/rv/monitors/tss/tss.c new file +91 -0
91 lines not on this page · raw message
kernel/trace/rv/monitors/tss/tss.h new file +47 -0
47 lines not on this page · raw message
kernel/trace/rv/monitors/tss/tss_trace.h new file +15 -0
@@ -0,0 +1,15 @@ +/* SPDX-License-Identifier: GPL-2.0 */ + +/* +* Snippet to be included in rv_trace.h +*/ + +#ifdef CONFIG_RV_MON_TSS +DEFINE_EVENT (event_da_monitor, event_tss, + TP_PROTO(char *state, char *event, char *next_state, bool final_state), +TP_ARGS (state, event, next_state, final_state)); + +DEFINE_EVENT (error_da_monitor, error_tss, +TP_PROTO (char *state, char *event), +TP_ARGS (state, event)); +#endif /* CONFIG_RV_MON_TSS */
kernel/trace/rv/rv_trace.h +2 -0
@@ -58,6 +58,8 @@ DECLARE_EVENT_CLASS(error_da_monitor, );#include <monitors/wip/wip_trace.h> +#include <monitors/tss/tss_trace.h> +#include <monitors/sco/sco_trace.h> // Add new monitors based on CONFIG_DA_MON_EVENTS_IMPLICIT here #endif /* CONFIG_DA_MON_EVENTS_IMPLICIT */
tools/verification/models/sched/sco.dot new file +18 -0
@@ -0,0 +1,18 @@ +digraph state_automaton { + center = true; + size = "7,11"; + {node [shape = plaintext] "scheduling_context"}; + {node [shape = plaintext, style=invis, label=""] "__init_thread_context"}; + {node [shape = ellipse] "thread_context"}; + {node [shape = plaintext] "thread_context"}; + "__init_thread_context" -> "thread_context"; + "scheduling_context" [label = "scheduling_context"]; + "scheduling_context" -> "thread_context" [ label = "schedule_exit" ]; + "thread_context" [label = "thread_context", color = green3]; + "thread_context" -> "scheduling_context" [ label = "schedule_entry" ]; + "thread_context" -> "thread_context" [ label = "sched_set_state" ]; + { rank = min ; + "__init_thread_context"; + "thread_context"; + } +}
tools/verification/models/sched/tss.dot new file +18 -0
@@ -0,0 +1,18 @@ +digraph state_automaton { + center = true; + size = "7,11"; + {node [shape = plaintext] "sched"}; + {node [shape = plaintext, style=invis, label=""] "__init_thread"}; + {node [shape = ellipse] "thread"}; + {node [shape = plaintext] "thread"}; + "__init_thread" -> "thread"; + "sched" [label = "sched"]; + "sched" -> "sched" [ label = "sched_switch" ]; + "sched" -> "thread" [ label = "schedule_exit" ]; + "thread" [label = "thread", color = green3]; + "thread" -> "sched" [ label = "schedule_entry" ]; + { rank = min ; + "__init_thread"; + "thread"; + } +}
Signature · 1 line
2.48.1
Gabriele Monaco
maintainerPATCH v2 6/11 Add snroc per-task monitor
In reply to Gabriele MonacoAdd a per-task monitor as part of the sched model:
* snroc: set non runnable on its own context
Monitor to ensure set_state happens only in the respective task's context
To: Ingo Molnar <[email protected]>
To: Peter Zijlstra <[email protected]>
--- kernel/trace/rv/Kconfig | 1 + kernel/trace/rv/Makefile | 1 + kernel/trace/rv/monitors/snroc/Kconfig | 14 ++++ kernel/trace/rv/monitors/snroc/snroc.c | 87 ++++++++++++++++++++ kernel/trace/rv/monitors/snroc/snroc.h | 47 +++++++++++ kernel/trace/rv/monitors/snroc/snroc_trace.h | 15 ++++ kernel/trace/rv/rv_trace.h | 1 + tools/verification/models/sched/snroc.dot | 18 ++++ 8 files changed, 184 insertions(+) create mode 100644 kernel/trace/rv/monitors/snroc/Kconfig create mode 100644 kernel/trace/rv/monitors/snroc/snroc.c create mode 100644 kernel/trace/rv/monitors/snroc/snroc.h create mode 100644 kernel/trace/rv/monitors/snroc/snroc_trace.h create mode 100644 tools/verification/models/sched/snroc.dot
kernel/trace/rv/Kconfig +1 -0
@@ -30,6 +30,7 @@ source "kernel/trace/rv/monitors/wwnr/Kconfig" source "kernel/trace/rv/monitors/sched/Kconfig" source "kernel/trace/rv/monitors/tss/Kconfig" source "kernel/trace/rv/monitors/sco/Kconfig" +source "kernel/trace/rv/monitors/snroc/Kconfig" # Add new monitors here config RV_REACTORS
kernel/trace/rv/Makefile +1 -0
@@ -8,6 +8,7 @@ obj-$(CONFIG_RV_MON_WWNR) += monitors/wwnr/wwnr.o obj-$(CONFIG_RV_MON_SCHED) += monitors/sched/sched.o obj-$(CONFIG_RV_MON_TSS) += monitors/tss/tss.o obj-$(CONFIG_RV_MON_SCO) += monitors/sco/sco.o +obj-$(CONFIG_RV_MON_SNROC) += monitors/snroc/snroc.o # Add new monitors here obj-$(CONFIG_RV_REACTORS) += rv_reactors.o obj-$(CONFIG_RV_REACT_PRINTK) += reactor_printk.o
kernel/trace/rv/monitors/snroc/Kconfig new file +14 -0
@@ -0,0 +1,14 @@ +# SPDX-License-Identifier: GPL-2.0-only +# +config RV_MON_SNROC + depends on RV + depends on RV_MON_SCHED + default y + select DA_MON_EVENTS_ID + bool "snroc monitor" + help + Monitor to ensure sched_set_state happens only in the respective task's context. + This monitor is part of the sched monitors collection. + + For further information, see: + Documentation/trace/rv/monitor_sched.rst
kernel/trace/rv/monitors/snroc/snroc.c new file +87 -0
87 lines not on this page · raw message
kernel/trace/rv/monitors/snroc/snroc.h new file +47 -0
47 lines not on this page · raw message
kernel/trace/rv/monitors/snroc/snroc_trace.h new file +15 -0
@@ -0,0 +1,15 @@ +/* SPDX-License-Identifier: GPL-2.0 */ + +/* +* Snippet to be included in rv_trace.h +*/ + +#ifdef CONFIG_RV_MON_SNROC +DEFINE_EVENT (event_da_monitor_id, event_snroc, + TP_PROTO(int id, char *state, char *event, char *next_state, bool final_state), +TP_ARGS (id, state, event, next_state, final_state)); + +DEFINE_EVENT (error_da_monitor_id, error_snroc, + TP_PROTO(int id, char *state, char *event), +TP_ARGS (id, state, event)); +#endif /* CONFIG_RV_MON_SNROC */
kernel/trace/rv/rv_trace.h +1 -0
@@ -120,6 +120,7 @@ DECLARE_EVENT_CLASS(error_da_monitor_id, );#include <monitors/wwnr/wwnr_trace.h> +#include <monitors/snroc/snroc_trace.h> // Add new monitors based on CONFIG_DA_MON_EVENTS_ID here #endif /* CONFIG_DA_MON_EVENTS_ID */
tools/verification/models/sched/snroc.dot new file +18 -0
@@ -0,0 +1,18 @@ +digraph state_automaton { + center = true; + size = "7,11"; + {node [shape = plaintext, style=invis, label=""] "__init_other_context"}; + {node [shape = ellipse] "other_context"}; + {node [shape = plaintext] "other_context"}; + {node [shape = plaintext] "own_context"}; + "__init_other_context" -> "other_context"; + "other_context" [label = "other_context", color = green3]; + "other_context" -> "own_context" [ label = "sched_switch_in" ]; + "own_context" [label = "own_context"]; + "own_context" -> "other_context" [ label = "sched_switch_out" ]; + "own_context" -> "own_context" [ label = "sched_set_state" ]; + { rank = min ; + "__init_other_context"; + "other_context"; + } +}
Signature · 1 line
2.48.1
Gabriele Monaco
maintainerPATCH v2 7/11 Add scpd, snep and sncid per-cpu monitors
In reply to Gabriele MonacoAdd 3 per-cpu monitors as part of the sched model:
* scpd: schedule called with preemption disabled
Monitor to ensure schedule is called with preemption disabled
* snep: schedule does not enable preempt
Monitor to ensure schedule does not enable preempt
* sncid: schedule not called with interrupt disabled Monitor to ensure schedule is not called with interrupt disabled
To: Ingo Molnar <[email protected]>
To: Peter Zijlstra <[email protected]>
--- kernel/trace/rv/Kconfig | 3 + kernel/trace/rv/Makefile | 3 + kernel/trace/rv/monitors/scpd/Kconfig | 15 +++ kernel/trace/rv/monitors/scpd/scpd.c | 96 ++++++++++++++++++++ kernel/trace/rv/monitors/scpd/scpd.h | 49 ++++++++++ kernel/trace/rv/monitors/scpd/scpd_trace.h | 15 +++ kernel/trace/rv/monitors/sncid/Kconfig | 15 +++ kernel/trace/rv/monitors/sncid/sncid.c | 96 ++++++++++++++++++++ kernel/trace/rv/monitors/sncid/sncid.h | 49 ++++++++++ kernel/trace/rv/monitors/sncid/sncid_trace.h | 15 +++ kernel/trace/rv/monitors/snep/Kconfig | 15 +++ kernel/trace/rv/monitors/snep/snep.c | 96 ++++++++++++++++++++ kernel/trace/rv/monitors/snep/snep.h | 49 ++++++++++ kernel/trace/rv/monitors/snep/snep_trace.h | 15 +++ kernel/trace/rv/rv_trace.h | 3 + tools/verification/models/sched/scpd.dot | 18 ++++ tools/verification/models/sched/sncid.dot | 18 ++++ tools/verification/models/sched/snep.dot | 18 ++++ 18 files changed, 588 insertions(+) create mode 100644 kernel/trace/rv/monitors/scpd/Kconfig create mode 100644 kernel/trace/rv/monitors/scpd/scpd.c create mode 100644 kernel/trace/rv/monitors/scpd/scpd.h create mode 100644 kernel/trace/rv/monitors/scpd/scpd_trace.h create mode 100644 kernel/trace/rv/monitors/sncid/Kconfig create mode 100644 kernel/trace/rv/monitors/sncid/sncid.c create mode 100644 kernel/trace/rv/monitors/sncid/sncid.h create mode 100644 kernel/trace/rv/monitors/sncid/sncid_trace.h create mode 100644 kernel/trace/rv/monitors/snep/Kconfig create mode 100644 kernel/trace/rv/monitors/snep/snep.c create mode 100644 kernel/trace/rv/monitors/snep/snep.h create mode 100644 kernel/trace/rv/monitors/snep/snep_trace.h create mode 100644 tools/verification/models/sched/scpd.dot create mode 100644 tools/verification/models/sched/sncid.dot create mode 100644 tools/verification/models/sched/snep.dot
kernel/trace/rv/Kconfig +3 -0
@@ -31,6 +31,9 @@ source "kernel/trace/rv/monitors/sched/Kconfig" source "kernel/trace/rv/monitors/tss/Kconfig" source "kernel/trace/rv/monitors/sco/Kconfig" source "kernel/trace/rv/monitors/snroc/Kconfig" +source "kernel/trace/rv/monitors/scpd/Kconfig" +source "kernel/trace/rv/monitors/snep/Kconfig" +source "kernel/trace/rv/monitors/sncid/Kconfig" # Add new monitors here config RV_REACTORS
kernel/trace/rv/Makefile +3 -0
@@ -9,6 +9,9 @@ obj-$(CONFIG_RV_MON_SCHED) += monitors/sched/sched.o obj-$(CONFIG_RV_MON_TSS) += monitors/tss/tss.o obj-$(CONFIG_RV_MON_SCO) += monitors/sco/sco.o obj-$(CONFIG_RV_MON_SNROC) += monitors/snroc/snroc.o +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 # Add new monitors here obj-$(CONFIG_RV_REACTORS) += rv_reactors.o obj-$(CONFIG_RV_REACT_PRINTK) += reactor_printk.o
kernel/trace/rv/monitors/scpd/Kconfig new file +15 -0
@@ -0,0 +1,15 @@ +# SPDX-License-Identifier: GPL-2.0-only +# +config RV_MON_SCPD + depends on RV + depends on PREEMPT_TRACER + depends on RV_MON_SCHED + default y + select DA_MON_EVENTS_IMPLICIT + bool "scpd monitor" + help + Monitor to ensure schedule is called with preemption disabled. + This monitor is part of the sched monitors collection. + + For further information, see: + Documentation/trace/rv/monitor_sched.rst
kernel/trace/rv/monitors/scpd/scpd.c new file +96 -0
96 lines not on this page · raw message
kernel/trace/rv/monitors/scpd/scpd.h new file +49 -0
49 lines not on this page · raw message
kernel/trace/rv/monitors/scpd/scpd_trace.h new file +15 -0
@@ -0,0 +1,15 @@ +/* SPDX-License-Identifier: GPL-2.0 */ + +/* +* Snippet to be included in rv_trace.h +*/ + +#ifdef CONFIG_RV_MON_SCPD +DEFINE_EVENT (event_da_monitor, event_scpd, + TP_PROTO(char *state, char *event, char *next_state, bool final_state), +TP_ARGS (state, event, next_state, final_state)); + +DEFINE_EVENT (error_da_monitor, error_scpd, +TP_PROTO (char *state, char *event), +TP_ARGS (state, event)); +#endif /* CONFIG_RV_MON_SCPD */
kernel/trace/rv/monitors/sncid/Kconfig new file +15 -0
@@ -0,0 +1,15 @@ +# SPDX-License-Identifier: GPL-2.0-only +# +config RV_MON_SNCID + depends on RV + depends on IRQSOFF_TRACER + depends on RV_MON_SCHED + default y + select DA_MON_EVENTS_IMPLICIT + bool "sncid monitor" + help + Monitor to ensure schedule is not called with interrupt disabled. + This monitor is part of the sched monitors collection. + + For further information, see: + Documentation/trace/rv/monitor_sched.rst
kernel/trace/rv/monitors/sncid/sncid.c new file +96 -0
96 lines not on this page · raw message
kernel/trace/rv/monitors/sncid/sncid.h new file +49 -0
49 lines not on this page · raw message
kernel/trace/rv/monitors/sncid/sncid_trace.h new file +15 -0
@@ -0,0 +1,15 @@ +/* SPDX-License-Identifier: GPL-2.0 */ + +/* +* Snippet to be included in rv_trace.h +*/ + +#ifdef CONFIG_RV_MON_SNCID +DEFINE_EVENT (event_da_monitor, event_sncid, + TP_PROTO(char *state, char *event, char *next_state, bool final_state), +TP_ARGS (state, event, next_state, final_state)); + +DEFINE_EVENT (error_da_monitor, error_sncid, +TP_PROTO (char *state, char *event), +TP_ARGS (state, event)); +#endif /* CONFIG_RV_MON_SNCID */
kernel/trace/rv/monitors/snep/Kconfig new file +15 -0
@@ -0,0 +1,15 @@ +# SPDX-License-Identifier: GPL-2.0-only +# +config RV_MON_SNEP + depends on RV + depends on PREEMPT_TRACER + depends on RV_MON_SCHED + default y + select DA_MON_EVENTS_IMPLICIT + bool "snep monitor" + help + Monitor to ensure schedule does not enable preempt. + This monitor is part of the sched monitors collection. + + For further information, see: + Documentation/trace/rv/monitor_sched.rst
kernel/trace/rv/monitors/snep/snep.c new file +96 -0
96 lines not on this page · raw message
kernel/trace/rv/monitors/snep/snep.h new file +49 -0
49 lines not on this page · raw message
kernel/trace/rv/monitors/snep/snep_trace.h new file +15 -0
@@ -0,0 +1,15 @@ +/* SPDX-License-Identifier: GPL-2.0 */ + +/* +* Snippet to be included in rv_trace.h +*/ + +#ifdef CONFIG_RV_MON_SNEP +DEFINE_EVENT (event_da_monitor, event_snep, + TP_PROTO(char *state, char *event, char *next_state, bool final_state), +TP_ARGS (state, event, next_state, final_state)); + +DEFINE_EVENT (error_da_monitor, error_snep, +TP_PROTO (char *state, char *event), +TP_ARGS (state, event)); +#endif /* CONFIG_RV_MON_SNEP */
kernel/trace/rv/rv_trace.h +3 -0
@@ -60,6 +60,9 @@ DECLARE_EVENT_CLASS(error_da_monitor,#include <monitors/wip/wip_trace.h> #include <monitors/tss/tss_trace.h> #include <monitors/sco/sco_trace.h> +#include <monitors/scpd/scpd_trace.h> +#include <monitors/snep/snep_trace.h> +#include <monitors/sncid/sncid_trace.h> // Add new monitors based on CONFIG_DA_MON_EVENTS_IMPLICIT here #endif /* CONFIG_DA_MON_EVENTS_IMPLICIT */
tools/verification/models/sched/scpd.dot new file +18 -0
@@ -0,0 +1,18 @@ +digraph state_automaton { + center = true; + size = "7,11"; + {node [shape = plaintext] "can_sched"}; + {node [shape = plaintext, style=invis, label=""] "__init_cant_sched"}; + {node [shape = ellipse] "cant_sched"}; + {node [shape = plaintext] "cant_sched"}; + "__init_cant_sched" -> "cant_sched"; + "can_sched" [label = "can_sched"]; + "can_sched" -> "can_sched" [ label = "schedule_entry\nschedule_exit" ]; + "can_sched" -> "cant_sched" [ label = "preempt_enable" ]; + "cant_sched" [label = "cant_sched", color = green3]; + "cant_sched" -> "can_sched" [ label = "preempt_disable" ]; + { rank = min ; + "__init_cant_sched"; + "cant_sched"; + } +}
tools/verification/models/sched/sncid.dot new file +18 -0
@@ -0,0 +1,18 @@ +digraph state_automaton { + center = true; + size = "7,11"; + {node [shape = plaintext, style=invis, label=""] "__init_can_sched"}; + {node [shape = ellipse] "can_sched"}; + {node [shape = plaintext] "can_sched"}; + {node [shape = plaintext] "cant_sched"}; + "__init_can_sched" -> "can_sched"; + "can_sched" [label = "can_sched", color = green3]; + "can_sched" -> "can_sched" [ label = "schedule_entry\nschedule_exit" ]; + "can_sched" -> "cant_sched" [ label = "irq_disable" ]; + "cant_sched" [label = "cant_sched"]; + "cant_sched" -> "can_sched" [ label = "irq_enable" ]; + { rank = min ; + "__init_can_sched"; + "can_sched"; + } +}
tools/verification/models/sched/snep.dot new file +18 -0
@@ -0,0 +1,18 @@ +digraph state_automaton { + center = true; + size = "7,11"; + {node [shape = plaintext, style=invis, label=""] "__init_non_scheduling_context"}; + {node [shape = ellipse] "non_scheduling_context"}; + {node [shape = plaintext] "non_scheduling_context"}; + {node [shape = plaintext] "scheduling_contex"}; + "__init_non_scheduling_context" -> "non_scheduling_context"; + "non_scheduling_context" [label = "non_scheduling_context", color = green3]; + "non_scheduling_context" -> "non_scheduling_context" [ label = "preempt_disable\npreempt_enable" ]; + "non_scheduling_context" -> "scheduling_contex" [ label = "schedule_entry" ]; + "scheduling_contex" [label = "scheduling_contex"]; + "scheduling_contex" -> "non_scheduling_context" [ label = "schedule_exit" ]; + { rank = min ; + "__init_non_scheduling_context"; + "non_scheduling_context"; + } +}
Signature · 1 line
2.48.1
Gabriele Monaco
maintainerPATCH v2 8/11 tools/rv: Add support for nested monitors
In reply to Gabriele MonacoRV now supports nested monitors, this functionality requires a container monitor, which has virtually no functionality besides holding other monitors, and nested monitors, that have a container as parent.
Nested monitors' sysfs folders are physically nested in the container's folder, and they are listed in the available_monitors file with the notation container:monitor.
These changes go against the assumption that each line in the available_monitors file correspond to a folder in the rv directory, breaking the functionality of the rv tool.
Add support for nested containers in the rv userspace tool, indenting nested monitors while listed and allowing both the notation with and without container name, which are equivalent:
# rv list mon1 mon2 container: - nested1 - nested2
## notation with container name
# rv mon container:nested1
## notation without container name
# rv mon nested1
Either way, enabling a nested monitor is the same as enabling any other non-nested monitor.
Selecting the container with rv mon enables all the nested monitors, if -t is passed, the trace also includes the monitor name next to the event:
# rv mon nested1 -t <idle>-0 [004] event state1 x event -> state2 <idle>-0 [004] error event not expected in state2
# rv mon sched -t <idle>-0 [004] event_nested1 state1 x event -> state2 <idle>-0 [004] error_nested1 event not expected in state2
--- tools/verification/rv/include/rv.h | 1 + tools/verification/rv/src/in_kernel.c | 226 ++++++++++++++++++++------ 2 files changed, 179 insertions(+), 48 deletions(-)
tools/verification/rv/include/rv.h +1 -0
@@ -7,6 +7,7 @@ struct monitor {char name[MAX_DA_NAME_LEN ];char desc[MAX_DESCRIPTION ];int enabled; +int nested; };int should_stop (void );
tools/verification/rv/src/in_kernel.c +178 -48
366 lines not on this page · raw message
Signature · 1 line
2.48.1
Gabriele Monaco
maintainerPATCH v2 9/11 verification/dot2k: Add support for nested monitors
In reply to Gabriele MonacoRV now supports nested monitors, this functionality requires a container monitor, which has virtually no functionality besides holding other monitors, and nested monitors, that have a container as parent.
Add the -p flag to pass a parent to a monitor, this sets it up while registering the monitor and adds necessary includes and configurations. Add the -c flag to create a container, since containers are empty, we don't allow supplying a dot model or a monitor type, the template is also different since functions to enable and disable the monitor are not defined, nor any tracepoint. The generated header file only allows to include the rv_monitor structure in children monitors.
--- tools/verification/dot2/dot2k | 27 ++++--- tools/verification/dot2/dot2k.py | 79 +++++++++++++++---- .../verification/dot2/dot2k_templates/Kconfig | 1 + .../verification/dot2/dot2k_templates/main.c | 4 +- .../dot2/dot2k_templates/main_container.c | 38 +++++++++ .../dot2/dot2k_templates/main_container.h | 3 + 6 files changed, 125 insertions(+), 27 deletions(-) create mode 100644 tools/verification/dot2/dot2k_templates/main_container.c create mode 100644 tools/verification/dot2/dot2k_templates/main_container.h
tools/verification/dot2/dot2k +18 -9
@@ -11,22 +11,30 @@ if __name__ == '__main__': from dot2.dot2k import dot2k import argparse - import ntpath - import os - import platform import sys + def is_container(): + """Should work even before parsing the arguments""" + return "-c" in sys.argv or "--container" in sys.argv + parser = argparse.ArgumentParser(description='transform .dot file into kernel rv monitor') - parser.add_argument('-d', "--dot", dest="dot_file", required=True) - parser.add_argument('-t', "--monitor_type", dest="monitor_type", required=True) - parser.add_argument('-n', "--model_name", dest="model_name", required=False) + parser.add_argument('-d', "--dot", dest="dot_file", required=not is_container()) + parser.add_argument('-t', "--monitor_type", dest="monitor_type", required=not is_container(), + help=f"Available options: {', '.join(dot2k.monitor_types.keys())}") + parser.add_argument('-n', "--model_name", dest="model_name", required=is_container()) parser.add_argument("-D", "--description", dest="description", required=False) parser.add_argument("-a", "--auto_patch", dest="auto_patch", action="store_true", required=False, help="Patch the kernel in place") + parser.add_argument("-p", "--parent", dest="parent", + required=False, help="Create a monitor nested to parent") + parser.add_argument("-c", "--container", dest="container", + action="store_true", required=False, + help="Create an empty monitor to be used as a container") params = parser.parse_args() - print("Opening and parsing the dot file %s" % params.dot_file) + if not is_container(): + print("Opening and parsing the dot file %s" % params.dot_file) try: monitor=dot2k(params.dot_file, params.monitor_type, vars(params)) except Exception as e:
@@ -37,8 +45,9 @@ if __name__ == '__main__': print("Writing the monitor into the directory %s" % monitor.name) monitor.print_files() print("Almost done, checklist") - print(" - Edit the %s/%s.c to add the instrumentation" % (monitor.name, monitor.name)) - print(monitor.fill_tracepoint_tooltip()) + if not is_container(): + print(" - Edit the %s/%s.c to add the instrumentation" % (monitor.name, monitor.name)) + print(monitor.fill_tracepoint_tooltip()) print(monitor.fill_makefile_tooltip()) print(monitor.fill_kconfig_tooltip()) print(monitor.fill_monitor_tooltip())
tools/verification/dot2/dot2k.py +63 -16
134 lines not on this page · raw message
tools/verification/dot2/dot2k_templates/Kconfig +1 -0
@@ -2,6 +2,7 @@ # config RV_MON_%%MODEL_NAME_UP%% depends on RV +%%MONITOR_DEPS%% select %%MONITOR_CLASS_TYPE%% bool "%%MODEL_NAME%% monitor" help
tools/verification/dot2/dot2k_templates/main.c +2 -2
@@ -15,7 +15,7 @@* #include <trace/events/sched.h> */ #include <rv_trace.h> - +%%INCLUDE_PARENT%%/* * This is the self-generated part of the monitor. Generally, there is no need * to touch this section.
@@ -74,7 +74,7 @@ static struct rv_monitor rv_%%MODEL_NAME%% = { static int __init register_%%MODEL_NAME%%(void) { - rv_register_monitor(&rv_%%MODEL_NAME%%); + rv_register_monitor(&rv_%%MODEL_NAME%%, %%PARENT%%);return 0 ; }
tools/verification/dot2/dot2k_templates/main_container.c new file +38 -0
@@ -0,0 +1,38 @@ +// SPDX-License-Identifier: GPL-2.0 +#include <linux/kernel.h> +#include <linux/module.h> +#include <linux/init.h> +#include <linux/rv.h> + +#define MODULE_NAME "%%MODEL_NAME%%" + +#include "%%MODEL_NAME%%.h" + +struct rv_monitor rv_%%MODEL_NAME%%; + +struct rv_monitor rv_%%MODEL_NAME%% = { + .name = "%%MODEL_NAME%%", + .description = "%%DESCRIPTION%%", + .enable = NULL, + .disable = NULL, + .reset = NULL, + .enabled = 0, +}; + +static int __init register_%%MODEL_NAME%%(void) +{ + rv_register_monitor(&rv_%%MODEL_NAME%%, NULL); + return 0; +} + +static void __exit unregister_%%MODEL_NAME%%(void) +{ + rv_unregister_monitor(&rv_%%MODEL_NAME%%); +} + +module_init(register_%%MODEL_NAME%%); +module_exit(unregister_%%MODEL_NAME%%); + +MODULE_LICENSE("GPL"); +MODULE_AUTHOR("dot2k: auto-generated"); +MODULE_DESCRIPTION("%%MODEL_NAME%%: %%DESCRIPTION%%");
tools/verification/dot2/dot2k_templates/main_container.h new file +3 -0
@@ -0,0 +1,3 @@ +/* SPDX-License-Identifier: GPL-2.0 */ + +extern struct rv_monitor rv_%%MODEL_NAME%%;
Signature · 1 line
2.48.1
Gabriele Monaco
maintainerPATCH v2 10/11 Documentation/rv: Add docs for the sched monitors
In reply to Gabriele MonacoAdd man page and kernel documentation for the sched monitors, as sched is a container of other monitors, document all in the same page. sched is the first nested monitor, also explain what is a nested monitor and how enabling containers or children monitors work.
To: Ingo Molnar <[email protected]>
To: Peter Zijlstra <[email protected]>
--- Documentation/tools/rv/rv-mon-sched.rst | 69 +++++++++ Documentation/trace/rv/monitor_sched.rst | 171 +++++++++++++++++++++++ 2 files changed, 240 insertions(+) create mode 100644 Documentation/tools/rv/rv-mon-sched.rst create mode 100644 Documentation/trace/rv/monitor_sched.rst
Documentation/tools/rv/rv-mon-sched.rst new file +69 -0
@@ -0,0 +1,69 @@ +.. SPDX-License-Identifier: GPL-2.0 + +============ +rv-mon-sched +============ +----------------------------- +Scheduler monitors collection +----------------------------- + +:Manual section: 1 + +SYNOPSIS +======== + +**rv mon sched** [*OPTIONS*] + +**rv mon <NESTED_MONITOR>** [*OPTIONS*] + +**rv mon sched:<NESTED_MONITOR>** [*OPTIONS*] + +DESCRIPTION +=========== + +The scheduler monitor collection is a container for several monitors to model +the behaviour of the scheduler. Each monitor describes a specification that +the scheduler should follow. + +As a monitor container, it will enable all nested monitors and set them +according to OPTIONS. +Nevertheless nested monitors can also be activated independently both by name +and by specifying sched: , e.g. to enable only monitor tss you can do any of: + + # rv mon sched:tss + + # rv mon tss + +See kernel documentation for further information about this monitor: +<https://docs.kernel.org/trace/rv/monitor_sched.html> + +OPTIONS +======= + +.. include:: common_ikm.rst + +NESTED MONITOR +============== + +The available nested monitors are: + * scpd: schedule called with preemption disabled + * snep: schedule does not enable preempt + * sncid: schedule not called with interrupt disabled + * snroc: set non runnable on its own context + * sco: scheduling context operations + * tss: task switch while scheduling + +SEE ALSO +======== + +**rv**\(1), **rv-mon**\(1) + +Linux kernel *RV* documentation: +<https://www.kernel.org/doc/html/latest/trace/rv/index.html> + +AUTHOR +====== + +Written by Gabriele Monaco <[email protected]> + +.. include:: common_appendix.rst
Documentation/trace/rv/monitor_sched.rst new file +171 -0
171 lines not on this page · raw message
Signature · 1 line
2.48.1
Gabriele Monaco
maintainerPATCH v2 11/11 tools/rv: Allow rv list to filter for container
In reply to Gabriele MonacoAdd possibility to supply the container name to rv list:
# rv list sched mon1 mon2 mon3
This lists only monitors in sched, without indentation. Supplying -h, any option (string starting with -) or more than 1 argument will still print the usage.
Passing a non-existent container prints nothing and passing no container continues to print all monitors, showing indentation for nested monitors, reported after their container.
--- tools/verification/rv/include/in_kernel.h | 2 +- tools/verification/rv/src/in_kernel.c | 36 +++++++++++++++------ tools/verification/rv/src/rv.c | 38 +++++++++++++++-------- 3 files changed, 53 insertions(+), 23 deletions(-)
tools/verification/rv/include/in_kernel.h +1 -1
@@ -1,3 +1,3 @@// SPDX-License-Identifier: GPL-2.0 -int ikm_list_monitors (void ); +int ikm_list_monitors (char *container);int ikm_run_monitor (char *monitor,int argc,char **argv);
tools/verification/rv/src/in_kernel.c +27 -9
@@ -180,19 +180,25 @@ static char *ikm_read_desc(char *monitor_name)/* * ikm_fill_monitor_definition - fill monitor's definition * -* Returns -1 on error, 0 otherwise. +* Returns -1 on error, 1 if the monitor does not belong in the container, 0 otherwise. +* container can be NULL */ -static int ikm_fill_monitor_definition (char *name,struct monitor *ikm) +static int ikm_fill_monitor_definition (char *name,struct monitor *ikm,char *container) {int enabled;char *desc, *nested_name; nested_name =strstr (name,":" );if (nested_name) { +/* it belongs in container if it starts with "container:" */ +if (container &&strstr (name, container) != name) +return 1 ; *nested_name ='/' ; ++nested_name; ikm->nested =1 ; }else { +if (container) +return 1 ; nested_name = name; ikm->nested =0 ; }
@@ -328,12 +334,12 @@ static int ikm_has_id(char *monitor_name)* * Returns 0 on success, -1 otherwise. */ -int ikm_list_monitors (void ) +int ikm_list_monitors (char *container) {char *available_monitors;struct monitor ikm = {0 };char *curr, *next; -int retval; +int retval, list_monitor =0 ; available_monitors =tracefs_instance_file_read (NULL ,"rv/available_monitors" ,NULL );
@@ -347,17 +353,29 @@ int ikm_list_monitors(void) next =strstr (curr,"\n" ); *next ='\0' ; - retval =ikm_fill_monitor_definition (curr, &ikm); -if (retval) + retval =ikm_fill_monitor_definition (curr, &ikm, container); +if (retval <0 )err_msg ("ikm: error reading %d in kernel monitor, skipping\n" , curr); -printf ("%s%-*s %s %s\n" , ikm.nested ?" - " :"" , - ikm.nested ?MAX_DA_NAME_LEN -3 :MAX_DA_NAME_LEN , - ikm.name, ikm.desc, ikm.enabled ?"[ON]" :"[OFF]" ); +if (!retval) { +int indent = ikm.nested && !container; + + list_monitor =1 ; +printf ("%s%-*s %s %s\n" , indent ?" - " :"" , + indent ?MAX_DA_NAME_LEN -3 :MAX_DA_NAME_LEN , + ikm.name, ikm.desc, ikm.enabled ?"[ON]" :"[OFF]" ); + } curr = ++next; }while (strlen (curr)); +if (!list_monitor) { +if (container) +printf ("-- No monitor found in container %s --\n" , container); +else +printf ("-- No monitor found --\n" ); + } +free (available_monitors);return 0 ;
tools/verification/rv/src/rv.c +25 -13
@@ -41,30 +41,42 @@ static void rv_list(int argc, char **argv) {static const char *const usage[] = {"" , -" usage: rv list [-h]" , +" usage: rv list [-h] [container]" ,"" ," list all available monitors" ,"" ," -h/--help: print this menu" , +"" , +" [container]: list only monitors in this container" ,NULL , }; -int i; - -if (argc >1 ) { +int i, print_help =0 , retval =0 ; +char *container =NULL ; + +if (argc ==2 ) { +if (!strcmp (argv[1 ],"-h" ) || !strcmp (argv[1 ],"--help" )) { + print_help =1 ; + retval =0 ; + }else if (argv[1 ][0 ] =='-' ) { +/* assume invalid option */ + print_help =1 ; + retval =1 ; + }else + container = argv[1 ]; + }else if (argc >2 ) { +/* more than 2 is always usage */ + print_help =1 ; + retval =1 ; + } +if (print_help) {fprintf (stderr,"rv version %s\n" ,VERSION ); - -/* more than 1 is always usage */ for (i =0 ; usage[i]; i++)fprintf (stderr,"%s\n" , usage[i]); - -/* but only -h is valid */ -if (!strcmp (argv[1 ],"-h" ) || !strcmp (argv[1 ],"--help" )) -exit (0 ); -else -exit (1 ); +exit (retval); } -ikm_list_monitors (); +ikm_list_monitors (container); +exit (0 ); }
Signature · 1 line
2.48.1