History

perf: Add PERF_RECORD_NAMESPACES to include namespaces related info

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.

Hari Bathini committed 9 years ago

Commit e4222671 parent 3ef5b405 files · +177 −1Browse files

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

Unified · Split

include/uapi/linux/perf_event.h+31−1
@@ -344,7 +344,8 @@ struct perf_event_attr { · 343 unmodified lines
344344 use_clockid : 1, /* use @clockid for time fields */
345345 context_switch : 1, /* context switch data */
346346 write_backward : 1, /* Write ring buffer from end to beginning */
347− __reserved_1 : 36;
347+ namespaces : 1, /* include namespaces data */
348+ __reserved_1 : 35;
348349
349350 union {
350351 __u32 wakeup_events; /* wakeup every n events */
@@ -610,6 +611,23 @@ struct perf_event_header { · 259 unmodified lines
610611 __u16 size;
611612 };
612613
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+
613631 enum perf_event_type {
614632
615633 /*
@@ -862,6 +880,18 @@ enum perf_event_type { · 246 unmodified lines
862880 */
863881 PERF_RECORD_SWITCH_CPU_WIDE = 15,
864882
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+
865895 PERF_RECORD_MAX, /* non-ABI */
866896 };
867897