Bug 203203 - Perf 'top -p PID' no longer records any samples
Summary: Perf 'top -p PID' no longer records any samples
Status: NEW
Alias: None
Product: Tracing/Profiling
Classification: Unclassified
Component: Perf tool (show other bugs)
Hardware: x86-64 Linux
: P1 normal
Assignee: Arnaldo Carvalho de Melo
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2019-04-09 15:17 UTC by Bastian Beranek
Modified: 2019-09-14 15:29 UTC (History)
7 users (show)

See Also:
Kernel Version: 5.0.7
Subsystem:
Regression: No
Bisected commit-id:


Attachments

Description Bastian Beranek 2019-04-09 15:17:56 UTC
When using "perf top -p PID" the counter of collected samples stays at 0 forever. However, running perf top -a and then zooming into a specific process works fine.

This is on Arch Linux x86_64 with:

$ uname -a
Linux bastian-desktop 5.0.7-arch1-1-ARCH #1 SMP PREEMPT Mon Apr 8 10:37:08 UTC 2019 x86_64 GNU/Linux

$ perf --version
perf version 5.0.g1c163f4

The problem is reproducable for any process of the same user. This is something that definitely worked a while ago, but I'm unable to tell when it broke.
Comment 1 Arnaldo Carvalho de Melo 2019-04-09 16:00:30 UTC
Reproduced the problem and bisected it down to this commit:

16c66bc167cc52992f66748aed7ac21396189457 is the first bad commit
commit 16c66bc167cc52992f66748aed7ac21396189457
Author: Jiri Olsa <jolsa@kernel.org>
Date:   Mon Nov 5 13:24:55 2018 +0100

    perf top: Add processing thread
    
    Add a new thread that takes care of the hist creating to alleviate the
    main reader thread so it can keep perf mmaps served in time so that we
    reduce the possibility of losing events.
    
    The 'perf top' command now spawns 2 extra threads, the data processing
    is the following:
    
      1) The main thread reads the data from mmaps and queues them to
         ordered events object;
    
      2) The processing threads takes the data from the ordered events
         object and create initial histogram;
    
      3) The GUI thread periodically sorts the initial histogram and
         presents it.
    
    Passing the data between threads 1 and 2 is done by having 2 ordered
    events queues. One is always being stored by thread 1 while the other is
    flushed out in thread 2.
    
    Passing the data between threads 2 and 3 stays the same as was initially
    for threads 1 and 3.
    
    Signed-off-by: Jiri Olsa <jolsa@kernel.org>
    Acked-by: David S. Miller <davem@davemloft.net>
    Acked-by: Namhyung Kim <namhyung@kernel.org>
    Tested-by: Arnaldo Carvalho de Melo <acme@redhat.com>
    Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
    Cc: Peter Zijlstra <peterz@infradead.org>
    Link: http://lkml.kernel.org/n/tip-hhf4hllgkmle9wl1aly1jli0@git.kernel.org
    Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>

:040000 040000 163fafd4c4b854e517509ca056977243244b890e e1bc2f7df3664e028f3db873c67effe90bae76c3 M	tools
[acme@quaco perf]$

[acme@quaco perf]$ git tag --contains 16c66bc167cc52992f66748aed7ac21396189457 | grep ^v | grep -v -- -rc
v5.0
[acme@quaco perf]$

I'll try to see what is that it is doing that breaks --pid, after lunch.
Comment 2 Jiri Olsa 2019-04-09 19:43:48 UTC
I think we need the change below,
the new perf top needs sorted data:

diff --git a/tools/perf/builtin-top.c b/tools/perf/builtin-top.c
index 1999d6533d12..fbbb0da43abb 100644
--- a/tools/perf/builtin-top.c
+++ b/tools/perf/builtin-top.c
@@ -1377,6 +1377,7 @@ int cmd_top(int argc, const char **argv)
                         * */
                        .overwrite      = 0,
                        .sample_time    = true,
+                       .sample_time_set = true,
                },
                .max_stack           = sysctl__max_stack(),
                .annotation_opts     = annotation__default_options,
Comment 3 Bastian Beranek 2019-04-10 09:55:29 UTC
Yes, thank you. That seems to work - although I can't easily check if all of the functionality is restored.
Comment 4 Carlo B 2019-07-16 04:03:09 UTC
Thank you Jiri i test other function and its working. :)

Castro B,
https://sparpedia.dk/
Comment 5 Emre Kozan 2019-09-14 15:29:38 UTC
Mini onarım ve Sunroof tamiri sistemleri
https://www.tesvikiyegaraj.com.tr/

Note You need to log in before you can comment on or make changes to this bug.