From: Ingo Molnar <mingo@elte.hu>
To: Paul Mackerras <paulus@samba.org>
Cc: "Zhang, Yanmin" <yanmin_zhang@linux.intel.com>,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH] perf_counter: Prevent oopses from per-cpu software counters
Date: Thu, 5 Feb 2009 15:22:29 +0100 [thread overview]
Message-ID: <20090205142229.GB28443@elte.hu> (raw)
In-Reply-To: <18826.28805.120988.303819@drongo.ozlabs.ibm.com>
* Paul Mackerras <paulus@samba.org> wrote:
> Impact: oops fix
>
> Yanmin Zhang reported that using a PERF_COUNT_TASK_CLOCK software
> counter as a per-cpu counter would reliably crash the system, because
> it calls __task_delta_exec with a null pointer. And indeed, a "task
> clock" counter only makes sense as a per-task counter. Similarly,
> counting page faults, context switches or cpu migrations only makes
> sense for a per-task counter.
>
> This fixes the problem by disallowing the use of the task clock,
> page fault, context switch and cpu migration software counters as
> per-cpu counters, since they all require a task context to obtain their
> data. The only software counter that can be used as a per-cpu counter
> is the cpu clock counter (PERF_COUNT_CPU_CYCLES).
>
> In order for sw_perf_counter_init to be able to tell whether we are
> setting up a per-task or a per-cpu counter, this arranges for counter->ctx
> to be initialized earlier, in perf_counter_alloc.
>
> The other minor change this makes is to ensure that if sw_perf_counter_init
> fails, we don't try to initialize the counter as a hardware counter.
> Since the user has passed a negative event type (and it isn't raw), they
> clearly don't intend it to be interpreted as a hardware event. This
> matters now that sw_perf_counter_init can fail for valid software event
> types (because of the check that the counter is a per-task counter).
Hm, i dont really think that the notion that it should not be possible to
use sw counters on a per CPU basis is valid.
You are right that "pagefaults" and "context switches" do get generated by
tasks - but there is a per cpu and system wide notion of 'number of
pagefaults', and people might be interested in monitoring that.
The existence and widespread use of "vmstat", and its display of system-wide
count of "context switches" (and administrator's reliance on judging a
workload based on those counts) is i think ample proof that it makes sense
to have those counters on a per CPU basis too.
So how about fixing these sw counts to properly work as percpu counters too?
Or am i misssing something subtle that makes that impossible?
Ingo
next prev parent reply other threads:[~2009-02-05 14:22 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-02-05 4:52 Paul Mackerras
2009-02-05 14:22 ` Ingo Molnar [this message]
2009-02-06 2:40 ` Paul Mackerras
2009-02-06 4:34 ` Paul Mackerras
2009-02-06 6:35 ` Zhang, Yanmin
2009-02-06 15:31 ` Ingo Molnar
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=20090205142229.GB28443@elte.hu \
--to=mingo@elte.hu \
--cc=linux-kernel@vger.kernel.org \
--cc=paulus@samba.org \
--cc=yanmin_zhang@linux.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®