Skip to content

Commit d0096c2

Browse files
glemcorostedt
authored andcommitted
rv: Replace tss and sncid monitors with more complete sts
The tss monitor currently guarantees task switches can happen only while scheduling, whereas the sncid monitor enforces scheduling occurs with interrupt disabled. Replace the monitors with a more comprehensive specification which implies both but also ensures that: * each scheduler call disable interrupts to switch * each task switch happens with interrupts disabled Cc: Ingo Molnar <[email protected]> Cc: Jonathan Corbet <[email protected]> Cc: Masami Hiramatsu <[email protected]> Cc: Nam Cao <[email protected]> Cc: Tomas Glozar <[email protected]> Cc: Juri Lelli <[email protected]> Cc: Clark Williams <[email protected]> Cc: John Kacur <[email protected]> Cc: Peter Zijlstra <[email protected]> Link: https://lore.kernel.org/[email protected] Signed-off-by: Gabriele Monaco <[email protected]> Signed-off-by: Steven Rostedt (Google) <[email protected]>
1 parent adcc3bf commit d0096c2

File tree

18 files changed

+385
-410
lines changed

18 files changed

+385
-410
lines changed

Documentation/trace/rv/monitor_sched.rst

Lines changed: 48 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -40,26 +40,6 @@ defined in by Daniel Bristot in [1].
4040

4141
Currently we included the following:
4242

43-
Monitor tss
44-
~~~~~~~~~~~
45-
46-
The task switch while scheduling (tss) monitor ensures a task switch happens
47-
only in scheduling context, that is inside a call to `__schedule`::
48-
49-
|
50-
|
51-
v
52-
+-----------------+
53-
| thread | <+
54-
+-----------------+ |
55-
| |
56-
| schedule_entry | schedule_exit
57-
v |
58-
sched_switch |
59-
+--------------- |
60-
| sched |
61-
+--------------> -+
62-
6343
Monitor sco
6444
~~~~~~~~~~~
6545

@@ -144,26 +124,55 @@ does not enable preemption::
144124
|
145125
scheduling_contex -+
146126

147-
Monitor sncid
148-
~~~~~~~~~~~~~
149-
150-
The schedule not called with interrupt disabled (sncid) monitor ensures
151-
schedule is not called with interrupt disabled::
127+
Monitor sts
128+
~~~~~~~~~~~
152129

153-
|
154-
|
155-
v
156-
schedule_entry +--------------+
157-
schedule_exit | |
158-
+----------------- | can_sched |
159-
| | |
160-
+----------------> | | <+
161-
+--------------+ |
162-
| |
163-
| irq_disable | irq_enable
164-
v |
165-
|
166-
cant_sched -+
130+
The schedule implies task switch (sts) monitor ensures a task switch happens
131+
only in scheduling context and up to once, as well as scheduling occurs with
132+
interrupts enabled but no task switch can happen before interrupts are
133+
disabled. When the next task picked for execution is the same as the previously
134+
running one, no real task switch occurs but interrupts are disabled nonetheless::
135+
136+
irq_entry |
137+
+----+ |
138+
v | v
139+
+------------+ irq_enable #===================# irq_disable
140+
| | ------------> H H irq_entry
141+
| cant_sched | <------------ H H irq_enable
142+
| | irq_disable H can_sched H --------------+
143+
+------------+ H H |
144+
H H |
145+
+---------------> H H <-------------+
146+
| #===================#
147+
| |
148+
schedule_exit | schedule_entry
149+
| v
150+
| +-------------------+ irq_enable
151+
| | scheduling | <---------------+
152+
| +-------------------+ |
153+
| | |
154+
| | irq_disable +--------+ irq_entry
155+
| v | | --------+
156+
| +-------------------+ irq_entry | in_irq | |
157+
| | | -----------> | | <-------+
158+
| | disable_to_switch | +--------+
159+
| | | --+
160+
| +-------------------+ |
161+
| | |
162+
| | sched_switch |
163+
| v |
164+
| +-------------------+ |
165+
| | switching | | irq_enable
166+
| +-------------------+ |
167+
| | |
168+
| | irq_enable |
169+
| v |
170+
| +-------------------+ |
171+
+-- | enable_to_exit | <-+
172+
+-------------------+
173+
^ | irq_disable
174+
| | irq_entry
175+
+---------------+ irq_enable
167176

