Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
B
bcc
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
bcc
Commits
baebe807
Commit
baebe807
authored
Feb 06, 2016
by
Brendan Gregg
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
use one map instead of two
parent
aa1e6ca3
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
8 additions
and
10 deletions
+8
-10
tools/biosnoop.py
tools/biosnoop.py
+8
-10
No files found.
tools/biosnoop.py
View file @
baebe807
...
...
@@ -21,12 +21,12 @@ b = BPF(text="""
#include <linux/blkdev.h>
struct val_t {
u32 pid;
char name[TASK_COMM_LEN];
};
BPF_HASH(start, struct request *);
BPF_HASH(pidbyreq, struct request *, u32);
BPF_HASH(commbyreq, struct request *, struct val_t);
BPF_HASH(infobyreq, struct request *, struct val_t);
// cache PID and comm by-req
int trace_pid_start(struct pt_regs *ctx, struct request *req)
...
...
@@ -35,9 +35,9 @@ int trace_pid_start(struct pt_regs *ctx, struct request *req)
struct val_t val = {};
pid = bpf_get_current_pid_tgid();
pidbyreq.update(&req, &pid);
if (bpf_get_current_comm(&val.name, sizeof(val.name)) == 0) {
commbyreq.update(&req, &val);
val.pid = pid;
infobyreq.update(&req, &val);
}
return 0;
...
...
@@ -74,12 +74,11 @@ int trace_req_completion(struct pt_regs *ctx, struct request *req)
// As bpf_trace_prink() is limited to a maximum of 1 string and 2
// integers, we'll use more than one to output the data.
//
valp = commbyreq.lookup(&req);
pidp = pidbyreq.lookup(&req);
if (pidp == 0 || valp == 0) {
valp = infobyreq.lookup(&req);
if (valp == 0) {
bpf_trace_printk("0 0 ? %d
\
\
n", req->__data_len);
} else {
bpf_trace_printk("0 %d %s %d
\
\
n",
*pidp
, valp->name,
bpf_trace_printk("0 %d %s %d
\
\
n",
valp->pid
, valp->name,
req->__data_len);
}
...
...
@@ -93,8 +92,7 @@ int trace_req_completion(struct pt_regs *ctx, struct request *req)
}
start.delete(&req);
pidbyreq.delete(&req);
commbyreq.delete(&req);
infobyreq.delete(&req);
return 0;
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment