]> www.infradead.org Git - users/jedix/linux-maple.git/log
users/jedix/linux-maple.git
10 years agodtrace: add .gitignore file
Kris Van Hees [Wed, 24 Dec 2014 14:02:00 +0000 (09:02 -0500)]
dtrace: add .gitignore file

The DTrace modules source tree did not have a .gitignore file, causing
reports of untracked files during git operations.  This has been
rectified.

Orabug: 20266608

Signed-off-by: Kris Van Hees <kris.van.hees@oracle.com>
Acked-by: Nick Alcock <nick.alcock@oracle.com>
11 years agodtrace: Updated NEWS and specfile
Kris Van Hees [Thu, 1 May 2014 13:22:33 +0000 (09:22 -0400)]
dtrace: Updated NEWS and specfile

Signed-off-by: Kris Van Hees <kris.van.hees@oracle.com>
11 years agodtrace: ensure one can try to get user pages without locking or faulting
Kris Van Hees [Tue, 29 Apr 2014 06:16:48 +0000 (02:16 -0400)]
dtrace: ensure one can try to get user pages without locking or faulting

This commit changes the FOLL_NOFAULT flag into a FOLL_IMMED flag, to
more accurately convey its meaning, i.e. to request user pages without
waiting for any locks and without servicing any page faults as a result
of the request.  This is necessary in order to request user pages from
interrupt context.

This also completes the implementation by ensuring that the PTE spinlock
is checked rather than trying to lock it (and possibly get stuck in a
deadlock spinning for it).

Orabug: 18653713

Signed-off-by: Kris Van Hees <kris.van.hees@oracle.com>
Acked-by: Chuck Anderson <chuck.anderson@oracle.com>
11 years agodtrace: Improve dtrace_getufpstack() (locks, stack detection, faults)
Nick Alcock [Mon, 24 Mar 2014 22:43:17 +0000 (22:43 +0000)]
dtrace: Improve dtrace_getufpstack() (locks, stack detection, faults)

dtrace_getufpstack() had several flaws exposed by ustack() of multithreaded
processes.  All the flaws touch the same small body of code, and none could be
verified to work until all were in place: hence this rather do-everything
commit.

Firstly, it was detecting the end of the stack using mm->start_stack.  This is
incorrect for all threads but the first, and is even incorrect for the first
thread in languages such as Go with split stacks.  As it is, this causes the
stack traversal to attempt to walk over a gap with no VMAs, causing a crash.

The correct solution is of course to look at the VMAs to find the VMA which
covers the user's stack address.  We are already looking at the VMAs in
is_code_addr(), but this is both a linear scan when all but no-mmu platforms
have better ways, and a *lockless* scan.  This is barely safe in the
single-threaded case, but in the multithreaded case other tasks sharing the same
mm may well be executing in parallel, and it becomes crucial that scanning the
VMAs be done under the mmap_sem.  Unfortunately we cannot always take the
mmap_sem: DTrace may well be invoked in contexts in which sleeping is
prohibited, and in which other threads have the semaphore.  So we must do a
down_read_trylock() on the mmap_sem, aborting the ustack() if we cannot take it
just as we already do if this is a process with no mm at all.  (We also need to
boost the mm_users to prevent problems with group exits.)

We are also accessing the pages themselves without pinning, which means
concurrent memory pressure could swap them out, or memory compaction move them
around.  We can use __get_user_pages() to get the VMA and pin the pages we need
simultaneously, as long as we use the newly-introduced FOLL_NOFAULT to ensure
that __get_user_pages() does not incur page faults.  We wrap __get_user_pages()
in a local find_user_vma(), which also arranges to optionally fail if particular
pages (such as the stack pages) are not in core.  (We need the VMA for some
pages so we can see if they are likely to be text-segment VMAs or not: such
pages do not need to be in core and ustack() need not fail if they are swapped
out.)

For efficiency's sake, we pin each stack page as we cross the page boundary into
it, releasing it afterwards.

But even this does not suffice.  FOLL_NOFAULT ensures that __get_user_pages()
will not fault, but does not ensure that a page fault will not happen when
accessing the page itself.  So we use the newly-introduced CPU_DTRACE_NOPF
machinery to entirely suppress page faults inside get_user() (and nowhere else),
and check it afterwards.

As an additional feature, dtrace_getufpstack() can now be called with a NULL
pcstack and a pcstack_limit of zero, meaning that the stack frame entries are
only counted, not recorded.  We use this feature to reimplement
dtrace_getustackdepth() in terms of dtrace_getufpstack().

With this change, multithreaded ustack()s appear to work, even in the presence
of non-glibc stack layouts (as used by Java and other non-glibc threading
libraries) and concurrent group exits and VMA changes.

Orabug: 18412802
Signed-off-by: Nick Alcock <nick.alcock@oracle.com>
Reviewed-by: Kris Van Hees <kris.van.hees@oracle.com>
Acked-by: Chuck Anderson <chuck.anderson@oracle.com>
11 years agodtrace: Updated NEWS and specfile
Kris Van Hees [Fri, 25 Apr 2014 14:03:57 +0000 (10:03 -0400)]
dtrace: Updated NEWS and specfile

Updated the NEWS and specfile to add a note that there is a known
regression on test stress/buffering/tst.resize1.d due to the memory
allocation checking changes that were made a while ago.  This
non-harmful regression will be fixed in the next release.

Signed-off-by: Kris Van Hees <kris.van.hees@oracle.com>
11 years agodtrace: update NEWS and spec file for 0.4.3-2
Kris Van Hees [Thu, 24 Apr 2014 09:33:56 +0000 (05:33 -0400)]
dtrace: update NEWS and spec file for 0.4.3-2

Signed-off-by: Kris Van Hees <kris.van.hees@oracle.com>
11 years agoDrop CPU_DTRACE_NOFAULT manipulation in progenyof().
Nick Alcock [Mon, 24 Mar 2014 22:51:43 +0000 (22:51 +0000)]
Drop CPU_DTRACE_NOFAULT manipulation in progenyof().

This is only doing a traversal of task_structs via real_parent.  This is
nonswappable, so faults are impossible, and blocking faults unnecessary.

Orabug: 18412802
Signed-off-by: Nick Alcock <nick.alcock@oracle.com>
Reviewed-by: Kris Van Hees <kris.van.hees@oracle.com>
Acked-by: Chuck Anderson <chuck.anderson@oracle.com>
11 years agoDrop CPU_DTRACE_NOFAULT manipulation around ustack calls.
Nick Alcock [Mon, 24 Mar 2014 22:50:06 +0000 (22:50 +0000)]
Drop CPU_DTRACE_NOFAULT manipulation around ustack calls.

