Skip to content

Commit 9c602ad

Browse files
HuangShijie2024Peter Zijlstra
authored andcommitted
sched/deadline: Fix schedstats vs deadline servers
In dl_server_start(), when schedstats is enabled, the following happens: dl_server_start() dl_se->dl_server = 1; enqueue_dl_entity() update_stats_enqueue_dl() __schedstats_from_dl_se() dl_task_of() BUG_ON(dl_server(dl_se)); Since only tasks have schedstats and internal entries do not, avoid trying to update stats in this case. Fixes: 63ba842 ("sched/deadline: Introduce deadline servers") Signed-off-by: Huang Shijie <[email protected]> Signed-off-by: Peter Zijlstra (Intel) <[email protected]> Acked-by: Juri Lelli <[email protected]> Link: https://lkml.kernel.org/r/[email protected]
1 parent aef6987 commit 9c602ad

File tree

1 file changed

+16
-22
lines changed

1 file changed

+16
-22
lines changed

kernel/sched/deadline.c

Lines changed: 16 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1896,46 +1896,40 @@ static inline bool __dl_less(struct rb_node *a, const struct rb_node *b)
18961896
return dl_time_before(__node_2_dle(a)->deadline, __node_2_dle(b)->deadline);
18971897
}
18981898

1899-
static inline struct sched_statistics *
1899+
static __always_inline struct sched_statistics *
19001900
__schedstats_from_dl_se(struct sched_dl_entity *dl_se)
19011901
{
1902+
if (!schedstat_enabled())
1903+
return NULL;
1904+
1905+
if (dl_server(dl_se))
1906+
return NULL;
1907+
19021908
return &dl_task_of(dl_se)->stats;
19031909
}
19041910

19051911
static inline void
19061912
update_stats_wait_start_dl(struct dl_rq *dl_rq, struct sched_dl_entity *dl_se)
19071913
{
1908-
struct sched_statistics *stats;
1909-
1910-
if (!schedstat_enabled())
1911-
return;
1912-
1913-
stats = __schedstats_from_dl_se(dl_se);
1914-
__update_stats_wait_start(rq_of_dl_rq(dl_rq), dl_task_of(dl_se), stats);
1914+
struct sched_statistics *stats = __schedstats_from_dl_se(dl_se);
1915+
if (stats)
1916+
__update_stats_wait_start(rq_of_dl_rq(dl_rq), dl_task_of(dl_se), stats);
19151917
}
19161918

19171919
static inline void
19181920
update_stats_wait_end_dl(struct dl_rq *dl_rq, struct sched_dl_entity *dl_se)
19191921
{
1920-
struct sched_statistics *stats;
1921-
1922-
if (!schedstat_enabled())
1923-
return;
1924-
1925-
stats = __schedstats_from_dl_se(dl_se);
1926-
__update_stats_wait_end(rq_of_dl_rq(dl_rq), dl_task_of(dl_se), stats);
1922+
struct sched_statistics *stats = __schedstats_from_dl_se(dl_se);
1923+
if (stats)
1924+
__update_stats_wait_end(rq_of_dl_rq(dl_rq), dl_task_of(dl_se), stats);
19271925
}
19281926

19291927
static inline void
19301928
update_stats_enqueue_sleeper_dl(struct dl_rq *dl_rq, struct sched_dl_entity *dl_se)
19311929
{
1932-
struct sched_statistics *stats;
1933-
1934-
if (!schedstat_enabled())
1935-
return;
1936-
1937-
stats = __schedstats_from_dl_se(dl_se);
1938-
__update_stats_enqueue_sleeper(rq_of_dl_rq(dl_rq), dl_task_of(dl_se), stats);
1930+
struct sched_statistics *stats = __schedstats_from_dl_se(dl_se);
1931+
if (stats)
1932+
__update_stats_enqueue_sleeper(rq_of_dl_rq(dl_rq), dl_task_of(dl_se), stats);
19391933
}
19401934

19411935
static inline void

0 commit comments

Comments
 (0)