From: Mel Gorman <mgorman@suse.de>
To: Yafang Shao <laoar.shao@gmail.com>
Cc: mingo@redhat.com, peterz@infradead.org, juri.lelli@redhat.com,
vincent.guittot@linaro.org, dietmar.eggemann@arm.com,
rostedt@goodmis.org, bsegall@google.com, bristot@redhat.com,
qianjun.kernel@gmail.com, linux-kernel@vger.kernel.org,
linux-rt-users@vger.kernel.org
Subject: Re: [PATCH 3/6] sched: make struct sched_statistics independent of fair sched class
Date: Tue, 1 Dec 2020 12:41:44 +0000 [thread overview]
Message-ID: <20201201124144.GT3306@suse.de> (raw)
In-Reply-To: <20201201115416.26515-4-laoar.shao@gmail.com>
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.
It's somewhat tentative but
Acked-by: Mel Gorman <mgorman@suse.de>
--
Mel Gorman
SUSE Labs
next prev parent reply other threads:[~2020-12-01 12:42 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-12-01 11:54 [PATCH 0/6] sched: support schedstats for RT sched class Yafang Shao
2020-12-01 11:54 ` [PATCH 1/6] sched: don't include stats.h in sched.h Yafang Shao
2020-12-01 11:54 ` [PATCH 2/6] sched, fair: use __schedstat_set() in set_next_entity() Yafang Shao
2020-12-01 12:28 ` Mel Gorman
2020-12-01 11:54 ` [PATCH 3/6] sched: make struct sched_statistics independent of fair sched class Yafang Shao
2020-12-01 12:41 ` Mel Gorman [this message]
2020-12-02 2:06 ` Yafang Shao
2020-12-01 13:19 ` kernel test robot
2020-12-01 13:30 ` kernel test robot
2020-12-01 11:54 ` [PATCH 4/6] sched: make schedstats helpers " Yafang Shao
2020-12-01 12:46 ` Mel Gorman
2020-12-02 2:04 ` Yafang Shao
2020-12-01 13:58 ` kernel test robot
2020-12-01 11:54 ` [PATCH 5/6] sched, rt: support sched_stat_runtime tracepoint for RT " Yafang Shao
2020-12-01 11:54 ` [PATCH 6/6] sched, rt: support schedstats " Yafang Shao
2020-12-01 13:59 ` kernel test robot
2020-12-01 14:13 ` kernel test robot
2020-12-01 14:30 ` kernel test robot
2020-12-02 2:07 ` Yafang Shao
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20201201124144.GT3306@suse.de \
--to=mgorman@suse.de \
--cc=bristot@redhat.com \
--cc=bsegall@google.com \
--cc=dietmar.eggemann@arm.com \
--cc=juri.lelli@redhat.com \
--cc=laoar.shao@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-rt-users@vger.kernel.org \
--cc=mingo@redhat.com \
--cc=peterz@infradead.org \
--cc=qianjun.kernel@gmail.com \
--cc=rostedt@goodmis.org \
--cc=vincent.guittot@linaro.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.