1. 08 4月, 2015 4 次提交
    • Y
      perf sched replay: Realloc the memory of pid_to_task stepwise to adapt to the... · 3a423a5c
      Yunlong Song 提交于
      perf sched replay: Realloc the memory of pid_to_task stepwise to adapt to the different pid_max configurations
      
      Although the memory of pid_to_task can be allocated via calloc according
      to the value of /proc/sys/kernel/pid_max, it cannot handle the case when
      pid_max is changed after 'perf sched record' has created its perf.data.
      
      If the new pid_max configured in 'perf sched replay' is smaller than the
      old pid_max configured in 'perf sched record', then it will cause the
      assertion failure problem.
      
      To solve this problem, we realloc the memory of pid_to_task stepwise
      once the passed-in pid parameter in register_pid is larger than the
      current pid_max.
      
      Example:
      
      Test environment: x86_64 with 160 cores
      
       $ cat /proc/sys/kernel/pid_max
       163840
       $ perf sched record ls
       $ echo 5000 > /proc/sys/kernel/pid_max
       $ cat /proc/sys/kernel/pid_max
       5000
      
      Before this patch:
      
       $ perf sched replay
       run measurement overhead: 221 nsecs
       sleep measurement overhead: 55356 nsecs
       the run test took 1000011 nsecs
       the sleep test took 1060940 nsecs
       perf: builtin-sched.c:337: register_pid: Assertion `!(pid >= (unsigned
       long)pid_max)' failed.
       Aborted
      
      After this patch:
      
       $ perf sched replay
       run measurement overhead: 221 nsecs
       sleep measurement overhead: 55611 nsecs
       the run test took 1000026 nsecs
       the sleep test took 1060486 nsecs
       nr_run_events:        10
       nr_sleep_events:      1562
       nr_wakeup_events:     5
       task      0 (                  :1:         1), nr_events: 1
       task      1 (                  :2:         2), nr_events: 1
       task      2 (                  :3:         3), nr_events: 1
       task      3 (                  :5:         5), nr_events: 1
       ...
      Signed-off-by: NYunlong Song <yunlong.song@huawei.com>
      Cc: Paul Mackerras <paulus@samba.org>
      Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
      Cc: Wang Nan <wangnan0@huawei.com>
      Link: http://lkml.kernel.org/r/1427809596-29559-5-git-send-email-yunlong.song@huawei.comSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      3a423a5c
    • Y
      perf sched replay: Alloc the memory of pid_to_task dynamically to adapt to the... · cb06ac25
      Yunlong Song 提交于
      perf sched replay: Alloc the memory of pid_to_task dynamically to adapt to the unexpected change of pid_max
      
      The current memory allocation of struct task_desc *pid_to_task[MAX_PID]
      is in a permanent and preset way, and it has two problems:
      
      Problem 1: If the pid_max, which is the max number of pids in the
      system, is much smaller than MAX_PID (1024*1000), then it causes a waste
      of stack memory. This may happen in the case where the number of cpu
      cores is much smaller than 1000.
      
      Problem 2: If the pid_max is changed from the default value to a value
      larger than MAX_PID, then it will cause assertion failure problem. The
      maximum value of pid_max can be set to pid_max_max (see pidmap_init
      defined in kernel/pid.c), which equals to PID_MAX_LIMIT. In x86_64,
      PID_MAX_LIMIT is 4*1024*1024 (defined in include/linux/threads.h). This
      value is much larger than MAX_PID, and will take up 32768 Kbytes
      (4*1024*1024*8/1024) for memory allocation of pid_to_task, which is much
      larger than the default 8192 Kbytes of the stack size of calling
      process.
      
      Due to these two problems, we use calloc to allocate the memory of
      pid_to_task dynamically.
      
      Example:
      
      Test environment: x86_64 with 160 cores
      
       $ cat /proc/sys/kernel/pid_max
       163840
       $ echo 1025000 > /proc/sys/kernel/pid_max
       $ cat /proc/sys/kernel/pid_max
       1025000
      
      Run some applications until the pid of some process is greater than
      the value of MAX_PID (1024*1000).
      
      Before this patch:
      
       $ perf sched replay
       run measurement overhead: 221 nsecs
       sleep measurement overhead: 55480 nsecs
       the run test took 1000008 nsecs
       the sleep test took 1063151 nsecs
       perf: builtin-sched.c:330: register_pid: Assertion `!(pid >= 1024000)'
       failed.
       Aborted
      
      After this patch:
      
       $ perf sched replay
       run measurement overhead: 221 nsecs
       sleep measurement overhead: 55435 nsecs
       the run test took 1000004 nsecs
       the sleep test took 1059312 nsecs
       nr_run_events:        10
       nr_sleep_events:      1562
       nr_wakeup_events:     5
       task      0 (                  :1:         1), nr_events: 1
       task      1 (                  :2:         2), nr_events: 1
       task      2 (                  :3:         3), nr_events: 1
       task      3 (                  :5:         5), nr_events: 1
       ...
      Signed-off-by: NYunlong Song <yunlong.song@huawei.com>
      Cc: Paul Mackerras <paulus@samba.org>
      Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
      Cc: Wang Nan <wangnan0@huawei.com>
      Link: http://lkml.kernel.org/r/1427809596-29559-4-git-send-email-yunlong.song@huawei.comSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      cb06ac25
    • Y
      perf sched replay: Increase the MAX_PID value to fix assertion failure problem · a35e27d0
      Yunlong Song 提交于
      Current MAX_PID is only 65536, which will cause assertion failure problem
      when CPU cores are more than 64 in x86_64.
      
      This is because the pid_max value in x86_64 is at least
      PIDS_PER_CPU_DEFAULT * num_possible_cpus() (see function pidmap_init
      defined in kernel/pid.c), where PIDS_PER_CPU_DEFAULT is 1024 (defined in
      include/linux/threads.h).
      
      Thus for MAX_PID = 65536, the correspoinding CPU cores are
      65536/1024=64.  This is obviously not enough at all for x86_64, and will
      cause an assertion failure problem due to BUG_ON(pid >= MAX_PID) in the
      codes.
      
      We increase MAX_PID value from 65536 to 1024*1000, which can be used in
      x86_64 with 1000 cores.
      
      This number is finally decided according to the limitation of stack size
      of calling process.
      
      Use 'ulimit -a', the result shows the stack size of any process is 8192
      Kbytes, which is defined in include/uapi/linux/resource.h (#define
      _STK_LIM (8*1024*1024)).
      
      Thus we choose a large enough value for MAX_PID, and make it satisfy to
      the limitation of the stack size, i.e., making the perf process take up
      a memory space just smaller than 8192 Kbytes.
      
      We have calculated and tested that 1024*1000 is OK for MAX_PID.
      
      This means perf sched replay can now be used with at most 1000 cores in
      x86_64 without any assertion failure problem.
      
      Example:
      
      Test environment: x86_64 with 160 cores
      
       $ cat /proc/sys/kernel/pid_max
       163840
      
      Before this patch:
      
       $ perf sched replay
       run measurement overhead: 240 nsecs
       sleep measurement overhead: 55379 nsecs
       the run test took 1000004 nsecs
       the sleep test took 1059424 nsecs
       perf: builtin-sched.c:330: register_pid: Assertion `!(pid >= 65536)'
       failed.
       Aborted
      
      After this patch:
      
       $ perf sched replay
       run measurement overhead: 221 nsecs
       sleep measurement overhead: 55397 nsecs
       the run test took 999920 nsecs
       the sleep test took 1053313 nsecs
       nr_run_events:        10
       nr_sleep_events:      1562
       nr_wakeup_events:     5
       task      0 (                  :1:         1), nr_events: 1
       task      1 (                  :2:         2), nr_events: 1
       task      2 (                  :3:         3), nr_events: 1
       task      3 (                  :5:         5), nr_events: 1
       ...
      Signed-off-by: NYunlong Song <yunlong.song@huawei.com>
      Cc: Paul Mackerras <paulus@samba.org>
      Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
      Cc: Wang Nan <wangnan0@huawei.com>
      Link: http://lkml.kernel.org/r/1427809596-29559-3-git-send-email-yunlong.song@huawei.comSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      a35e27d0
    • Y
      perf sched replay: Use struct task_desc instead of struct task_task for correct meaning · 0755bc4d
      Yunlong Song 提交于
      There is no struct task_task at all, thus it is a typo error in the old
      commits, now fix it to what it should be in order to avoid unnecessary
      misunderstanding.
      Signed-off-by: NYunlong Song <yunlong.song@huawei.com>
      Cc: Paul Mackerras <paulus@samba.org>
      Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
      Cc: Wang Nan <wangnan0@huawei.com>
      Link: http://lkml.kernel.org/r/1427809596-29559-2-git-send-email-yunlong.song@huawei.comSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      0755bc4d
  2. 11 3月, 2015 1 次提交
  3. 03 3月, 2015 2 次提交
    • A
      perf sched: No need to keep the session around · ae536acf
      Arnaldo Carvalho de Melo 提交于
      We were keeping the session around just because we kept pointers to
      struct thread instances, but now we reference count them, so no need
      for deferring the perf_session__delete call to after we traverse the
      work_list entries.
      
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Borislav Petkov <bp@suse.de>
      Cc: David Ahern <dsahern@gmail.com>
      Cc: Don Zickus <dzickus@redhat.com>
      Cc: Frederic Weisbecker <fweisbec@gmail.com>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Stephane Eranian <eranian@google.com>
      Link: http://lkml.kernel.org/n/tip-9agtck6jdr3rebdp39z1lo0e@git.kernel.orgSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      ae536acf
    • A
      perf tools: Reference count struct thread · f3b623b8
      Arnaldo Carvalho de Melo 提交于
      We need to do that to stop accumulating entries in the dead_threads
      linked list, i.e. we were keeping references to threads in struct hists
      that continue to exist even after a thread exited and was removed from
      the machine threads rbtree.
      
      We still keep the dead_threads list, but just for debugging, allowing us
      to iterate at any given point over the threads that still are referenced
      by things like struct hist_entry.
      
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Borislav Petkov <bp@suse.de>
      Cc: David Ahern <dsahern@gmail.com>
      Cc: Don Zickus <dzickus@redhat.com>
      Cc: Frederic Weisbecker <fweisbec@gmail.com>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Stephane Eranian <eranian@google.com>
      Link: http://lkml.kernel.org/n/tip-3ejvfyed0r7ue61dkurzjux4@git.kernel.orgSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      f3b623b8
  4. 23 2月, 2015 1 次提交
  5. 09 10月, 2014 1 次提交
  6. 16 8月, 2014 1 次提交
  7. 14 8月, 2014 2 次提交
  8. 12 8月, 2014 1 次提交
  9. 18 7月, 2014 1 次提交
  10. 17 7月, 2014 1 次提交
  11. 01 6月, 2014 1 次提交
  12. 16 5月, 2014 2 次提交
  13. 13 5月, 2014 1 次提交
  14. 12 5月, 2014 3 次提交
  15. 16 4月, 2014 1 次提交
  16. 19 3月, 2014 1 次提交
    • R
      perf sched: Fixup header alignment in 'latency' output · 80790e0b
      Ramkumar Ramachandra 提交于
      Before:
      
       ---------------------------------------------------------------------------------------------------------------
        Task                  |   Runtime ms  | Switches | Average delay ms | Maximum delay ms | Maximum delay at     |
       ---------------------------------------------------------------------------------------------------------------
        ...                   |               |          |                  |                  |
        git:24540             |    336.622 ms |       10 | avg:    0.032 ms | max:    0.062 ms | max at: 115610.111046 s
        git:24541             |      0.457 ms |        1 | avg:    0.000 ms | max:    0.000 ms | max at:  0.000000 s
       -----------------------------------------------------------------------------------------
        TOTAL:                |    396.542 ms |      353 |
       ---------------------------------------------------
      
      After:
      
       -----------------------------------------------------------------------------------------------------------------
        Task                  |   Runtime ms  | Switches | Average delay ms | Maximum delay ms | Maximum delay at       |
       -----------------------------------------------------------------------------------------------------------------
        ...                   |               |          |                  |                  |
        git:24540             |    336.622 ms |       10 | avg:    0.032 ms | max:    0.062 ms | max at: 115610.111046 s
        git:24541             |      0.457 ms |        1 | avg:    0.000 ms | max:    0.000 ms | max at:      0.000000 s
       -----------------------------------------------------------------------------------------------------------------
        TOTAL:                |    396.542 ms |      353 |
       ---------------------------------------------------
      Signed-off-by: NRamkumar Ramachandra <artagnon@gmail.com>
      Cc: David Ahern <dsahern@gmail.com>
      Cc: Frederic Weisbecker <fweisbec@gmail.com>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Link: http://lkml.kernel.org/r/1395065901-25740-1-git-send-email-artagnon@gmail.comSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      80790e0b
  17. 28 12月, 2013 1 次提交
  18. 07 11月, 2013 1 次提交
  19. 04 11月, 2013 1 次提交
  20. 23 10月, 2013 2 次提交
  21. 22 10月, 2013 1 次提交
  22. 29 8月, 2013 1 次提交
  23. 12 8月, 2013 4 次提交
  24. 13 7月, 2013 2 次提交
  25. 09 7月, 2013 1 次提交
  26. 01 4月, 2013 1 次提交
    • A
      Revert "perf sched: Handle PERF_RECORD_EXIT events" · 1c6763cb
      Arnaldo Carvalho de Melo 提交于
      This reverts commit 0439539f.
      
      This caused this segfault:
      
      [root@sandy linux]# perf sched rec
      ^C[ perf record: Woken up 1 times to write data ]
      [ perf record: Captured and wrote 1.306 MB perf.data (~57062 samples) ]
      perf
      [root@sandy linux]# perf sched lat
      perf: builtin-sched.c:781: thread_atoms_search: Assertion `!(thread != atoms->thread)' failed.
      Aborted (core dumped)
      [root@sandy linux]#
      
      Further investigation is needed to check that even with machine__remove_thread()
      not really deleting the thread referenced in the PERF_RECORD_EXIT (it goes to
      machine->dead_threads, because references may still exist to them in things like
       hist, etc) some event later comes for this dead thread and then
      machine__findnew_thread() will create a new thead instance that will not be the
      same as the one referenced by work_atoms->thread in thread_atoms_search().
      
      For now just revert this patch to get the 'perf sched lat' back working.
      
      Cc: David Ahern <dsahern@gmail.com>
      Cc: Frederic Weisbecker <fweisbec@gmail.com>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Cc: Mike Galbraith <efault@gmx.de>
      Cc: Namhyung Kim <namhyung@gmail.com>
      Cc: Paul Mackerras <paulus@samba.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Stephane Eranian <eranian@google.com>
      echo Link: http://lkml.kernel.org/n/tip-`ranpwd -l 24`@git.kernel.org
      Link: http://lkml.kernel.org/n/tip-hg4s6e5txiwqe00h8rdg1sin@git.kernel.orgSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      1c6763cb
  27. 25 1月, 2013 1 次提交