From: Abel Wu <wuyun.abel@bytedance.com>
To: Peter Zijlstra <peterz@infradead.org>,
Ingo Molnar <mingo@kernel.org>,
Vincent Guittot <vincent.guittot@linaro.org>,
Dietmar Eggemann <dietmar.eggemann@arm.com>,
Valentin Schneider <valentin.schneider@arm.com>
Cc: Barry Song <21cnbao@gmail.com>,
Benjamin Segall <bsegall@google.com>,
Chen Yu <yu.c.chen@intel.com>,
Daniel Jordan <daniel.m.jordan@oracle.com>,
"Gautham R . Shenoy" <gautham.shenoy@amd.com>,
Joel Fernandes <joel@joelfernandes.org>,
K Prateek Nayak <kprateek.nayak@amd.com>,
Mike Galbraith <efault@gmx.de>, Qais Yousef <qyousef@layalina.io>,
Tim Chen <tim.c.chen@linux.intel.com>,
Yicong Yang <yangyicong@huawei.com>,
Youssef Esmat <youssefesmat@chromium.org>,
linux-kernel@vger.kernel.org, Abel Wu <wuyun.abel@bytedance.com>
Subject: [PATCH v2 4/4] sched/stats: Add statistics for pick_eevdf()
Date: Wed, 15 Nov 2023 11:36:47 +0800 [thread overview]
Message-ID: <20231115033647.80785-5-wuyun.abel@bytedance.com> (raw)
In-Reply-To: <20231115033647.80785-1-wuyun.abel@bytedance.com>
For statistical purpose only, not intended to upstream.
Signed-off-by: Abel Wu <wuyun.abel@bytedance.com>
---
kernel/sched/fair.c | 12 ++++++++++--
kernel/sched/sched.h | 5 +++++
kernel/sched/stats.c | 6 ++++--
3 files changed, 19 insertions(+), 4 deletions(-)
diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
index 4197258b76ab..94d9318ac484 100644
--- a/kernel/sched/fair.c
+++ b/kernel/sched/fair.c
@@ -881,13 +881,16 @@ static struct sched_entity *pick_eevdf(struct cfs_rq *cfs_rq)
struct sched_entity *se = __pick_first_entity(cfs_rq);
struct sched_entity *curr = cfs_rq->curr;
struct sched_entity *best = NULL;
+ struct rq *rq = rq_of(cfs_rq);
/*
* We can safely skip eligibility check if there is only one entity
* in this cfs_rq, saving some cycles.
*/
- if (cfs_rq->nr_running == 1)
+ if (cfs_rq->nr_running == 1) {
+ schedstat_inc(rq->pick_direct);
return curr && curr->on_rq ? curr : se;
+ }
if (curr && (!curr->on_rq || !entity_eligible(cfs_rq, curr)))
curr = NULL;
@@ -896,15 +899,20 @@ static struct sched_entity *pick_eevdf(struct cfs_rq *cfs_rq)
* Once selected, run a task until it either becomes non-eligible or
* until it gets a new slice. See the HACK in set_next_entity().
*/
- if (sched_feat(RUN_TO_PARITY) && curr && curr->vlag == curr->deadline)
+ if (sched_feat(RUN_TO_PARITY) && curr && curr->vlag == curr->deadline) {
+ schedstat_inc(rq->pick_parity);
return curr;
+ }
/* Pick the leftmost entity if it's eligible */
if (se && entity_eligible(cfs_rq, se)) {
+ schedstat_inc(rq->pick_fast);
best = se;
goto found;
}
+ schedstat_inc(rq->pick_slow);
+
/* Heap search for the EEVD entity */
while (node) {
struct rb_node *left = node->rb_left;
diff --git a/kernel/sched/sched.h b/kernel/sched/sched.h
index 539c7e763f15..85a79990a698 100644
--- a/kernel/sched/sched.h
+++ b/kernel/sched/sched.h
@@ -1105,6 +1105,11 @@ struct rq {
/* try_to_wake_up() stats */
unsigned int ttwu_count;
unsigned int ttwu_local;
+
+ unsigned int pick_direct;
+ unsigned int pick_parity;
+ unsigned int pick_fast;
+ unsigned int pick_slow;
#endif
#ifdef CONFIG_CPU_IDLE
diff --git a/kernel/sched/stats.c b/kernel/sched/stats.c
index 857f837f52cb..4b862c798989 100644
--- a/kernel/sched/stats.c
+++ b/kernel/sched/stats.c
@@ -133,12 +133,14 @@ static int show_schedstat(struct seq_file *seq, void *v)
/* runqueue-specific stats */
seq_printf(seq,
- "cpu%d %u 0 %u %u %u %u %llu %llu %lu",
+ "cpu%d %u 0 %u %u %u %u %llu %llu %lu %u %u %u %u",
cpu, rq->yld_count,
rq->sched_count, rq->sched_goidle,
rq->ttwu_count, rq->ttwu_local,
rq->rq_cpu_time,
- rq->rq_sched_info.run_delay, rq->rq_sched_info.pcount);
+ rq->rq_sched_info.run_delay, rq->rq_sched_info.pcount,
+ rq->pick_direct, rq->pick_parity,
+ rq->pick_fast, rq->pick_slow);
seq_printf(seq, "\n");
--
2.37.3
prev parent reply other threads:[~2023-11-15 3:37 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-11-15 3:36 [PATCH v2 0/4] sched/eevdf: Optimize reweight and pick Abel Wu
2023-11-15 3:36 ` [PATCH v2 1/4] sched/eevdf: Fix vruntime adjustment on reweight Abel Wu
2023-11-15 3:36 ` [PATCH v2 2/4] sched/eevdf: Sort the rbtree by virtual deadline Abel Wu
2023-11-15 9:04 ` [tip: sched/core] " tip-bot2 for Abel Wu
2023-11-15 3:36 ` [PATCH v2 3/4] sched/eevdf: O(1) fastpath for task selection Abel Wu
2023-11-15 9:04 ` [tip: sched/core] " tip-bot2 for Abel Wu
2023-11-15 3:36 ` Abel Wu [this message]
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=20231115033647.80785-5-wuyun.abel@bytedance.com \
--to=wuyun.abel@bytedance.com \
--cc=21cnbao@gmail.com \
--cc=bsegall@google.com \
--cc=daniel.m.jordan@oracle.com \
--cc=dietmar.eggemann@arm.com \
--cc=efault@gmx.de \
--cc=gautham.shenoy@amd.com \
--cc=joel@joelfernandes.org \
--cc=kprateek.nayak@amd.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@kernel.org \
--cc=peterz@infradead.org \
--cc=qyousef@layalina.io \
--cc=tim.c.chen@linux.intel.com \
--cc=valentin.schneider@arm.com \
--cc=vincent.guittot@linaro.org \
--cc=yangyicong@huawei.com \
--cc=youssefesmat@chromium.org \
--cc=yu.c.chen@intel.com \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®