linux-surface / repo

Package repositories for linux-surface
https://pkg.surfacelinux.com/
6 stars 4 forks source link

Build and publish `linux-tools-surface` #5

Open danielzgtg opened 3 years ago

danielzgtg commented 3 years ago

It would be nice if a linux-tools-surface package was built and published.

I am trying to profile one of my programs. On a standard kernel, I can apt install linux-tools-generic, but with this kernel, there is no linux-tools-surface. That prevents perf from working and me from profiling my program

qzed commented 3 years ago

Yeah, the problem with that is that the official Debian/Ubuntu build system for the kernel was a bit too much maintenance work for us (seeing as none of us actually uses a Debian-based distro), so we decided to go with the kernel bindeb-pkg target and some wrapper packages. And the kernel makefile doesn't have a target for the tools package.

So to implement this we'll need to write a package from scratch I think. I don't have much time for experiments right now, so do you maybe want to have a look at implementing that?

I think this should be implemented in the linux-surface repo, so that the tools package gets built with/after the kernel package, i.e. integrated into the debian.yml and debian_lts.yml workflows. The wrapper packages are generated in this script, so maybe we need something like that for the tools package. Packaging should essentially call the appropriate targets in tools/Makefile (whatever they are) and then package that as linux-tools-surface-kernelversion as well as generating a wrapper for that.

StollD commented 3 years ago

I really dont know anything about perf and not a lot about debian packaging, but is there any issue with the perf program from linux-tools-generic? Is it bound to the kernel it was compiled from?

We support installing the surface kernel without removing the default one, and in fact even recommend it, so it should be possible to just use the perf that comes with linux-tools-generic (unless it is bound to the kernel somehow, again, I dont know).

danielzgtg commented 3 years ago

perf depends on being matched to the precise kernel version it came from:

$ perf
WARNING: perf not found for kernel 5.11.2

  You may need to install the following packages for this specific kernel:
    linux-tools-5.11.2-surface
    linux-cloud-tools-5.11.2-surface

  You may also want to install one of the following packages to keep up to date:
    linux-tools-surface
    linux-cloud-tools-surface
NP-chaonay commented 2 years ago

perf depends on being matched to the precise kernel version it came from:

if I not wrong, the linux tools binary supports <= the version of src that it compiled (idk about this however there may some very lower version that also not able to run); and seem linux-tools-generic of Ubuntu/debians seem to overwrite the file for every update of kernel and its tools.

however I have compile it myself there is something not work on Ubuntu 22.04 LTS. (I have not less and not much building knowledge)