dtrace_getufpstack() and (as of the last commit) dtrace_getustackdepth() both
manipulate the CPU_DTRACE_NOFAULT flag themselves: clearing it after calling
those functions is redundant, and setting it is actually dangerous, since
other functions dtrace_getustackdepth() calls (such as __get_user_pages() do
not expect to have instructions that incur page faults silently skipped without
faulting.

Orabug: 18412802
Signed-off-by: Nick Alcock <nick.alcock@oracle.com>
Reviewed-by: Kris Van Hees <kris.van.hees@oracle.com>
Acked-by: Chuck Anderson <chuck.anderson@oracle.com>
11 years agoPass down the tgid to userspace in u{stack,sym,mod,addr}().
Nick Alcock [Mon, 17 Mar 2014 16:39:07 +0000 (16:39 +0000)]
Pass down the tgid to userspace in u{stack,sym,mod,addr}().

Userspace does not know how to attach to threads, only processes (thread group
leaders).  All it's doing after attaching is looking up symbols, which are per-
process anyway, so rather than go to the effort of teaching userspace to grab
and release non-thread-group-leaders, simply pass the tgid to userspace so that
it can grab everything the same way.

Also pass the pid (== tid) down, because DTrace consumers could reasonably want
to know the actual thread ID in which the u*() fired (though our userspace does
not care).

This means we are passing one extra item on the buffer for ustack() et al:
internal uses are adjusted accordingly.

Orabug: 18412802
Signed-off-by: Nick Alcock <nick.alcock@oracle.com>
Reviewed-by: Kris Van Hees <kris.van.hees@oracle.com>
Acked-by: Chuck Anderson <chuck.anderson@oracle.com>
11 years agoFix the pid and ppid variables in multithreaded processes.
Nick Alcock [Mon, 17 Mar 2014 16:29:34 +0000 (16:29 +0000)]
Fix the pid and ppid variables in multithreaded processes.

pid is currently equal to the Linux-side PID: i.e., from userspace's
perspective, the thread ID.  tgid is equal to the thread ID of the parent.  Both
of these are at best inconvenient and at worst wrong: they should both use the
thread group ID of their respective task, which corresponds to the
userspace-visible PID.

Orabug: 18412802
Signed-off-by: Nick Alcock <nick.alcock@oracle.com>
Reviewed-by: Kris Van Hees <kris.van.hees@oracle.com>
11 years agodtrace: NEWS and specfile update for 0.4.3
Kris Van Hees [Tue, 15 Apr 2014 21:00:35 +0000 (17:00 -0400)]
dtrace: NEWS and specfile update for 0.4.3

Signed-off-by: Kris Van Hees <kris.van.hees@oracle.com>
11 years agodtrace: add support for profile-* probes
Kris Van Hees [Fri, 14 Mar 2014 15:40:53 +0000 (11:40 -0400)]
dtrace: add support for profile-* probes

This commit adds support in the profile provider for profile-*
probes, i.e. probes that fire at a specifid frequency/interval on
all active CPUs.  Support is also added for passing the appropriate
program counter (kernel or user) as probe argument, as required for
tick-* and profile-* probes.

Orabug: 18323513

Signed-off-by: Kris Van Hees <kris.van.hees@oracle.com>
Acked-by: Chuck Anderson <chuck.anderson@oracle.com>
11 years agoUpdated specfile for 0.4.2-3.
Nick Alcock [Wed, 29 Jan 2014 21:45:36 +0000 (21:45 +0000)]
Updated specfile for 0.4.2-3.

Signed-off-by: Nick Alcock <nick.alcock@oracle.com>
11 years agoHave the new dtrace-modules-provider-headers obsolete the old.
Nick Alcock [Wed, 29 Jan 2014 20:35:12 +0000 (20:35 +0000)]
Have the new dtrace-modules-provider-headers obsolete the old.

The package name has changed but the new package contains the same files as the
old, so we need to Obsolete: the old ones so that yum will remove them.

(Because the old scheme generated package names on the fly according to the
running kernel, the list in this patch may well be missing a few packages.)

Caveat: this fixes 'yum update' but cannot fix direct RPM installation.
You'll have to uninstall the old package manually if you do that.

Orabug: 18061595
Reviewed-by: Kris Van Hees <kris.van.hees@oracle.com>
Signed-off-by: Nick Alcock <nick.alcock@oracle.com>
11 years agoRemove kernel version from name of dtrace-modules-provider-headers package.
Nick Alcock [Thu, 16 Jan 2014 13:22:08 +0000 (13:22 +0000)]
Remove kernel version from name of dtrace-modules-provider-headers package.

This package had a kernel-version-dependent name on the grounds that it
consisted of kernel headers meant to be included by a single kernel version.
This reasoning was flawed: the headers do not change as the kernel is rebuilt,
and as the package provides files that are not under a kernel-version-specific
path, 'yum update' can attempt to install two versions at once, and conflict.

The right solution is to name the package without a kernel-version-specific part.
(We keep the name unchanged when built against earlier kernels, to avoid
sneaking unrelated changes into security errata releases.)

Orabug: 18061595
Reviewed-by: Kris Van Hees <kris.van.hees@oracle.com>
Signed-off-by: Nick Alcock <nick.alcock@oracle.com>
11 years agodtrace: updated spec file and NEWS
Kris Van Hees [Sat, 21 Dec 2013 21:33:02 +0000 (16:33 -0500)]
dtrace: updated spec file and NEWS

Signed-off-by: Kris Van Hees <kris.van.hees@oracle.com>
11 years agodtrace: Fix RPM dependencies.
Kris Van Hees [Fri, 20 Dec 2013 16:19:01 +0000 (11:19 -0500)]
dtrace: Fix RPM dependencies.

Userspace depends on dtrace-modules-headers so that it can #include the headers
shared between kernel and userspace.  However, it is crucial that this inclusion
not drag in the dtrace module itself, nor the kernel on which it depends,
because that module might be of a version different to that already on the
system (likely older, which would cause yum upgrade to fail).

So drop the dependency between dtrace-modules-headers and the module itself.

Also, userspace has ceased depending on the dtrace-kernel-interface capability,
in favour of automatic but explicit yum installation of module RPMs when needed:
so drop that capability, unversion the dtrace-modules-headers capability, and
remove the kernel version from the dtrace-modules-headers package's name, since
it is not dependent on the running kernel in any way.  Unversion the
modules-provider-headers capability too, but leave its name versioned: since it
is meant for provider authors, and providers are kernel modules, it is
necessarily kernel-version-dependent.

--

Modified to allow building of modules prior to 0.4.2 using the older scheme
for dependencies, and use the new scheme starting with 0.4.2.

Orabug: 17804881
Signed-off-by: Nick Alcock <nick.alcock@oracle.com>
Signed-off-by: Kris Van Hees <kris.van.hees@oracle.com>
11 years agodtrace: vtimestamp implementation
Kris Van Hees [Tue, 17 Dec 2013 23:08:17 +0000 (18:08 -0500)]
dtrace: vtimestamp implementation

This commit adds DTrace vtimestamp support.  It keeps track of how much
time a task has spent actually processing on a CPU.  The time is set to
zero at task creation, and is updated whenever the task leaves a CPU
(gets scheduled off), and when the dtrace_probe() function is entered,
to enusre that the most recent value of consumed time is reported.

Some code got moved around for consistency of the implementation.

Orabug: 17741477

Reviewed-by: Dan Duval <dan.duval@oracle.com>
Signed-off-by: Kris Van Hees <kris.van.hees@oracle.com>
11 years agodtrace: implement SDT in kernel modules
Kris Van Hees [Tue, 17 Dec 2013 23:06:57 +0000 (18:06 -0500)]
dtrace: implement SDT in kernel modules

Full implementation of SDT probes in kernel modules.

The dtrace_sdt.sh script has been modified to handle both the creation
of the SDT stubs and the SDT info.  It's syntax has therefore changed:

  dtrace_sdt.sh sdtstub <stubfile> <object-file> <object-file>*
or
  dtrace_sdt.sh sdtinfo <infofile> vmlinux.o
or
  dtrace_sdt.sh sdtinfo <infofile> vmlinux.o .tmp_vmlinux1
or
  dtrace_sdt.sh sdtinfo <infofile> <kmod>.o kmod

The first form generates a stub file in assembler to ensure that the
(fake) functions that are called from SDT probe points will not longer
be reported as undefined symbols, and to ensure that when SDT is not
enabled, the probes become calls to a function that simply returns.

The second form creates the initial (dummy) SDT info file for the kernel
linking process, mainly to ensure that its size is known.  The third
form then creates the true SDT info file for the kernel, based on the
kernel object file and the first stage linked kernel image.

The fourth and final form generates SDT info for a kernel module, based
on its initial linked object.

This commit also enables the test probes in the dt_test module.

Orabug: 17851716

Reviewed-by: Jamie Iles <jamie.iles@oracle.com>
Signed-off-by: Kris Van Hees <kris.van.hees@oracle.com>
11 years agodtrace: fix conditionals for changelog composition
Kris Van Hees [Mon, 16 Dec 2013 19:42:07 +0000 (14:42 -0500)]
dtrace: fix conditionals for changelog composition

Build failure indicated that under some conditions, the changelog created in
the specfile by means of build version conditionals resulted in out-of-order
entries in the changelog.  This has been corrected.

Signed-off-by: Kris Van Hees <kris.van.hees@oracle.com>
11 years agodtrace: make the release tag dependent on the kernel version
Kris Van Hees [Tue, 3 Dec 2013 20:15:14 +0000 (15:15 -0500)]
dtrace: make the release tag dependent on the kernel version

Signed-off-by: Kris Van Hees <kris.van.hees@oracle.com>
11 years agodtrace: fix changelog for 0.4.0 series
Kris Van Hees [Tue, 3 Dec 2013 19:55:57 +0000 (14:55 -0500)]
dtrace: fix changelog for 0.4.0 series

Signed-off-by: Kris Van Hees <kris.van.hees@oracle.com>
11 years agodtrace: support auto-building of dtrace-module for UEK kernels
Kris Van Hees [Mon, 18 Nov 2013 09:35:10 +0000 (04:35 -0500)]
dtrace: support auto-building of dtrace-module for UEK kernels

This provides the mechanics to ensure that dtrace-mpdule RPMs can be built
automatically when UEK kernels are built.

This also fixes the correct handling of specifying build_kver.

Signed-off-by: Kris Van Hees <kris.van.hees@oracle.com>
11 years agodtrace: prepare spec file for errata release (3.87.13-16.2.1/0.4.1-3)
Kris Van Hees [Wed, 6 Nov 2013 21:43:14 +0000 (16:43 -0500)]
dtrace: prepare spec file for errata release (3.87.13-16.2.1/0.4.1-3)

Signed-off-by: Kris Van Hees <kris.van.hees@oracle.com>
11 years agodtrace: Updated NEWS and spec file
Kris Van Hees [Wed, 6 Nov 2013 21:39:07 +0000 (16:39 -0500)]
dtrace: Updated NEWS and spec file

Signed-off-by: Kris Van Hees <kris.van.hees@oracle.com>
11 years agodtrace: provide a corrected implementation of the 'errno' D variable
Kris Van Hees [Thu, 31 Oct 2013 09:22:56 +0000 (05:22 -0400)]
dtrace: provide a corrected implementation of the 'errno' D variable

This commit provides a corrected implementation for the 'errno' D variable.
It is defined as holding the error code (if non-zero) during the current
system call execution.  If the system call is successful, or if no system
call is being executed, its value is to be 0.  On (Open)Solaris, this was
retrieved from a task variable that is assigned an error code as soon as
an error is encountered during the processing of a system call, i.e. system
calls use a task variable to store any error code encountered during
execution, and this is used upon return from the system call to alert
userspace of the error code status of the system call.  In Linux, system
calls are implemented in the more regular fashion (for Linux at least)
of returning error codes as return values of functions, and therefore
there is no task level variable to consult.  So, instead we recognize that
at this point) 'errno' only has meaning during the processing of syscall
return probes, which are handled from the system call wrapper, after the
system call implementation has been executed.

