Re: [PATCH v3 0/7] sched: support schedstats for RT sched class

From
Yafang Shao <hidden>
Date
2021-08-31 12:58:34
Also in
lkml
Reply to
Peter Zijlstra, 2021-08-31
On Tue, Aug 31, 2021 at 6:08 PM Peter Zijlstra [off-list ref] wrote:
On Tue, Aug 24, 2021 at 11:29:39AM +0000, Yafang Shao wrote:
quoted
Hi Ingo, Peter,

This feature is useful to trace the sched details of RT tasks. Hopefully
you can give some feedback on it.

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.
Do you really want schedstats or do you want the tracepoints?
I really want the schedstats, which is very helpful to help us profile
thread-level latency.
The tracepoints is a bonus.
In general
I really want to cut back on the built-in statistics crud we carry,
Pls. don't.
There are really use cases of statistics.
Our use case as follows,

Userspace Code Scope         Profiler

{
    user_func_abc();   <----      uprobe_begin() get the start statistics
    ...
    user_func_xyz();   <----       uprobe_end()  get the end statistics
}

Then with this profiler we can easily get what happened in this scope
and why its latency was great:
    scope_latency = Wait + Sleep + Blocked [1]  + Run (stime + utime)

If there is no schedstats, we have to trace the heavy sched::sched_switch.

[1]. With patch #5 and don't include sum_block_runtime in sum_sleep_runtime
there's too much and it seems to keep growing forever :-(

(as is the case here, you're extending it as well)

That said; making schedstats cover the other classes can be seen as
fixing an inconsistency, but then you forgot deadline.
There's no deadline task on our server, so I didn't support it for deadline.
But with this patchset, it is very easy to extend it to deadline and
any other sched classes.

quoted
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
    ...
};
Yeah, this seems to give a terrible mess, let me see if I can come up
with anything less horrible.


-- 
Thanks
Yafang
Thread (20 messages) 20 messages, 2 authors, last reply 2021-08-31
Keyboard shortcuts
hback out one level
jnext message in thread / next series-diff position
kprevious message in thread / previous series-diff position
ldrill in
Escclose help / fold thread tree
?toggle this help