Skip to content

Commit 820725b

Browse files
committed
sched: Add deadline tracepoints
Add the following tracepoints: * sched_dl_throttle(dl_se, cpu, type): Called when a deadline entity is throttled * sched_dl_replenish(dl_se, cpu, type): Called when a deadline entity's runtime is replenished * sched_dl_update(dl_se, cpu, type): Called when a deadline entity updates without throttle or replenish * sched_dl_server_start(dl_se, cpu, type): Called when a deadline server is started * sched_dl_server_stop(dl_se, cpu, type): Called when a deadline server is stopped Those tracepoints can be useful to validate the deadline scheduler with RV and are not exported to tracefs. Reviewed-by: Phil Auld <pauld@redhat.com> Acked-by: Juri Lelli <juri.lelli@redhat.com> Link: https://lore.kernel.org/r/20260330111010.153663-11-gmonaco@redhat.com Signed-off-by: Gabriele Monaco <gmonaco@redhat.com>
1 parent da282bf commit 820725b

3 files changed

Lines changed: 54 additions & 0 deletions

File tree

include/trace/events/sched.h

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -896,6 +896,32 @@ DECLARE_TRACE(sched_set_need_resched,
896896
TP_PROTO(struct task_struct *tsk, int cpu, int tif),
897897
TP_ARGS(tsk, cpu, tif));
898898

899+
#define DL_OTHER 0
900+
#define DL_TASK 1
901+
#define DL_SERVER_FAIR 2
902+
#define DL_SERVER_EXT 3
903+
904+
DECLARE_TRACE(sched_dl_throttle,
905+
TP_PROTO(struct sched_dl_entity *dl_se, int cpu, u8 type),
906+
TP_ARGS(dl_se, cpu, type));
907+
908+
DECLARE_TRACE(sched_dl_replenish,
909+
TP_PROTO(struct sched_dl_entity *dl_se, int cpu, u8 type),
910+
TP_ARGS(dl_se, cpu, type));
911+
912+
/* Call to update_curr_dl_se not involving throttle or replenish */
913+
DECLARE_TRACE(sched_dl_update,
914+
TP_PROTO(struct sched_dl_entity *dl_se, int cpu, u8 type),
915+
TP_ARGS(dl_se, cpu, type));
916+
917+
DECLARE_TRACE(sched_dl_server_start,
918+
TP_PROTO(struct sched_dl_entity *dl_se, int cpu, u8 type),
919+
TP_ARGS(dl_se, cpu, type));
920+
921+
DECLARE_TRACE(sched_dl_server_stop,
922+
TP_PROTO(struct sched_dl_entity *dl_se, int cpu, u8 type),
923+
TP_ARGS(dl_se, cpu, type));
924+
899925
#endif /* _TRACE_SCHED_H */
900926

901927
/* This part must be outside protection */

kernel/sched/core.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,11 @@ EXPORT_TRACEPOINT_SYMBOL_GPL(sched_compute_energy_tp);
122122
EXPORT_TRACEPOINT_SYMBOL_GPL(sched_entry_tp);
123123
EXPORT_TRACEPOINT_SYMBOL_GPL(sched_exit_tp);
124124
EXPORT_TRACEPOINT_SYMBOL_GPL(sched_set_need_resched_tp);
125+
EXPORT_TRACEPOINT_SYMBOL_GPL(sched_dl_throttle_tp);
126+
EXPORT_TRACEPOINT_SYMBOL_GPL(sched_dl_replenish_tp);
127+
EXPORT_TRACEPOINT_SYMBOL_GPL(sched_dl_update_tp);
128+
EXPORT_TRACEPOINT_SYMBOL_GPL(sched_dl_server_start_tp);
129+
EXPORT_TRACEPOINT_SYMBOL_GPL(sched_dl_server_stop_tp);
125130

126131
DEFINE_PER_CPU_SHARED_ALIGNED(struct rq, runqueues);
127132
DEFINE_PER_CPU(struct rnd_state, sched_rnd_state);

kernel/sched/deadline.c

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,19 @@ static inline bool is_dl_boosted(struct sched_dl_entity *dl_se)
115115
}
116116
#endif /* !CONFIG_RT_MUTEXES */
117117

