Skip to content
Snippets Groups Projects
  1. Mar 17, 2021
  2. Mar 15, 2021
  3. Mar 14, 2021
    • zhenwei pi's avatar
      tools/virtiostat: add filter · fa7bec9f
      zhenwei pi authored
      
      Add device driver/name filter for virtiostat.
      
      Suggested by Yonghong, also use bpf_probe_read_kernel_str to copy
      string from kernel.
      
      Signed-off-by: default avatarzhenwei pi <pizhenwei@bytedance.com>
      fa7bec9f
    • Guodong Xu's avatar
      In GCC10.2 suffix '.isra.0' was appended to 'finish_task_switch' · 00b72fd8
      Guodong Xu authored
      When buildiing kernel with GCC10 [2] in Debian on an Arm64 machine, it was
      found the new "inter-procedural optimization improvements" [1] makes symbol
      name 'finish_task_switch' changed to 'finish_task_switch.isra.0'.
      
      Details:
      The results, when built with gcc 9.3:
      nm ../linux.buildout/kernel/sched/core.o | grep finish_task_switch
      0000000000001288 t finish_task_switch
      
      However, when built with gcc 10.2:
      nm ../linux.buildout/kernel/sched/core.o | grep finish_task_switch
      00000000000012d0 t finish_task_switch.isra.0
      
      The same symbols (with xxx.isra.0 or without, respectively of course) also
      appear in final file 'System.map' and in '/proc/kallsyms' when booting. This
      negatively impact the tracing tools commonly used in kernel debugging, such
      as bcc tools offcputime and runqlat. They hardcode 'finish_task_switch'
      (without the .isra.0 suffix) into their scripts.
      
      This patch fix the issue by changing the hardcoded 'finish_task_switch' string
      to a python regular expression pattern who can match both the traditional form
      'finish_task_switch' and the new gcc10 form 'finish_task_switch.isra.0'
      (with single digit at the end). attach_kprobe()'s input parameter 'event_re'
      is used for this type of pattern matching.
      
      [1] https://gcc.gnu.org/gcc-10/changes.html
      
      
      [2] ARCH=arm64 make Image
      
      Signed-off-by: default avatarGuodong Xu <guodong.xu@linaro.org>
      00b72fd8
  4. Mar 12, 2021
  5. Mar 08, 2021
  6. Mar 05, 2021
    • Edward Wu's avatar
      Fix abnormal symbol parsing when __irqentry_text_end is before __irqentry_text_start · a090b462
      Edward Wu authored
      
      On my ARM64 kernel 5.4 case
      
      Symbol:
      ffffffc0100820b8 T __irqentry_text_end
      ffffffc0100820b8 T __irqentry_text_start
      
      It will ignore all functions after __irqentry_text_start until __irqentry_text_end.
      But this case __irqentry_text_end is before __irqentry_text_start.
      So the problem happens.
      
      Signed-off-by: default avatarEdward Wu <edwardwu@realtek.com>
      a090b462
    • Barret Rhoden's avatar
      libbpf-tools: add funclatency · 08d6340f
      Barret Rhoden authored
      
      This is a port of BCC's funclatency.  Usage:
      
      ---------
      Time functions and print latency as a histogram
      
      Usage: funclatency [-h] [-m|-u] [-p PID] [-d DURATION] [ -i INTERVAL ]
                         [-T] FUNCTION
             Choices for FUNCTION: FUNCTION         (kprobe)
                                   LIBRARY:FUNCTION (uprobe a library in -p PID)
                                   :FUNCTION        (uprobe the binary of -p PID)
      
        -m, --milliseconds         Output in milliseconds
        -u, --microseconds         Output in microseconds
        -p, --pid=PID              Process ID to trace
        -d, --duration=DURATION    Duration to trace
        -i, --interval=INTERVAL    Summary interval in seconds
        -T, --timestamp            Print timestamp
      
        -?, --help                 Give this help list
            --usage                Give a short usage message
        -V, --version              Print program version
      
      Mandatory or optional arguments to long options are also mandatory or optional
      for any corresponding short options.
      
      Examples:
        ./funclatency do_sys_open         # time the do_sys_open() kernel function
        ./funclatency -m do_nanosleep     # time do_nanosleep(), in milliseconds
        ./funclatency -u vfs_read         # time vfs_read(), in microseconds
        ./funclatency -p 181 vfs_read     # time process 181 only
        ./funclatency -p 181 c:read       # time the read() C library function
        ./funclatency -p 181 :foo         # time foo() from pid 181's userspace
        ./funclatency -i 2 -d 10 vfs_read # output every 2 seconds, for 10s
        ./funclatency -mTi 5 vfs_read     # output every 5 seconds, with timestamps
      
      ---------
      
      It supports kprobes and has limited support for uprobes.  Currently, you
      cannot uprobe a library unless you provide a PID.  It does not support
      wildcard patterns.
      
      Some of the functions for uprobes are useful for other programs, so I
      put those in uprobe_helpers.{c,h}.
      
      Signed-off-by: default avatarBarret Rhoden <brho@google.com>
      08d6340f
  7. Mar 03, 2021
    • Yonghong Song's avatar
      fix a llvm-triggered compilation error · 99993978
      Yonghong Song authored
      Upstream (llvm13) patch
        https://reviews.llvm.org/D97223
      
      
      changed function signature for CreateAtomicRMW().
      The error message:
        /home/yhs/work/bcc/src/cc/frontends/b/codegen_llvm.cc:
           In member function ‘ebpf::StatusTuple ebpf::cc::CodegenLLVM
              ::emit_atomic_add(ebpf::cc::MethodCallExprNode*)’:
        /home/yhs/work/bcc/src/cc/frontends/b/codegen_llvm.cc:720:75:
           error: no matching function for call to
              ‘llvm::IRBuilder<>::CreateAtomicRMW(llvm::AtomicRMWInst::BinOp,
               llvm::Value*&, llvm::Value*&, llvm:: AtomicOrdering)’
             AtomicRMWInst::Add, lhs, rhs, AtomicOrdering::SequentiallyConsistent);
                                                                                 ^
        In file included from /home/yhs/work/bcc/src/cc/frontends/b/codegen_llvm.cc:31:
        /home/yhs/work/llvm-project/llvm/build/install/include/llvm/IR/IRBuilder.h:1721:18:
            note: candidate:
        ‘llvm::AtomicRMWInst* llvm::IRBuilderBase::CreateAtomicRMW(llvm::AtomicRMWInst::BinOp,
            llvm::Value*, llvm::Value*, llvm::MaybeAlign, llvm::AtomicOrdering,
            llvm::SyncScope::ID)’
         AtomicRMWInst *CreateAtomicRMW(AtomicRMWInst::BinOp Op, Value *Ptr,
                        ^~~~~~~~~~~~~~~
        /home/yhs/work/llvm-project/llvm/build/install/include/llvm/IR/IRBuilder.h:1721:18: note:
        candidate expects 6 arguments, 4 provided
      
      Fixed the issue with correct arguments.
      
      Signed-off-by: default avatarYonghong Song <yhs@fb.com>
      99993978
  8. Mar 02, 2021
  9. Feb 26, 2021
  10. Feb 25, 2021
  11. Feb 22, 2021
    • Yonghong Song's avatar
      Allow python usdt attachment with pid -1 · 8e6f333c
      Yonghong Song authored
      
      For usdt with semaphore, user needs to provide pid in order
      to create a usdt since enabling semaphore requires write to
      virtual memory of the user process.
      
      For attachment to corresponding usdt uprobe, we can pass
      valid pid to perf_event_open() syscall so usdt is only
      triggered for this process, or pass pid -1 permits usdt is
      to triggered for all processes.
      
      There are use cases for usdt to be triggered for other
      processes than just one process. For example, for python
      usdt function__entry/function__return, users may want to
      trace usdt of a particular python process and all its
      children processes.
      
      C++ already has API to permit ignoring pid during attachment.
         attach_usdt(const USDT& usdt, pid_t pid = -1)
      This patch added similar functionality to python with an
      additional parameter to BPF constructor to indicate whether
      attach_usdt can ignore pid or not.
      
      Signed-off-by: default avatarYonghong Song <yhs@fb.com>
      8e6f333c
    • Jonathan Giddy's avatar
      ec0691e7
    • Emilien Gobillot's avatar
      add bpf_map_lookup_and_delete_batch in bcc (#3234) · c3b11e52
      Emilien Gobillot authored
      * add bpf_map_lookup_and_delete_batch in bcc
      * add test_map_batch_ops.py to test batch lookup and delete on map
      * add items_lookup_and_delete_batch() in the reference guide
    • zhenwei pi's avatar
      tools/virtiostat: add virtiostat tool · 86148954
      zhenwei pi authored
      
      Add a new tool virtiostat to trace VIRTIO devices IO statistics.
      
      Although we have already had iostat(to show block device statistics),
      iftop(to show network device statistics), other devices of VIRTIO
      family(Ex, console, balloon, GPU and so on) also need tools for each
      type. virtiostat works in virtio lower layer, and it could trace all
      the devices.
      
      Signed-off-by: default avatarzhenwei pi <pizhenwei@bytedance.com>
      86148954
    • Dane Springmeyer's avatar
      include common.h for std::make_unique · c3bcec17
      Dane Springmeyer authored
      c3bcec17
  12. Feb 19, 2021
  13. Feb 18, 2021
    • Jerome Marchand's avatar
      tools: include kasan header in slabtoprate · 33393d30
      Jerome Marchand authored
      slabtoprate fails on 5.10 kernels because of a missing kasan_reset_tag
      declaration. We need to include the kasan header file.
      
      Fixes the following error:
      In file included from /virtual/main.c:12:
      include/linux/slub_def.h:181:27: warning: implicit declaration of function 'kasan_reset_tag' is invalid in C99 [-Wimplicit-function-declaration]
              return reciprocal_divide(kasan_reset_tag(obj) - addr,
                                       ^
      include/linux/slub_def.h:181:48: error: invalid operands to binary expression ('int' and 'void *')
              return reciprocal_divide(kasan_reset_tag(obj) - addr,
                                       ~~~~~~~~~~~~~~~~~~~~ ^ ~~~~
      1 warning and 1 error generated.
      Traceback (most recent call last):
        File "/usr/share/bcc/tools/slabratetop", line 115, in <module>
          b = BPF(text=bpf_text)
        File "/usr/lib/python3.9/site-packages/bcc/__init__.py", line 364, in __init__
          raise Exception("Failed to compile BPF module %s" % (src_file or "<text>"))
      Exception: Failed to compile BPF module <text>
      33393d30
  14. Feb 11, 2021
  15. Feb 07, 2021
  16. Feb 06, 2021
Loading