168177
References
169178
----------

kernel/trace/rv/Kconfig

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,12 +50,11 @@ source "kernel/trace/rv/monitors/wip/Kconfig"
5050
source "kernel/trace/rv/monitors/wwnr/Kconfig"
5151

5252
source "kernel/trace/rv/monitors/sched/Kconfig"
53-
source "kernel/trace/rv/monitors/tss/Kconfig"
5453
source "kernel/trace/rv/monitors/sco/Kconfig"
5554
source "kernel/trace/rv/monitors/snroc/Kconfig"
5655
source "kernel/trace/rv/monitors/scpd/Kconfig"
5756
source "kernel/trace/rv/monitors/snep/Kconfig"
58-
source "kernel/trace/rv/monitors/sncid/Kconfig"
57+
source "kernel/trace/rv/monitors/sts/Kconfig"
5958
# Add new sched monitors here
6059

6160
source "kernel/trace/rv/monitors/rtapp/Kconfig"

kernel/trace/rv/Makefile

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,14 @@ obj-$(CONFIG_RV) += rv.o
66
obj-$(CONFIG_RV_MON_WIP) += monitors/wip/wip.o
77
obj-$(CONFIG_RV_MON_WWNR) += monitors/wwnr/wwnr.o
88
obj-$(CONFIG_RV_MON_SCHED) += monitors/sched/sched.o
9-
obj-$(CONFIG_RV_MON_TSS) += monitors/tss/tss.o
109
obj-$(CONFIG_RV_MON_SCO) += monitors/sco/sco.o
1110
obj-$(CONFIG_RV_MON_SNROC) += monitors/snroc/snroc.o
1211
obj-$(CONFIG_RV_MON_SCPD) += monitors/scpd/scpd.o
1312
obj-$(CONFIG_RV_MON_SNEP) += monitors/snep/snep.o
14-
obj-$(CONFIG_RV_MON_SNCID) += monitors/sncid/sncid.o
1513
obj-$(CONFIG_RV_MON_RTAPP) += monitors/rtapp/rtapp.o
1614
obj-$(CONFIG_RV_MON_PAGEFAULT) += monitors/pagefault/pagefault.o
1715
obj-$(CONFIG_RV_MON_SLEEP) += monitors/sleep/sleep.o
16+
obj-$(CONFIG_RV_MON_STS) += monitors/sts/sts.o
1817
# Add new monitors here
1918
obj-$(CONFIG_RV_REACTORS) += rv_reactors.o
2019
obj-$(CONFIG_RV_REACT_PRINTK) += reactor_printk.o

kernel/trace/rv/monitors/sncid/Kconfig

Lines changed: 0 additions & 15 deletions
This file was deleted.

kernel/trace/rv/monitors/sncid/sncid.c

Lines changed: 0 additions & 95 deletions
This file was deleted.

kernel/trace/rv/monitors/sncid/sncid.h

Lines changed: 0 additions & 49 deletions
This file was deleted.

kernel/trace/rv/monitors/sncid/sncid_trace.h

Lines changed: 0 additions & 15 deletions
This file was deleted.

kernel/trace/rv/monitors/sts/Kconfig

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# SPDX-License-Identifier: GPL-2.0-only
2+
#
3+
config RV_MON_STS
4+
depends on RV
5+
depends on TRACE_IRQFLAGS
6+
depends on RV_MON_SCHED
7+
default y
8+
select DA_MON_EVENTS_IMPLICIT
9+
bool "sts monitor"
10+
help
11+
Monitor to ensure relationships between scheduler and task switches
12+
* the scheduler is called and returns with interrupts disabled
13+
* each call to the scheduler has up to one switch
14+
* switches only happen inside the scheduler
15+
* each call to the scheduler disables interrupts to switch
16+
This monitor is part of the sched monitors collection.
17+
18+
For further information, see:
19+
Documentation/trace/rv/monitor_sched.rst

0 commit comments

Comments
 (0)