118+
static inline u8 dl_get_type(struct sched_dl_entity *dl_se, struct rq *rq)
119+
{
120+
if (!dl_server(dl_se))
121+
return DL_TASK;
122+
if (dl_se == &rq->fair_server)
123+
return DL_SERVER_FAIR;
124+
#ifdef CONFIG_SCHED_CLASS_EXT
125+
if (dl_se == &rq->ext_server)
126+
return DL_SERVER_EXT;
127+
#endif
128+
return DL_OTHER;
129+
}
130+
118131
static inline struct dl_bw *dl_bw_of(int i)
119132
{
120133
RCU_LOCKDEP_WARN(!rcu_read_lock_sched_held(),
@@ -733,6 +746,7 @@ static inline void replenish_dl_new_period(struct sched_dl_entity *dl_se,
733746
dl_se->dl_throttled = 1;
734747
dl_se->dl_defer_armed = 1;
735748
}
749+
trace_sched_dl_replenish_tp(dl_se, cpu_of(rq), dl_get_type(dl_se, rq));
736750
}
737751

738752
/*
@@ -848,6 +862,8 @@ static void replenish_dl_entity(struct sched_dl_entity *dl_se)
848862
if (dl_se->dl_throttled)
849863
dl_se->dl_throttled = 0;
850864

865+
trace_sched_dl_replenish_tp(dl_se, cpu_of(rq), dl_get_type(dl_se, rq));
866+
851867
/*
852868
* If this is the replenishment of a deferred reservation,
853869
* clear the flag and return.
@@ -1345,6 +1361,7 @@ static inline void dl_check_constrained_dl(struct sched_dl_entity *dl_se)
13451361
dl_time_before(rq_clock(rq), dl_next_period(dl_se))) {
13461362
if (unlikely(is_dl_boosted(dl_se) || !start_dl_timer(dl_se)))
13471363
return;
1364+
trace_sched_dl_throttle_tp(dl_se, cpu_of(rq), dl_get_type(dl_se, rq));
13481365
dl_se->dl_throttled = 1;
13491366
if (dl_se->runtime > 0)
13501367
dl_se->runtime = 0;
@@ -1508,6 +1525,7 @@ static void update_curr_dl_se(struct rq *rq, struct sched_dl_entity *dl_se, s64
15081525

15091526
throttle:
15101527
if (dl_runtime_exceeded(dl_se) || dl_se->dl_yielded) {
1528+
trace_sched_dl_throttle_tp(dl_se, cpu_of(rq), dl_get_type(dl_se, rq));
15111529
dl_se->dl_throttled = 1;
15121530

15131531
/* If requested, inform the user about runtime overruns. */
@@ -1532,6 +1550,8 @@ static void update_curr_dl_se(struct rq *rq, struct sched_dl_entity *dl_se, s64
15321550

15331551
if (!is_leftmost(dl_se, &rq->dl))
15341552
resched_curr(rq);
1553+
} else {
1554+
trace_sched_dl_update_tp(dl_se, cpu_of(rq), dl_get_type(dl_se, rq));
15351555
}
15361556

15371557
/*
@@ -1810,6 +1830,7 @@ void dl_server_start(struct sched_dl_entity *dl_se)
18101830
if (WARN_ON_ONCE(!cpu_online(cpu_of(rq))))
18111831
return;
18121832

1833+
trace_sched_dl_server_start_tp(dl_se, cpu_of(rq), dl_get_type(dl_se, rq));
18131834
dl_se->dl_server_active = 1;
18141835
enqueue_dl_entity(dl_se, ENQUEUE_WAKEUP);
18151836
if (!dl_task(dl_se->rq->curr) || dl_entity_preempt(dl_se, &rq->curr->dl))
@@ -1821,6 +1842,8 @@ void dl_server_stop(struct sched_dl_entity *dl_se)
18211842
if (!dl_server(dl_se) || !dl_server_active(dl_se))
18221843
return;
18231844

1845+
trace_sched_dl_server_stop_tp(dl_se, cpu_of(dl_se->rq),
1846+
dl_get_type(dl_se, dl_se->rq));
18241847
dequeue_dl_entity(dl_se, DEQUEUE_SLEEP);
18251848
hrtimer_try_to_cancel(&dl_se->dl_timer);
18261849
dl_se->dl_defer_armed = 0;

0 commit comments

Comments
 (0)