Re: [PATCH v3 2/3] perf tool: add PERF_RECORD_NAMESPACES to include namespaces related info

From: Eric W. Biederman
Date: Mon Dec 12 2016 - 16:55:06 EST


Hari Bathini <hbathini@xxxxxxxxxxxxxxxxxx> writes:

> This patch updates perf tool to examine PERF_RECORD_NAMESPACES events
> emitted by the kernel when fork, clone, setns or unshare are invoked.
> Also, it synthesizes PERF_RECORD_NAMESPACES events for processes that
> were running prior to invocation of perf record, the data for which
> is taken from /proc/$PID/ns. These changes make way for analyzing
> events with regard to namespaces.

> diff --git a/tools/perf/util/event.h b/tools/perf/util/event.h
> index 8d363d5..a73bc8e 100644
> --- a/tools/perf/util/event.h
> +++ b/tools/perf/util/event.h
> @@ -39,6 +39,13 @@ struct comm_event {
> char comm[16];
> };
>
> +struct namespaces_event {
> + struct perf_event_header header;
> + u32 pid, tid;
> + u64 dev_num;
> + u64 inode_num[NAMESPACES_MAX];
> +};

This suffers from the same issue I pointed out with the
kernel interface. We need one device number per inode.
Today we only have one device number but that may change in
the future. These are st_dev and st_inode from stat, and
you need both of them per namespace to be unique.

I do not want to get into a situation where I have to implement a
namespace of namespaces in the future.

Eric