Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

funcgraph, funcslower, functrace: Make -p switch respect all the process' threads #55

Merged
merged 3 commits into from Sep 5, 2017

Conversation

goldshtn
Copy link
Contributor

@goldshtn goldshtn commented Sep 4, 2017

Fixes #53 for the tools that use set_ftrace_pid as the filtering technique.
Now, traverse /proc/$pid/task to find the "kernel" pids (thread ids) and use
them instead. Also, add -L switch if anyone really wants thread-based filters.

The -p switch used to set the `set_ftrace_pid` file, which is really
a thread id from the user's perspective. As a result, only the main
thread would be traced. Fix by enumerating the thread ids from /proc/
$pid/task and putting them all in `set_ftrace_pid` when asked.

Signed-off-by: Sasha Goldshtein <goldshtn@gmail.com>
Signed-off-by: Sasha Goldshtein <goldshtn@gmail.com>
Signed-off-by: Sasha Goldshtein <goldshtn@gmail.com>
@goldshtn
Copy link
Contributor Author

goldshtn commented Sep 4, 2017

There are quite a few additional tools, which use perf --filter with something
like common_pid == $pid. These need to be handled separately -- haven't
tested them yet.

@goldshtn
Copy link
Contributor Author

goldshtn commented Sep 4, 2017

Addressed the other tools in #56.

@goldshtn
Copy link
Contributor Author

goldshtn commented Sep 5, 2017

@brendangregg Could you please take a look?

@brendangregg
Copy link
Owner

Thanks!

I'll accept it as it's supposed to work. You didn't break anything. But there are issues with older kernels to be aware about. From a quick test:

  • Linux 4.4: doesn't honor set_ftrace_pid
  • Linux 4.9-rc5: works
  • Linux 4.13-rc1: works

@brendangregg brendangregg merged commit f7860d6 into brendangregg:master Sep 5, 2017
@goldshtn
Copy link
Contributor Author

goldshtn commented Sep 6, 2017

That's really weird. I can find set_ftrace_pid mentioned as early as 2010 on the LWN: https://lwn.net/Articles/370423/. From looking at some commits, it seems that torvalds/linux@4104d32 broke it and then torvalds/linux@e3eea14 fixed it, unless it's not the same issue. The fixing commit should have been in 4.2-rc4, but 🤷‍♂️

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants