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

can i add perf in this ubuntu #329

Closed
qweccc opened this issue May 6, 2016 · 12 comments
Closed

can i add perf in this ubuntu #329

qweccc opened this issue May 6, 2016 · 12 comments

Comments

@qweccc
Copy link

qweccc commented May 6, 2016

can i add perf in this ubuntu

WARNING: perf not found for kernel 3.4.0+

You may need to install the following packages for this specific kernel:
linux-tools-3.4.0+

@qweccc qweccc changed the title cna i add perf in this ubuntu can i add perf in this ubuntu May 6, 2016
@russalex
Copy link
Contributor

russalex commented May 6, 2016

At this time we are focusing on providing the Bash on Ubuntu environment and some of the developer tools (i.e. node). Tools like perf have taken a lower priority. For future releases we'll be using our User Voice page to help inform us on the priorities of the community.

@BeverlyXu
Copy link

Would love to see this feature.

@therealkenc
Copy link
Collaborator

Will be available in WSL2 20H1, or in Insiders now.

@bushidocodes
Copy link

I'm on 20H1, and I'm unclear how to make this work.

❯ perf
WARNING: perf not found for kernel 4.19.84-microsoft

  You may need to install the following packages for this specific kernel:
    linux-tools-4.19.84-microsoft-standard
    linux-cloud-tools-4.19.84-microsoft-standard

  You may also want to install one of the following packages to keep up to date:
    linux-tools-standard
    linux-cloud-tools-standard

I saw you mention this command in another issue. Here is what I see

❯ cat /proc/config.gz | gunzip - | grep PERF_EVENTS
CONFIG_HAVE_PERF_EVENTS=y
CONFIG_PERF_EVENTS=y
# CONFIG_PERF_EVENTS_INTEL_UNCORE is not set
# CONFIG_PERF_EVENTS_INTEL_RAPL is not set
# CONFIG_PERF_EVENTS_INTEL_CSTATE is not set
# CONFIG_PERF_EVENTS_AMD_POWER is not set
CONFIG_HAVE_PERF_EVENTS_NMI=y

It seems like perhaps the kernel supports it, but I still am missing the associated aptitude packages.

@Biswa96
Copy link

Biswa96 commented Dec 3, 2019

You can build those Linux kernel tools from source code. Shallow clone the WSL2 Linux kernel repo, cd into tools folder, run make perf. The binary will be in that folder.

@crvdgc
Copy link

crvdgc commented Dec 11, 2019

You can build those Linux kernel tools from source code. Shallow clone the WSL2 Linux kernel repo, cd into tools folder, run make perf. The binary will be in that folder.

The built perf binary can't be executed due to the failure of perf_event_open system call, see #4595 . On my system, it gives

$ ./perf record --call-graph=dwarf /path/to/binary
perf_event_open(..., 0) failed unexpectedly with error 22 (Invalid argument)
Error:
The sys_perf_event_open() syscall returned with 22 (Invalid argument) for event (cycles:u).
/bin/dmesg | grep -i perf may provide additional information.

@Biswa96
Copy link

Biswa96 commented Dec 11, 2019

@crvdgc In the previous comment by @bushidocodes, he mentioned WSL2 which uses actual Linux kernel. Hence perf works.

@crvdgc
Copy link

crvdgc commented Dec 11, 2019

@crvdgc In the previous comment by @bushidocodes, he mentioned WSL2 which uses actual Linux kernel. Hence perf works.

Oh, you're right. I didn't realized you were replying to the WSL2 comment. Thanks.

@postwait
Copy link

postwait commented Apr 2, 2020

I'm running insider release and my kernel (WSL2) is 4.4.0-19592-Microsoft and I'm having the same issue as @crvdgc in that perf will not run due to perf_event_open erroring:

perf_event_open({type=PERF_TYPE_SOFTWARE, size=0 /* PERF_ATTR_SIZE_??? */, config=PERF_COUNT_SW_CPU_CLOCK, ...}, -1, 0,
-1, PERF_FLAG_FD_CLOEXEC) = -1 EINVAL (Invalid argument)
perf_event_open({type=PERF_TYPE_SOFTWARE, size=0 /* PERF_ATTR_SIZE_??? */, config=PERF_COUNT_SW_CPU_CLOCK, ...}, -1, 0,
-1, 0) = -1 EINVAL (Invalid argument)

How do I get 4.19.84-microsoft ?

@postwait
Copy link

postwait commented Apr 2, 2020

I solved my own issue, I thought WSL2 was the default on insider. I needed to upgrade my wsl

wsl --set-version Ubuntu-18.04 2

Then I built perf and it works... to save other people the effort and pain I pushed it to github... hopefully microsoft will build this and I can delete this work-around

https://github.com/postwait/wsl2-stuff/tree/master/linux-tools

@qweccc
Copy link
Author

qweccc commented May 28, 2020

perf worked, running on WSL2 gentoo

@Trass3r
Copy link

Trass3r commented Aug 24, 2020

https://github.com/postwait/wsl2-stuff/tree/master/linux-tools

Thanks, I built a VSCode + Docker environment based on this: https://github.com/Trass3r/WSL2-Linux-Kernel-Docker-Build/releases.
Works fine but we still need HW perf counters: #4678

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

No branches or pull requests

10 participants