platform/upstream/bcc.git
7 years agoAdds zlib1g-dev Debian package build dependency
Alexandros [Thu, 16 Feb 2017 10:47:27 +0000 (12:47 +0200)]
Adds zlib1g-dev Debian package build dependency

When building from source in Debian, zlib1g-dev is needed or else
'/usr/bin/ld: cannot find -lz' error will occur.

7 years agoMerge pull request #974 from r4f4/fix-undo
Brenden Blanco [Wed, 15 Feb 2017 16:45:29 +0000 (08:45 -0800)]
Merge pull request #974 from r4f4/fix-undo

Revert "undo rebase"

7 years agoRevert "undo rebase"
Rafael Fonseca [Wed, 15 Feb 2017 16:28:26 +0000 (17:28 +0100)]
Revert "undo rebase"

This reverts commit a112514cba8e4844c405e3f1bd341289c4d2a158.

The changes the commit reverted are legit and should not have been
reverted.

7 years agoMerge pull request #969 from goldshtn/clock-monotonic
Brenden Blanco [Wed, 15 Feb 2017 15:10:56 +0000 (07:10 -0800)]
Merge pull request #969 from goldshtn/clock-monotonic

Move monotonic_time to BPF class, use CLOCK_MONOTONIC

7 years agoMerge pull request #968 from mslusarz/deb-pkg-config
Brenden Blanco [Tue, 14 Feb 2017 21:46:28 +0000 (13:46 -0800)]
Merge pull request #968 from mslusarz/deb-pkg-config

Add pkg-config file to Debian packages.

7 years agoAdd pkg-config file to Debian packages.
Marcin Ślusarz [Tue, 14 Feb 2017 20:05:49 +0000 (21:05 +0100)]
Add pkg-config file to Debian packages.

7 years agoMerge pull request #942 from r4f4/fix-filetop
Brenden Blanco [Tue, 14 Feb 2017 16:50:53 +0000 (08:50 -0800)]
Merge pull request #942 from r4f4/fix-filetop

filetop: Fix TypeError by not mixing bytes and str.

7 years agofiletop: Fix TypeError by not mixing bytes and str.
Rafael Fonseca [Mon, 6 Feb 2017 16:07:28 +0000 (17:07 +0100)]
filetop: Fix TypeError by not mixing bytes and str.

When executing the filetop command tool, the following message was
generated:

Traceback (most recent call last):
  File "/usr/share/bcc/tools/filetop", line 190, in <module>
    name = name[:-3] + "..."
TypeError: can't concat bytes to str

Also, by decoding the bytes we print the strings without a leading "b'"
making the output more readable.

7 years agoMerge pull request #871 from zhiyisun/patch
Brenden Blanco [Tue, 14 Feb 2017 08:19:18 +0000 (00:19 -0800)]
Merge pull request #871 from zhiyisun/patch

Add optional kernel flags for running networking examples in INSTALL.md

7 years agoMerge branch 'master' into patch
Brenden Blanco [Tue, 14 Feb 2017 08:18:43 +0000 (00:18 -0800)]
Merge branch 'master' into patch

7 years agoMerge pull request #949 from ShelbyFrances/trace_enhancements
Brenden Blanco [Tue, 14 Feb 2017 02:15:08 +0000 (18:15 -0800)]
Merge pull request #949 from ShelbyFrances/trace_enhancements

tools/trace accepts abspath arguments to -I (and some doc tweaks)

7 years agoMerge pull request #956 from r4f4/fix-ucalls
Brenden Blanco [Tue, 14 Feb 2017 02:14:20 +0000 (18:14 -0800)]
Merge pull request #956 from r4f4/fix-ucalls

Fix ucalls

7 years agoMerge pull request #965 from r4f4/fix-tools-py2
Brenden Blanco [Tue, 14 Feb 2017 02:06:50 +0000 (18:06 -0800)]
Merge pull request #965 from r4f4/fix-tools-py2

fixes #962 - fix lambda on both py2 and py3

7 years agoMerge pull request #920 from pchaigno/pid-filter-gethostlatency
Brendan Gregg [Mon, 13 Feb 2017 22:39:02 +0000 (14:39 -0800)]
Merge pull request #920 from pchaigno/pid-filter-gethostlatency

gethostlatency: Filter by process ID

