Comments (5)
Not doing it wrong...this is a limitation of the currently implemented BCC rewriter. It only supports one level of variable dereference via bpf_probe_read (up to fpath.dentry).
Try the following:
#include <linux/fs.h>
void run_read(struct pt_regs *ctx, struct file *file)
{
struct dentry *dent = file->f_path.dentry;
if (file != NULL && dent != NULL) {
struct qstr d_name = {};
bpf_probe_read(&d_name, sizeof(d_name), &dent->d_name);
bpf_trace_printk("read %s\n", d_name.name);
} else {
bpf_trace_printk("was null");
}
}
Let's leave this issue open, I consider this limitation worth fixing.
from bcc.
Ok, thanks.
I'm going to postpone this approach for now: walking the d_parent entries to reconstruct a pathname (or at least get the parent directory) means a lot of code and strings. I'll see what I can do with just d_iname.
from bcc.
Give it a shot! :)
from bcc.
Wow:
# diff fsslower.old fsslower.new
81,86c81
< struct vfsmount *mnt = file->f_path.mnt;
< struct super_block *mnt_sb = NULL;
< bpf_probe_read(&mnt_sb, sizeof(mnt_sb), &mnt->mnt_sb);
< u64 s_bdev = 0;
< bpf_probe_read(&s_bdev, sizeof(s_bdev), &mnt_sb->s_bdev);
< if (s_bdev == 0) {
---
> if (file->f_path.mnt->mnt_sb->s_bdev == 0) {
Thanks!
from bcc.
Actually, internally rewriter generates:
#include <linux/fs.h>
// void run_read(struct pt_regs *ctx, struct file *file, struct dentry
*dentry)
attribute((section(".bpf.fn.run_read")))
void run_read(struct pt_regs *ctx, struct file *file)
{file = ctx->di;
// void *name = 0;
if (file != NULL && ({ struct dentry * _val; memset(&_val, 0,
sizeof(_val)); bpf_probe_read(&_val, sizeof(_val), (u64)file +
offsetof(struct file, f_path.dentry)); _val; }) != NULL) {
// bpf_trace_printk("read %s\n", file->f_path.dentry->d_iname);
({ char fmt[] = "read %s\n"; bpf_trace_printk(_fmt, sizeof(_fmt),
({ const unsigned char * _val; memset(&_val, 0, sizeof(_val));
bpf_probe_read(&_val, sizeof(_val), (u64)({ struct dentry * _val;
memset(&_val, 0, sizeof(_val)); bpf_probe_read(&_val, sizeof(_val),
(u64)file + offsetof(struct file, f_path.dentry)); _val; }) +
offsetof(struct dentry, d_name.name)); _val; })); });
} else {
({ char fmt[] = "was null"; bpf_trace_printk(_fmt, sizeof(_fmt));
});
}
}
Add debug=4 to BPF constructor will show the above debug information.
Very nice work.
On Tue, Sep 15, 2015 at 4:48 PM, Brendan Gregg [email protected]
wrote:
Wow:
diff fsslower.old fsslower.new
81,86c81
< struct vfsmount *mnt = file->f_path.mnt;
< struct super_block *mnt_sb = NULL;
< bpf_probe_read(&mnt_sb, sizeof(mnt_sb), &mnt->mnt_sb);
< u64 s_bdev = 0;
< bpf_probe_read(&s_bdev, sizeof(s_bdev), &mnt_sb->s_bdev);< if (s_bdev == 0) {
if (file->f_path.mnt->mnt_sb->s_bdev == 0) {
Thanks!
—
Reply to this email directly or view it on GitHub
#188 (comment).
from bcc.
Related Issues (20)
- ImportError: cannot import name 'BPF' from 'bcc' (unknown location)
- python-bcc works only if clang-libs Installed, fails with only clang16-libs Installed
- libbpf javagc fails when no PID is provided
- bpflist doesn't show attached probes
- Build fail from source HOT 4
- Fail building from source HOT 1
- attach_raw_socket function does not work well on Qualcomm modem HOT 1
- Build bcc from source code failed HOT 1
- Unable to obtain the complete function call stack of `__memset_avx2_erms`.
- Backported probe_user_read* probe_kernel_read* are not used by bcc HOT 3
- some libbpf-tools tooling / libbpf seems broken on thinlto-compiled kernel
- Not sure I understand the full issue or suggestion here. As it is now, we're just using standard gcc logic when compiling. HOT 1
- `bcc_procutils_which_so(libname, pid)` finds library unused by the process
- BCC source setup make error on Debian Bookworm HOT 3
- attach to specific address of user space spplication in c
- Using funclatency.py to trace bpf_map_lookup_elem HOT 1
- Use `-Werror=undef` when compiling bcc to catch issues when a macro is not defined. HOT 1
- fatal error: clang/Basic/FileManager.h: No such file or directory
- fatal error: -Werror=sign-compare with lastest libbpf-tools
- BPF.ring_buffer_poll(timeout=T) documentation ambigious HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from bcc.