diff options
author | jhb <jhb@FreeBSD.org> | 2012-04-05 17:13:14 +0000 |
---|---|---|
committer | jhb <jhb@FreeBSD.org> | 2012-04-05 17:13:14 +0000 |
commit | 5829de48d948e74cb77c117659140afff0ee33b3 (patch) | |
tree | c9ac7a271fa3242d8c2cd110bfe596a577e6f5f0 /usr.bin/kdump | |
parent | 1bdacb70cf554a29338ec17d997277abfc6f57e1 (diff) | |
download | FreeBSD-src-5829de48d948e74cb77c117659140afff0ee33b3.zip FreeBSD-src-5829de48d948e74cb77c117659140afff0ee33b3.tar.gz |
Add new ktrace records for the start and end of VM faults. This gives
a pair of records similar to syscall entry and return that a user can
use to determine how long page faults take. The new ktrace records are
enabled via the 'p' trace type, and are enabled in the default set of
trace points.
Reviewed by: kib
MFC after: 2 weeks
Diffstat (limited to 'usr.bin/kdump')
-rw-r--r-- | usr.bin/kdump/kdump.1 | 4 | ||||
-rw-r--r-- | usr.bin/kdump/kdump.c | 33 | ||||
-rw-r--r-- | usr.bin/kdump/mksubr | 23 |
3 files changed, 59 insertions, 1 deletions
diff --git a/usr.bin/kdump/kdump.1 b/usr.bin/kdump/kdump.1 index 4e60137..c03985e 100644 --- a/usr.bin/kdump/kdump.1 +++ b/usr.bin/kdump/kdump.1 @@ -28,7 +28,7 @@ .\" @(#)kdump.1 8.1 (Berkeley) 6/6/93 .\" $FreeBSD$ .\" -.Dd February 23, 2008 +.Dd April 5, 2012 .Dt KDUMP 1 .Os .Sh NAME @@ -171,6 +171,8 @@ The possible operations are: .It Li USER Ta data from user process Ta the data .It Li STRU Ta various syscalls Ta structure .It Li SCTL Ta Xr sysctl 3 requests Ta MIB name +.It Li PFLT Ta enter page fault Ta fault address and type +.It Li PRET Ta return from page fault Ta fault result .El .Sh SEE ALSO .Xr ktrace 1 diff --git a/usr.bin/kdump/kdump.c b/usr.bin/kdump/kdump.c index 2756778..4d8e109 100644 --- a/usr.bin/kdump/kdump.c +++ b/usr.bin/kdump/kdump.c @@ -102,6 +102,8 @@ void ktrsockaddr(struct sockaddr *); void ktrstat(struct stat *); void ktrstruct(char *, size_t); void ktrcapfail(struct ktr_cap_fail *); +void ktrfault(struct ktr_fault *); +void ktrfaultend(struct ktr_faultend *); void usage(void); void ioctlname(unsigned long, int); @@ -306,6 +308,13 @@ main(int argc, char *argv[]) break; case KTR_CAPFAIL: ktrcapfail((struct ktr_cap_fail *)m); + break; + case KTR_FAULT: + ktrfault((struct ktr_fault *)m); + break; + case KTR_FAULTEND: + ktrfaultend((struct ktr_faultend *)m); + break; default: printf("\n"); break; @@ -448,6 +457,12 @@ dumpheader(struct ktr_header *kth) case KTR_CAPFAIL: type = "CAP "; break; + case KTR_FAULT: + type = "PFLT"; + break; + case KTR_FAULTEND: + type = "PRET"; + break; default: sprintf(unknown, "UNKNOWN(%d)", kth->ktr_type); type = unknown; @@ -1631,6 +1646,24 @@ ktrcapfail(struct ktr_cap_fail *ktr) capname((intmax_t)ktr->cap_held); break; } + printf("\n"); +} + +void +ktrfault(struct ktr_fault *ktr) +{ + + printf("0x%jx ", ktr->vaddr); + vmprotname(ktr->type); + printf("\n"); +} + +void +ktrfaultend(struct ktr_faultend *ktr) +{ + + vmresultname(ktr->result); + printf("\n"); } #if defined(__amd64__) || defined(__i386__) diff --git a/usr.bin/kdump/mksubr b/usr.bin/kdump/mksubr index 99dd80f..bc466d5 100644 --- a/usr.bin/kdump/mksubr +++ b/usr.bin/kdump/mksubr @@ -187,6 +187,8 @@ cat <<_EOF_ #include <nfsserver/nfs.h> #include <ufs/ufs/quota.h> #include <sys/capability.h> +#include <vm/vm.h> +#include <vm/vm_param.h> #include "kdump_subr.h" @@ -334,6 +336,26 @@ sockoptlevelname(int level, int decimal) } } +/* + * MANUAL + * + * Used for page fault type. Cannot use auto_or_type since the macro + * values contain a cast. Also, VM_PROT_NONE has to be handled specially. + */ +void +vmprotname (int type) +{ + int or = 0; + + if (type == VM_PROT_NONE) { + (void)printf("VM_PROT_NONE"); + return; + } + if_print_or(type, VM_PROT_READ, or); + if_print_or(type, VM_PROT_WRITE, or); + if_print_or(type, VM_PROT_EXECUTE, or); + if_print_or(type, VM_PROT_COPY, or); +} _EOF_ auto_or_type "accessmodename" "[A-Z]_OK[[:space:]]+0?x?[0-9A-Fa-f]+" "sys/unistd.h" @@ -373,6 +395,7 @@ auto_if_type "sockipprotoname" "IPPROTO_[[:alnum:]]+[[:space:]]+" auto_switch_type "sockoptname" "SO_[A-Z]+[[:space:]]+0x[0-9]+" "sys/socket.h" auto_switch_type "socktypename" "SOCK_[A-Z]+[[:space:]]+[1-9]+[0-9]*" "sys/socket.h" auto_or_type "thrcreateflagsname" "THR_[A-Z]+[[:space:]]+0x[0-9]+" "sys/thr.h" +auto_switch_type "vmresultname" "KERN_[A-Z]+[[:space:]]+[0-9]+" "vm/vm_param.h" auto_or_type "wait4optname" "W[A-Z]+[[:space:]]+[0-9]+" "sys/wait.h" auto_switch_type "whencename" "SEEK_[A-Z]+[[:space:]]+[0-9]+" "sys/unistd.h" |