Linux "Perf" tool cannot run inside docker images? - linux

I knew that "perf" tool requires installation correspond to specific linux kernel versions. And I knew that all docker images run with the same linux kernel version, no matter linux distribution version.
I'm using ubuntu 16.04 inside docker and already installed linux-tools-common, start perf tell me I still lack some packages:'
# perf
/usr/bin/perf: line 32: lsb_release: command not found
WARNING: perf not found for kernel 4.9.12
You may need to install the following packages for this specific kernel:
linux-tools-4.9.12-moby
linux-cloud-tools-4.9.12-moby
You may also want to install one of the following packages to keep up to date:
linux-tools-moby
linux-cloud-tools-moby
Then I tried to install what I missed:
root#xxxxxx:/# apt-get install linux-tools-4.9.12-moby linux-cloud-tools-4.9.12-moby
Reading package lists... Done
Building dependency tree
Reading state information... Done
E: Unable to locate package linux-tools-4.9.12-moby
E: Couldn't find any package by glob 'linux-tools-4.9.12-moby'
E: Couldn't find any package by regex 'linux-tools-4.9.12-moby'
E: Unable to locate package linux-cloud-tools-4.9.12-moby
E: Couldn't find any package by glob 'linux-cloud-tools-4.9.12-moby'
E: Couldn't find any package by regex 'linux-cloud-tools-4.9.12-moby'
root#b2543b6e985d:/# apt-get install linux-tools-moby linux-cloud-tools-moby
Reading package lists... Done
Building dependency tree
Reading state information... Done
E: Unable to locate package linux-tools-moby
E: Unable to locate package linux-cloud-tools-moby
(1) So weird, but how to solve this installation problem?
(2) Plus: I'm still confused, if there's no strict match between "perf" and "kernel", how could "perf" work well inside docker of linux?

I knew that "perf" tool requires installation correspond to specific linux kernel versions. And I knew that all docker images run with the same linux kernel version, no matter linux distribution version.
Perf tool from other version of kernel still can be used (the syscalls in perf_event subsystem have good design and are compatible with older/newer tools). So, you can just find any perf binary (not the /usr/bin/perf script) anywhere, check its library depends with (ldd ..path_to_perf/perf) and copy perf inside Docker (and install libs).
Usage of hardware events, system-wide or kernel profiling may be limited in the docker, so try
perf -e cycles:u ./program (hardware counter only for user-space),
perf -e task-clock ./program (software timer for kernel and user-space),
perf -e task-clock:u ./program (software timer for user-space only),

Related

Error /lib/x86_64-linux-gnu/libc.so.6: version `GLIBC_2.34' not found

firstly, I google'd a lot but nothing I found related to my case, I have an ELF executable file I'm trying to run it in my Ubuntu WSL, I've changed the permissions (chmod +x file), when I run it, this error shows up
/lib/x86_64-linux-gnu/libc.so.6: version `GLIBC_2.34' not found (required by myFile)
and when I use ld command this shows up to me
myFile(.eh_frame); no .eh_frame_hdr table will be created
and when I tried to upgrade GLIBC it says it's up-do-date
Reading package lists... Done
Building dependency tree
Reading state information... Done
libc6 is already the newest version (2.31-0ubuntu9.7).
libc6 set to manually installed.
0 upgraded, 0 newly installed, 0 to remove and 215 not upgraded.
and then I tried manually installing the deb file from https://packages.ubuntu.com/impish/amd64/libc6/download but this shows up to me :
dpkg: regarding libc6_2.34-0ubuntu3.2_amd64.deb containing libc6:amd64:
libc6:amd64 breaks fakeroot (<< 1.25.3-1.1ubuntu2~)
fakeroot (version 1.24-1) is present and installed.
dpkg: error processing archive libc6_2.34-0ubuntu3.2_amd64.deb (--install):
installing libc6:amd64 would break fakeroot, and
deconfiguration is not permitted (--auto-deconfigure might help)
Errors were encountered while processing:
libc6_2.34-0ubuntu3.2_amd64.deb
DISCLAIMER: I am not a linux professional, just found a way for my own problem with glibc not found error msg:
maybe you cannot use the binary since it was compiled with gcc-11 and your gcc version of your linux distribution and version only is gcc-9 and therefore only provides glibc_2.31 (I guess).
you can try to compile the program yourself from source. I had to do this with the new stockfish version 15, which also uses updated glibc_2.32/2.33/2.34 and my linux-mint does not provide that.
But compiling from source worked like a charm. Maybe this is an option for you.
I have some similar situation,
I copyed my executed file from a centos VM1 to another centos VM2,then I got the same question,I just copy the source code to VM2,and recompile it,then the question is solved.
I got a makefile and a shell script to compile it,so the compilation process is simple,update glibc may cause other problem and is more complicated,and i am a caiji,hope to help u
I've got this error with buildroot-2022.11 when executing make.
Ubuntu 20.04 - added this repo as described in the link
sudo apt update
sudo apt install libc6
It automatically installed 2.35 for me.

How to use Linux perf tool on WSL2? How to have perf for the correct kernel?

