• Namhyung Kim's avatar
    perf tools: Use /proc/<PID>/task/<TID>/status for PERF_RECORD_ event synthesis · 30626e08
    Namhyung Kim authored
    To save memory usage, it needs to reduce the number of entries in the
    proc filesystem.  It's using /proc/<PID>/task directory to traverse
    threads in the process and then kernel creates /proc/<PID>/task/<TID>
    entries.
    
    After that it checks the thread info using the /proc/<TID>/status file
    rather than /proc/<PID>/task/<TID>/status.  As far as I can see, they
    are the same and contain all the info we need.
    
    Using the latter eliminates the unnecessary /proc/<TID> entry.  This can
    be useful especially a large number of threads are used in the system.
    In my experiment around 1KB of memory on average was saved for each
    thread (which is not a thread group leader).
    
    To do this, pass both pid and tid to perf_event_prepare_comm() if it
    knows them.  In case it doesn't know, passing 0 as pid will do the old
    way.
    Signed-off-by: default avatarNamhyung Kim <namhyung@kernel.org>
    Acked-by: default avatarJiri Olsa <jolsa@redhat.com>
    Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
    Cc: Andi Kleen <ak@linux.intel.com>
    Cc: Ian Rogers <irogers@google.com>
    Cc: Ingo Molnar <mingo@kernel.org>
    Cc: Mark Rutland <mark.rutland@arm.com>
    Cc: Peter Zijlstra <peterz@infradead.org>
    Cc: Stephane Eranian <eranian@google.com>
    Link: https://lore.kernel.org/r/20210202090118.2008551-2-namhyung@kernel.orgSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
    30626e08
synthetic-events.c 51.2 KB