• William Cohen's avatar
    Wcohen/efficiency (#2063) · 218f7482
    William Cohen authored
    * Reduce instrumentation overhead with the sys_enter and sys_exit tracepoints
    
    The ucalls script initially used kprobes and kretprobes on each of the
    hundreds of syscalls functions in the system.  This approach causes a
    large number of probes to be set up at the start and removed at the
    conclusion of the script's execution resulting in slow start up.
    
    Like the syscount.py script the ucall syscall instrumentation has been
    modified to use the sys_enter and sys_exit tracepoints.  This only
    requires the installation and removal of one or two tracepoints to
    implement and results in much shorter times to start and stop the
    ucalls script.
    
    Another benefit of this change is syscalls on newer kernels will be
    monitored with the "-S" option.  The regular expression used to find
    the locations for the kprobes and kretprobes for all the possible
    syscall functions would not would match the syscall function naming
    convention in newer kernels.
    
    * Update ucalls_examples.txt to match current "-S" option output
    
    * Add required "import subprocess" and remove unneeded "global syscalls"
    
    * Factor out the syscall_name code into a separate python module syscall.py
    
    Multiple scripts are going to find the syscall_name() function useful
    when using the syscall tracepoints.  Factoring out this code into a
    separate python module avoids having to replicate this code in
    multiple scripts.
    
    * Use the syscall_name() function in syscount.py to make it more compact.
    
    * Update the default syscall mappings and the way that they were generated
    
    The default table was missing some newer syscall mapping. Regenerated
    the table using the syscallent.h file from Fedora 30
    strace-4.25-1.fc30.src.rpm.  Also updated the comment with the command
    actually used to generate the mappings.
    
    * Add license information and upsdate the syscalls
    
    The default x86_64 syscall dictionary mapping syscalls numbers to
    names has been updated. The following syscall x86_64 names have been
    updated:
    
        18: b"pwrite64",
        60: b"exit",
        166: b"umount2",
    
    The following syscall x86_64 have been added:
    
        313: b"finit_module",
        314: b"sched_setattr",
        315: b"sched_getattr",
        316: b"renameat2",
        317: b"seccomp",
        318: b"getrandom",
        319: b"memfd_create",
        320: b"kexec_file_load",
        321: b"bpf",
        322: b"execveat",
        323: b"userfaultfd",
        324: b"membarrier",
        325: b"mlock2",
        326: b"copy_file_range",
        327: b"preadv2",
        328: b"pwritev2",
        329: b"pkey_mprotect",
        330: b"pkey_alloc",
        331: b"pkey_free",
        332: b"statx",
        333: b"io_pgetevents",
        334: b"rseq",
    
    * Eliminate stderr output and use of shell features
    
    Redirect all stderr output so it isn't seen.  Also avoid use of the
    shell pipe and tail command.  Just strip off the first line in the
    python code instead.
    
    * Update lib/ucalls.py smoke test to required linux-4.7
    
    The use of tracepoints in the ucalls.py requires linux-4.7. Changed
    the test to only run with a suitable kernel.  The libs/ucalls.py
    script is no longer inserting hundreds of kprobes and is much faster
    as a result, so removed the timeout adjustment and the comment about
    it being slow.
    218f7482
ucalls_example.txt 3.91 KB