I am trying to use the perf tool of Linux on my WSL2 using Windows10 machine. I have done every step of the accepted answer here:Is there any method to run perf under WSL?
When I ran "make" comment, I got a warning:
Warning: Kernel ABI header at 'tools/include/uapi/linux/stat.h'
differs from latest version at 'include/uapi/linux/stat.h'
But the perf executable was still created.
However when I try to use perf like this:
sudo perf record -g myexe myargs
I received this error:
WARNING: perf not found for kernel 5.10.16.3-microsoft
You may need to install the following packages for this specific
kernel:
linux-tools-5.10.16.3-microsoft-standard-WSL2
linux-cloud-tools-5.10.16.3-microsoft-standard-WSL2
Then I tried to run this:
sudo apt install linux-tools-5.10.16.3-microsoft-standard-WSL2
However that did not work either, I got this:
Reading package lists... Done Building dependency tree Reading state
information... Done E: Unable to locate package
linux-tools-5.10.16.3-microsoft-standard-WSL2 E: Couldn't find any
package by glob 'linux-tools-5.10.16.3-microsoft-standard-WSL2'
What should I do now?

Fixing libc.so.6 unexpected reloc type 0x25

I'm trying to install gcc4.9 on a SUSE system without an internet connection. I compiled gcc on an Ubuntu machine and installed it into a prefix, then copied the prefix folder to the SUSE machine. When I tried to run it gcc complained about not finding GLIBC_2_14, so I downloaded an rpm for libc6 online and included it into the prefix folders. my LD_LIBRARY_PATH includes prefix/lib and prefix/lib64. When I try to run any program now (ls, cp, cat, etc) I get the error error while loading shared libraries: /home/***/prefix/lib64/libc.so.6: unexpected reloc type 0x25.
Is there any way I can fix this so that I can get gcc4.9 up and running on this system?
As an alternative, is it possible to build gcc staticaly so that I don't have to worry about linking at all when I transfer it between computers?
my LD_LIBRARY_PATH includes prefix/lib and prefix/lib64
See this answer for explanation of why this can't work.
Is there any way I can fix this so that I can get gcc4.9 up and running on this system?
Your best bet is to install whatever GCC package comes with the SuSE system, then use that GCC to configure and install gcc-4.9 on it.
If for some reason you can't do that, this answer has some of the ways in which you can build gcc-4.9 on a newer system and have it still work on an older one.
is it possible to build gcc staticaly so that I don't have to worry about linking at all when I transfer it between computers?
Contrary to popular belief, fully-static binaries are generally less portable then dynamic ones on Linux.

Invalid configuration i686-redhat-linux-gnu on CentOS

I launch this command to build rpm package:
#>rpmbuild --rebuild -vv vqadmin-toaster-2.3.7-1.4.1.src.rpm
I'm on CentOs 6.4 and i want to build and install qmailtoaster packets.
Only this packet get an error:
checking build system type... Invalid configuration 'i686-redhat-linux-gnu': machine 'i686-redhat-linux' not recognized
What can i do? this is first time that i'm compiling RPM packages, any ideas?
i also run into the same problem, according to qmailtoaster installation script the command suppose to be
rpmbuild --rebuild --with cnt5064 vqadmin-toaster-2.3.7-1.4.1.src.rpm
built it has the same error msg as above
and I Google around and found out
vqadmin build error
many of our programs are running automake versions that PREDATE 64-bit linux... and while most apps will build just fine (albeit less optimized), vqadmin 2.3.7 does NOT build successfully in this "unknown-linux" environment.
He offers a x86_64 rpm at the bottom

Compiling erlang with systemtap but require dtrace

I'm compiling erlang otp from source like following:
./configure --with-dynamic-trace=systemtap
But it reports error:
checking for dtrace... no
configure: error: No dtrace utility found.
I think systemtap is for linux usage and it is different from dtrace, am I right?
After installed dtrace Now the error is:
dtrace: failed to compile script emulator/beam/erlang_dtrace.d: Preprocessor not found
configure: error: Could not precompile erlang_dtrace.d: dtrace -h failed
configure: error: /root/otp/erts/configure failed for erts
Which distro are you using? I'd forget using DTRACE, it will be a bit harder to make it to work than Systemtap (at least it was for me). I'm using Systemtap and it works perfectly.
If you are not using Fedora/RH you should patch your kernel with UTRACE or use a kernel >= 3.5 with UPBOBES enabled.
To verify if your kernel has UTRACE/UPROBE enabled run this:
grep UTRACE /boot/config-$(uname -r)
or
grep PROBES /boot/config-$(uname -r)
For example, in my machine (Ubuntu 12.04 with Mainline kernel 3.5):
$ grep UTRACE /boot/config-$(uname -r)
$
$ grep UPROBES /boot/config-$(uname -r)
CONFIG_ARCH_SUPPORTS_UPROBES=y
CONFIG_UPROBES=y
You should also have systemtap installed. The version shipped with Ubuntu (my case) is quite old, so I compiled it from source (traditional configure/make/make install). You can get it here:
http://sourceware.org/systemtap/ftp/releases/
I'm using version 1.8.
Then try to recompile it again. It should work.
Regards
After installing systemtap(sudo apt-get install systemtap), exiting or logging out from the current shell session then logging in may help.
Also, you may try using kerl.

Resources