With the advert of container technologies like docker, that depend on namespaces for isolation, there is a need for tracing support for namespaces. This patch introduces new PERF_RECORD_NAMESPACES event for recording namespaces related info. By recording info for every namespace, it is left to userspace to take a call on the definition of a container and trace containers by updating perf tool accordingly. Each namespace has a combination of device and inode numbers. Though every namespace has the same device number currently, that may change in future to avoid the need for a namespace of namespaces. Considering such possibility, record both device and inode numbers separately for each namespace.
Showing the changes to include/uapi/linux (1 of 5 files). Show all
Unified · Split
| @@ -344,7 +344,8 @@ struct perf_event_attr { · 343 unmodified lines | ||
| 344 | 344 | use_clockid : 1, /* use @clockid for time fields */ |
| 345 | 345 | context_switch : 1, /* context switch data */ |
| 346 | 346 | write_backward : 1, /* Write ring buffer from end to beginning */ |
| 347 | − __reserved_1 : 36; | |
| 347 | + namespaces : 1, /* include namespaces data */ | |
| 348 | + __reserved_1 : 35; | |
| 348 | 349 | |
| 349 | 350 | union { |
| 350 | 351 | __u32 wakeup_events; /* wakeup every n events */ |
| @@ -610,6 +611,23 @@ struct perf_event_header { · 259 unmodified lines | ||
| 610 | 611 | __u16 size; |
| 611 | 612 | }; |
| 612 | 613 | |
| 614 | +struct perf_ns_link_info { | |
| 615 | + __u64 dev; | |
| 616 | + __u64 ino; | |
| 617 | +}; | |
| 618 | + | |
| 619 | +enum { | |
| 620 | + NET_NS_INDEX = 0, | |
| 621 | + UTS_NS_INDEX = 1, | |
| 622 | + IPC_NS_INDEX = 2, | |
| 623 | + PID_NS_INDEX = 3, | |
| 624 | + USER_NS_INDEX = 4, | |
| 625 | + MNT_NS_INDEX = 5, | |
| 626 | + CGROUP_NS_INDEX = 6, | |
| 627 | + | |
| 628 | + NR_NAMESPACES, /* number of available namespaces */ | |
| 629 | +}; | |
| 630 | + | |
| 613 | 631 | enum perf_event_type { |
| 614 | 632 | |
| 615 | 633 | /* |
| @@ -862,6 +880,18 @@ enum perf_event_type { · 246 unmodified lines | ||
| 862 | 880 | */ |
| 863 | 881 | PERF_RECORD_SWITCH_CPU_WIDE = 15, |
| 864 | 882 | |
| 883 | + /* | |
| 884 | + * struct { | |
| 885 | + * struct perf_event_header header; | |
| 886 | + * u32 pid; | |
| 887 | + * u32 tid; | |
| 888 | + * u64 nr_namespaces; | |
| 889 | + * { u64 dev, inode; } [nr_namespaces]; | |
| 890 | + * struct sample_id sample_id; | |
| 891 | + * }; | |
| 892 | + */ | |
| 893 | + PERF_RECORD_NAMESPACES = 16, | |
| 894 | + | |
| 865 | 895 | PERF_RECORD_MAX, /* non-ABI */ |
| 866 | 896 | }; |
| 867 | 897 | |