#260 operf --pid may not collect samples for new cloned children

None
closed
None
5
2014-09-11
2013-11-12
Maynard Johnson
No

When operf is started with the "--pid" option, we check the /proc/<pid>/task directory to see if the process has created any threads yet. If the process has indeed created one or more threads, then we clear the inherit bit when we call perf_event_open for both the passed process (parent) and all of its children. Then, if the parent spawns any more children after this point (by either thread creation or by fork of a new process), no samples are collected for those children.

Discussion

  • The attached patch (which addresses this bug) was posted to the oprofile-list for review on May 23.

     
  • Carl Love
    Carl Love
    2014-06-23

    Patch applies with a little fuzz. Must be a little out of date with regards to the current source tree.

    I pulled down the latest source tree, applied the patch, compiled, installed and did some touch tests to collect data on a workload by specifying the pid. The process didn't spawn children. Tried with a second workload that created child processes after operf was started. The data collection appears to work as expected. The patch appears to work correctly to the extent I can test it.

    I see one typo in the header comment.

    • If operf is started on a multi-threaded app (i.e., one that uses
      pthreads) with the "--pid" option
    • If said app has already started at least one thread
    • It the app either creates new threads or forks new processes
      *^********
      I think it should be "If" not "It"

      after operf has started
      ...

     
    • status: open --> open-fixed
    • Group: -->
     
  • Patch applied on June 23.

     
    • Status: open-fixed --> closed