logfile ``` Kernel version is same on what running and source dir used (5.18.4-surface) [keys] X: Failed to compile Xi: Failed to install [Conclude from below] command to install all but excluded one that failed: export DESTDIR=... # seem that x86_energy_perf_policy_install dont work on non-root even destdir is set make acpi_install; make counter_install; make cpupower_install; make debugging_install; make freefall_install; make gpio_install; make hv_install; make iio_install; make pci_install; make perf_install; make bootconfig_install; make spi_install; make tmon_install; make turbostat_install; make usb_install; make vm_install; make wmi_install; make x86_energy_perf_policy_install; [For each avaiable tools] acpi X btf > message here DESCEND bpf Auto-detecting system features: ... libbfd: [ on ] ... disassembler-four-args: [ on ] DESCEND bpftool Auto-detecting system features: ... libbfd: [ on ] ... disassembler-four-args: [ on ] ... zlib: [ on ] ... libcap: [ on ] ... clang-bpf-co-re: [ on ] make[2]: Nothing to be done for 'all'. DESCEND runqslower Couldn't find kernel BTF; set VMLINUX_BTF to specify its location. make[2]: *** [Makefile:75: /home/np-chaonay/Misc/KernelBuild/v5.18-surface_eprm1/tools/bpf/runqslower/.output//vmlinux.h] Error 1 make[1]: *** [Makefile:119: runqslower] Error 2 make: *** [Makefile:69: bpf] Error 2 > not know about that, skipped Xi cgroup > build ok but not install with error msg DESCEND cgroup make[1]: *** No rule to make target 'install'. Stop. make: *** [Makefile:113: cgroup_install] Error 2 counter cpupower debugging firewire Xi firmware > build ok but not install with error msg make: *** No rule to make target 'firmware_install'. Stop. freefall gpio hv iio X intel-speed-select > Error here DESCEND power/x86/intel-speed-select make -f /home/np-chaonay/Misc/KernelBuild/v5.18-surface_eprm1/tools/build/Makefile.build dir=. obj=intel-speed-select CC hfi-events.o LD intel-speed-select-in.o LINK intel-speed-select /usr/bin/ld: cannot find -lnl-genl-3: No such file or directory collect2: error: ld returned 1 exit status make[1]: *** [Makefile:45: intel-speed-select] Error 1 make: *** [Makefile:89: intel-speed-select] Error 2 > cannot resolve further Xi leds > build ok but not install with error msg make: *** No rule to make target 'leds_install'. Stop. Xi objtool > build ok but not install with error msg DESCEND objtool make[1]: *** No rule to make target 'install'. Stop. make: *** [Makefile:113: objtool_install] Error 2 pci perf Xi selftest > build ok but not install with error msg make: *** No rule to make target 'selftest_install'. Stop. bootconfig spi tmon X tracing > error msg DESCEND tracing DESCEND latency cc -Wall -Wextra -g -O2 -o latency-collector latency-collector.c -lpthread latency-collector.c:26:10: fatal error: tracefs.h: No such file or directory 26 | #include | ^~~~~~~~~~~ compilation terminated. make[2]: *** [Makefile:14: latency-collector] Error 1 make[1]: *** [Makefile:11: latency] Error 2 make: *** [Makefile:69: tracing] Error 2 > cannot resolve further turbostat usb X virtio > error msg DESCEND virtio cc -g -O2 -Werror -Wno-maybe-uninitialized -Wall -I. -I../include/ -I ../../usr/include/ -Wno-pointer-sign -fno-strict-overflow -fno-strict-aliasing -fno-common -MMD -U_FORTIFY_SOURCE -include ../../include/linux/kconfig.h -pthread -c -o virtio_test.o virtio_test.c In file included from ./linux/scatterlist.h:4, from ./linux/virtio.h:4, from ./linux/virtio_config.h:3, from ../../usr/include/linux/vhost_types.h:16, from ../../usr/include/linux/vhost.h:14, from virtio_test.c:17: ./linux/kernel.h:32:28: error: conflicting types for ‘phys_addr_t’; have ‘long long unsigned int’ 32 | typedef unsigned long long phys_addr_t; | ^~~~~~~~~~~ In file included from ../../usr/include/linux/stat.h:5, from /usr/include/x86_64-linux-gnu/bits/statx.h:31, from /usr/include/x86_64-linux-gnu/sys/stat.h:465, from virtio_test.c:12: ../include/linux/types.h:69:13: note: previous declaration of ‘phys_addr_t’ with type ‘phys_addr_t’ {aka ‘unsigned int’} 69 | typedef u32 phys_addr_t; | ^~~~~~~~~~~ make[1]: *** [: virtio_test.o] Error 1 make: *** [Makefile:69: virtio] Error 2 > cannot resolve further vm wmi x86_energy_perf_policy ```

but thats doesn't end well as there are something wrong such as cpupower which goto /usr/lib64 but the Ubuntu seem not read lib file from that and got libcpupower.so.0: cannot open shared object file: No such file or directory

and after that I just notice that I have break much of system packaging, so recommended to not using make install from that, if you have done maybe reinstall linux tools package from repo, every single package that already in your system (excluded residue config pkg)

danielzgtg commented 1 year ago

I mainly wanted this perf so that I can more easily profile iptsd. But now there is iptsd-perf an iptsd-dump so I think I'll try debugging it on my desktop instead.