From: Tejun Heo <tj-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>
To: Glauber Costa <glommer-GEFAQzZX7r8dnm+yROfE0A@public.gmane.org>
Cc: Peter Zijlstra
<a.p.zijlstra-/NLkJaSkS4VmR6Xm/wNWPw@public.gmane.org>,
Paul Turner <pjt-hpIqsD4AKlfQT0dZR+AlfA@public.gmane.org>,
linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
cgroups-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
Frederic Weisbecker
<fweisbec-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>,
devel-GEFAQzZX7r8dnm+yROfE0A@public.gmane.org
Subject: Re: [PATCH v7 09/11] sched: record per-cgroup number of context switches
Date: Thu, 6 Jun 2013 17:04:52 -0700 [thread overview]
Message-ID: <20130607000452.GS5045@htj.dyndns.org> (raw)
In-Reply-To: <1369825402-31046-10-git-send-email-glommer-GEFAQzZX7r8dnm+yROfE0A@public.gmane.org>
Hello,
Maybe we should break off addition of switch stats to a separate set?
They are two separate things.
On Wed, May 29, 2013 at 03:03:20PM +0400, Glauber Costa wrote:
> @@ -3642,6 +3642,8 @@ pick_next_task_fair(struct rq *rq, struct task_struct *prev)
> prev->sched_class->put_prev_task(rq, prev);
>
> do {
> + if (likely(prev))
> + cfs_rq->nr_switches++;
> se = pick_next_entity(cfs_rq);
> set_next_entity(cfs_rq, se);
> cfs_rq = group_cfs_rq(se);
> @@ -3651,6 +3653,22 @@ pick_next_task_fair(struct rq *rq, struct task_struct *prev)
> if (hrtick_enabled(rq))
> hrtick_start_fair(rq, p);
>
> + /*
> + * This condition is extremely unlikely, and most of the time will just
> + * consist of this unlikely branch, which is extremely cheap. But we
> + * still need to have it, because when we first loop through cfs_rq's,
> + * we can't possibly know which task we will pick. The call to
> + * set_next_entity above is not meant to mess up the tree in this case,
> + * so this should give us the same chain, in the same order.
> + */
> + if (unlikely(p == prev)) {
> + se = &p->se;
> + for_each_sched_entity(se) {
> + cfs_rq = cfs_rq_of(se);
> + cfs_rq->nr_switches--;
> + }
> + }
> +
This concern may be fringe but the above breaks the monotonically
increasing property of the stat. Depending on the timing, a very
unlucky consumer of the stat may see the counter going backward which
can lead to nasty things. I'm not sure whether the fact that it'd be
very difficult to trigger is a pro or con.
Thanks.
--
tejun
next prev parent reply other threads:[~2013-06-07 0:04 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-05-29 11:03 [PATCH v7 00/11] per-cgroup cpu-stat Glauber Costa
2013-05-29 11:03 ` [PATCH v7 04/11] sched: adjust exec_clock to use it as cpu usage metric Glauber Costa
[not found] ` <1369825402-31046-5-git-send-email-glommer-GEFAQzZX7r8dnm+yROfE0A@public.gmane.org>
2013-06-06 23:00 ` Tejun Heo
2013-05-29 11:03 ` [PATCH v7 09/11] sched: record per-cgroup number of context switches Glauber Costa
[not found] ` <1369825402-31046-10-git-send-email-glommer-GEFAQzZX7r8dnm+yROfE0A@public.gmane.org>
2013-06-07 0:04 ` Tejun Heo [this message]
[not found] ` <1369825402-31046-1-git-send-email-glommer-GEFAQzZX7r8dnm+yROfE0A@public.gmane.org>
2013-05-29 11:03 ` [PATCH v7 01/11] don't call cpuacct_charge in stop_task.c Glauber Costa
2013-05-29 11:03 ` [PATCH v7 02/11] cgroup: implement CFTYPE_NO_PREFIX Glauber Costa
2013-05-29 11:03 ` [PATCH v7 03/11] cgroup, sched: let cpu serve the same files as cpuacct Glauber Costa
2013-05-29 11:03 ` [PATCH v7 05/11] cpuacct: don't actually do anything Glauber Costa
[not found] ` <1369825402-31046-6-git-send-email-glommer-GEFAQzZX7r8dnm+yROfE0A@public.gmane.org>
2013-06-06 23:16 ` Tejun Heo
2013-05-29 11:03 ` [PATCH v7 06/11] sched: document the cpu cgroup Glauber Costa
2013-06-06 23:28 ` Tejun Heo
2013-05-29 11:03 ` [PATCH v7 07/11] sched: account guest time per-cgroup as well Glauber Costa
[not found] ` <1369825402-31046-8-git-send-email-glommer-GEFAQzZX7r8dnm+yROfE0A@public.gmane.org>
2013-06-06 23:48 ` Tejun Heo
2013-05-29 11:03 ` [PATCH v7 08/11] sched: Push put_prev_task() into pick_next_task() Glauber Costa
[not found] ` <1369825402-31046-9-git-send-email-glommer-GEFAQzZX7r8dnm+yROfE0A@public.gmane.org>
2013-06-06 23:56 ` Tejun Heo
2013-05-29 11:03 ` [PATCH v7 10/11] sched: change nr_context_switches calculation Glauber Costa
2013-05-29 11:03 ` [PATCH v7 11/11] sched: introduce cgroup file stat_percpu Glauber Costa
2013-06-06 1:49 ` [PATCH v7 00/11] per-cgroup cpu-stat Tejun Heo
[not found] ` <20130606014929.GS10693-9pTldWuhBndy/B6EtB590w@public.gmane.org>
2013-06-06 7:58 ` Glauber Costa
2013-06-07 0:06 ` Tejun Heo
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=20130607000452.GS5045@htj.dyndns.org \
--to=tj-dgejt+ai2ygdnm+yrofe0a@public.gmane.org \
--cc=a.p.zijlstra-/NLkJaSkS4VmR6Xm/wNWPw@public.gmane.org \
--cc=cgroups-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=devel-GEFAQzZX7r8dnm+yROfE0A@public.gmane.org \
--cc=fweisbec-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org \
--cc=glommer-GEFAQzZX7r8dnm+yROfE0A@public.gmane.org \
--cc=linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=pjt-hpIqsD4AKlfQT0dZR+AlfA@public.gmane.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).