Skip to content

Commit edb70ea

Browse files
committed
libbpf-tools/biosnoop: Fix incorrect sizeof in bpf_get_current_comm
sizeof(&piddata.comm) returns the size of the pointer (8 bytes on 64-bit), while sizeof(piddata.comm) returns the actual size of the char array (TASK_COMM_LEN). This error caused the task command to be truncated. Original output (truncated COMM): TIME(s) COMM PID DISK T SECTOR BYTES LAT(ms) 0.000634 f2fs_ck 298 mmcblk0 WSM 5037016 16384 0.108 0.004835 kworker 2628 mmcblk0 WFSM 5037048 4096 0.464 Fixed output: TIME(s) COMM PID DISK T SECTOR BYTES LAT(ms) 0.000253 f2fs_ckpt-254: 298 mmcblk0 WSM 5032920 20480 0.903 0.002865 kworker/0:0 2628 mmcblk0 WFSM 5032960 4096 0.495 Change-Id: Iaf1753055a9117e3cf6dbbf6dc6a6c753a584f6c Signed-off-by: Ism Hong <ism.hong@gmail.com>
1 parent b11c1bd commit edb70ea

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

libbpf-tools/biosnoop.bpf.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ int trace_pid(struct request *rq)
6262
struct piddata piddata = {};
6363

6464
piddata.pid = id >> 32;
65-
bpf_get_current_comm(&piddata.comm, sizeof(&piddata.comm));
65+
bpf_get_current_comm(&piddata.comm, sizeof(piddata.comm));
6666
bpf_map_update_elem(&infobyreq, &rq, &piddata, 0);
6767
return 0;
6868
}

0 commit comments

Comments
 (0)