345869 |
04-Apr-2019 |
markj |
MFC r345359, r345384: Don't attempt to measure TSC skew when running as a VM guest.
PR: 218452 |
315012 |
10-Mar-2017 |
markj |
MFC r313841, r313850: Prevent CPU migration when checking the DTrace nofault flag on x86. |
314667 |
04-Mar-2017 |
avg |
MFC r283291: don't use CALLOUT_MPSAFE with callout_init()
The main purpose of this MFC is to reduce conflicts for other merges. Parts of the original change have already "trickled down" via individual MFCs. |
300029 |
17-May-2016 |
avg |
MFC r298473,298787: add invpcid, fix sahf/lahf in dtrace disassembler |
299001 |
03-May-2016 |
markj |
MFC r297771: Initialize SDT probes during SI_SUB_DTRACE_PROVIDER. |
297077 |
20-Mar-2016 |
mav |
MFC r277300 (by smh): Mechanically convert cddl sun #ifdef's to illumos
Since the upstream for cddl code is now illumos not sun, mechanically convert all sun #ifdef's to illumos #ifdef's which have been used in all newer code for some time.
Also do a manual pass to correct the use if #ifdef comments as per style(9) as well as few uses of #if defined(__FreeBSD__) vs #ifndef illumos. |
294368 |
20-Jan-2016 |
jhb |
MFC 289769,289822,290143,290144: Rename remaining linux32 symbols from linux_* to linux32_*.
289769: Rename remaining linux32 symbols such as linux_sysent[] and linux_syscallnames[] from linux_* to linux32_* to avoid conflicts with linux64.ko. While here, add support for linux64 binaries to systrace. - Update NOPROTO entries in amd64/linux/syscalls.master to match the main table to fix systrace build. - Add a special case for union l_semun arguments to the systrace generation. - The systrace_linux32 module now only builds the systrace_linux32.ko. module on amd64. - Add a new systrace_linux module that builds on both i386 and amd64. For i386 it builds the existing systrace_linux.ko. For amd64 it builds a systrace_linux.ko for 64-bit binaries.
289822: Fix build for the KTR-enabled kernels.
290143: Fix build with DEBUG defined.
290144: Update for LINUX32 rename. The assembler didn't complain about undefined symbols but just used 0 after the rename. |
289809 |
23-Oct-2015 |
avg |
MFC r288363: std: it is important that func name is never an empty string |
289803 |
23-Oct-2015 |
avg |
MFC r288362: sdt: start checking version field when parsing probe definitions |
289791 |
23-Oct-2015 |
avg |
MFC r288365: sdt: static-ize couple of variables |
289788 |
23-Oct-2015 |
avg |
MFC r288364: sdt module does not seem to actually use any symbol from opensolaris module |
289786 |
23-Oct-2015 |
avg |
MFC r288361: dtrace_getarg: remove stray return statement on amd64, powerpc |
286396 |
07-Aug-2015 |
kib |
MFC r285643: When checking for the valid value of the frame pointer, verify that it belongs to the kernel stack address range for the thread. |
286305 |
05-Aug-2015 |
kib |
MFC r285041: Use single instance of the identical INKERNEL() and PMC_IN_KERNEL() macros on amd64 and i386. On i386, correct the lowest kernel address. |
285759 |
21-Jul-2015 |
markj |
MFC r285663, r285664, r285667: Ensure that locstat_nsecs() has no effect when lockstat probes are not enabled or when the profiled lock carries the LO_NOPROFILE flag.
PR: 201642, 201517 Approved by: re (gjb) Tested by: Jason Unovitch |
284136 |
07-Jun-2015 |
pfg |
MFC r278166, MFV r266993:
4469 DTrace helper tracing should be dynamic
Reference: https://illumos.org/issues/4469
Obtained from: Illumos Phabric: D1551 Reviewed by: markj |
283676 |
29-May-2015 |
markj |
MFC r281915: Make vpanic() externally visible.
MFC r281916: Fix DTrace's panic() action. |
282748 |
11-May-2015 |
avg |
MFC r275576: remove opensolaris cyclic code, replace with high-precision callouts |
281482 |
13-Apr-2015 |
markj |
MFC r280834: Bound the number of frames traversed when executing the ustackdepth action. |
273736 |
27-Oct-2014 |
hselasky |
MFC r263710, r273377, r273378, r273423 and r273455:
- De-vnet hash sizes and hash masks. - Fix multiple issues related to arguments passed to SYSCTL macros.
Sponsored by: Mellanox Technologies |
273110 |
14-Oct-2014 |
pfg |
MFC r267851:
Continue the crusade towards a dev_clone()-free kernel, removing its usage from dtrace. The dtrace code already uses cdevpriv(9) since FreeBSD 8, so this change is quite harmless.
Originally by: davide Reviewed by: markj |
270186 |
19-Aug-2014 |
grehan |
MFC r266103
Update dis_tables.c to the latest Illumos version.
This includes decodes of recent Intel instructions, in particular VT-x and related instructions. This allows the FBT provider to locate the exit points of routines that include these new instructions.
Illumos issues: 3414 Need a new word of AT_SUN_HWCAP bits 3415 Add isainfo support for f16c and rdrand 3416 Need disassembler support for rdrand and f16c 3413 isainfo -v overflows 80 columns 3417 mdb disassembler confuses rdtscp for invlpg 1518 dis should support AMD SVM/AMD-V/Pacifica instructions 1096 i386 disassembler should understand complex nops 1362 add kvmstat for monitoring of KVM statistics 1363 add vmregs[] variable to DTrace 1364 need disassembler support for VMX instructions 1365 mdb needs 16-bit disassembler support
This corresponds to Illumos-gate (github) version eb23829ff08a873c612ac45d191d559394b4b408 |
269557 |
05-Aug-2014 |
markj |
MFC r267759, r267761
r267759: Fix a couple of bugs on amd64 when fetching probe arguments beyond the first five for probes entered through a UD fault (i.e. FBT probes).
Specifically, handle the fact that dtrace_invop_callsite must be 16 byte-aligned and thus may not immediately follow the call to dtrace_invop() in dtrace_invop_start(). Also fetch register arguments and the stack pointer through a struct trapframe instead of a struct reg.
r267761: Fix some bugs when fetching probe arguments in i386. Firstly ensure that the 4 byte-aligned dtrace_invop_callsite can be found and that it immediately follows the call to dtrace_invop(). Secondly, fix some pointer arithmetic to account for differences between struct i386_frame and illumos' struct frame. Finally, ensure that dtrace_getarg() isn't inlined. It works by following a fixed number of frame pointers to the probe site, so inlining breaks it.
PR: 191260 |
269545 |
05-Aug-2014 |
markj |
MFC r267706: Allow creation of SDT probes from a module in which no providers are defined. This ensures that the sdt:zfs:: probes appear despite the fact the sdt provider is defined in the kernel rather than in zfs.ko. |
269531 |
04-Aug-2014 |
markj |
MFC r256822: When fetching function arguments out of a frame on amd64, explicitly select the register based on the argument index rather than relying on the fields in struct reg to be in the right order. This assumption is incorrect on FreeBSD and generally led to bogus argument values for the sixth argument of PID and USDT probes; the first five are passed directly to dtrace_probe() via the fasttrap trap handler and so were correctly handled. |
269520 |
04-Aug-2014 |
markj |
MFC r256571: Add a function, memstr, which can be used to convert a buffer of null-separated strings to a single string. This can be used to print the full arguments of a process using execsnoop (from the DTrace toolkit) or with the following one-liner:
dtrace -n 'syscall::execve:return {trace(curpsinfo->pr_psargs);}'
Note that this relies on the process arguments being cached via the struct proc, which means that it will not work for argvs longer than kern.ps_arg_cache_limit. However, the following rather non-portable script can be used to extract any argv at exec time:
fbt::kern_execve:entry { printf("%s", memstr(args[1]->begin_argv, ' ', args[1]->begin_envv - args[1]->begin_argv)); }
The debug.dtrace.memstr_max sysctl limits the maximum argument size to memstr(). |
269342 |
31-Jul-2014 |
markj |
MFC r264434: DTrace's pid provider works by inserting breakpoint instructions at probe sites and installing a hook at the kernel's trap handler. The fasttrap code will emulate the overwritten instruction in some common cases, but otherwise copies it out into some scratch space in the traced process' address space and ensures that it's executed after returning from the trap.
In Solaris and illumos, this (per-thread) scratch space comes from some reserved space in TLS, accessible via the fs segment register. This approach is somewhat unappealing on FreeBSD since it would require some modifications to rtld and jemalloc (for static TLS) to ensure that TLS is executable, and would thus introduce dependencies on their implementation details. I think it would also be impossible to safely trace static binaries compiled without these modifications.
This change implements the functionality in a different way, by having fasttrap map pages into the target process' address space on demand. Each page is divided into 64-byte chunks for use by individual threads, and fasttrap's process descriptor struct has been extended to keep track of any scratch space allocated for the corresponding process.
With this change it's possible to trace all libc functions in a program, e.g. with
pid$target:libc.so.*::entry {@[probefunc] = count();}
Previously this would generally cause the victim process to crash, as tracing memcpy on amd64 requires the functionality described above. |
269272 |
29-Jul-2014 |
markj |
MFC r264435: Ensure that all eight syscall arguments are available to dtrace_probe(), rather than just the first five. |
268578 |
12-Jul-2014 |
rpaulo |
MFC 267929, 267937, 267939, 267940, 267941, 267942, 267987, 268006:
2915 DTrace in a zone should see "cpu", "curpsinfo", et al 2916 DTrace in a zone should be able to access fds[] 2917 DTrace in a zone should have limited provider access 4477 DTrace should speak JSON Add stubs for CTF functions which are not yet implemented. 4474 DTrace Userland CTF Support 4475 DTrace userland Keyword 4476 DTrace tests should be better citizens 4479 pid provider types 4480 dof emulation is missing checks 4471 DTrace count() with histogram 4472 DTrace full width distribution histograms 4473 DTrace frequency trails |
266102 |
15-May-2014 |
markj |
MFC r262665: Expose a few DTrace parameters as sysctls under kern.dtrace and add descriptions for several existing sysctls.
PR: 187027 |
265277 |
03-May-2014 |
markj |
MFC r262543: Fix the struct reg mappings for i386 and amd64, which differ between illumos and FreeBSD. |
265273 |
03-May-2014 |
markj |
MFC r262542: Move some files that are identical on i386 and amd64 to an x86 subdirectory rather than keeping duplicate copies. |
262054 |
17-Feb-2014 |
avg |
MFC r260132: Allocate the probe ID unrhdr before the DTrace kld_* event handlers are registered |
262042 |
17-Feb-2014 |
avg |
MFC r257417: Remove references to an unused fasttrap probe hook |
262040 |
17-Feb-2014 |
avg |
MFC r257152: Do some cleanup of the SDT code |
260817 |
17-Jan-2014 |
avg |
MFC r258622: dtrace sdt: remove the ugly sname parameter of SDT_PROBE_DEFINE |
260670 |
15-Jan-2014 |
jhibbits |
MFC r256543,r259245,r259421,r259668,r259674
r256543:
Add fasttrap for PowerPC. This is the last piece of the DTrace/ppc puzzle. It's incomplete, it doesn't contain full instruction emulation, but it should be sufficient for most cases.
r259245,r259421: (FBT)
FBT now does work fully on PowerPC.
Save r3 before using it for the trap check, else we end up saving the new r3, containing the trap instruction encoding (0x7c810808), and restoring it back with the frame on return. This caused it to panic on my ppc32 machine.
r259668,r259674: Fix a typo in the FBT code. |
256281 |
10-Oct-2013 |
gjb |
Copy head (r256279) to stable/10 as part of the 10.0-RELEASE cycle.
Approved by: re (implicit) Sponsored by: The FreeBSD Foundation
|
256148 |
08-Oct-2013 |
markj |
Initialize and free the DTrace taskqueue in the dtrace module load/unload handlers rather than in the dtrace device open/close methods. The current approach can cause a panic if the device is closed which the taskqueue thread is active, or if a kernel module containing a provider is unloaded while retained enablings are present and the dtrace device isn't opened.
Submitted by: gibbs (original version) Reviewed by: gibbs Approved by: re (glebius) MFC after: 2 weeks
|
255359 |
07-Sep-2013 |
davide |
- Use make_dev_credf(MAKEDEV_REF) instead of the race-prone make_dev()+ dev_ref() in the clone handlers that still use it. - Don't set SI_CHEAPCLONE flag, it's not used anywhere neither in devfs (for anything real)
Reviewed by: kib
|
255161 |
02-Sep-2013 |
jhibbits |
Whitespace cleanup.
|
255099 |
31-Aug-2013 |
jhibbits |
Fixes for DTrace on PowerPC:
- Implement dtrace_getarg() - Sync fbt with x86, and fix a typo. - Pull in the time synchronization code from amd64.
|
254813 |
24-Aug-2013 |
markj |
Rename the kld_unload event handler to kld_unload_try, and add a new kld_unload event handler which gets invoked after a linker file has been successfully unloaded. The kld_unload and kld_load event handlers are now invoked with the shared linker lock held, while kld_unload_try is invoked with the lock exclusively held.
Convert hwpmc(4) to use these event handlers instead of having kern_kldload() and kern_kldunload() invoke hwpmc(4) hooks whenever files are loaded or unloaded. This has no functional effect, but simplifes the linker code somewhat.
Reviewed by: jhb
|
254713 |
23-Aug-2013 |
avg |
fbt: drop a local write-only variable
Discovered with: gcc46 MFC after: 4 days
|
254634 |
22-Aug-2013 |
jhibbits |
Make dtrace_copy() actually work on PowerPC. Although unused currently, it may be used in the future by dtrace.
|
254509 |
19-Aug-2013 |
jhibbits |
Fix some ppc64 dtrace bugs, and enable systrace_freebsd32 for ppc64.
|
254468 |
17-Aug-2013 |
markj |
Add a "translated type" argument to SDT_PROBE_ARGTYPE() and add some macros which allow one to define SDT probes that specify translated types. The idea is to make it easy to write SDT probe definitions that can work across multiple operating systems. In particular, this makes it possible to port illumos SDT probes to FreeBSD without changing their argument types, so long as the appropriate translators are defined. Then DTrace scripts written for Solaris/illumos will work on FreeBSD without any changes.
MFC after: 1 week
|
254309 |
14-Aug-2013 |
markj |
Use kld_{load,unload} instead of mod_{load,unload} for the linker file load and unload event handlers added in r254266.
Reported by: jhb X-MFC with: r254266
|
254268 |
13-Aug-2013 |
markj |
FreeBSD's DTrace implementation has a few problems with respect to handling probes declared in a kernel module when that module is unloaded. In particular,
* Unloading a module with active SDT probes will cause a panic. [1] * A module's (FBT/SDT) probes aren't destroyed when the module is unloaded; trying to use them after the fact will generally cause a panic.
This change fixes both problems by porting the DTrace module load/unload handlers from illumos and registering them with the corresponding EVENTHANDLER(9) handlers. This allows the DTrace framework to destroy all probes defined in a module when that module is unloaded, and to prevent a module unload from proceeding if some of its probes are active. The latter problem has already been fixed for FBT probes by checking lf->nenabled in kern_kldunload(), but moving the check into the DTrace framework generalizes it to all kernel providers and also fixes a race in the current implementation (since a probe may be activated between the check and the call to linker_file_unload()).
Additionally, the SDT implementation has been reworked to define SDT providers/probes/argtypes in linker sets rather than using SYSINIT/SYSUNINIT to create and destroy SDT probes when a module is loaded or unloaded. This simplifies things quite a bit since it means that pretty much all of the SDT code can live in sdt.ko, and since it becomes easier to integrate SDT with the DTrace framework. Furthermore, this allows FreeBSD to be quite flexible in that SDT providers spanning multiple modules can be created on the fly when a module is loaded; at the moment it looks like illumos' SDT implementation requires all SDT probes to be statically defined in a single kernel table.
PR: 166927, 166926, 166928 Reported by: davide [1] Reviewed by: avg, trociny (earlier version) MFC after: 1 month
|
253996 |
06-Aug-2013 |
avg |
opensolaris code: translate INVARIANTS to DEBUG and ZFS_DEBUG
Do this by forcing inclusion of sys/cddl/compat/opensolaris/sys/debug_compat.h via -include option into all source files from OpenSolaris. Note that this -include option must always be after -include opt_global.h.
Additionally, remove forced definition of DEBUG for some modules and fix their build without DEBUG.
Also, meaning of DEBUG was overloaded to enable WITNESS support for some OpenSolaris (primarily ZFS) locks. Now this overloading is removed and that use of DEBUG is replaced with a new option OPENSOLARIS_WITNESS.
MFC after: 17 days
|
253772 |
29-Jul-2013 |
avg |
dtrace disassembler: take the latest/last CDDL code from OpenSolaris
OpenSolaris version is: 13108:33bb8a0301ab 6762020 Disassembly support for Intel Advanced Vector Extensions (AVX)
This corresponds to Illumos-gate (github) version ab47273fedff893c8ae22ec39ffc666d4fa6fc8b
MFC after: 3 weeks
|
252850 |
05-Jul-2013 |
markj |
Hide references to mod_lock. In FreeBSD it is always acquired with the provider lock held, so its use has no effect.
|
252325 |
28-Jun-2013 |
markj |
The dtmalloc provider uses the short description of a malloc type as the function name of its corresponding DTrace probes. These descriptions may contain whitespace, but probe names cannot, so just replace any whitespace with underscores when creating probes.
MFC after: 1 week
|
251238 |
02-Jun-2013 |
markj |
SDT probes can directly pass up to five arguments as arguments to dtrace_probe(). Arguments beyond these five must be obtained in an architecture-specific way; this can be done through the getargval provider method, and through dtrace_getarg() if getargval isn't overridden.
This change fixes two off-by-one bugs in the way these arguments are fetched in FreeBSD's DTrace implementation. First, the SDT provider must set the aframes parameter to 1 when creating a probe. The aframes parameter controls the number of frames that dtrace_getarg() will step over in order to find the frame containing the extra arguments. On FreeBSD, dtrace_getarg() is called in SDT probe context via
dtrace_probe()->dtrace_dif_emulate()->dtrace_dif_variable->dtrace_getarg()
so aframes must be 3 since the arguments are in dtrace_probe()'s frame; it was previously being called with a value of 2 instead. illumos uses a different aframes value for SDT probes, but this is because illumos SDT probes fire by triggering the #UD fault handler rather than calling dtrace_probe() directly.
The second bug has to do with the way arguments are grabbed out dtrace_probe()'s frame on amd64. The code currently jumps over the first stack argument and retrieves the rest of them using a pointer into the stack. This works on i386 because all of dtrace_probe()'s arguments will be on the stack and the first argument is the probe ID, which should be ignored. However, it is incorrect to ignore the first stack argument on amd64, so we correct the pointer used to access the arguments.
MFC after: 2 weeks
|
251237 |
02-Jun-2013 |
markj |
Port the SDT test now that it's possible to create SDT probes that take seven arguments.
The original test uses Solaris' uadmin system call to trigger the test probe; this change adds a sysctl to the dtrace_test module and gets the test program to trigger the test probe via the sysctl handler.
The test is currently failing on amd64 because of some bugs in the way that probe arguments beyond the first five are obtained - these bugs will be fixed in a separate change.
|
250574 |
12-May-2013 |
markj |
Bring back part of r249367 by adding DTrace's temporal option, which allows users to guarantee that the output of DTrace scripts will be time-ordered. This option is enabled by adding the line
#pragma D option temporal
to the beginning of a script, or by adding '-x temporal' to the arguments of dtrace(1).
This change fixes a bug in the original port of the temporal option. This bug was causing some assertions to fail, so they had been disabled; in this revision the assertions are working properly and are enabled.
The DTrace version number has been bumped from 1.9.0 to 1.9.1 to reflect the language change that's being introduced.
This change corresponds to part of illumos-gate commit e5803b76927480: 3021 option for time-ordered output from dtrace(1M)
Reviewed by: pfg Obtained from: illumos MFC after: 1 month
|
248642 |
23-Mar-2013 |
avg |
fbt_getargdesc: correctly handle types for return probes
MFC after: 6 days
|
248640 |
23-Mar-2013 |
avg |
fbt_typoff_init: fix an off by one in determining required memory size
This issue would be silent most of the time, but if the requested memory is a multiple of a page size, then accessing one element beyond the end would lead to a kernel page fault. Otherwise, the unlucky last type would just be inaccessible.
Reported by: glebius Tested by: glebius MFC after: 6 days
|
248457 |
18-Mar-2013 |
jhibbits |
Add FBT for PowerPC DTrace. Also, clean up the DTrace assembly code, much of which is not necessary for PowerPC.
The FBT module can likely be factored into 3 separate files: common, intel, and powerpc, rather than duplicating most of the code between the x86 and PowerPC flavors.
All DTrace modules for PowerPC will be MFC'd together once Fasttrap is completed.
|
246538 |
08-Feb-2013 |
pluknet |
Fix warning: comparison of unsigned expression < 0 is always false.
Reported by: clang
|
246275 |
03-Feb-2013 |
jhibbits |
Fix the PowerPC DTrace copy functions. The kernel doesn't hold the same view to the user map, so use the md copy in/out functions provided by the kernel.
MFC with: r242723
|
244631 |
23-Dec-2012 |
rstone |
Correct a series of errors in the hand-rolled locking for drace_debug.c:
- Use spinlock_enter()/spinlock_exit() to prevent a thread holding a debug lock from being preempted to prevent other threads waiting on that lock from starvation.
- Handle the possibility of CPU migration in between the fetch of curcpu and the call to spinlock_enter() by saving curcpu in a local variable.
- Use memory barriers to prevent reordering of loads and stores of the data protected by the lock outside of the critical section
- Eliminate false sharing of the locks by moving them into the structures that they protect and aligning them to a cacheline boundary.
- Record the owning thread in the lock to make debugging future problems easier.
Reviewed by: rpaulo (initial version) MFC after: 2 weeks
|
242723 |
07-Nov-2012 |
jhibbits |
Implement DTrace for PowerPC. This includes both 32-bit and 64-bit.
There is one known issue: Some probes will display an error message along the lines of: "Invalid address (0)"
I tested this with both a simple dtrace probe and dtruss on a few different binaries on 32-bit. I only compiled 64-bit, did not run it, but I don't expect problems without the modules loaded. Volunteers are welcome.
MFC after: 1 month
|
238552 |
17-Jul-2012 |
gnn |
Change UL to ULL since time is 32 bits.
Pointed out by: avg@ MFC after: 2 weeks
|
238537 |
16-Jul-2012 |
gnn |
Add support for walltimestamp in DTrace.
Submitted by: Fabian Keil MFC after: 2 weeks
|
238169 |
06-Jul-2012 |
avg |
r237748 continuation: fix nopw (0f 1f) behavior with respect to modifiers
To do: proper merge with Illumos vendor area.
Reported by: emaste Tested by: emaste Obtained from: Illumos commit 13442:4adbe6de60c8 MFC after: 5 days
|
238168 |
06-Jul-2012 |
avg |
r237748 continuation: segment-override prefixes are not invalid in long mode
Update DTrace disassembler accordingly. The code to treat the prefixes as null prefixes was already in place. Although in practice compilers seem to generate only cs-prefix for use in long NOPs, the same treatment is applied to all of cs, ds, es, ss for consistency.
Reported by: emaste Tested by: emaste Obtained from: Illumos commit 13442:4adbe6de60c8 (+ local changes) MFC after: 5 days
|
237748 |
29-Jun-2012 |
avg |
dtrace instruction decoder: add 0x0f 0x1f NOP opcode support
According to the AMD manual the whole range from 0x09 to 0x1f are NOPs. Intel manual mentions only 0x1f. Use only Intel one for now, it seems to be the one actually generated by compilers. Use gdb mnemonic for the operation: "nopw".
[1] AMD64 Architecture Programmer's Manual Volume 3: General-Purpose and System Instructions [2] Software Optimization Guide for AMD Family 10h Processors [3] Intel(R) 64 and IA-32 Architectures Software Developer’s Manual Volume 2 (2A, 2B & 2C): Instruction Set Reference, A-Z
Tested by: Fabian Keil <freebsd-listen@fabiankeil.de> (earlier version) MFC after: 3 days
|
236567 |
04-Jun-2012 |
gnn |
Integrate a fix for a very odd signal delivery problem found by Bryan Cantril and others in the Solaris/Illumos version of DTrace.
Obtained from: https://www.illumos.org/issues/789 MFC after: 2 weeks
|
236566 |
04-Jun-2012 |
zml |
Fix DTrace TSC skew calculation:
The skew calculation here is exactly backwards. We were able to repro it on a multi-package ESX server running a FreeBSD VM, where the TSCs can be pretty evil.
MFC after: 1 week
Submitted by: Jeff Ford <jeffrey.ford2@isilon.com> Reviewed by: avg, gnn
|
233552 |
27-Mar-2012 |
rstone |
Instead of only iterating over the set of known SDT probes when sdt.ko is loaded and unloaded, also have sdt.ko register callbacks with kern_sdt.c that will be called when a newly loaded KLD module adds more probes or a module with probes is unloaded.
This fixes two issues: first, if a module with SDT probes was loaded after sdt.ko was loaded, those new probes would not be available in DTrace. Second, if a module with SDT probes was unloaded while sdt.ko was loaded, the kernel would panic the next time DTrace had cause to try and do anything with the no-longer-existent probes.
This makes it possible to create SDT probes in KLD modules, although there are still two caveats: first, any SDT probes in a KLD module must be part of a DTrace provider that is defined in that module. At present DTrace only destroys probes when the provider is destroyed, so you can still panic the system if a KLD module creates new probes in a provider from a different module(including the kernel) and then unload the the first module.
Second, the system will panic if you unload a module containing SDT probes while there is an active D script that has enabled those probes.
MFC after: 1 month
|
233525 |
26-Mar-2012 |
gonzo |
- For o32 ABI get arguments from the stack - Clear CPU_DTRACE_FAULT flag in userland backtrace routine. It just means we hit wrong memory region and should stop.
|
233521 |
26-Mar-2012 |
gonzo |
Properly cast 64-bit dofhp_dof to pointer.
For i386 this change is no-op. For AMD64 it was tested with DTrace test suite: results are the same from the test run before the change and after
|
233484 |
26-Mar-2012 |
gonzo |
Use macroses to load/store pointers and increase indexes instead of hardcoded MIPS64 instructions
|
233409 |
24-Mar-2012 |
gonzo |
Add device part of DTrace/MIPS code
|
227441 |
11-Nov-2011 |
rstone |
Correct the types of the arguments to return probes of the syscall provider. Previously we were erroneously supplying the argument types of the corresponding entry probe.
Reviewed by: rpaulo MFC after: 1 week
|
227430 |
10-Nov-2011 |
rstone |
On i386, fbt probes are implemented by writing an invalid opcode over certain instructions in a function prologue or epilogue. DTrace has a hook into the invalid opcode fault handler that checks whether the fault was due to an probe and if so, runs the DTrace magic.
Upon returning from an invalid opcode fault caused by a probe, DTrace must emulate the instruction that was replaced with the invalid opcode and then return control to the instruction following the invalid opcode.
There were a pair of related bugs in the emulation for the leave instruction. The leave instruction is used to pop off a stack frame prior to returning from a function. The emulation for this instruction must move the trap frame for the invalid opcode fault down the stack to the bottom of the stack frame that is being removed, and then execute an iret.
At two points in this process, the emulation code was storing values above the current value of the stack pointer. This opened up a window in which if we were two take an interrupt, the trap frame for the interrupt would overwrite the values stored on the stack, causing the system to panic later.
The first bug was that at one point the emulation code saves the new value for $esp above the current stack pointer value. The fix is to save this value instead inside of the original trap frame. At this point we do not need the original trap frame so this is safe.
The second bug is that when the emulate code loads $esp from the stack, it points part-way through the new trap frame instead of at its beginning. The emulation code adjusts the stack pointer to the correct value immediately afterwards, but this still leaves a one instruction window in which an interrupt would corrupt this trap frame. Fix this by adjusting the stack frame value before loading it into $esp.
This fixes panics in invop_leave on i386 when using fbt return probes.
Reviewed by: rpaulo, attilio MFC after: 1 week
|
227293 |
07-Nov-2011 |
ed |
Mark MALLOC_DEFINEs static that have no corresponding MALLOC_DECLAREs.
This means that their use is restricted to a single C file.
|
226452 |
16-Oct-2011 |
marcel |
Define dtrace_cmpset_long in terms of atomic_cmpset_long and not by virtue of inline assembly. Now this file compiles on all supported architectures.
|
223758 |
04-Jul-2011 |
attilio |
With retirement of cpumask_t and usage of cpuset_t for representing a mask of CPUs, pc_other_cpus and pc_cpumask become highly inefficient.
Remove them and replace their usage with custom pc_cpuid magic (as, atm, pc_cpumask can be easilly represented by (1 << pc_cpuid) and pc_other_cpus by (all_cpus & ~(1 << pc_cpuid))).
This change is not targeted for MFC because of struct pcpu members removal and dependency by cpumask_t retirement.
MD review by: marcel, marius, alc Tested by: pluknet MD testing by: marcel, marius, gonzo, andreast
|
222813 |
07-Jun-2011 |
attilio |
etire the cpumask_t type and replace it with cpuset_t usage.
This is intended to fix the bug where cpu mask objects are capped to 32. MAXCPU, then, can now arbitrarely bumped to whatever value. Anyway, as long as several structures in the kernel are statically allocated and sized as MAXCPU, it is suggested to keep it as low as possible for the time being.
Technical notes on this commit itself: - More functions to handle with cpuset_t objects are introduced. The most notable are cpusetobj_ffs() (which calculates a ffs(3) for a cpuset_t object), cpusetobj_strprint() (which prepares a string representing a cpuset_t object) and cpusetobj_strscan() (which creates a valid cpuset_t starting from a string representation). - pc_cpumask and pc_other_cpus are target to be removed soon. With the moving from cpumask_t to cpuset_t they are now inefficient and not really useful. Anyway, for the time being, please note that access to pcpu datas is protected by sched_pin() in order to avoid migrating the CPU while reading more than one (possible) word - Please note that size of cpuset_t objects may differ between kernel and userland. While this is not directly related to the patch itself, it is good to understand that concept and possibly use the patch as a reference on how to deal with cpuset_t objects in userland, when accessing kernland members. - KTR_CPUMASK is changed and now is represented through a string, to be set as the example reported in NOTES.
Please additively note that no MAXCPU is bumped in this patch, but private testing has been done until to MAXCPU=128 on a real 8x8x2(htt) machine (amd64).
Please note that the FreeBSD version is not yet bumped because of the upcoming pcpu changes. However, note that this patch is not targeted for MFC.
People to thank for the time spent on this patch: - sbruno, pluknet and Nicholas Esborn (nick AT desert DOT net) tested several revision of the patches and really helped in improving stability of this work. - marius fixed several bugs in the sparc64 implementation and reviewed patches related to ktr. - jeff and jhb discussed the basic approach followed. - kib and marcel made targeted review on some specific part of the patch. - marius, art, nwhitehorn and andreast reviewed MD specific part of the patch. - marius, andreast, gonzo, nwhitehorn and jceel tested MD specific implementations of the patch. - Other people have made contributions on other patches that have been already committed and have been listed separately.
Companies that should be mentioned for having participated at several degrees: - Yahoo! for having offered the machines used for testing on big count of CPUs. - The FreeBSD Foundation for having sponsored my devsummit attendance, which has been instrumental. - Sandvine for having offered offices and infrastructure during development.
(I really hope I didn't forget anyone, if it happened I apologize in advance).
|
221990 |
16-May-2011 |
avg |
better integrate cyclic module with clocksource/eventtimer subsystem
Now in the case when one-shot timers are used cyclic events should fire closer to theier scheduled times. As the cyclic is currently used only to drive DTrace profile provider, this is the area where the change makes a difference.
Reviewed by: mav (earlier version, a while ago) X-MFC after: clocksource/eventtimer subsystem
|
221740 |
10-May-2011 |
avg |
dtrace: remove unused code
Which is also useless, IMO.
MFC after: 5 days
|
220437 |
08-Apr-2011 |
art |
Stripped '32' suffix from linux systrace module name on i386.
Approved by: avg
|
220433 |
07-Apr-2011 |
jkim |
Use atomic load & store for TSC frequency. It may be overkill for amd64 but safer for i386 because it can be easily over 4 GHz now. More worse, it can be easily changed by user with 'machdep.tsc_freq' tunable (directly) or cpufreq(4) (indirectly). Note it is intentionally not used in performance critical paths to avoid performance regression (but we should, in theory). Alternatively, we may add "virtual TSC" with lower frequency if maximum frequency overflows 32 bits (and ignore possible incoherency as we do now).
|
219561 |
12-Mar-2011 |
avg |
add DTrace systrace support for linux32 and freebsd32 on amd64 syscalls
Add systrace_linux32 and systrace_freebsd32 modules which provide support for tracing compat system calls in addition to native system call tracing provided by systrace module.
Provided that all the systrace modules are loaded now you can select what syscalls to trace in the following manner:
syscall::xxx:yyy - work on all system calls that match the specification syscall:freebsd:xxx:yyy - only native system calls syscall:linux32:xxx:yyy - linux32 compat system calls syscall:freebsd32:xxx:yyy - freebsd32 compat system calls on amd64
PR: kern/152822 Submitted by: Artem Belevich <fbsdlist@src.cx> Reviewed by: jhb (earlier version) MFC after: 3 weeks
|
218909 |
21-Feb-2011 |
brucec |
Fix typos - remove duplicate "the".
PR: bin/154928 Submitted by: Eitan Adler <lists at eitanadler.com> MFC after: 3 days
|
216505 |
17-Dec-2010 |
avg |
cyclic xcall: use smp_no_rendevous_barrier as setup function parameter
In this case we call target function only on a single CPU and do not need any synchronization at the setup stage.
It's a bit non-obvious but setup function of NULL means that smp_rendezvous_cpus waits for all CPUs to arrive at the rendezvous point, but without doing any actual setup. While using smp_no_rendevous_barrier means that each CPU proceeds on its own schedule without any synchronization whatsoever.
MFC after: 3 weeks
|
216254 |
07-Dec-2010 |
avg |
opensolaris cyclic: fix deadlock and make a little bit closer to upstream
The dealock was caused in the following way: - thread T1 on CPU C1 holds a spin mutex, IPIs CPU C2 and waits for the IPI to be handled - C2 executes timer interrupt filter, thus has interrupts disabled, and gets blocked on the spin mutex held by T1 The problem seems to have been introduced by simplifications made to OpenSolaris code during porting. The problem is fixed by reorganizing the code to more closely resemble the upstream version. Interrupt filter (cyclic_fire) now doesn't acquire any locks, all per-CPU data accesses are performed on a target CPU with preemption and interrupts disabled thus precluding concurrent access to the data. cyp_mtx spin mutex is used to disable preemtion and interrupts; it's not used for classical mutual exclusion, because xcall already serializes calls to a CPU. It's an emulation of OpenSolaris cyb_set_level(CY_HIGH_LEVEL) call, the spin mutexes could probably be reduced to just a spinlock_enter()/_exit() pair.
Diff with upstream version is now reduced by ~500 lines, however it still remains quite large - many things that are not needed (at the moment) or are irrelevant on FreeBSD were simply ripped out during porting. Examples of such things: - support for CPU onlining/offlining - support for suspend/resume - support for running callouts at soft interrupt levels - support for callout rebinding from CPU to CPU - support for CPU partitions
Tested by: Artem Belevich <fbsdlist@src.cx> MFC after: 3 weeks X-MFC with: r216252
|
216252 |
07-Dec-2010 |
avg |
opensolaris cyclic xcall: no need for special handling of curcpu
smp_rendezvous_cpus already properly handles current CPU case and non-SMP case.
MFC after: 3 weeks
|
216251 |
07-Dec-2010 |
avg |
dtrace_xcall: no need for special handling of curcpu
smp_rendezvous_cpus alreadt does the right thing in a very similar fashion, so the code was kind of duplicating that.
MFC after: 3 weeks
|
216250 |
07-Dec-2010 |
avg |
dtrace_gethrtime_init: pin to master while examining other CPUs
Also use pc_cpumask to be future-friendly.
Reviewed by: jhb MFC after: 2 weeks
|
212093 |
01-Sep-2010 |
rpaulo |
Make the /dev/dtrace/helper node have the mode 0660. This allows programs that refuse to run as root (pgsql) to install probes when their user is part of the wheel group.
Sponsored by: The FreeBSD Foundation > Description of fields to fill in above: 76 columns --| > PR: If a GNATS PR is affected by the change. > Submitted by: If someone else sent in the change. > Reviewed by: If someone else reviewed your modification. > Approved by: If you needed approval for this commit. > Obtained from: If the change is from a third party. > MFC after: N [day[s]|week[s]|month[s]]. Request a reminder email. > Security: Vulnerability reference (one per line) or description. > Empty fields above will be automatically removed.
M dev/dtrace/dtrace_load.c
|
211611 |
22-Aug-2010 |
rpaulo |
Destroy the helper device when unloading.
Sponsored by: The FreeBSD Foundation
|
211610 |
22-Aug-2010 |
rpaulo |
Add more compatibility structure members needed by the upcoming fasttrap DTrace device.
Sponsored by: The FreeBSD Foundation
|
211608 |
22-Aug-2010 |
rpaulo |
Kernel DTrace support for: o uregs (sson@) o ustack (sson@) o /dev/dtrace/helper device (needed for USDT probes)
The work done by me was: Sponsored by: The FreeBSD Foundation
|
211607 |
22-Aug-2010 |
rpaulo |
Add a function compatibility function dtrace_instr_size_isa() that on FreeBSD does the same as dtrace_dis_isize().
Sponsored by: The FreeBSD Foundation
|
209059 |
11-Jun-2010 |
jhb |
Update several places that iterate over CPUs to use CPU_FOREACH().
|
208453 |
23-May-2010 |
kib |
Reorganize syscall entry and leave handling.
Extend struct sysvec with three new elements: sv_fetch_syscall_args - the method to fetch syscall arguments from usermode into struct syscall_args. The structure is machine-depended (this might be reconsidered after all architectures are converted). sv_set_syscall_retval - the method to set a return value for usermode from the syscall. It is a generalization of cpu_set_syscall_retval(9) to allow ABIs to override the way to set a return value. sv_syscallnames - the table of syscall names.
Use sv_set_syscall_retval in kern_sigsuspend() instead of hardcoding the call to cpu_set_syscall_retval().
The new functions syscallenter(9) and syscallret(9) are provided that use sv_*syscall* pointers and contain the common repeated code from the syscall() implementations for the architecture-specific syscall trap handlers.
Syscallenter() fetches arguments, calls syscall implementation from ABI sysent table, and set up return frame. The end of syscall bookkeeping is done by syscallret().
Take advantage of single place for MI syscall handling code and implement ptrace_lwpinfo pl_flags PL_FLAG_SCE, PL_FLAG_SCX and PL_FLAG_EXEC. The SCE and SCX flags notify the debugger that the thread is stopped at syscall entry or return point respectively. The EXEC flag augments SCX and notifies debugger that the process address space was changed by one of exec(2)-family syscalls.
The i386, amd64, sparc64, sun4v, powerpc and ia64 syscall()s are changed to use syscallenter()/syscallret(). MIPS and arm are not converted and use the mostly unchanged syscall() implementation.
Reviewed by: jhb, marcel, marius, nwhitehorn, stas Tested by: marcel (ia64), marius (sparc64), nwhitehorn (powerpc), stas (mips) MFC after: 1 month
|
206901 |
20-Apr-2010 |
rpaulo |
Rename the cyclic global variable lapic_cyclic_clock_func to just cyclic_clock_func. This will make more sense when we start developing non x86 cyclic version.
|
206900 |
20-Apr-2010 |
rpaulo |
The amd64 version of the cyclic dtrace module is a verbatim copy of the i386 version, so instead having a copy of the same file, use Makefile foo to include the i386 version on amd64.
|
195710 |
15-Jul-2009 |
avg |
dtrace_gethrtime: improve scaling of TSC ticks to nanoseconds
Currently dtrace_gethrtime uses formula similar to the following for converting TSC ticks to nanoseconds: rdtsc() * 10^9 / tsc_freq The dividend overflows 64-bit type and wraps-around every 2^64/10^9 = 18446744073 ticks which is just a few seconds on modern machines.
Now we instead use precalculated scaling factor of 10^9*2^N/tsc_freq < 2^32 and perform TSC value multiplication separately for each 32-bit half. This allows to avoid overflow of the dividend described above. The idea is taken from OpenSolaris. This has an added feature of always scaling TSC with invariant value regardless of TSC frequency changes. Thus the timestamps will not be accurate if TSC actually changes, but they are always proportional to TSC ticks and thus monotonic. This should be much better than current formula which produces wildly different non-monotonic results on when tsc_freq changes.
Also drop write-only 'cp' variable from amd64 dtrace_gethrtime_init() to make it identical to the i386 twin.
PR: kern/127441 Tested by: Thomas Backman <serenity@exscape.org> Reviewed by: jhb Discussed with: current@, bde, gnn Silence from: jb Approved by: re (gnn) MFC after: 1 week
|
194850 |
24-Jun-2009 |
avg |
dtrace/amd64: fix virtual address checks
On amd64 KERNBASE/kernbase does not mean start of kernel memory. This should fix a KASSERT panic in dtrace_copycheck when copyin*() is used in D program. Also make checks for user memory a bit stricter.
Reported by: Thomas Backman <serenity@exscape.org> Submitted by: wxs (kaddr part) Tested by: Thomas Backman (prototype), wxs Reviewed by: alc (concept), jhb, current@ Aprroved by: jb (concept) MFC after: 2 weeks PR: kern/134408
|
192853 |
26-May-2009 |
sson |
Add the OpenSolaris dtrace lockstat provider. The lockstat provider adds probes for mutexes, reader/writer and shared/exclusive locks to gather contention statistics and other locking information for dtrace scripts, the lockstat(1M) command and other potential consumers.
Reviewed by: attilio jhb jb Approved by: gnn (mentor)
|
191517 |
26-Apr-2009 |
ed |
Remove empty directories from the HEAD.
Discussed with: developers, imp
|
190581 |
30-Mar-2009 |
mav |
Integrate user/mav/ata branch:
Add ch_suspend/ch_resume methods for PCI controllers and implement them for AHCI. Refactor AHCI channel initialization according to it.
Fix Port Multipliers operation. It is far from perfect yet, but works now. Tested with JMicron JMB363 AHCI + SiI 3726 PMP pair. Previous version was also tested with SiI 4726 PMP.
Hardware sponsored by: Vitsch Electronics / VEHosting.nl
|
190419 |
25-Mar-2009 |
rwatson |
Move dtnfsclient.c in the cddl tree to nfs_kdtrace.c in the nfsclient directory, since it's under a BSD license, and this keeps NFS internals- aware tracing parts close to NFS.
MFC after: 1 month Suggested by: jhb
|
190380 |
24-Mar-2009 |
rwatson |
Add DTrace probes to the NFS access and attribute caches. Access cache events are:
nfsclient:accesscache:flush:done nfsclient:accesscache:get:hit nfsclient:accesscache:get:miss nfsclient:accesscache:load:done
They pass the vnode, uid, and requested or loaded access mode (if any); the load event may also report a load error if the RPC fails.
The attribute cache events are:
nfsclient:attrcache:flush:done nfsclient:attrcache:get:hit nfsclient:attrcache:get:miss nfsclient:attrcache:load:done
They pass the vnode, optionally the vattr if one is present (hit or load), and in the case of a load event, also a possible RPC error.
MFC after: 1 month Sponsored by: Google, Inc.
|
190293 |
22-Mar-2009 |
rwatson |
Add dtnfsclient, a first cut at an NFSv2/v3 client reuest DTrace provider. The NFS client exposes 'start' and 'done' probes for NFSv2 and NFSv3 RPCs when using the new RPC implementation, passing in the vnode, mbuf chain, credential, and NFSv2 or NFSv3 procedure number. For 'done' probes, the error number is also available.
Probes are named in the following way:
... nfsclient:nfs2:write:start nfsclient:nfs2:write:done ... nfsclient:nfs3:access:start nfsclient:nfs3:access:done ...
Access to the unmarshalled arguments is not easily available at this point in the stack, but the passed probe arguments are sufficient to to a lot of interesting things in practice. Technically, these probes may cover multiple RPC retransmits, and even transactions if the transaction ID change as a result of authentication failure or a jukebox error from the server, but usefully capture the intent of a single NFS request, such as access, getattr, write, etc.
Typical use might involve profiling RPC latency by system call, number of RPCs, how often a getattr leads to a call to access, when failed access control checks occur, etc. More detailed RPC information might best be provided by adding a krpc provider. It would also be useful to add NFS client probes for events such as the access cache or attribute cache satisfying requests without an RPC.
Sponsored by: Google, Inc. MFC after: 1 month
|
185310 |
25-Nov-2008 |
ganbold |
Remove unused variable.
Found with: Coverity Prevent(tm) CID: 3669,3671
Approved by: jb
|
184698 |
05-Nov-2008 |
rodrigc |
Merge latest DTrace changes from Perforce.
|
183381 |
26-Sep-2008 |
ed |
Remove unit2minor() use from kernel code.
When I changed kern_conf.c three months ago I made device unit numbers equal to (unneeded) device minor numbers. We used to require bitshifting, because there were eight bits in the middle that were reserved for a device major number. Not very long after I turned dev2unit(), minor(), unit2minor() and minor2unit() into macro's. The unit2minor() and minor2unit() macro's were no-ops.
We'd better not remove these four macro's from the kernel, because there is a lot of (external) code that may still depend on them. For now it's harmless to remove all invocations of unit2minor() and minor2unit().
Reviewed by: kib
|
179260 |
23-May-2008 |
jb |
The cyclic timer device. This is a cut down version of the one in OpenSolaris. We don't have the lock levels that they do, so this is just hooked into clock interrupts.
|
179237 |
23-May-2008 |
jb |
Custom DTrace kernel module files plus FreeBSD-specific DTrace providers.
|