It would therefore be sufficient and correct to assign the value of 'errno'
at that point, but that would require a task variable to be added to the
task struct in order for this value to be recorded.

In order to avoid adding a member to the task struct, we (ab)use the fact
that we can recognize whether we are executing a D action for a syscall
return probe, and if we are *and* if 'errno' is being retrieved, we look
at the arg0 value for the probe (which is defined as the return value of
the syscall), and if the value is between 0 and -2048, we return the error
code it represents as errno.

Orabug: 17704568

Signed-off-by: Kris Van Hees <kris.van.hees@oracle.com>
Reviewed-by: Chuck Anderson <chuck.anderson@oracle.com>
11 years agodtrace: Updated specfile and NEWS
Kris Van Hees [Wed, 23 Oct 2013 21:25:36 +0000 (17:25 -0400)]
dtrace: Updated specfile and NEWS

Update for 0.4.1 release.

Signed-off-by: Kris Van Hees <kris.van.hees@oracle.com>
11 years agodtrace: fix lock ordering issues, mutex_owned(), and mutex debugging
Kris Van Hees [Thu, 17 Oct 2013 23:18:44 +0000 (19:18 -0400)]
dtrace: fix lock ordering issues, mutex_owned(), and mutex debugging

Several cases of potential lock ordering issues were identified and resolved.
Both static and dynamic analysis of locking comes clean for DTrace after this
commit is applied.

The mutex_owned() function was not accounting for the possibility that a lock
might have an owner registered while unlocked.

Orabug: 17624236

Signed-off-by: Kris Van Hees <kris.van.hees@oracle.com>
11 years agodtrace: ensure userspace stack memory access cannot page fault
Kris Van Hees [Thu, 17 Oct 2013 09:45:22 +0000 (05:45 -0400)]
dtrace: ensure userspace stack memory access cannot page fault

Orabug: 17591351

