1. 27 Feb, 2018 1 commit
    • Yonghong Song's avatar
      fix hang with "trace.py --max-events # · a7554fc4
      Yonghong Song authored
      Currently running "trace.py --max-events #" (shortname "trace.py -M #")
      will hang like below:
      
        -bash-4.2$ sudo ./trace.py -M 2 'SyS_futex'
        PID     TID     COMM            FUNC
        137727  138229  IOThreadPool0   SyS_futex
        138250  151288  OBC Dispatcher  SyS_futex
        ^C^Z
        [1]+  Stopped                 sudo ./trace.py -M 2 'SyS_futex'
        -bash-4.2$
      
      The hang happens in perf_reader_free.
      
      Commit cd5d4a6c ("fix a race condition between perf_reader
      munmap and read") fixed a race condition by adding some coordination
      between perf_reader_event_read and perf_reader_free.
      
      In this case, however, the callback function inside perf_reader_event_read
      never returns and actually calling exit(). This is because
      the maximum number of perf_events have been received. The exit()
      is calling BPF object cleanup() which calls perf_reader_free to
      free the ring buffer. perf_reader_free got stuck since it thinks
      perf_reader_event_reader did not finish yet.
      
      To fix this, a checking for thread_id is added so that
      perf_reader_free will proceed without locking if the perf_reader_read
      tid is the same as perf_reader_free since this signals that
      the callback function calls/triggers perf_reader_free.
      
      After the fix,
      
        -bash-4.2$ sudo ./trace.py -M 2 'SyS_futex'
        PID     TID     COMM            FUNC
        137727  138178  load-monitor    SyS_futex
        6359    6440    load-monitor    SyS_futex
        -bash-4.2$
      Reported-by: default avatarTeng Qin <qinteng@fb.com>
      Signed-off-by: default avatarYonghong Song <yhs@fb.com>
      a7554fc4
  2. 26 Feb, 2018 3 commits
  3. 25 Feb, 2018 2 commits
  4. 24 Feb, 2018 1 commit
  5. 23 Feb, 2018 2 commits
    • 4ast's avatar
      Merge pull request #1602 from iovisor/yhs_dev2 · f3d3c94b
      4ast authored
      add a BPFModule API to disable rw_engine sscanf/snprintf functions
      f3d3c94b
    • Yonghong Song's avatar
      add a BPFModule API to disable rw_engine sscanf/snprintf functions · db7b8eb0
      Yonghong Song authored
      Currently, for every table of a module, corresponding
      key/value sscanf/snprintf functions will be generated.
      These functions are mostly used for python API to
      facilitate passing keys between python and C++.
      
      It is a known issue that these sscanf/snprintf functions
      can consume a lot of system resources esp. memory for
      large arrays. Commit 22eae8c6 ("Use late-binding to
      finalize snprintf/sscanf") avoids unnecessary code
      generation for snprintf/sscanf until they are called.
      Even with this commit, however, the overhead can still
      be significant for large arrays.
      
      For example, the following large array,
        #define TCP6_RXMIT_BUCKET_BITS 18
        struct tcp6_rxmit_tbl {
          __u64 buckets[1 << TCP6_RXMIT_BUCKET_BITS];
        };
        BPF_ARRAY(rxmit_marking_map, struct tcp6_rxmit_tbl, 1);
      is used inside Facebook.
      If it is added to examples/cpp/HelloWorld.cpp,
      the HelloWorld RSS memory will increase from 7MB to
      370MB.
      
      This patch add a BPFModule API and a C++ API to
      disable rw_engine sscanf/snprintf function through additional
      constructor parameters. rw_engine support for Python is not affected.
      Signed-off-by: default avatarYonghong Song <yhs@fb.com>
      db7b8eb0
  6. 21 Feb, 2018 1 commit
    • Gary Lin's avatar
      opensnoop: convert args.name to bytes · 40fd6692
      Gary Lin authored
      This commit fixes the following error with python3:
      
      Traceback (most recent call last):
        File "_ctypes/callbacks.c", line 234, in 'calling callback function'
        File "/usr/lib/python3.6/site-packages/bcc/table.py", line 508, in raw_cb_
          callback(cpu, data, size)
        File "./opensnoop.py", line 169, in print_event
          if args.name and args.name not in event.comm:
      TypeError: a bytes-like object is required, not 'str'
      Signed-off-by: default avatarGary Lin <glin@suse.com>
      40fd6692
  7. 20 Feb, 2018 1 commit
  8. 19 Feb, 2018 1 commit
  9. 18 Feb, 2018 1 commit
  10. 17 Feb, 2018 1 commit
  11. 16 Feb, 2018 1 commit
  12. 15 Feb, 2018 2 commits
  13. 14 Feb, 2018 5 commits
  14. 12 Feb, 2018 2 commits
  15. 11 Feb, 2018 2 commits
  16. 10 Feb, 2018 3 commits
  17. 09 Feb, 2018 2 commits
  18. 08 Feb, 2018 5 commits
    • Brenden Blanco's avatar
      tools: switch to v2/3 independent bytes usage · 42d6098f
      Brenden Blanco authored
      Conform to bytes encoding for some portion of the tools/tests, such that
      smoke tests pass on python3. More conversions are surely required.
      Signed-off-by: default avatarBrenden Blanco <bblanco@gmail.com>
      42d6098f
    • Brenden Blanco's avatar
      python/bcc: add internal _assert_is_bytes usage · c0ca99a2
      Brenden Blanco authored
      Move bcc internals to sanitize all arguments as bytes instead of str
      type. For now, disable warnings or actual assertion, to be turned on
      incrementally.
      c0ca99a2
    • Brenden Blanco's avatar
      python: Add 2/3 compat wrappers for byte strings · e663541c
      Brenden Blanco authored
      Introduce some helpers for managing bytes/unicode objects in a way that
      bridges the gap from python2 to 3.
      
      1. Add printb() helper for writing bytes output directly to stdout. This
      avoids complaints from print() in python3, which expects a unicode
      str(). Since python 3.5, `b"" % bytes()` style format strings should
      work and we can write tools with common code, once we convert format
      strings to bytes.
      http://legacy.python.org/dev/peps/pep-0461/
      
      2. Add a class for wrapping command line arguments that are intended for
      comparing to debugged memory, for instance running process COMM or
      kernel pathname data. The approach takes some of the discussion from
      http://legacy.python.org/dev/peps/pep-0383/ into account, though
      unfortunately the python2-future implementation of "surrogateescape" is
      buggy, therefore this iteration is partial.
      
      The object instance should only ever be coerced into a bytes object.
      This silently invokes encode(sys.getfilesystemencoding()), which if it
      fails implies that the tool was passed junk characters on the command
      line. Thereafter the tool should implement only bytes-bytes comparisons
      (for instance re.search(b"", b"")) and bytes stdout printing (see
      printb).
      
      3. Add an _assert_is_bytes helper to check for improper usage of str
      objects in python arguments. The behavior of the assertion can be
      tweaked by changing the bcc.utils._strict_bytes bool.
      
      Going forward, one should never invoke decode() on a bpf data stream,
      e.g. the result of a table lookup or perf ring output. Leave that data
      in the native bytes() representation.
      Signed-off-by: default avatarBrenden Blanco <bblanco@gmail.com>
      e663541c
    • Brenden Blanco's avatar
      Fix file desc leak in test_tools_smoke · c28f6e86
      Brenden Blanco authored
      Signed-off-by: default avatarBrenden Blanco <bblanco@gmail.com>
      c28f6e86
    • yonghong-song's avatar
      Merge pull request #1569 from joelagnel/bcc-cross-compile · e01c993a
      yonghong-song authored
      BCC cross compilation support
      e01c993a
  19. 06 Feb, 2018 4 commits