perf.c: add support for struct perf_event_attr.namespaces

This field was introduced by linux kernel commit v4.12-rc1~152^2~42^2~10.

* configure.ac (AC_CHECK_MEMBERS): Add  perf_event_attr.namespaces.
* perf_event_struct.h (struct perf_event_attr): Add namespaces field.
* perf.c (print_perf_event_attr): Print namespaces field.
Update comment for __reserved_1 field.
* tests/perf_event_open.c (struct pea_flags): Add namespaces field.
(print_event_attr): Update expected output.
This commit is contained in:
Eugene Syromyatnikov 2018-01-08 19:48:42 +01:00 committed by Dmitry V. Levin
parent fd334b39b0
commit 7527de8263
4 changed files with 19 additions and 6 deletions

View File

@ -367,6 +367,7 @@ AC_CHECK_MEMBERS(m4_normalize([
struct perf_event_attr.use_clockid,
struct perf_event_attr.context_switch,
struct perf_event_attr.write_backward,
struct perf_event_attr.namespaces,
struct perf_event_attr.bp_type,
struct perf_event_attr.config1,
struct perf_event_attr.config2,

8
perf.c
View File

@ -304,7 +304,8 @@ print_perf_event_attr(struct tcb *const tcp, const kernel_ulong_t addr)
", comm_exec=%u"
", use_clockid=%u"
", context_switch=%u"
", write_backward=%u",
", write_backward=%u"
", namespaces=%u",
attr->mmap_data,
attr->sample_id_all,
attr->exclude_host,
@ -315,7 +316,8 @@ print_perf_event_attr(struct tcb *const tcp, const kernel_ulong_t addr)
attr->comm_exec,
attr->use_clockid,
attr->context_switch,
attr->write_backward);
attr->write_backward,
attr->namespaces);
/*
* Print it only in case it is non-zero, since it may contain flags we
@ -324,7 +326,7 @@ print_perf_event_attr(struct tcb *const tcp, const kernel_ulong_t addr)
if (attr->__reserved_1) {
tprintf(", __reserved_1=%#" PRIx64,
(uint64_t) attr->__reserved_1);
tprints_comment("Bits 63..28");
tprints_comment("Bits 63..29");
}
if (attr->watermark)

View File

@ -40,7 +40,8 @@ struct perf_event_attr {
use_clockid :1,
context_switch :1,
write_backward :1,
__reserved_1 :36;
namespaces :1,
__reserved_1 :35;
union {
uint32_t wakeup_events;
uint32_t wakeup_watermark;

View File

@ -102,7 +102,8 @@ struct pea_flags {
use_clockid :1,
context_switch :1,
write_backward :1,
__reserved_1 :36;
namespaces :1,
__reserved_1 :35;
};
static const char *
@ -351,9 +352,17 @@ print_event_attr(struct perf_event_attr *attr_ptr, size_t size,
# endif
printf(", write_backward=%" PRIu64, val);
val =
# ifdef HAVE_STRUCT_PERF_EVENT_ATTR_NAMESPACES
attr->namespaces;
# else
flags_data.flags.namespaces;
# endif
printf(", namespaces=%" PRIu64, val);
val = flags_data.flags.__reserved_1;
if (val)
printf(", __reserved_1=%#" PRIx64 " /* Bits 63..28 */", val);
printf(", __reserved_1=%#" PRIx64 " /* Bits 63..29 */", val);
printf(", %s=%u",
attr->watermark ? "wakeup_watermark" : "wakeup_events",