5 karma · joined July 3, 2015
Unfortunately, I don't believe the high level list of which hooks have gpl helpers is published, so reading the code is the best method currently.
Where GPL comes in is when you use BPF to introspect the kernel. It is quite possible to use BPF programs with the kprobe hook to extract data about how the kernel itself works, and the opinion of the kernel developers on this is that such use cases are within the realm of GPL protection.
We're really hoping that this set of tools has only the minimal requirements, that being the kernel.
Since Clang/LLVM can be linked as a static or dynamic library, we only have a build-time dependency on those, and opt for the static library. The build scripts have steps to build clang+llvm from source if your distro doesn't include it. The binaries that we ship hide this and should (if we've done things right) only have a libc and few misc .so dependencies. A change under test even adds a fully static lua version.
On the kernel side, we don't conditionally compile anything based on kernel features, and instead try/fail at runtime. You can just upgrade your kernel and the tools will start to take advantage of the new features immediately.
The req->rq_disk->disk_name expression would expand into:
({ typeof(char [32]) _val; memset(&_val, 0, sizeof(_val)); bpf_probe_read(&_val, sizeof(_val), (u64)({ typeof(struct gendisk *) _val; memset(&_val, 0, sizeof(_val)); bpf_probe_read(&_val, sizeof(_val), (u64)req + offsetof(struct request, rq_disk)); _val; }) + offsetof(struct gendisk, disk_name)); _val; }));
If you are playing with the tools, the BPF() class takes an optional argument debug=, where bit 2 (0x4) will print the rewritten C output for your edification.
A couple comparison points I noticed while briefly investigating shark:
C code is passed to clang+llc as external calls, whereas in BCC clang+llvm are statically linked in.
Both support native (lua/python) bindings to the eBPF maps.
In shark, I don't see that it is easy to dereference kprobe'd function arguments, as it is in `bpf_trace_printk("1 W %s %d %d ?\\n", req->rq_disk->disk_name, ...)` of <bcc>/tools/biosnoop.
This should also answer your last question, which was where is "%s" used. tools/opensnoop also uses string printks.
Comparison points aside, I intentionally made sure that the clang legwork that is being done in BCC is wrapped with a C api, so any language bindings besides python should be trivial to implement. It would be ideal (in my mind) if shark could leverage libbcc and make both tools better in the process.