Signed-off-by: Kris Van Hees <kris.van.hees@oracle.com>
11 years agodtrace: ensure speculation buffer cleaning does not race with buffer freeing
Kris Van Hees [Thu, 17 Oct 2013 09:44:20 +0000 (05:44 -0400)]
dtrace: ensure speculation buffer cleaning does not race with buffer freeing

Orabug: 17553446

Signed-off-by: Kris Van Hees <kris.van.hees@oracle.com>
11 years agodtrace: reject enabling is referencing module fails and do not count it
Kris Van Hees [Thu, 17 Oct 2013 09:42:04 +0000 (05:42 -0400)]
dtrace: reject enabling is referencing module fails and do not count it

Signed-off-by: Kris Van Hees <kris.van.hees@oracle.com>
11 years agodtrace: ensure state is free'd after use (memleak fix)
Kris Van Hees [Thu, 17 Oct 2013 09:41:37 +0000 (05:41 -0400)]
dtrace: ensure state is free'd after use (memleak fix)

Signed-off-by: Kris Van Hees <kris.van.hees@oracle.com>
11 years agodtrace: align module code with new cyclics API
Kris Van Hees [Thu, 17 Oct 2013 09:40:47 +0000 (05:40 -0400)]
dtrace: align module code with new cyclics API

Orabug: 17553446

Signed-off-by: Kris Van Hees <kris.van.hees@oracle.com>
11 years agodtrace: update getufpstack implementation to be safer
Kris Van Hees [Thu, 10 Oct 2013 20:17:13 +0000 (16:17 -0400)]
dtrace: update getufpstack implementation to be safer

The dtrace_getufpstack() function was a death trap when called for cases where
current happened to be in a transitional state (no mm) or a kthread.  It was
also using find_vma() when that was not quite necessary.  Finally, it was not
correctly using the saved stack pointer from userspace correctly (in one place
it used old_rsp as appropriate, but in another p->thread.usersp).  The code
has been rewritten to make use of the fact that the only valid stack addresses
that can be in use when this function is called must appear between the current
stack pointer position (old_rsp) and the bottom of the stack (mm->start_stack).
Therefore, no vma is necessary anymore.

The new implementation also ensures that when there is no mm, or we're dealing
with a kthread, the resulting data is still formatted correctly, i.e. with a
PID in the first slot, and zeros in all other slots.

This commit effectively builds on top of the fix applied by Nick Alcock.

Orabug: 17591351

Signed-off-by: Kris Van Hees <kris.van.hees@oracle.com>
11 years agodtrace: armour ustack() against kernel threads, !task->mm, and corrupt usersp.
Nick Alcock [Thu, 10 Oct 2013 23:32:25 +0000 (00:32 +0100)]
dtrace: armour ustack() against kernel threads, !task->mm, and corrupt usersp.

Kernel threads have no userspace stack, by definition: we should not assume they
do.  Further, tasks with no mm (whether because they are kernel threads or for
any other reason) should not be ustack()ed, nor tasks in which find_vma() cannot
find the vma corresponding to the usersp.  (Possible causes for this might be a
task which just smashed its own userspace sp or a task which is in the middle of
exiting or exec()ing.)

Orabug: 17591351

Signed-off-by: Nick Alcock <nick.alcock@oracle.com>
11 years agodtrace: Ensure that provider names are unique in the context of a PID
Kris Van Hees [Mon, 30 Sep 2013 13:19:20 +0000 (09:19 -0400)]
dtrace: Ensure that provider names are unique in the context of a PID

Orabug: 17476663

Signed-off-by: Kris Van Hees <kris.van.hees@oracle.com>
11 years agodtrace: ensure &tp->ftt_mtp is set to 0s for is-enabled probes also
Kris Van Hees [Sun, 22 Sep 2013 22:03:36 +0000 (18:03 -0400)]
dtrace: ensure &tp->ftt_mtp is set to 0s for is-enabled probes also

Signed-off-by: Kris Van Hees <kris.van.hees@oracle.com>
11 years agodtrace: Update NEWS
Kris Van Hees [Fri, 20 Sep 2013 14:00:57 +0000 (10:00 -0400)]
dtrace: Update NEWS

Signed-off-by: Kris Van Hees <kris.van.hees@oracle.com>
11 years agodtrace: Various memory allocation fixes (leaks, footprint reduction, ...)
Kris Van Hees [Fri, 20 Sep 2013 13:53:05 +0000 (09:53 -0400)]
dtrace: Various memory allocation fixes (leaks, footprint reduction, ...)

Orabug: 17488207

Signed-off-by: Kris Van Hees <kris.van.hees@oracle.com>
11 years agodtrace: UEK3 build -16
Kris Van Hees [Tue, 17 Sep 2013 12:11:47 +0000 (08:11 -0400)]
dtrace: UEK3 build -16

Signed-off-by: Kris Van Hees <kris.van.hees@oracle.com>
11 years agodtrace: prevent Oops caused by preemption issues with probes
Kris Van Hees [Fri, 13 Sep 2013 14:36:07 +0000 (10:36 -0400)]
dtrace: prevent Oops caused by preemption issues with probes

It was possible (specifically with direct-call probes) for the execution of
actions (using the DIF emulator) to get preempted, causing interesting side
effects because dtrace_probe() (and the functions it calls) are designed to
run on a specific CPU without any interruption especially not from another
call to dtrace_probe()).  Since the UEK3 kernel uses voluntary preemption,
the behaviour was not as expected and explicit preemption protection had to
be added to resolve this.

Orabug: 17403196
Signed-off-by: Kris Van Hees <kris.van.hees@oracle.com>
11 years agodtrace: fix for psinfo allocation during execve
Kris Van Hees [Fri, 13 Sep 2013 14:33:41 +0000 (10:33 -0400)]
dtrace: fix for psinfo allocation during execve

Allocate the psinfo structure from a slab (alike other structures related to
the task_struct), and use kmalloc() for the argv and envp members (with size
limit to avoid allocation issues).

Orabug: 17407069
Signed-off-by: Kris Van Hees <kris.van.hees@oracle.com>
11 years agodtrace: General cleanup of debug info and fix syscall probe module name.
Kris Van Hees [Fri, 13 Sep 2013 14:11:59 +0000 (10:11 -0400)]
dtrace: General cleanup of debug info and fix syscall probe module name.

Signed-off-by: Kris Van Hees <kris.van.hees@oracle.com>
11 years agodtrace: fixes for the module build
Kris Van Hees [Thu, 5 Sep 2013 21:23:16 +0000 (17:23 -0400)]
dtrace: fixes for the module build

Signed-off-by: Kris Van Hees <kris.van.hees@oracle.com>
11 years agodtrace: remove debugging code
Kris Van Hees [Thu, 5 Sep 2013 21:12:50 +0000 (17:12 -0400)]
dtrace: remove debugging code

