From: Mikael Pettersson <mikpe@csd.uu.se>
To: linux-kernel@vger.kernel.org
Subject: [PATCH] x86 performance counters driver 3.0-pre2 for 2.5.44: overview [0/4]
Date: Thu, 24 Oct 2002 16:59:49 +0200 (MET DST) [thread overview]
Message-ID: <200210241459.QAA03571@kim.it.uu.se> (raw)
Here is perfctr-3.0-pre2 for 2.5.44. This is the 2.5-ready version
of the Linux/x86 performance-monitoring counters kernel extension.
Please consider it for inclusion in 2.5/2.6.
This is part 0 of 4: overview.
This adds support for user-space use of the x86 performance counters.
Major features include:
- CPU support for P5, P6, P4, K7, Centaur, VIA, and Cyrix.
- Overflow interrupts routed back as signals to user-space.
- Per-process virtualised performance counters. This is what makes it
actually useful for user-space :-)
- Performance counter handles are file descriptors. Allows mmap()ing
the counter sums for low-overhead sampling. Also used for a simple
remote-control interface, which allows a monitor process to control
the counters of another process, with ptrace-like access rules.
- Access via a new sys_perfctr() system call.
- Internal organisation as an architecture-specific low-level driver
and one or more architecture-neutral higher-level drivers. It could
easily support several other architectures.
Impact on the kernel:
- The x86 thread_struct is extended with a pointer to that process'
performance counter state. The state is large so it's allocated lazily.
(The state also needs to be a separate object for other reasons.)
- Callbacks in fork(), exec(), exit(), switch_to(), and update_one_process()
to maintain the per-process counters. These callbacks do nothing if the
process has no counters. Disabling CONFIG_PERFCTR_VIRTUAL eliminates
the callback code altogether.
- Adds one system call.
- Adds an interrupt handler for the local APIC LVTPC vector.
- No #ifdefs added to the kernel's C source files.
Known limitations:
- Hyperthreaded P4s will require that processes using the counters have
CPU affinity masks restricting them to even-numbered logical CPUs.
I will take care of this once the basic code is in the kernel.
- The code is not preempt-safe. This is fixable.
- The NMI watchdog, oprofile, and perfctr all want to own the local APIC
LVTPC vector and the CPU performance counter registers. I will implement
a manager to ensure that only one driver at a time uses these resources.
Known design issues:
- The code exists mostly under drivers/perfctr/, partly because the
driver can support other archs easily, and partly because I hate not
having related code in one place.
- The system-call interface is NOT architecture neutral. There are lots
of reasons for this:
* Abstracting away HW details and inventing a "high-level" API is hard
work and would bloat the kernel. User-space libraries can take care
of the conversions when needed. (And current libraries do just that.)
* For low-overhead sampling to work user-space needs to understand the
HW state layout anyway.
* Different CPUs have different capabilities. You can't count FLOPS on
a K7 for instance. Again, user-space needs to know CPU-specific details.
Versions up to perfctr-2.0 were announced regularly on LKML. Since then,
discussions have been done mostly on the perfctr-devel list and directly
with users and user-space tool developers. (A contributing factor to this
was that VGER refused to distribute my perfctr-2.0 announcement post.) The
main differences between the external perfctr-2.x package and perctr-3.x are:
- Dropped unnecessary stuff like support for 2.2 kernels and modular builds.
- Changed from ioctl()s on special files to proper system call interface.
- Removed the global-mode performance counter driver, since the SMP CPU
numbering changes in 2.5 utterly broke its API.
The perfctr-3.x patch files can also be obtained from
http://www.csd.uu.se/~mikpe/linux/perfctr/3.x/patchkit/.
/Mikael
reply other threads:[~2002-10-24 14:53 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=200210241459.QAA03571@kim.it.uu.se \
--to=mikpe@csd.uu.se \
--cc=linux-kernel@vger.kernel.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
Powered by JetHome