This provides the implementation for ustack's getupcstack function, and the
related ustackdepth. Due to the frequent use of omit-framepointer in the
compilation of userspace code, ustack will return all addresses on the stack
that reference into memory areas with executable code.
Signed-off-by: Kris Van Hees <kris.van.hees@oracle.com>
Revert "stack() / jstack(): Send PID to userspace."
This reverts commit d42235829341592e23996d727bc5c3beebec1e57. The bug with
the PID not being passed is a bug in dtrace_isa.c instead, and there is a slot
already reserved for that. So this patch was not necessary, and the bug will
be fixed in dtrace_isa.c get_ufpstack and get_upcstack with a subsequent
commit.
Signed-off-by: Kris Van Hees <kris.van.hees@oracle.com>
Kris Van Hees [Thu, 7 Feb 2013 21:30:08 +0000 (16:30 -0500)]
Adding more compile time debugging for development.
This patch expands the developer debugging coverage, adding more (compile time
enabled) debugging statements that can help during DTrace kernel side bug
hunting.
Signed-off-by: Kris Van Hees <kris.van.hees@oracle.com>
Kris Van Hees [Wed, 23 Jan 2013 09:53:14 +0000 (04:53 -0500)]
USDT implementation (Phase 1).
This rather large patch provides the implementation for USDT support at the
DTrace kernel core level, and the fasttrap provider level. It ensures that
executables can register their embedded providers (with USDT probes), that
the probes are visible to the dtrace userspace utility, and that probes are
properly removed upon executable completion, execve() invocation, or any
unexpected executable termination.
The following parts are provided by this patch:
- meta-provider support (dtrace_ptofapi)
- helper ioctl interface (dtrace_dev)
- DIF validation for helper objects (dtrace_dif)
- DOF processing for helpers for provider and probe definitions (dtrace_dof)
- fasttrap meta-provider for USDT only (fasttrap*)
The dtrace_helper.c file was removed because this code belongs in dtrace_dof.c
instead.
Minimal changes were made to the core kernel in exec.c, sched.h, exit.c, and
fork.c to add support for process-specific helpers (and those encapsulate
providers and probes).
Signed-off-by: Kris Van Hees <kris.van.hees@oracle.com>
Kris Van Hees [Wed, 23 Jan 2013 09:42:32 +0000 (04:42 -0500)]
Add basic development debugging framework.
This patch adds some defines that can be used to provide debugging output in
support of development. This is debugging output that is controlled at build
time rather than runtime. For production builds, this will always be disabled.
Signed-off-by: Kris Van Hees <kris.van.hees@oracle.com>
Kris Van Hees [Wed, 23 Jan 2013 09:29:45 +0000 (04:29 -0500)]
Disable providers that do not work.
We currently do not have fbt and lockstat available as providers in a stable
state. Disable building them until we are ready to release them in alpha
status with at least a reasonable expectation that they won't crash anything.
Signed-off-by: Kris Van Hees <kris.van.hees@oracle.com>
Kris Van Hees [Sun, 6 Jan 2013 09:51:59 +0000 (04:51 -0500)]
Differentiate between multi-providers and meta-providers.
Renamed and module init/exit macro to reflect that this is a multi-provider
module (i.e. one that registers multiple providers in one kernel module) rather
than a meta-provider (a module that dynamically creates providers on demand).
Also added the list of providers to register/unregister as a 2nd argument to
the macro rather than expecting that the list of providers will be provided by
a global variable with a specific name.
Signed-off-by: Kris Van Hees <kris.van.hees@oracle.com>
Kris Van Hees [Fri, 19 Oct 2012 08:37:53 +0000 (04:37 -0400)]
Internal performance measurement support code.
The dt_perf provider implements a few probes that are used in performance
(or more accurately put, overhead) measurements. It uses an ioctl()
interface to trigger N-count interations of invoking probes through
various mechanisms, and a probe to post the results back to userspace.
This code also adds an SDT probe in the DTrace kernel support code, just
to measure overhead for triggering trap based SDT probes.
Signed-off-by: Kris Van Hees <kris.van.hees@oracle.com>
Nick Alcock [Wed, 10 Oct 2012 18:37:49 +0000 (19:37 +0100)]
DTrace-independent CTF.
These largely cosmetic changes remove mention of DTrace from the CTF code,
making it clear that it is freely usable by non-DTrace consumers.
The changes are:
- dtrace_ctf.ko is now named ctf.ko, and is stored in kernel/ctf rather than
kernel/dtrace, controlled by a new CONFIG_CTF Kconfig option select'ed by
CONFIG_DTRACE. (CONFIG_DT_DISABLE_CTF, being largely a DTrace debugging
option, remains under DTrace configure control). The function used to
trigger loading of ctf.ko has changed name similarly, from
dtrace_ctf_forceload() to ctf_forceload().
- The CTF section names have changed, from .dtrace_ctf.* to .ctf.* (which as a
bonus is more obviously related to the .ctf directory long used to store the
CTF data during the build process).
- The shared CTF repository is now stored in .ctf.shared_ctf instead of
.dtrace_ctf.dtrace_ctf, making its intended use somewhat clearer.
These changes depend on a suitably changed libdtrace-ctf: a suitably changed
userspace is needed to take advantage of them. The dtrace-kernel-interface is
bumped accordingly.
Signed-off-by: Nick Alcock <nick.alcock@oracle.com>
Fix name of lwp-create and lwp-exit probes in SDT argument mappings.
The argument mapping for SDT probes incorrectly listed lwp_create instead of
lwp-create, and lwp_exit instead of lwp-exit. Also, lwp-exit was listed to
have a single int argument whereas it is not supposed to have any arguments.
Signed-off-by: Kris Van Hees <kris.van.hees@oracle.com>
Nick Alcock [Thu, 13 Sep 2012 14:01:58 +0000 (15:01 +0100)]
SPEC: Rename the DTrace kernel to kernel-uek-dtrace-.
This means that automatic upgrades between DTrace and non-DTrace kernels are no
longer an issue.
(The kernel still provides all the same RPM capabilities as it used to, so no
other packages need change, excepting only the DTrace module, which explicitly
requires the matching DTrace kernel.)
Signed-off-by: Nick Alcock <nick.alcock@oracle.com>
Removed ASSIST_* definitions because they are no longer necessary (though they
may come back in the future).
Changed the behaviour of DTrace in interrupt context to base it on in_irq()
rather than in_interrupt().
On Linux it is always safe to dereference current, so there is no need to do
special casing on various process-based DIF functions. There is no need to
fake values coming from the 0-pid process.
Added curcpu variables.
Added d_path() function. This takes a struct path and turns it into a string.
Renumbered the register IDs to match the xlator support at userspace, and to
also match the on-stack order of registers.
Have dtrace_getreg() operate on the task rather than just a set of registers,
because (in 64-bit mode) segment registers have their value stored in fields
in the process-specific task info.
Implemented the raise() action.
Changed the deadman interal to 10s, and timeout/user to 120s.
Signed-off-by: Kris Van Hees <kris.van.hees@oracle.com>
Change the DTrace startup handling (at boot time) for SDT.
The DTrace OS level handling was initialized at DTrace module load, which
caused major indigestion on the side of the scheduler when SDT probe points at
crucial locations in the scheduler were being patched by one CPU while another
was trying to get some real work done. Even a nice stop_machine() based
approach turned out not to be possible, because that *cough* depends on the
scheduler also.
Instead, the DTrace OS support is initialized from the Linux boot sequence,
before SMP is enabled, which removes the complications altogether (and it is a
lot cleaner and faster). We also call CPU-specific initialization for DTrace
during the boot sequence, albeit *after* the CPUs have been identified for SMP,
to ensure that we get accurate information.
Renamed sdt_register.c to be dtrace_sdt.c (for consistency). And implemented
a better patching of SDT probe points.
Added a 'nosdt' kernel command line option to allow system wide diabling of
SDT probe points (at the kernel level). This can be used when the patching of
SDT probe points somehow causes a problem.
Signed-off-by: Kris Van Hees <kris.van.hees@oracle.com>
Changed io SDT probe points to be located at the buffer_head level rather than
the bio level. This may need to be revisted depending on further analysis,
but doing it this way provides consistent semantics that were not guaranteed by
the previous bio-based placement.
Changed the sched STD probes to not pass irrelevant arguments, and to pass
specific runqueue CPU information. The CPU information is not available from
the task structure, so it needs to be passed explicily.
Added proc SDT probes start and lwp-start.
Added proc SDT probes for signal-discard and signal-clear.
Corrected the argument to the exit proc SDT probe, which should indicate the
reason for the process termination (exit, killed, core dumped) rather than the
return code of the process.
Provided argument information for all the new (and changed) SDT probe points.
This depends on working xlator support in userspace.
Enabling of SDT probes now uses a generic dtrace_invop_(enable|disable) rather
than SDT-specific functions.
SDT probes are not destroyed correctly, to ensure that subsequent uses will not
result in unpleasant events.
Signed-off-by: Kris Van Hees <kris.van.hees@oracle.com>
Nick Alcock [Fri, 20 Jul 2012 22:02:56 +0000 (23:02 +0100)]
DIF_SUBR_RW_READ_HELD's parameter should be an rwlock_t.
Even if Solaris gives DIF_SUBR_RW_READ_HELD and DIF_SUBR_RW_WRITE_HELD different
parameter types, that doesn't mean we have to copy its mistake. An rwlock is an
rwlock whether you are testing for a read or a write hold.
Signed-off-by: Nick Alcock <nick.alcock@oracle.com>
Nick Alcock [Fri, 20 Jul 2012 22:00:07 +0000 (23:00 +0100)]
Force dtrace_ctf.ko to be loaded whenever dtrace.ko is.
DTrace userspace makes the simplifying assumption that dtrace_ctf.ko (containing
the CTF for the kernel, for built-in modules, and for shared types, but no code)
is always loaded whenever DTrace is usable. (The CTF itself is in a non-loaded
section, but having dtrace_ctf.ko in the list of loaded modules means that we
can eliminate an annoying set of dtrace_ctf-related special case.)
We do this by introducing a dummy function dtrace_ctf_forceload() into the
dtrace_ctf module, which DTrace then calls: depmod will then arrange for
dtrace_ctf to be loaded when we need it.
Signed-off-by: Nick Alcock <nick.alcock@oracle.com>
- sched-tick SDT probe.
- FBT probe point discovery and probe creation.
- Moving code around for the kernel pseudo-module handling since it gets used
by both the SDT code and the FBT code.
Signed-off-by: Kris Van Hees <kris.van.hees@oracle.com>
Kris Van Hees [Tue, 7 Feb 2012 09:31:48 +0000 (04:31 -0500)]
Changed from using mutex_is_locked() to a new mutex_owned(), in support of the
Solaris MUTEX_HELD() macro. The former was merely testing whether the mutex was
locked, whereas the real test needed here is whether the mutex is held by the
current thread.
Signed-off-by: Kris Van Hees <kris.van.hees@oracle.com>
Kris Van Hees [Tue, 31 Jan 2012 10:04:53 +0000 (05:04 -0500)]
Make all allocations that are allowed to fail atomic, and surpress warnings
about out-of-memory conditions, since they are not harmful. Also, do not allow
DTrace allocations to access the emergency pools.
Signed-off-by: Kris Van Hees <kris.van.hees@oracle.com>
Kris Van Hees [Tue, 17 Jan 2012 20:03:17 +0000 (15:03 -0500)]
Fix signed division and modulo operations in DIF.
Ensure that SDT probe points are patched with a NOP sequence at boot time.
Remove debugging output during SDT registration.
Signed-off-by: Kris Van Hees <kris.van.hees@oracle.com>
Kris Van Hees [Thu, 12 Jan 2012 21:36:54 +0000 (16:36 -0500)]
Fix for incorrect handling of BUFSIZE = 0. The handling of aggregations was
flawed in that even without any ECBs with aggregation, the code logic was
assuming there was at least one aggregation (the sentinel in the IDR). The
handling of the aggregations IDR in the DTrace state has been updated to use
an explicit counter because the IDR functionality does not provide us with an
API function to determine the amount of elements in the IDR.
Signed-off-by: Kris Van Hees <kris.van.hees@oracle.com>
Kris Van Hees [Thu, 12 Jan 2012 20:15:15 +0000 (15:15 -0500)]
Initial values for min and max aggregate functions were incorrectly set to be
UINT64 values rather than INT64 values, causing the initial minimum value to
be -1, and the initial maximum value to be 0. Corrected to be INT64 values.
Signed-off-by: Kris Van Hees <kris.van.hees@oracle.com>
Kris Van Hees [Wed, 11 Jan 2012 06:18:41 +0000 (01:18 -0500)]
Ensure that the die notifier hook is installed whenever DTrace is enabled,
since page fault and general protection fault handling depends on it, and that
is needed for safe memory access support in DTrace.
Work around an apparent bug in Xen where an invalid opcode fault is delivered
as a general protection failure instead.
Signed-off-by: Kris Van Hees <kris.van.hees@oracle.com>
Kris Van Hees [Mon, 5 Dec 2011 20:01:27 +0000 (15:01 -0500)]
SDT implementation (core kernel support for providing a list of static probe
points for the kernel pseudo-module, dtrace SDT meta-provider support, ...).
Also, new script (dtrace_sdt.sh) to extract locations of SDT probe points in
the core kernel.
Signed-off-by: Kris Van Hees <kris.van.hees@oracle.com>
Kris Van Hees [Mon, 14 Nov 2011 15:17:45 +0000 (10:17 -0500)]
Enable processing the SDT probe point info at boot time (before SMP is actually
enabled), if DTrace SDT support has been enabled (built-in or as module). For
now, provide some verbose info on the probe points getting resolved.
Signed-off-by: Kris Van Hees <kris.van.hees@oracle.com>
Kris Van Hees [Fri, 11 Nov 2011 07:34:04 +0000 (02:34 -0500)]
Fix resolving addresses of relocation records for SDT probe points. The
addresses were being calculated based on the wrong starting point (_stext
whereas it ought to be _text), and the base was not taken into account.
Fixed the writing of NOPs in the location of the probe point calls, since
the existing case was causing kernel paging faults. Made the add_nops()
function in alternative.c non-static so it can be used in sdt_register.
Use add_nops() to select the most appropriate NOP sequence for replacing the
probe point call, and write the NOPs using text_poke().
Signed-off-by: Kris Van Hees <kris.van.hees@oracle.com>
Kris Van Hees [Thu, 3 Nov 2011 17:59:00 +0000 (13:59 -0400)]
Fixed the allocation of cyclics that was the cuase for some obscure crashes
during the testsuite execution. Problem was that cyclics were being allocated
in chunks, with a new array being allocated as (prev-size + chink-size), and
then the old entries being copied over. However, because the hrtimer struct is
embedded in the cyclic struct, this meant that hrtimer structs were being moved
outside the hrtimer code.
Signed-off-by: Kris Van Hees <kris.van.hees@oracle.com>
Kris Van Hees [Thu, 27 Oct 2011 17:15:26 +0000 (13:15 -0400)]
Handle the case where regs (during cyclic processing) is NULL. This indicates
a bug but with this code change we'll survive that case and simply not have
meaningful PC and UPC values as argument to the probe, which is better than a
full scale OOPS due to NULL pointer dereference.
Signed-off-by: Kris Van Hees <kris.van.hees@oracle.com>
Kris Van Hees [Thu, 27 Oct 2011 14:39:19 +0000 (10:39 -0400)]
Implementation for tracing stub-based system calls. Due to the need for
specialized code handling (mainly passing in a pt_regs structure as one of
the arguments), some syscalls are called through a stub in assembly code.
We duplicate the stub cdode in dtrace_stubs_x86_64.S, but instead of calling
the actual syscall implementation code call our own syscall-specific handler,
which ensures that entry and return probes are called as enabled, and then
call the underlying implementation directly for handling the syscall.
Also removed debugging output that is no longer relevant (code cleanup).
Signed-off-by: Kris Van Hees <kris.van.hees@oracle.com>
Kris Van Hees [Fri, 14 Oct 2011 02:42:27 +0000 (22:42 -0400)]
Stacktrace dumping has been moved to the GPL-licensed dtrace_os.c because it
depends on a symbol that is exported as GPL-only. Functionality in dtrace_isa
that requires stacktrace dumping can now use dtrace_stacktrace().
The GPL-licensed dtrace_os.h C header file is now made available through the
/include/linux hierarchy, and it is included in dtrace.h.
Fixed a bug in dtrace_relocs.c where section names where copied into a memory
area that was 1 byte short, causing various unpleasant forms of behaviour.
Signed-off-by: Kris Van Hees <kris.van.hees@oracle.com>
Nick Alcock [Mon, 3 Oct 2011 16:20:15 +0000 (17:20 +0100)]
Finish GPL/CDDL splitting work.
kernel/dtrace and all that it #includes is now GPLv2, with the aid of a new
systrace_os.h header containing the subset of systrace.h needed by the GPL shim.
Conversely, dtrace/ is entirely CDDL.
dtrace_ioctl.h is now an exported, header in include/linux/, to ease future
sharing by the userspace side. It is probably not copyrightable (as is essential
for interoperability and contains no creative elements), but if it has any license
at all it is GPLv2 like the other headers in that directory (many of which are
include them.)
Signed-off-by: Nick Alcock <nick.alcock@oracle.com>
Nick Alcock [Fri, 30 Sep 2011 17:55:09 +0000 (18:55 +0100)]
Initial commit of DTrace.
Build via a simple 'make' if you're already running this kernel, or via 'make
KERNELDIR=/path/to/kernel/top/level' otherwise. Installed via 'make install'.
Signed-off-by: Nick Alcock <nick.alcock@oracle.com>