lkml.org 
[lkml]   [2020]   [Dec]   [1]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
From
Date
SubjectRe: [PATCH 3/6] sched: make struct sched_statistics independent of fair sched class
On Tue, Dec 1, 2020 at 8:41 PM Mel Gorman <mgorman@suse.de> wrote:
>
> On Tue, Dec 01, 2020 at 07:54:13PM +0800, Yafang Shao wrote:
> > If we want to use schedstats facility, we should move out of
> > struct sched_statistics from the struct sched_entity or add it into other
> > sctructs of sched entity as well. Obviously the latter one is bad because
> > that requires more spaces. So we should move it into a common struct which
> > can be used by all sched classes.
> >
> > The struct sched_statistics is the schedular statistics of a task_struct
> > or a task_group. So we can move it into struct task_struct and
> > struct task_group to achieve the goal.
> >
> > Below is the detailed explaination of the change in the structs.
> >
> > - Before this patch
> >
> > struct task_struct { |-> struct sched_entity {
> > ... | ...
> > struct sched_entity *se; ---| struct sched_statistics statistics;
> > struct sched_rt_entity *rt; ...
> > ... ...
> > }; };
> >
> > struct task_group { |--> se[0]->statistics : schedstats of CPU0
> > ... |
> > #ifdef CONFIG_FAIR_GROUP_SCHED |
> > struct sched_entity **se; --|--> se[1]->statistics : schedstats of CPU1
> > |
> > #endif |
> > |--> se[N]->statistics : schedstats of CPUn
> >
> > #ifdef CONFIG_FAIR_GROUP_SCHED
> > struct sched_rt_entity **rt_se; (N/A)
> > #endif
> > ...
> > };
> >
> > The '**se' in task_group is allocated in the fair sched class, which is
> > hard to be reused by other sched class.
> >
> > - After this patch
> >
> > 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
> > ...
> > };
> >
> > After the patch it is clearly that both of se or rt_se can easily get the
> > sched_statistics by a task_struct or a task_group.
> >
> > Signed-off-by: Yafang Shao <laoar.shao@gmail.com>
>
> I didn't see anything wrong as such, it's mostly a mechanical
> conversion. The one slight caveat is the potential change in cache
> location for the statistics but it's not necessarily negative. The stats
> potentially move to a different cache line but it's less obvious whether
> that even matters given the location is very similar.
>
> There is increased overhead now when schedstats are *enabled* because
> _schedstat_from_sched_entity() has to be called but it appears that it is
> protected by a schedstat_enabled() check. So ok, schedstats when enabled
> are now a bit more expensive but they were expensive in the first place
> so does it matter?
>
> I'd have been happied if there was a comparison with schedstats enabled
> just in case the overhead is too high but it could also do with a second
> set of eyeballs.
>

Sure, I will do the comparison. Thanks for the review again.


> It's somewhat tentative but
>
> Acked-by: Mel Gorman <mgorman@suse.de>
>
> --
> Mel Gorman
> SUSE Labs



--
Thanks
Yafang

\
 
 \ /
  Last update: 2020-12-02 03:09    [W:0.108 / U:3.416 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site