• Hari Bathini's avatar
    perf tools: Add 'cgroup_id' sort order keyword · d890a98c
    Hari Bathini authored
    This patch introduces a cgroup identifier entry field in perf report to
    identify or distinguish data of different cgroups. It uses the device
    number and inode number of cgroup namespace, included in perf data with
    the new PERF_RECORD_NAMESPACES event, as cgroup identifier.
    
    With the assumption that each container is created with it's own cgroup
    namespace,  this allows assessment/analysis of multiple containers at
    once.
    
    A simple test for this would be to clone a few processes passing
    SIGCHILD & CLONE_NEWCROUP flags to each of them, execute shell and run
    different workloads  on each of those contexts,  while running perf
    record command with --namespaces option.
    
    Shown below is the output of perf report, sorted with cgroup identifier,
    on perf.data generated with the above test scenario, clearly indicating
    one context's considerable use of kernel memory in comparison with
    others:
    
    	$ perf report -s cgroup_id,sample --stdio
    	#
    	# Total Lost Samples: 0
    	#
    	# Samples: 5K of event 'kmem:kmalloc'
    	# Event count (approx.): 5965
    	#
    	# Overhead  cgroup id (dev/inode)       Samples
    	# ........  .....................  ............
    	#
    	    81.27%  3/0xeffffffb                   4848
    	    16.24%  3/0xf00000d0                    969
    	     1.16%  3/0xf00000ce                     69
    	     0.82%  3/0xf00000cf                     49
    	     0.50%  0/0x0                            30
    
    While this is a start, there is further scope of improving this. For
    example, instead of cgroup namespace's device and inode numbers, dev
    and inode numbers of some or all namespaces may be used to distinguish
    which processes are running in a given container context.
    
    Also, scripts to map device and inode info to containers sounds
    plausible for better tracing of containers.
    Signed-off-by: default avatarHari Bathini <hbathini@linux.vnet.ibm.com>
    Tested-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
    Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
    Cc: Alexei Starovoitov <ast@fb.com>
    Cc: Ananth N Mavinakayanahalli <ananth@linux.vnet.ibm.com>
    Cc: Aravinda Prasad <aravinda@linux.vnet.ibm.com>
    Cc: Brendan Gregg <brendan.d.gregg@gmail.com>
    Cc: Daniel Borkmann <daniel@iogearbox.net>
    Cc: Eric Biederman <ebiederm@xmission.com>
    Cc: Jiri Olsa <jolsa@redhat.com>
    Cc: Peter Zijlstra <peterz@infradead.org>
    Cc: Sargun Dhillon <sargun@sargun.me>
    Cc: Steven Rostedt <rostedt@goodmis.org>
    Link: http://lkml.kernel.org/r/148891933338.25309.756882900782042645.stgit@hbathini.in.ibm.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
    d890a98c
sort.c 68.9 KB