7 years agogethostlatency: Filter on PID
Paul Chaignon [Mon, 23 Jan 2017 21:43:10 +0000 (22:43 +0100)]
gethostlatency: Filter on PID

7 years agoMerge pull request #964 from goldshtn/utools-missing-probes
4ast [Mon, 13 Feb 2017 20:46:52 +0000 (12:46 -0800)]
Merge pull request #964 from goldshtn/utools-missing-probes

u* tools: Gracefully handle missing probes

7 years agotools: Document use of -I <path> in trace, argdist
ShelbyFrances [Wed, 8 Feb 2017 02:56:53 +0000 (05:56 +0300)]
tools: Document use of -I <path> in trace, argdist

7 years agotools: support -I abspath in trace, argdist
ShelbyFrances [Wed, 8 Feb 2017 02:56:52 +0000 (05:56 +0300)]
tools: support -I abspath in trace, argdist

7 years agotools/trace: Document DSO tracing in tools/trace_example.txt
ShelbyFrances [Wed, 8 Feb 2017 02:56:37 +0000 (05:56 +0300)]
tools/trace: Document DSO tracing in tools/trace_example.txt

7 years agou* tools: Gracefully handle missing probes
Sasha Goldshtein [Wed, 8 Feb 2017 21:02:11 +0000 (16:02 -0500)]
u* tools: Gracefully handle missing probes

When the target process is missing the required USDT probes, it can
be a simple mistake (e.g. attaching a script as Java to a Python
process), or a runtime that is not instrumented with the required
probes. Attempt to gracefully handle the error and print a helpful
message instructing the user why the error might have occurred.

```
$ uthreads -l java $(pidof python)
Error attaching USDT probes: the specified pid might not contain
the given language's runtime, or the runtime was not built with the
required USDT probes. Look for a configure flag similar to
--with-dtrace or --enable-dtrace. To check which probes are present
in the process, use the tplist tool.
```

7 years agoMerge pull request #963 from goldshtn/utools-php
4ast [Mon, 13 Feb 2017 15:58:06 +0000 (07:58 -0800)]
Merge pull request #963 from goldshtn/utools-php

u* tools: PHP support

7 years agoMerge pull request #961 from goldshtn/ugc-filters
4ast [Mon, 13 Feb 2017 15:57:22 +0000 (07:57 -0800)]
Merge pull request #961 from goldshtn/ugc-filters

ugc: Add -M for minimum time and -F for text filtering

7 years agofixes #962 - fix lambda on both py2 and py3
Rafael Fonseca [Mon, 13 Feb 2017 15:04:33 +0000 (16:04 +0100)]
fixes #962 - fix lambda on both py2 and py3

See: https://www.python.org/dev/peps/pep-3113/

7 years agoucalls: fix lambda syntax on python3
Rafael Fonseca [Mon, 13 Feb 2017 14:52:04 +0000 (15:52 +0100)]
ucalls: fix lambda syntax on python3

