History

blktrace: export cgroup info in trace

Currently blktrace isn't cgroup aware. blktrace prints out task name of current context, but the task of current context isn't always in the cgroup where the BIO comes from. We can't use task name to find out IO cgroup. For example, Writeback BIOs always comes from flusher thread but the BIOs are for different blk cgroups. Request could be requeued and dispatched from completely different tasks. MD/DM are another examples. This patch tries to fix the gap. We print out cgroup fhandle info in blktrace. Userspace can use open_by_handle_at() syscall to find the cgroup by fhandle. Or userspace can use name_to_handle_at() syscall to find fhandle for a cgroup and use a BPF program to filter out blktrace for a specific cgroup. We add a new 'blk_cgroup' trace option for blk tracer. It's default off. Application which doesn't know the new option isn't affected. When it's on, we output fhandle info right after blk_io_trace with an extra bit set in event action. So from application point of view, blktrace with the option will output new actions. I didn't change blk trace event yet, since I'm not sure if changing the trace event output is an ABI issue. If not, I'll do it later.

Shaohua Li committed 9 years ago

Commit ca1136c1 parent 121508d2 files · +161 −73Browse files

Showing the changes to include/uapi/linux (1 of 2 files). Show all

Unified · Split

include/uapi/linux/blktrace_api.h+3−0
@@ -52,6 +52,7 @@ enum blktrace_act { · 51 unmodified lines
52 __BLK_TA_REMAP, /* bio was remapped */52 __BLK_TA_REMAP, /* bio was remapped */
53 __BLK_TA_ABORT, /* request aborted */53 __BLK_TA_ABORT, /* request aborted */
54 __BLK_TA_DRV_DATA, /* driver-specific binary data */54 __BLK_TA_DRV_DATA, /* driver-specific binary data */
55 __BLK_TA_CGROUP = 1 << 8, /* from a cgroup*/
55};56};
56 57
57/*58/*
@@ -61,6 +62,7 @@ enum blktrace_notify { · 3 unmodified lines
61 __BLK_TN_PROCESS = 0, /* establish pid/name mapping */62 __BLK_TN_PROCESS = 0, /* establish pid/name mapping */
62 __BLK_TN_TIMESTAMP, /* include system clock */63 __BLK_TN_TIMESTAMP, /* include system clock */
63 __BLK_TN_MESSAGE, /* Character string message */64 __BLK_TN_MESSAGE, /* Character string message */
65 __BLK_TN_CGROUP = __BLK_TA_CGROUP, /* from a cgroup */
64};66};
65 67
66 68
@@ -107,6 +109,7 @@ struct blk_io_trace { · 40 unmodified lines
107 __u32 cpu; /* on what cpu did it happen */109 __u32 cpu; /* on what cpu did it happen */
108 __u16 error; /* completion error */110 __u16 error; /* completion error */
109 __u16 pdu_len; /* length of data after this trace */111 __u16 pdu_len; /* length of data after this trace */
112 /* cgroup id will be stored here if exists */
110};113};
111 114
112/*115/*

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t