From: Lei Wen <leiwen@marvell.com>
To: Paul Turner <pjt@google.com>, Alex Shi <alex.shi@intel.com>,
Peter Zijlstra <peterz@infradead.org>,
Ingo Molnar <mingo@elte.hu>, <mingo@redhat.com>,
Kamalesh Babulal <kamalesh@linux.vnet.ibm.com>,
Lei Wen <leiwen@marvell.com>, <linux-kernel@vger.kernel.org>
Subject: [V2 1/2] sched: add trace events for task and rq usage tracking
Date: Mon, 1 Jul 2013 20:33:21 +0800 [thread overview]
Message-ID: <1372682002-15373-2-git-send-email-leiwen@marvell.com> (raw)
In-Reply-To: <1372682002-15373-1-git-send-email-leiwen@marvell.com>
Since we could track task in the entity level now, we may want to
investigate tasks' running status by recording the trace info, so that
could make some tuning if needed.
Signed-off-by: Lei Wen <leiwen@marvell.com>
---
include/trace/events/sched.h | 57 ++++++++++++++++++++++++++++++++++++++++++
kernel/sched/fair.c | 29 +++++++++++++++++++--
2 files changed, 84 insertions(+), 2 deletions(-)
diff --git a/include/trace/events/sched.h b/include/trace/events/sched.h
index e5586ca..effe047 100644
--- a/include/trace/events/sched.h
+++ b/include/trace/events/sched.h
@@ -430,6 +430,63 @@ TRACE_EVENT(sched_pi_setprio,
__entry->oldprio, __entry->newprio)
);
+TRACE_EVENT(sched_task_weighted_load,
+
+ TP_PROTO(struct task_struct *tsk, unsigned long load, unsigned long weight),
+
+ TP_ARGS(tsk, load, weight),
+
+ TP_STRUCT__entry(
+ __field(pid_t, pid)
+ __field(int, cpu)
+ __field(unsigned long, load)
+ __field(unsigned long, weight)
+ ),
+
+ TP_fast_assign(
+ __entry->pid = tsk->pid;
+ __entry->cpu = task_thread_info(tsk)->cpu;
+ __entry->load = load;
+ __entry->weight= weight;
+ ),
+
+ TP_printk("cpu=%d pid=%d load=%lu weight=%lu",
+ __entry->cpu, __entry->pid,
+ __entry->load, __entry->weight)
+);
+
+DECLARE_EVENT_CLASS(sched_cfs_rq_load_contri_template,
+
+ TP_PROTO(int cpu, unsigned long load, unsigned long total),
+
+ TP_ARGS(cpu, load, total),
+
+ TP_STRUCT__entry(
+ __field(int, cpu)
+ __field(unsigned long, load)
+ __field(unsigned long, total)
+ ),
+
+ TP_fast_assign(
+ __entry->cpu = cpu;
+ __entry->load = load;
+ __entry->total = total;
+ ),
+
+ TP_printk("cpu=%d avg=%lu total=%lu",
+ __entry->cpu,
+ __entry->load,
+ __entry->total)
+ );
+
+DEFINE_EVENT(sched_cfs_rq_load_contri_template, sched_cfs_rq_runnable_load,
+ TP_PROTO(int cpu, unsigned long load, unsigned long total),
+ TP_ARGS(cpu, load, total));
+
+DEFINE_EVENT(sched_cfs_rq_load_contri_template, sched_cfs_rq_blocked_load,
+ TP_PROTO(int cpu, unsigned long load, unsigned long total),
+ TP_ARGS(cpu, load, total));
+
#endif /* _TRACE_SCHED_H */
/* This part must be outside protection */
diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
index f77f9c5..07bd74c 100644
--- a/kernel/sched/fair.c
+++ b/kernel/sched/fair.c
@@ -1346,6 +1346,7 @@ static inline u64 __synchronize_entity_decay(struct sched_entity *se)
return 0;
se->avg.load_avg_contrib = decay_load(se->avg.load_avg_contrib, decays);
+ trace_sched_task_weighted_load(task_of(se), se->avg.load_avg_contrib, se->load.weight);
se->avg.decay_count = 0;
return decays;
@@ -1445,6 +1446,7 @@ static inline void __update_task_entity_contrib(struct sched_entity *se)
contrib = se->avg.runnable_avg_sum * scale_load_down(se->load.weight);
contrib /= (se->avg.runnable_avg_period + 1);
se->avg.load_avg_contrib = scale_load(contrib);
+ trace_sched_task_weighted_load(task_of(se), se->avg.load_avg_contrib, se->load.weight);
}
/* Compute the current contribution to load_avg by se, return any delta */
@@ -1498,10 +1500,16 @@ static inline void update_entity_load_avg(struct sched_entity *se,
if (!update_cfs_rq)
return;
- if (se->on_rq)
+ if (se->on_rq) {
cfs_rq->runnable_load_avg += contrib_delta;
- else
+ trace_sched_cfs_rq_runnable_load(cpu_of(rq_of(cfs_rq)),
+ cfs_rq->runnable_load_avg, cfs_rq->load.weight);
+ } else {
subtract_blocked_load_contrib(cfs_rq, -contrib_delta);
+ trace_sched_cfs_rq_blocked_load(cpu_of(rq_of(cfs_rq)),
+ cfs_rq->blocked_load_avg,
+ cfs_rq->blocked_load_avg + cfs_rq->runnable_load_avg);
+ }
}
/*
@@ -1531,6 +1539,9 @@ static void update_cfs_rq_blocked_load(struct cfs_rq *cfs_rq, int force_update)
}
__update_cfs_rq_tg_load_contrib(cfs_rq, force_update);
+ trace_sched_cfs_rq_blocked_load(cpu_of(rq_of(cfs_rq)),
+ cfs_rq->blocked_load_avg,
+ cfs_rq->blocked_load_avg + cfs_rq->runnable_load_avg);
}
static inline void update_rq_runnable_avg(struct rq *rq, int runnable)
@@ -1584,10 +1595,15 @@ static inline void enqueue_entity_load_avg(struct cfs_rq *cfs_rq,
/* migrated tasks did not contribute to our blocked load */
if (wakeup) {
subtract_blocked_load_contrib(cfs_rq, se->avg.load_avg_contrib);
+ trace_sched_cfs_rq_blocked_load(cpu_of(rq_of(cfs_rq)),
+ cfs_rq->blocked_load_avg,
+ cfs_rq->blocked_load_avg + cfs_rq->runnable_load_avg);
update_entity_load_avg(se, 0);
}
cfs_rq->runnable_load_avg += se->avg.load_avg_contrib;
+ trace_sched_cfs_rq_runnable_load(cpu_of(rq_of(cfs_rq)),
+ cfs_rq->runnable_load_avg, cfs_rq->load.weight);
/* we force update consideration on load-balancer moves */
update_cfs_rq_blocked_load(cfs_rq, !wakeup);
}
@@ -1608,6 +1624,9 @@ static inline void dequeue_entity_load_avg(struct cfs_rq *cfs_rq,
cfs_rq->runnable_load_avg -= se->avg.load_avg_contrib;
if (sleep) {
cfs_rq->blocked_load_avg += se->avg.load_avg_contrib;
+ trace_sched_cfs_rq_blocked_load(cpu_of(rq_of(cfs_rq)),
+ cfs_rq->blocked_load_avg,
+ cfs_rq->blocked_load_avg + cfs_rq->runnable_load_avg);
se->avg.decay_count = atomic64_read(&cfs_rq->decay_counter);
} /* migrations, e.g. sleep=0 leave decay_count == 0 */
}
@@ -5894,6 +5913,9 @@ static void switched_from_fair(struct rq *rq, struct task_struct *p)
__synchronize_entity_decay(&p->se);
subtract_blocked_load_contrib(cfs_rq,
p->se.avg.load_avg_contrib);
+ trace_sched_cfs_rq_blocked_load(cpu_of(rq_of(cfs_rq)),
+ cfs_rq->blocked_load_avg,
+ cfs_rq->blocked_load_avg + cfs_rq->runnable_load_avg);
}
#endif
}
@@ -5994,6 +6016,9 @@ static void task_move_group_fair(struct task_struct *p, int on_rq)
*/
p->se.avg.decay_count = atomic64_read(&cfs_rq->decay_counter);
cfs_rq->blocked_load_avg += p->se.avg.load_avg_contrib;
+ trace_sched_cfs_rq_blocked_load(cpu_of(rq_of(cfs_rq)),
+ cfs_rq->blocked_load_avg,
+ cfs_rq->blocked_load_avg + cfs_rq->runnable_load_avg);
#endif
}
}
--
1.7.10.4
next prev parent reply other threads:[~2013-07-01 12:34 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-07-01 7:10 [PATCH 0/2] sched: add trace event for per-entity tracking Lei Wen
2013-07-01 7:10 ` [PATCH 1/2] sched: add trace events for task and rq usage tracking Lei Wen
2013-07-01 9:43 ` Kamalesh Babulal
2013-07-01 12:18 ` Lei Wen
2013-07-01 7:10 ` [PATCH 2/2] sched: update cfs_rq weight earlier in enqueue_entity Lei Wen
2013-07-01 8:06 ` [PATCH 0/2] sched: add trace event for per-entity tracking Alex Shi
2013-07-01 8:49 ` Lei Wen
2013-07-01 12:33 ` [PATCH V2 " Lei Wen
2013-07-01 12:33 ` Lei Wen [this message]
2013-07-01 12:44 ` [V2 1/2] sched: add trace events for task and rq usage tracking Peter Zijlstra
2013-07-01 13:25 ` Lei Wen
2013-07-01 12:33 ` [V2 2/2] sched: update cfs_rq weight earlier in enqueue_entity Lei Wen
2013-07-01 14:07 ` Paul Turner
2013-07-02 2:52 ` Lei Wen
2013-07-02 12:15 ` [PATCH V3 0/2] sched: add trace event for per-entity tracking Lei Wen
2013-07-02 12:15 ` [V3 1/2] sched: add trace events for task and rq usage tracking Lei Wen
2013-07-03 12:46 ` Lei Wen
2013-07-02 12:15 ` [V3 2/2] sched: update cfs_rq weight earlier in enqueue_entity Lei Wen
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=1372682002-15373-2-git-send-email-leiwen@marvell.com \
--to=leiwen@marvell.com \
--cc=alex.shi@intel.com \
--cc=kamalesh@linux.vnet.ibm.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@elte.hu \
--cc=mingo@redhat.com \
--cc=peterz@infradead.org \
--cc=pjt@google.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
Powered by JetHome