Skip to content

sched: support schedstats for RT sched class

Yafang Shao linux-rt-users lkml 2 versions – In review

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v2 Latest6 patches 1 replyIn review
  2. v16 patches 6 repliesSuperseded

Changes in v2 from the cover letter

- Fix the build failure reported by kernel test robot.
- Add the performance data with 'perf bench sched pipe', suggested by Mel.
- Make the struct sched_statistics cacheline aligned.
- Introduce task block time in schedstats

Patches in v2 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/6sched, fair: use __schedstat_set() in set_next_entity()kernel/sched/fair.c+1 -10 replies
2/6sched: make struct sched_statistics independent of fair sched classinclude/linux/sched.h kernel/sched/core.c kernel/sched/deadline.c +6 more+210 -960 replies
3/6sched: make schedstats helpers independent of fair sched classkernel/sched/fair.c kernel/sched/stats.c kernel/sched/stats.h+156 -1140 replies
4/6sched: introduce task block time in schedstatsinclude/linux/sched.h kernel/sched/debug.c kernel/sched/stats.c+7 -20 replies
5/6sched, rt: support sched_stat_runtime tracepoint for RT sched classkernel/sched/rt.c+2 -00 replies
6/6sched, rt: support schedstats for RT sched classkernel/sched/rt.c+137 -00 replies

Reviews trailers per patch

3 of 6 patches have a Reviewed-by or Acked-by.

PatchMel Gorman
1/6A-b
2/6A-b
3/6A-b
4/6
5/6
6/6

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.

Read the v2 thread

Cover letter [PATCH v2 0/6] sched: support schedstats for RT sched class

We want to measure the latency of RT tasks in our production environment with schedstats facility, but currently schedstats is only supported for fair sched class. In order to support if for other sched classes, we should make it independent of fair sched class. The struct sched_statistics is the schedular statistics of a task_struct or a task_group, both of which are independent of sched class. So we can move struct sched_statistics into struct task_struct and struct task_group to achieve the goal.

After the patchset, schestats are orgnized as follows,

struct task_struct {
    ...
    struct sched_statistics statistics;
    ...
    struct sched_entity *se;
    struct sched_rt_entity *rt;
    ...
};
struct task_group {                    |---> stats[0] : of CPU0
    ...                                |
    struct sched_statistics **stats; --|---> stats[1] : of CPU1
    ...                                |
                                       |---> stats[n] : of CPUn
 #ifdef CONFIG_FAIR_GROUP_SCHED
    struct sched_entity **se;
 #endif
 #ifdef CONFIG_RT_GROUP_SCHED
    struct sched_rt_entity  **rt_se;
 #endif
    ...
};

The sched_statistics members may be frequently modified when schedstats is enabled, in order to avoid impacting on random data which may in the same cacheline with them, the struct sched_statistics is defined as cacheline aligned.

Then we can use schedstats to trace RT tasks as well, for example,
Interface File

 task schedstats :  /proc/[pid]/sched
 group schedstats:  /proc/sched_debug
 tracepoints     :  sched:sched_stat_{runtime, wait, sleep, iowait, blocked}

As PATCH #2 and #3 changes the core struct in the scheduler, so I did 'perf bench sched pipe' to measure the sched performance before and after the change, suggested by Mel. Below is the data, which are all in usecs/op.

                             Before             After
  kernel.sched_schedstats=0  6.0~6.1            6.0~6.1
  kernel.sched_schedstats=1  6.2~6.4            6.2~6.4

No obvious difference after the change.

Changes since v1:
- Fix the build failure reported by kernel test robot.
- Add the performance data with 'perf bench sched pipe', suggested by Mel.
- Make the struct sched_statistics cacheline aligned.
- Introduce task block time in schedstats

Changes since RFC:
- improvement of schedstats helpers, per Mel.
- make struct schedstats independent of fair sched class

Yafang Shao (6):
sched, fair: use __schedstat_set() in set_next_entity()
sched: make struct sched_statistics independent of fair sched class
sched: make schedstats helpers independent of fair sched class
sched: introduce task block time in schedstats
sched, rt: support sched_stat_runtime tracepoint for RT sched class sched, rt: support schedstats for RT sched class

 include/linux/sched.h    |   7 +-
 kernel/sched/core.c      |  24 +++--
 kernel/sched/deadline.c  |   4 +-
 kernel/sched/debug.c     |  90 +++++++++--------
 kernel/sched/fair.c      | 210 ++++++++++++++++-----------------------
 kernel/sched/rt.c        | 143 +++++++++++++++++++++++++-
 kernel/sched/sched.h     |   3 +
 kernel/sched/stats.c     | 104 +++++++++++++++++++
 kernel/sched/stats.h     |  89 +++++++++++++++++
 kernel/sched/stop_task.c |   4 +-
 10 files changed, 489 insertions(+), 189 deletions(-)
Signature · 1 line
2.18.2