$ ucalls
  File "./ucalls", line 239
    data = map(lambda (k, v): (k.clazz + "." + k.method,
                      ^
SyntaxError: invalid syntax

See: https://www.python.org/dev/peps/pep-3113/

7 years agoucalls: fix map behaviour on python3
Rafael Fonseca [Mon, 13 Feb 2017 14:46:54 +0000 (15:46 +0100)]
ucalls: fix map behaviour on python3

On python3 map returns a generator instead of a list. This fixes the
following error:

Traceback (most recent call last):
  File "./ucalls", line 280, in <module>
    data = get_data()   # [(function, (num calls, latency in ns))]
  File "./ucalls", line 255, in get_data
    data.extend(syscalls)
AttributeError: 'map' object has no attribute 'extend'

7 years agoMerge pull request #959 from r4f4/fix-uobjnew
Brenden Blanco [Fri, 10 Feb 2017 17:44:17 +0000 (09:44 -0800)]
Merge pull request #959 from r4f4/fix-uobjnew

Fix uobjnew and ustat on python3

7 years agoMerge pull request #953 from Appdynamics/master
Brenden Blanco [Fri, 10 Feb 2017 17:27:53 +0000 (09:27 -0800)]
Merge pull request #953 from Appdynamics/master

Debian jessie .deb build config and automated test fixes.

7 years agoustat: fix lambda syntax on python3.
Rafael Fonseca [Fri, 10 Feb 2017 12:56:02 +0000 (13:56 +0100)]
ustat: fix lambda syntax on python3.

$ ./ustat
  File "./ustat", line 242
    counts = sorted(counts.items(), key=lambda (_, v):
                                               ^
SyntaxError: invalid syntax

7 years agouobjnew: fix lambda syntax in python3
Rafael Fonseca [Fri, 10 Feb 2017 12:51:31 +0000 (13:51 +0100)]
uobjnew: fix lambda syntax in python3

$ ./uobjnew
  File "./uobjnew", line 150
    data = sorted(data.items(), key=lambda (k, v): v.num_allocs)
                                           ^
SyntaxError: invalid syntax

7 years agousdt: convert text from bytes to str
Rafael Fonseca [Fri, 10 Feb 2017 12:50:13 +0000 (13:50 +0100)]
usdt: convert text from bytes to str

This fixes a TypeError in python 3, e.g, when executing uobjnew

Traceback (most recent call last):
  File "./uobjnew", line 134, in <module>
    bpf = BPF(text=program, usdt_contexts=[usdt])
  File "/usr/lib/python3.5/site-packages/bcc/__init__.py", line 224, in __init__
    text = usdt_text + text
TypeError: can't concat bytes to str

7 years agoMerge pull request #958 from iovisor/dpkg-deb-compress
4ast [Thu, 9 Feb 2017 23:56:08 +0000 (15:56 -0800)]
Merge pull request #958 from iovisor/dpkg-deb-compress

Use fast compression in test deb builds

7 years agoUse fast compression in test deb builds
Brenden Blanco [Thu, 9 Feb 2017 22:58:33 +0000 (14:58 -0800)]
Use fast compression in test deb builds

Builds on GCE/ubuntu image were taking a long time due to combination of
disk speed/single core, and the default dpkg-deb compression level
(-z9). The dpkg-deb alone step was taking up to 5 minutes. Reduce to ~1
minute by forcing -z1. Unfortunately, it was not obvious how to capture
the option in debuild command, so this is a bit hacky.

Signed-off-by: Brenden Blanco <bblanco@gmail.com>
7 years agoMerge pull request #957 from iovisor/misc_fixes
4ast [Thu, 9 Feb 2017 20:44:09 +0000 (12:44 -0800)]
Merge pull request #957 from iovisor/misc_fixes

Fixes for LLVM4+, python3

7 years agopython3 compat: tracepoint fixes
Brenden Blanco [Thu, 9 Feb 2017 20:03:55 +0000 (12:03 -0800)]
python3 compat: tracepoint fixes

Signed-off-by: Brenden Blanco <bblanco@gmail.com>
7 years agopython3 compat: add missing str->bytes conversion
Brenden Blanco [Thu, 9 Feb 2017 19:21:15 +0000 (11:21 -0800)]
python3 compat: add missing str->bytes conversion

Signed-off-by: Brenden Blanco <bblanco@gmail.com>
7 years agoFix for test_log_buf to work with python3
Brenden Blanco [Thu, 9 Feb 2017 19:11:23 +0000 (11:11 -0800)]
Fix for test_log_buf to work with python3

In python3, output needs to be converted from ascii to str before the
"error_msg in str" test will succeed. This change should be backwards
compatible with python2.

Signed-off-by: Brenden Blanco <bblanco@gmail.com>
7 years agoStyle fixes for loader.cc
Brenden Blanco [Thu, 9 Feb 2017 18:59:16 +0000 (10:59 -0800)]
Style fixes for loader.cc

Diff generated by clang-format

Signed-off-by: Brenden Blanco <bblanco@gmail.com>
7 years agoUse builtin clang::CompilerInvocation object
Brenden Blanco [Thu, 9 Feb 2017 18:56:03 +0000 (10:56 -0800)]
Use builtin clang::CompilerInvocation object

Recent llvm changed the calling convention of setInvocation, breaking
3.9/4.0 compatibility. This new approach works for both.

Signed-off-by: Brenden Blanco <bblanco@gmail.com>
7 years agoExplicitly mark b functions as nounwind
Brenden Blanco [Thu, 9 Feb 2017 18:53:29 +0000 (10:53 -0800)]
Explicitly mark b functions as nounwind

Without marking as nounwind, recent llvm started generating .eh_frame
section, which is invalid for bpf target jit.

Signed-off-by: Brenden Blanco <bblanco@gmail.com>
7 years agoMark additional helper function as inline
Brenden Blanco [Thu, 9 Feb 2017 18:52:40 +0000 (10:52 -0800)]
Mark additional helper function as inline

Signed-off-by: Brenden Blanco <bblanco@gmail.com>
7 years agoMerge pull request #916 from pchaigno/use-pid-to-resolve-lib
Brenden Blanco [Thu, 9 Feb 2017 18:21:03 +0000 (10:21 -0800)]
Merge pull request #916 from pchaigno/use-pid-to-resolve-lib

Use PID to resolve path of target libraries

7 years agoMerge pull request #951 from r4f4/fix-trace-py3
Brenden Blanco [Thu, 9 Feb 2017 18:18:20 +0000 (10:18 -0800)]
Merge pull request #951 from r4f4/fix-trace-py3

trace: fix for python3

7 years agoMerge pull request #952 from ColinIanKing/master
Brenden Blanco [Thu, 9 Feb 2017 18:13:23 +0000 (10:13 -0800)]
Merge pull request #952 from ColinIanKing/master

snapcraft: add in some missing tools from the snapcraft apps list

7 years agoMerge pull request #955 from r4f4/fix-tplist
4ast [Thu, 9 Feb 2017 17:02:03 +0000 (09:02 -0800)]
Merge pull request #955 from r4f4/fix-tplist

tplist: don't fail if no verbosity is supplied

7 years agoMerge pull request #954 from brendangregg/master
Brenden Blanco [Thu, 9 Feb 2017 15:58:00 +0000 (07:58 -0800)]
Merge pull request #954 from brendangregg/master

update tools pic

7 years agotplist: don't fail if no verbosity is supplied
Rafael Fonseca [Thu, 9 Feb 2017 15:20:24 +0000 (16:20 +0100)]
tplist: don't fail if no verbosity is supplied

Initialise the verbosity argument to 0, so that when no verbosity is
provided we don't fail with

$ tplist
kvmmmu:kvm_mmu_pagetable_walk
unorderable types: NoneType() > int()

7 years agoStill figuring out anchors in markdown.
Michael Przybylski [Fri, 20 Jan 2017 15:55:07 +0000 (07:55 -0800)]
Still figuring out anchors in markdown.

7 years agoStill figuring out anchors in markdown.
Michael Przybylski [Fri, 20 Jan 2017 15:53:56 +0000 (07:53 -0800)]
Still figuring out anchors in markdown.

7 years agoBuilding on Debian Jessie
Michael Przybylski [Fri, 20 Jan 2017 15:29:58 +0000 (07:29 -0800)]
Building on Debian Jessie

Minor debian/control file updates
Added Debian - Source section to INSTALL.md

7 years agoYanked all libbcc.so tests out of test/lua/test_standalone.sh
Michael Przybylski [Fri, 20 Jan 2017 09:10:27 +0000 (01:10 -0800)]
Yanked all libbcc.so tests out of test/lua/test_standalone.sh

On 30 April 2016 Vicent Marti modified src/lua/CMakeLists.txt to
statically link libbcc into bcc-lua.  This causes one of the tests
in test/lua/test_standalone.sh to fail, and renders all of the tests
related to libbcc.so obsolete.

7 years agoFixed TestUprobes.test_simple_library() in test_uprobes.lua
Michael Przybylski [Fri, 20 Jan 2017 07:54:03 +0000 (23:54 -0800)]
Fixed TestUprobes.test_simple_library() in test_uprobes.lua

7 years agoFixed failing test_simple_library() in test_uprobes.py
Michael Przybylski [Fri, 20 Jan 2017 07:21:07 +0000 (23:21 -0800)]
Fixed failing test_simple_library() in test_uprobes.py

7 years agoDebian jessie compile/test work in progress.
Michael Przybylski [Thu, 12 Jan 2017 17:04:44 +0000 (09:04 -0800)]
Debian jessie compile/test work in progress.

7 years agoUpdate tools to use new BPF.monotonic_time method
Sasha Goldshtein [Thu, 9 Feb 2017 09:19:53 +0000 (04:19 -0500)]
Update tools to use new BPF.monotonic_time method

7 years agoMove monotonic_time to BPF class, use CLOCK_MONOTONIC
Sasha Goldshtein [Thu, 9 Feb 2017 09:18:04 +0000 (04:18 -0500)]
Move monotonic_time to BPF class, use CLOCK_MONOTONIC

This allows all the tools (currently: trace and memleak) to use the
`monotonic_time` facility, with the fix to use `CLOCK_MONOTONIC`
instead of `CLOCK_MONOTONIC_RAW`. Resolves #931.

7 years agoupdate tools pic
Brendan Gregg [Thu, 9 Feb 2017 07:49:21 +0000 (23:49 -0800)]
update tools pic

7 years agou* tools: PHP support
Sasha Goldshtein [Wed, 8 Feb 2017 19:32:51 +0000 (14:32 -0500)]
u* tools: PHP support

Introduce PHP support to ucalls, uflow, and ustat. The PHP probes
used are for function entry and exit, file compile (~ class load),
and exception throw. This requires a PHP runtime built with the
`--enable-dtrace` configure switch. Some probes also require
USE_ZEND_DTRACE=1.

Resolves #945.

7 years agotrace: fix for python3
Rafael Fonseca [Wed, 8 Feb 2017 15:14:31 +0000 (16:14 +0100)]
trace: fix for python3

xrange does not exist in py3.

7 years agosnapcraft: add in some missing tools from the snapcraft apps list
Colin Ian King [Wed, 8 Feb 2017 18:29:05 +0000 (18:29 +0000)]
snapcraft: add in some missing tools from the snapcraft apps list

Add in capable, deadlock-detector, llcstat, mountsnoop, profile,
runqlen, solisten, tplist, ucalls, uflow, ugc, uobjnew, ustat
and uthreads. Includes some re-ordering as well.

Signed-off-by: Colin Ian King <colin.king@canonical.com>
7 years agougc: Add -M for minimum time and -F for text filtering
Sasha Goldshtein [Wed, 8 Feb 2017 18:22:40 +0000 (13:22 -0500)]
ugc: Add -M for minimum time and -F for text filtering

Filter out collections that are shorter than x milliseconds by using
`ugc -M x`. Display only collections that contain a certain string s
in their description by using `ugc -F s`. The latter option is not
implemented in the kernel, but rather just before printing the event
in the user script (for simplicity), and documented as such.

7 years agoMerge pull request #948 from shodoco/master
4ast [Wed, 8 Feb 2017 16:37:11 +0000 (08:37 -0800)]
Merge pull request #948 from shodoco/master

bcc: add support for lpm trie map type

7 years agobcc: update kernel-versions.md for lpm trie change
Huapeng Zhou [Wed, 8 Feb 2017 07:27:20 +0000 (23:27 -0800)]
bcc: update kernel-versions.md for lpm trie change

7 years agobcc: add support for lpm trie map type
Huapeng Zhou [Tue, 7 Feb 2017 23:03:32 +0000 (15:03 -0800)]
bcc: add support for lpm trie map type

7 years agoMerge pull request #946 from goldshtn/install-fc2425
Brenden Blanco [Tue, 7 Feb 2017 20:08:39 +0000 (12:08 -0800)]
Merge pull request #946 from goldshtn/install-fc2425

Update installation instructions for FC24 and FC25

7 years agoMerge pull request #947 from rnav/powerpc64-doc-update
4ast [Tue, 7 Feb 2017 16:33:44 +0000 (08:33 -0800)]
Merge pull request #947 from rnav/powerpc64-doc-update

docs/kernel-versions: add reference to powerpc64 constant blinding support

7 years agodocs/kernel-versions: add reference to powerpc64 constant blinding support
Naveen N. Rao [Tue, 7 Feb 2017 14:53:50 +0000 (20:23 +0530)]
docs/kernel-versions: add reference to powerpc64 constant blinding support

... introduced in v4.9

Signed-off-by: Naveen N. Rao <naveen.n.rao@linux.vnet.ibm.com>
7 years agoUpdate installation instructions for FC24 and FC25
Sasha Goldshtein [Tue, 7 Feb 2017 10:09:07 +0000 (05:09 -0500)]
Update installation instructions for FC24 and FC25

It turns out that for FC24 and FC25, there is a sufficiently recent
version of Clang in the official package sources, so we don't need
to fetch it from llvm.org using wget. Tested manually on a pair of
fresh FC24 and FC25 VMs, and confirmed that BCC builds and runs OK.

7 years agoMerge pull request #936 from kennyyu/kennyyu-deadlock-detector
4ast [Tue, 7 Feb 2017 04:56:12 +0000 (20:56 -0800)]
Merge pull request #936 from kennyyu/kennyyu-deadlock-detector

tools: add tool to detect potential deadlocks in running programs

7 years agoMerge pull request #944 from derek0883/mybcc
4ast [Tue, 7 Feb 2017 04:54:43 +0000 (20:54 -0800)]
Merge pull request #944 from derek0883/mybcc

switch bcc to use single instance per bcc process, fixed issue #940

7 years agoswitch bcc to use single instance per bcc process,
Derek [Tue, 7 Feb 2017 03:34:11 +0000 (19:34 -0800)]
switch bcc to use single instance per bcc process,
instance dir is bcc_pid, fixed issue #940

7 years agoMerge branch 'master' into kennyyu-deadlock-detector
Kenny Yu [Mon, 6 Feb 2017 20:41:44 +0000 (12:41 -0800)]
Merge branch 'master' into kennyyu-deadlock-detector

7 years agoMerge pull request #943 from edwardshao/topic/fix-docs-commit-link
4ast [Mon, 6 Feb 2017 18:26:31 +0000 (10:26 -0800)]
Merge pull request #943 from edwardshao/topic/fix-docs-commit-link

docs: fix "BPF attached to sockets" commit link

7 years agodocs: fix "BPF attached to sockets" commit link
Edward Shao [Mon, 6 Feb 2017 17:27:27 +0000 (01:27 +0800)]
docs: fix "BPF attached to sockets" commit link

7 years agoMerge branch 'master' into kennyyu-deadlock-detector
Kenny Yu [Sun, 5 Feb 2017 23:31:22 +0000 (15:31 -0800)]
Merge branch 'master' into kennyyu-deadlock-detector

7 years agoMerge pull request #937 from netoptimizer/for_upstream01
4ast [Sun, 5 Feb 2017 16:24:37 +0000 (08:24 -0800)]
Merge pull request #937 from netoptimizer/for_upstream01

docs: keep track of when prealloc of map elements were introduced

7 years agoAddress round 2 of comments in https://github.com/iovisor/bcc/pull/936
Kenny Yu [Sat, 4 Feb 2017 02:50:33 +0000 (18:50 -0800)]
Address round 2 of comments in https://github.com/iovisor/bcc/pull/936

- Specify when `--binary` is needed (statically vs dynamically-linked
  binaries).

- Make `-h`, `_examples.txt`, and man page have concrete examples and
  be more user-friendly.

7 years agoMerge branch 'master' into kennyyu-deadlock-detector
Kenny Yu [Fri, 3 Feb 2017 22:24:40 +0000 (14:24 -0800)]
Merge branch 'master' into kennyyu-deadlock-detector

7 years agoFix a few small typos
Kenny Yu [Fri, 3 Feb 2017 21:33:20 +0000 (13:33 -0800)]
Fix a few small typos

7 years agoAddress comments from https://github.com/iovisor/bcc/pull/936
Kenny Yu [Fri, 3 Feb 2017 17:39:39 +0000 (09:39 -0800)]
Address comments from https://github.com/iovisor/bcc/pull/936

- Remove dependency on networkx. I did this by copying only the parts I needed
  from networkx, and adapting it to only use what I needed. These include:
  `DiGraph`, `strongly_connected_components`, `simple_cyles`

- Symbolize global and static mutexes. In order to do this, I subshell out to
  `subshell`. This isn't very efficient, but this only happens at the end of
  the program if a deadlock is found, so it's not too bad.

- `--verbose` mode to print graph statistics

- Make `--binary` flag optional. Not needed by default, However, this is needed
  on kernels without this recent kernel patch
  (https://lkml.org/lkml/2017/1/13/585, submitted 2 weeks ago): we can't attach
  a uprobe on a binary that has `:` in the path name. Instead, we can create a
  symlink without `:` in the path and pass that to the `--binary` argument
  instead.

7 years agodocs: keep track of when prealloc of map elements were introduced
Jesper Dangaard Brouer [Fri, 3 Feb 2017 07:46:48 +0000 (08:46 +0100)]
docs: keep track of when prealloc of map elements were introduced

Kernel v4.6-rc1~91^2~108^2~6
 commit 6c9059817432 ("bpf: pre-allocate hash map elements")

Introduced default preallocation of mem elements to solve a deadlock
(when kprobe'ing the memory allocator itself).

This change is also a performance enhancement.

The commit also introduced a map_flags on BPF_MAP_CREATE, which can disable
this preallocation again BPF_F_NO_PREALLOC.

Signed-off-by: Jesper Dangaard Brouer <brouer@redhat.com>
7 years agotools: add tool to detect potential deadlocks in running programs
Kenny Yu [Thu, 2 Feb 2017 18:05:31 +0000 (10:05 -0800)]
tools: add tool to detect potential deadlocks in running programs

`deadlock_detector` is a new tool to detect potential deadlocks (lock order
inversions) in a running process. The program attaches uprobes on
`pthread_mutex_lock` and `pthread_mutex_unlock` to build a mutex wait directed
graph, and then looks for a cycle in this graph. This graph has the following
properties:

- Nodes in the graph represent mutexes.
- Edge (A, B) exists if there exists some thread T where lock(A) was called
  and lock(B) was called before unlock(A) was called.

If there is a cycle in this graph, this indicates that there is a lock order
inversion (potential deadlock). If the program finds a lock order inversion, the
program will dump the cycle of mutexes, dump the stack traces where each mutex
was acquired, and then exit.

The format of the output uses a similar output as ThreadSanitizer (See example:
https://github.com/google/sanitizers/wiki/ThreadSanitizerDeadlockDetector)

This program can only find potential deadlocks that occur while the program is
tracing the process. It cannot find deadlocks that may have occurred before the
program was attached to the process.

If the traced process has many mutexes and threads, this program will add a
very large overhead because every mutex lock/unlock and clone call will be
traced. This tool is meant for debugging only, and you should run this tool
only on programs where the slowdown is acceptable.

Note: This tool adds a dependency on `networkx` for the graph libraries
(building a directed graph and cycle detection).

Note: This tool does not work for shared mutexes or recursive mutexes.

For shared (read-write) mutexes, a deadlock requires a cycle in the wait
graph where at least one of the mutexes in the cycle is acquiring exclusive
(write) ownership.

For recursive mutexes, lock() is called multiple times on the same mutex.
However, there is no way to determine if a mutex is a recursive mutex
after the mutex has been created. As a result, this tool will not find
potential deadlocks that involve only one mutex.

7 years agoMerge pull request #935 from wcohen/wcohen/lua_opt
Brenden Blanco [Fri, 3 Feb 2017 00:55:51 +0000 (16:55 -0800)]
Merge pull request #935 from wcohen/wcohen/lua_opt

Allow RPMS to be built on ppc64 and aarch64 by making luajit optional

7 years agoAllow RPMS to be built on ppc64 and aarch64 by making luajit optional
William Cohen [Thu, 2 Feb 2017 22:24:32 +0000 (17:24 -0500)]
Allow RPMS to be built on ppc64 and aarch64 by making luajit optional

Not all architectures have luajit supported.  The bcc configure and
build were already was set up to make the luajit dependent parts
optional.  The bcc.spec now makes the luajit dependent parts optional
too allowing Fedora 25 builds on ppc64, ppc64le, and aarch64.  This
change has been tested and allows the resulting srpm to build on the
Fedora koji build system for the newly added architectures.

Signed-off-by: William Cohen <wcohen@redhat.com>
7 years agoMerge pull request #928 from goldshtn/tp-data-loc
4ast [Wed, 1 Feb 2017 18:21:16 +0000 (10:21 -0800)]
Merge pull request #928 from goldshtn/tp-data-loc

Support for __data_loc tracepoint fields

7 years agotplist: Don't ignore __data_loc fields
Sasha Goldshtein [Wed, 1 Feb 2017 09:57:01 +0000 (09:57 +0000)]
tplist: Don't ignore __data_loc fields

7 years agotests: Add test for TP_DATA_LOC_READ_CONST
Sasha Goldshtein [Wed, 1 Feb 2017 09:39:12 +0000 (09:39 +0000)]
tests: Add test for TP_DATA_LOC_READ_CONST

7 years agocc: Support for __data_loc tracepoint fields
Sasha Goldshtein [Wed, 1 Feb 2017 06:58:59 +0000 (06:58 +0000)]
cc: Support for __data_loc tracepoint fields

`__data_loc` fields are dynamically sized by the kernel at
runtime. The field data follows the tracepoint structure entry,
and needs to be extracted in a special way. The `__data_loc` field
itself is a 32-bit value that consists of two 16-bit parts: the
high 16 bits are the length of the data, and the low 16 bits are
the offset of the data from the beginning of the tracepoint
structure. From a cursory look, there are >200 tracepoints in
recent kernels that have this kind of field.

This patch fixes `tp_frontend_action.cc` to recognize and emit
`__data_loc` fields correctly, as 32-bit opaque fields. Then, it
introduces two helper macros:

`TP_DATA_LOC_READ(dst, field)` reads from `args->field` by finding
the right offset and length and emitting the `bpf_probe_read`
required to fetch the data. This will only work with new kernels.

`TP_DATA_LOC_READ_CONST(dst, field, length)` takes a user-specified
length rather than finding it from `args->field`. This will work
on older kernels, where the BPF verifier doesn't allow non-constant
sizes to be passed to `bpf_probe_read`.

7 years agoMerge pull request #918 from derek0883/mybcc
4ast [Wed, 1 Feb 2017 04:39:09 +0000 (20:39 -0800)]
Merge pull request #918 from derek0883/mybcc

Handling multiple concurrent probe users.

7 years agoenum bpf_probe_attach_type to CAPITAL
Derek [Wed, 1 Feb 2017 03:28:10 +0000 (19:28 -0800)]
enum bpf_probe_attach_type to CAPITAL

7 years agoundo rebase
Derek [Wed, 1 Feb 2017 02:22:24 +0000 (18:22 -0800)]
undo rebase

7 years agoMerge pull request #927 from rnav/powerpc-fixes
4ast [Tue, 31 Jan 2017 17:59:34 +0000 (09:59 -0800)]
Merge pull request #927 from rnav/powerpc-fixes

powerpc: update the build triplet

7 years agopowerpc: update the build triplet
Naveen N. Rao [Tue, 31 Jan 2017 11:49:17 +0000 (17:19 +0530)]
powerpc: update the build triplet

The more commonly used triplet on ppc64le happens to be
powerpc64le-unknown-linux-gnu. The existing one causes problems in
certain build environments. Change this.

While at it, also include support for building on big endian.

Reported-by: Anton Blanchard <anton@samba.org>
Signed-off-by: Naveen N. Rao <naveen.n.rao@linux.vnet.ibm.com>
7 years agoMerge branch 'mybcc' of https://github.com/derek0883/bcc into mybcc
Derek [Tue, 31 Jan 2017 05:16:55 +0000 (21:16 -0800)]
Merge branch 'mybcc' of https://github.com/derek0883/bcc into mybcc

7 years agokeep 'enum bpf_attach_type' inside libbpf.h, renamed it to bpf_probe_attach_type
Derek [Tue, 31 Jan 2017 05:03:02 +0000 (21:03 -0800)]
keep 'enum bpf_attach_type' inside libbpf.h, renamed it to bpf_probe_attach_type
using static buf size in libbpf.c. for uprobe, set buf size to PATH_MAX

7 years agoFixed test case test_trace4.py error
Derek [Sun, 29 Jan 2017 01:43:15 +0000 (17:43 -0800)]
Fixed test case test_trace4.py error

7 years ago Handling multiple concurrent probe users.
Derek [Sun, 29 Jan 2017 00:11:28 +0000 (16:11 -0800)]
Handling multiple concurrent probe users.
    remove event_desc from front-end, handle it inside libbpf
    Event naming pattern changed to $(eventname)_bcc_$(pid)

7 years agorename event_name for lua
Derek [Thu, 26 Jan 2017 02:01:16 +0000 (18:01 -0800)]
rename event_name for lua

7 years agorename event name in detach_uprobe/detach_uretprobe
Derek [Tue, 24 Jan 2017 04:46:35 +0000 (20:46 -0800)]
rename event name in detach_uprobe/detach_uretprobe

7 years agorename event name in detach_kprobe/detach_kretprobe
Derek [Tue, 24 Jan 2017 04:32:59 +0000 (20:32 -0800)]
rename event name in detach_kprobe/detach_kretprobe

7 years agoHandling multiple concurrent probe users.
Derek [Mon, 23 Jan 2017 04:58:23 +0000 (20:58 -0800)]
Handling multiple concurrent probe users.
Event naming pattern changed to $(eventname)_bcc_$(pid)
Detect /sys/kernel/debug/tracing/instances in bpf_attach_probe,
if it exist, then will per-instance event, if failed the make global
event instance as same as before.