From: Ingo Molnar <mingo@elte.hu>
To: Paul Mackerras <paulus@samba.org>
Cc: Jaswinder Singh Rajput <jaswinder@kernel.org>,
Thomas Gleixner <tglx@linutronix.de>,
linux-kernel@vger.kernel.org, Mike Galbraith <efault@gmx.de>
Subject: Re: [PATCH] Make context switch and migration software counters work again
Date: Fri, 13 Feb 2009 12:23:33 +0100 [thread overview]
Message-ID: <20090213112333.GE15679@elte.hu> (raw)
In-Reply-To: <18837.21802.429822.796289@cargo.ozlabs.ibm.com>
* Paul Mackerras <paulus@samba.org> wrote:
> Jaswinder Singh Rajput reported that commit 23a185ca8abbeef caused the
> context switch and migration software counters to report zero always.
> With that commit, the software counters only count events that occur
> between sched-in and sched-out for a task. This is necessary for the
> counter enable/disable prctls and ioctls to work. However, the
> context switch and migration counts are incremented after sched-out
> for one task and before sched-in for the next. Since the increment
> doesn't occur while a task is scheduled in (as far as the software
> counters are concerned) it doesn't count towards any counter.
>
> Thus the context switch and migration counters need to count events
> that occur at any time, provided the counter is enabled, not just
> those that occur while the task is scheduled in (from the perf_counter
> subsystem's point of view). The problem though is that the software
> counter code can't tell the difference between being enabled and being
> scheduled in, and between being disabled and being scheduled out,
> since we use the one pair of enable/disable entry points for both.
> That is, the high-level disable operation simply arranges for the
> counter to not be scheduled in any more, and the high-level enable
> operation arranges for it to be scheduled in again.
>
> One way to solve this would be to have sched_in/out operations in the
> hw_perf_counter_ops struct as well as enable/disable. However, this
> takes a simpler approach: it adds a 'prev_state' field to the
> perf_counter struct that allows a counter's enable method to know
> whether the counter was previously disabled or just inactive
> (scheduled out), and therefore whether the enable method is being
> called as a result of a high-level enable or a schedule-in operation.
>
> This then allows the context switch, migration and page fault counters
> to reset their hw.prev_count value in their enable functions only if
> they are called as a result of a high-level enable operation.
> Although page faults would normally only occur while the counter is
> scheduled in, this changes the page fault counter code too in case
> there are ever circumstances where page faults get counted against a
> task while its counters are not scheduled in.
>
> Signed-off-by: Paul Mackerras <paulus@samba.org>
Applied to tip:perfcounters/core, thanks Paul!
> This was the simplest fix I could come up with that allowed enable/
> disable to work properly. In some ways having separate sched_in/out
> and enable/disable operations would be nicer but it started to get
> rather invasive. In future it might be useful to have sched-in/out
> separate from enable/disable so that we can optimize sched-in/out.
> For example, on the POWER processors we could use the PM mark bit to
> turn counting on and off quickly in the case where only one task is
> currently using the PMU on a given cpu and there are no per-cpu
> counters.
Agreed. Right now we do have some context-switching overhead for
inherited counters, clearly visible in context-switch intense
workloads if they are run via perfstat, so it would be very nice
to optimize this some more.
Ingo
next prev parent reply other threads:[~2009-02-13 11:23 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-02-13 11:10 Paul Mackerras
2009-02-13 11:23 ` Ingo Molnar [this message]
2009-02-14 0:13 ` Paul Mackerras
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=20090213112333.GE15679@elte.hu \
--to=mingo@elte.hu \
--cc=efault@gmx.de \
--cc=jaswinder@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=paulus@samba.org \
--cc=tglx@linutronix.de \
/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®