Signed-off-by: Kris Van Hees <kris.van.hees@oracle.com>
11 years agodtrace: Ensure that USDT probes are carried over correctly across fork().
Kris Van Hees [Thu, 29 Aug 2013 22:07:21 +0000 (18:07 -0400)]
dtrace: Ensure that USDT probes are carried over correctly across fork().

When a process forks, its child will have a copy of the address space of the
parent, and therefore any enabled USDT probes from the parent will also fire
for the child.  In order for those probe firings to be valid, the child must
have its own pid-specific providers (created by duplicating the parent's
providers).

This commit also adds some additional cleanup.

Orabug: 17346878

Signed-off-by: Kris Van Hees <kris.van.hees@oracle.com>
11 years agodtrace: Fix frame offsets for direct called probes (ERROR and syscalls).
Kris Van Hees [Wed, 28 Aug 2013 22:19:59 +0000 (18:19 -0400)]
dtrace: Fix frame offsets for direct called probes (ERROR and syscalls).

Orabug: 17368166

Signed-off-by: Kris Van Hees <kris.van.hees@oracle.com>
11 years agodtrace: fix retrieval of arg5 through arg9
Kris Van Hees [Tue, 27 Aug 2013 19:49:50 +0000 (15:49 -0400)]
dtrace: fix retrieval of arg5 through arg9

Fix the retrieval of arguments passed on the stack for SDT, USDT, and direct
call probes.  This commit also adds trivial support for testcases related to
this fix.

Orabug: 17368166

Signed-off-by: Kris Van Hees <kris.van.hees@oracle.com>
11 years agoBug fix for logic to determine the (inode, offset) pair for uprobes.
Kris Van Hees [Wed, 14 Aug 2013 12:44:01 +0000 (08:44 -0400)]
Bug fix for logic to determine the (inode, offset) pair for uprobes.

The logic used to determine the (inode, offset) pair needed by uprobes, and
caculated based on an address in a process memory space. was flawed.  This
caused USDT probes in shared libraries to not work correctly.

Signed-off-by: Kris Van Hees <kris.van.hees@oracle.com>
11 years agoEnsure memory allocation results are checked throughout the code.
Kris Van Hees [Mon, 12 Aug 2013 09:27:40 +0000 (05:27 -0400)]
Ensure memory allocation results are checked throughout the code.

Signed-off-by: Kris Van Hees <kris.van.hees@oracle.com>
11 years agoBug fix for fasttrap module unloading.
Kris Van Hees [Wed, 7 Aug 2013 20:09:27 +0000 (16:09 -0400)]
Bug fix for fasttrap module unloading.

Various scenarios have been uncovered where unloading of the fasttrap module
would result in an assertion failure.

Essentially, what is going on is that an executable may register providers
for USDT probes (i.e. pass a DOF object to DTrace through the helper interface)
while there isn't any consumer active.  Any attempt to remove the fasttrap
provider at this point in time causes an assertion failure on the reference
count for all providers instantiated by the the meta-provider (fasttrap),
because module removal cannot be stopped once it has been initiated.

The solution is to take a reference on the meta-provider module whenever a new
provider is instantiated in it, and to put the reference back when that
provider is retired (removed from use).  I.e. the module will be listed as in
use as long as there are providers associated with it.

Signed-off-by: Kris Van Hees <kris.van.hees@oracle.com>
11 years agoRemove pre-alpha features for release.
Kris Van Hees [Wed, 24 Jul 2013 07:31:51 +0000 (03:31 -0400)]
Remove pre-alpha features for release.

Signed-off-by: Kris Van Hees <kris.van.hees@oracle.com>
11 years agoBug fix for module unloading.
Kris Van Hees [Wed, 7 Aug 2013 07:44:08 +0000 (03:44 -0400)]
Bug fix for module unloading.

Once a consumer has opened the /dev/dtrace/dtrace device file, providers can
no longer be safely unloaded, until the last consumer closed the device file.
This commit adds code to ensure this behaviour.  Failing to do so results in
almost certain OOPSes because Linux does not support kernel modules "refusing"
to be unloaded in response to an rmmod.

Signed-off-by: Kris Van Hees <kris.van.hees@oracle.com>
11 years agoFix fasttrap ioctls and headers_check.
Nick Alcock [Wed, 31 Jul 2013 19:01:52 +0000 (20:01 +0100)]
Fix fasttrap ioctls and headers_check.

These were being included before their structure definitions, leading to the
possibility of wrong values for FASTTRAPIOC_*.

Instead, split the FASTTRAPIOC* definitions into a new header, fasttrap_ioctl.h:
this includes fasttrap.h to get the structure definitions, and is also included
by it, so that either header can be included to get the ioctl definitions. We
then extend "make headers_check" so that it does the extended ioctl checks on
all headers named *ioctl.h, not just ioctl.h. (These checks are quite grotesque:
we don't want to run them on every DTrace uapi header if that can be avoided.)

Signed-off-by: Nick Alcock <nick.alcock@oracle.com>
11 years agoRe-enable DTrace ioctl()-size debugging.
Nick Alcock [Wed, 31 Jul 2013 15:17:30 +0000 (16:17 +0100)]
Re-enable DTrace ioctl()-size debugging.

We move the shared user/kernel ioctl-debugging function to a new
<linux/dtrace/ioctl_debug.h> header, to avoid problems with other
<linux/dtrace/ioctl.h> users.

Signed-off-by: Nick Alcock <nick.alcock@oracle.com>
12 years agoAdd RPM changelog.
Nick Alcock [Thu, 25 Jul 2013 17:52:57 +0000 (18:52 +0100)]
Add RPM changelog.

Allow specification of build_kver to override the kver at RPM build time,
as with variant and build_variant.

Signed-off-by: Nick Alcock <nick.alcock@oracle.com>
12 years agoAdd a warning to be displayed when tracepoint enabling fails. Update NEWS.
Kris Van Hees [Tue, 23 Jul 2013 21:30:31 +0000 (17:30 -0400)]
Add a warning to be displayed when tracepoint enabling fails.  Update NEWS.

Signed-off-by: Kris Van Hees <kris.van.hees@oracle.com>
12 years agoFix provider header requirements.
Nick Alcock [Tue, 23 Jul 2013 18:54:32 +0000 (19:54 +0100)]
Fix provider header requirements.

This should depend on dtrace-modules-headers with a version equal to the dtrace
kernel interface, not on dtrace-modules-headers-%{kver}, which doesn't exist.

Signed-off-by: Nick Alcock <nick.alcock@oracle.com>
12 years agoSPEC: Changes for UEK merge.
Nick Alcock [Tue, 23 Jul 2013 12:32:19 +0000 (13:32 +0100)]
SPEC: Changes for UEK merge.

Boost the associated kernel version to 3.8.13-1.  Kernel package
is now named kernel-uek, not kernel-uek-dtrace, unless the build_variant
is defined to specify a different name.  Reintroduce merging of
config-dtrace into .config.  Revert unnecessary changes from upstream
UEK specfile, in preparation for merge (e.g. forced building of firmware).

Signed-off-by: Nick Alcock <nick.alcock@oracle.com>
12 years agoBoost ustackframes_default.
Nick Alcock [Mon, 22 Jul 2013 23:43:23 +0000 (00:43 +0100)]
Boost ustackframes_default.

The incidence of false positives in ustack scanning is quite high,
so a substantial number of frames are needed for quite short actual
call stacks in userspace.

So boost the default to 100 for now.

Signed-off-by: Nick Alcock <nick.alcock@oracle.com>
12 years agoMake old_rsp available to kernel modules.
Kris Van Hees [Mon, 22 Jul 2013 12:19:29 +0000 (08:19 -0400)]
Make old_rsp available to kernel modules.

In order to get access to the RSP value during system call and trap processing,
code needs access to the old_rsp per-cpu variable.  Since we use this from a
kernel module, it needs to be exported (it is only accessible through macros -
there isn't an accessor function exported anywhere for it).

Signed-off-by: Kris Van Hees <kris.van.hees@oracle.com>
12 years agoRemove unnecessary 32-bit code.
Kris Van Hees [Fri, 19 Jul 2013 22:17:57 +0000 (18:17 -0400)]
Remove unnecessary 32-bit code.

Since DTrace for Linux is only being developed for 64-bit platforms, various
pieces of conditional-controlled code can be removed because they only apply
for 32-bit DTrace implementations.  Note that this does not have anything to
do with (future) support for 32-bit applications runnings and being traced on
a 64-bit host.

Signed-off-by: Kris Van Hees <kris.van.hees@oracle.com>
12 years agoClean up ioctl debugging output, and remove dtrace_ioctl_sizes().
Kris Van Hees [Fri, 19 Jul 2013 22:15:48 +0000 (18:15 -0400)]
Clean up ioctl debugging output, and remove dtrace_ioctl_sizes().

The debugging messages printed for ioctl code were not clear enough.  This has
been rectified.

The dtrace_ioctl_sizes() function and call to it were removed from the code
because the function defined in ioctl.h was causing interference with the
compilation of userspace tools.

Signed-off-by: Kris Van Hees <kris.van.hees@oracle.com>
12 years agoAdd debugging for enablings.
Kris Van Hees [Fri, 19 Jul 2013 22:14:06 +0000 (18:14 -0400)]
Add debugging for enablings.

Added dt_dbg_enable() to support adding debugging statements in the handling
of enablings.

Signed-off-by: Kris Van Hees <kris.van.hees@oracle.com>
12 years agoEnsure that the fasttrap device file can be opened.
Kris Van Hees [Fri, 19 Jul 2013 21:58:43 +0000 (17:58 -0400)]
Ensure that the fasttrap device file can be opened.

The DTrace utility tries to open the fasttrap provider device file when USDT
probes are being used, and due to the open function returning -EAGAIN, the
DTrace utility would report that the pid provider is unavailable because the
resource is temporarily unavailable.  The function now correctly returns 0.

Signed-off-by: Kris Van Hees <kris.van.hees@oracle.com>
12 years agoFix format string errors in buffer storage debugging messages.
Nick Alcock [Thu, 20 Jun 2013 15:28:33 +0000 (16:28 +0100)]
Fix format string errors in buffer storage debugging messages.

Signed-off-by: Nick Alcock <nick.alcock@oracle.com>
12 years agoDrop stack debugging messages.
Nick Alcock [Thu, 20 Jun 2013 15:27:17 +0000 (16:27 +0100)]
Drop stack debugging messages.

We don't need these any more, we know ustack()'s kernel side works.

Signed-off-by: Nick Alcock <nick.alcock@oracle.com>
12 years agoSPEC: Fix the name of the kernel development package in BuildRequires.
Nick Alcock [Thu, 6 Jun 2013 16:53:46 +0000 (17:53 +0100)]
SPEC: Fix the name of the kernel development package in BuildRequires.

We flipped it to kernel-uek-devel, but now (after fixing the package name)
it is called kernel-uek-dtrace-devel again.

Signed-off-by: Nick Alcock <nick.alcock@oracle.com>
12 years agoSPEC: Boost the associated kernel version to 3.8.12.
Nick Alcock [Thu, 6 Jun 2013 16:08:50 +0000 (17:08 +0100)]
SPEC: Boost the associated kernel version to 3.8.12.

Signed-off-by: Nick Alcock <nick.alcock@oracle.com>
12 years agoEnsure that arg6 through arg9 get retrieved correctly for USDT probes.
Kris Van Hees [Fri, 31 May 2013 06:48:37 +0000 (02:48 -0400)]
Ensure that arg6 through arg9 get retrieved correctly for USDT probes.

A bug in the implementation of retrieving arguments from the stack caused
bogus values to be returned for arg6 through arg9 on x86_64.  This has been
resolved.

This commit also removes various debugging output that is no longer needed.

Signed-off-by: Kris Van Hees <kris.van.hees@oracle.com>
12 years agoFinish the implementation of is-enabled USDT probes.
Kris Van Hees [Thu, 23 May 2013 14:52:00 +0000 (10:52 -0400)]
Finish the implementation of is-enabled USDT probes.

This commit completes the implementation of is-enabled USDT probes, i.e. probes
that when fired cause an execution flow change.  This makes it possible (when
using USDT) to encode more complex code sections that are only executed if a
specific USDT probe has been enabled, i.e. when a consumer is listening for
s specific USDT probe.  This is most commonly used for cases where a USDT probe
might require additional computation for one or more of its arguments, and so
it would be too expensive to always do that computation, whether the probe is
enabled or not.  With is-enabled probes, the overhead when DTrace is not used
is negligible (2 NOPs), and when DTrace is in use but the guarded probe is not
enabled, the cost is a single probe firing (without calling dtrace_probe()).

Signed-off-by: Kris Van Hees <kris.van.hees@oracle.com>
12 years agoFixes for tracepoint cleanup.
Kris Van Hees [Wed, 22 May 2013 23:25:48 +0000 (19:25 -0400)]
Fixes for tracepoint cleanup.

Various fixes to handle tracepoint cleanup.  It is important to note that it is
most common that USDT providers will be cleaned up (asynchronously) when the
process/task they relate to is already gone.  We therefore cannot use a (pid,
addr) pair to identify the tracepoint for removal.  The new implementation
stores the (inode, offset) pair calculated right before registering the uprobe,
so that we can use that same pair again when unregistering.

Signed-off-by: Kris Van Hees <kris.van.hees@oracle.com>
12 years agoFixes for locking issues and cleanup workqueue handling.
Kris Van Hees [Wed, 22 May 2013 07:48:44 +0000 (03:48 -0400)]
Fixes for locking issues and cleanup workqueue handling.

Signed-off-by: Kris Van Hees <kris.van.hees@oracle.com>
12 years agoUpdate syscall tracing in view of Linux 3.8 changes.
Kris Van Hees [Tue, 21 May 2013 06:48:39 +0000 (02:48 -0400)]
Update syscall tracing in view of Linux 3.8 changes.

The handling of various stub-based syscalls in Linux 3.8 changed to no longer
use the saved registers directly.  This change is now also reflected in the
DTrace overrides for those system calls.

Also reset the compilatio debug settings to all-off (they should only be
turned on in local compilations - never in the repo.)

Signed-off-by: Kris Van Hees <kris.van.hees@oracle.com>
12 years agoUSDT implementation (phase 2).
Kris Van Hees [Mon, 20 May 2013 20:46:58 +0000 (16:46 -0400)]
USDT implementation (phase 2).

This commit contains the 2nd phase of the USDT implementation for DTrace for
Linux.  It provides the mechanics of fasttrap probes (enabling, firing, and
disabling).  It also contains various debugging statements that will be cleaned
up in a future commit.  They exist right now, because this commit represents a
work in progress that is known to contain various bugs and loose ends.  The
commit for this code is provided as a "sharing of the pain" , and to ensure
that others can start playing with this code and test the interaction with
userspace.

Signed-off-by: Kris Van Hees <kris.van.hees@oracle.com>
12 years agoFix to exclude stack addresses from pcstack.
Kris Van Hees [Thu, 2 May 2013 19:24:22 +0000 (15:24 -0400)]
Fix to exclude stack addresses from pcstack.

Because the stack is considered executable memory, addresses on the stack that
point back into the stack were considered potential return address addresses,
and therefore they were (incorrectly) included in the pcstack output.

Signed-off-by: Kris Van Hees <kris.van.hees@oracle.com>
12 years agoRevamp and split up DTrace headers. Add ioctl() debugging machinery.
Nick Alcock [Mon, 29 Apr 2013 12:57:15 +0000 (13:57 +0100)]
Revamp and split up DTrace headers.  Add ioctl() debugging machinery.

It has always been annoying that we have a duplicate set of DTrace headers
in userspace, and further annoying that the DTrace header we have is such a
monolithic monster.

This fixes both of these, at the cost of a (very) little extra complexity when
maintaining the headers.  It also adds automated machinery to verify that each
of the new headers is 'standalone enough'.

What does 'standalone enough' mean?  This is the problem that has stopped us
sharing DTrace headers between userspace and kernelspace for a long time: they
depend on types that come from different places and have different definitions
in the kernel and in userspace, and can never be made to come from the same
place.

So we fix this by dictating that the headers are standalone *given* that certain
headers are included first.  For userspace, this set is <sys/types.h>,
<ctf/types.h>, and <unistd.h>; for kernelspace, the set is <linux/types.h> and a
newly-introduced header included as <dtrace/types.h>.  We avoid exposing this
requirement to header users by arranging for the header included as "dtrace.h"
in kernelspace and as <sys/dtrace.h> to include the prerequisite headers, and
enough other headers that the users of those headers can keep using them exactly
as they did before.  (There is a single exception for dtrace/iocl.h: see below.)

Where have the headers gone? They have been split in two directions (and the
Kbuild machinery has been adjusted to have its include paths point at the
appropriate places).

All DTrace headers, even <linux/dtrace_cpu.h> in the global kernel tree, have
had 'defines headers' split out of them, named ${header}_defines.h.  These
headers contain all typedefs, enums and #defines which do not depend on
visibility into structure definitions declared in the main non-defines header,
and opaque forwardings for all structure definitions declared in that header.
This means that users can include the defines header if they only want opaque
use of structures and relevant constants.  (This has necessitated some
mechanical changes to the DTrace headers to convert uses of foo_t typedefs into
'struct foo' where necessary.  Not all uses have been converted: only those that
need to be).  An _defines header is always accompanied by a corresponding non
_defines header (even if it is just one #include), but the reverse is not true.

In addition to this split, the core dtrace.h header has been split into three
pieces:

 - dtrace/include/uapi/linux/dtrace/*.h contains the majority of the headers,
   split into _defines and further by section roughly corresponding with the
   comment-delimited sections in the original file.  The include paths have been
   set up so that these can be used via

   #include <linux/dtrace/blah.h>

   in both userspace and kernelspace.

   #include <linux/include/dtrace.h> includes all the headers in the same order
   as they were originally.

   These headers are installed in userspace and used by dtrace-util.  They
   should always contain a CDDL license header, and should not use any
   kernel-specific types (modulo those that userspace normally uses, such as
   those related to kernel-specific functionality such as ioctl()).  If you use
   a new kernel-specific type, please add a definition of it to
   uts/common/sys/dtrace_types.h in userspace too.

   The old dtrace_ioctl.h has been renamed to <linux/dtrace/ioctl.h> and
   moved in here too.  It has gained some extra machinery to help debug
   ioctl() type size conflicts.  If you call dtrace_ioctl_sizes(), then
   dtrace_size_dbg_print() (not defined here) is repeatedly called with
   two parameters, the name of each ioctl() type and the size of that type.
   Please keep this list up to date, it is useful!

   There is one unfortunate exception to the userspace-types rule here:
   ioctl.h needs types from <linux/dtrace_cpu_defines.h>, which is not
   even a userspace-installed header.  So userspace must provide a copy of
   this header with appropriate typedefs as well.  (This should probably
   be fixed in due course.)

   <linux/dtrace/universal.h> defines constants and types used by virtually
   everything in any way related to dtrace.

 - dtrace/include/dtrace/*.h contains headers that are not shared with
   userspace, included as <dtrace/blah.h>:

   - <dtrace/types.h>: this contains the kernel-side definitions of types
     used in the shared headers.  (It has not been 'gardened' in any way,
     so probably contains a lot of other types as well).  This header is
     installed into the same place as the shared userspace headers.  This
     header needs a bit of care maintaining, as not everything kernel-
     side is allowable in it: see below.

   - <dtrace/provider.h>: The provider API, and its corresponding
     <dtrace/provider_defines.h> defines header.  This includes <dtrace/types.h>
     itself, so should be standalone -- however, this has not been in any way
     tested yet, unlike for the userspace headers.  This header is also
     installed into the same place as the shared userspace headers.

   - <dtrace/dtrace_impl.h> and <dtrace/dtrace_impl_defines.h>.

     These headers contain definitions used only by the DTrace core, and are
     not installed anywhere.

Note that because of the rules regarding kernel-specific types in the UAPI
DTrace headers, a number of uses of CONFIG_64BIT and CONFIG_BIG_ENDIAN have been
reverted to their Solaris-era-and-userspace _LP64 and _LITTLE_ENDIAN forms;
<dtrace/types.h> translates between the two.  (We have also fixed up a
couple of places in core DTrace where the nonexistent _BIG_ENDIAN was used.)

There are several things called dtrace.h now, which might get confusing:

- dtrace.h at the top level is for the DTrace core and included providers
  alone.  Anything goes in here.  It is never installed anywhere, and not even
  standalone providers can see it.

- dtrace/include/uapi/linux/dtrace/dtrace.h is shared with userspace and with
  standalone providers, and needs to follow the same rules as all such shared
  headers.

We have two new packages, dtrace-modules-$kver-headers and
dtrace-modules-$kver-provider-headers; to make it easy for people to Require
them, they provide features named 'dtrace-modules-headers' and
'dtrace-modules-provider-headers' using the same incrementing API version number
as 'dtrace-kernel-interface' (both currently 1).  dtrace-modules-headers serves
much the same purpose as dtrace-kernel-interface, tracking changes in the
userspace/kernelspace API: the dtrace-modules-provider-headers version number
tracks changes in the DTrace core/provider API.

The top-level Makefile has acquired two new rules, headers_install and
headers_check.  The former is a simple emulation of the top-level
headers_install rule, and is used by the RPM build system.  The latter checks to
be sure that the userspace-side headers can be #included on their own
(modulo only <unistd.h> et al, as above), and that dtrace/ioctl.h has all its
types in scope with appropriate sizes, since if they aren't everything will
appear to work until userspace tries to invoke the ioctl() and gets an -ENOTTY
error.

The latter is particularly difficult, since the size-checking machinery only
works for kernelspace builds, and the headers_check build is userspace.  So that
machinery hacks up a sort of halfway-house to the kernel environment, enough to
do the ioctl() size checks but not enough to #include arbitrary kernel
headers (among other things, there are no CONFIG constants here).  This means
that changes to those kernel-side headers which are included by this
machinery (in particular dtrace/types.h, dtrace_os.h) need to include a
headers_check run to make sure that machinery hasn't broken.  In general,
surrounding suspect definitions with an #ifndef HEADERS_CHECK should suffice:
nearly all of dtrace_os.h is so surrounded (and if we ever move dtrace_id_t out
into the shared headers, as perhaps we should, this problem will become less
serious).  (Feel free to make the headers_check dtrace/ioctl.h compilation
environment more like that used for the real kernel.)

Signed-off-by: Nick Alcock <nick.alcock@oracle.com>
12 years agoOS/arch specific ustack implementation.
Kris Van Hees [Fri, 26 Apr 2013 06:09:26 +0000 (02:09 -0400)]
OS/arch specific ustack implementation.

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>
12 years agoEnsure PID is passed as first element for ustack.
Kris Van Hees [Tue, 23 Apr 2013 08:08:25 +0000 (04:08 -0400)]
Ensure PID is passed as first element for ustack.

Code that uses getupcstack and getufpstack expects to see the PID of the
associated process in the first slot of the program counter array.

Signed-off-by: Kris Van Hees <kris.van.hees@oracle.com>
12 years agoRevert "stack() / jstack(): Send PID to userspace."
Kris Van Hees [Wed, 10 Apr 2013 08:40:53 +0000 (04:40 -0400)]
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>
12 years agostack() / jstack(): Send PID to userspace.
Nick Alcock [Thu, 28 Mar 2013 20:46:09 +0000 (20:46 +0000)]
stack() / jstack(): Send PID to userspace.

The stack() and jstack() actions expect the buffer to begin with the PID under
investigation, rather than just being a stream of addresses, as now.

Adjust the buffer size and contents accordingly.

Signed-off-by: Nick Alcock <nick.alcock@oracle.com>
12 years agoAdding more compile time debugging for development.
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>
12 years agoUSDT implementation (Phase 1).
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>
12 years agoAdd basic development debugging framework.
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>
12 years agoUpdate copyright statements.
Kris Van Hees [Wed, 23 Jan 2013 09:37:30 +0000 (04:37 -0500)]
Update copyright statements.

Various updates were made to files in the past months, and copyright statements
were never updated to reflect that.

Signed-off-by: Kris Van Hees <kris.van.hees@oracle.com>
12 years agoDisable providers that do not work.
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>
12 years agoDifferentiate between multi-providers and meta-providers.
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>
12 years agoAdding missing build specs for dt_perf.
Kris Van Hees [Fri, 26 Oct 2012 13:32:44 +0000 (09:32 -0400)]
Adding missing build specs for dt_perf.

Signed-off-by: Kris Van Hees <kris.van.hees@oracle.com>
12 years agoRemove unnecessary and inconsistemt use of argument name in prototypes.
Kris Van Hees [Mon, 22 Oct 2012 08:48:01 +0000 (04:48 -0400)]
Remove unnecessary and inconsistemt use of argument name in prototypes.

Signed-off-by: Kris Van Hees <kris.van.hees@oracle.com>
12 years agoClean up a file that is no longer used.
Kris Van Hees [Fri, 19 Oct 2012 09:12:48 +0000 (05:12 -0400)]
Clean up a file that is no longer used.

Signed-off-by: Kris Van Hees <kris.van.hees@oracle.com>
12 years agoInternal performance measurement support code.
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>
12 years agoMiscellaneous 3.6 porting work.
Kris Van Hees [Thu, 18 Oct 2012 15:53:56 +0000 (16:53 +0100)]
Miscellaneous 3.6 porting work.

Missing headers, catering for header movement, the occasional missing
prototype, and changes in the way the syscall table is built.

Signed-off-by: Kris Van Hees <kris.van.hees@oracle.com>
12 years agoDTrace-independent CTF.
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>
12 years agoType and grammar fix.
Kris Van Hees [Wed, 19 Sep 2012 06:40:37 +0000 (02:40 -0400)]
Type and grammar fix.

Signed-off-by: Kris Van Hees <kris.van.hees@oracle.com>
12 years agoFix name of lwp-create and lwp-exit probes in SDT argument mappings.
Kris Van Hees [Tue, 18 Sep 2012 22:33:36 +0000 (18:33 -0400)]
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>
12 years agoAdd NEWS file.
Kris Van Hees [Tue, 18 Sep 2012 22:32:15 +0000 (18:32 -0400)]
Add NEWS file.

Added the NEWS file to the branch, and updated the spec file to ensure that
the NEWS file gets installed properly.

Signed-off-by: Kris Van Hees <kris.van.hees@oracle.com>
12 years agoSPEC: Rename the DTrace kernel to kernel-uek-dtrace-.
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>
12 years agoFix depmod invocation on RPM %post-installation.
Nick Alcock [Wed, 12 Sep 2012 21:53:27 +0000 (22:53 +0100)]
Fix depmod invocation on RPM %post-installation.

The kernel module directory name includes the karch, so our depmod invocation
should as well.

Signed-off-by: Nick Alcock <nick.alcock@oracle.com>
12 years agoAdd a specfile.
Nick Alcock [Mon, 10 Sep 2012 19:38:52 +0000 (20:38 +0100)]
Add a specfile.

No changelog for this release yet.

Signed-off-by: Nick Alcock <nick.alcock@oracle.com>
12 years agoAdditional action support (and bug fixes).
Kris Van Hees [Sun, 9 Sep 2012 21:34:48 +0000 (17:34 -0400)]
Additional action support (and bug fixes).

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>