Provide python perf module

Bug #2051560 reported by Lucas Kanashiro
8
This bug affects 1 person
Affects Status Importance Assigned to Milestone
linux (Ubuntu)
Status tracked in Oracular
Noble
Fix Released
Undecided
Unassigned
Oracular
Fix Committed
Undecided
Unassigned

Bug Description

[Impact]

We need to provide the python perf module, because some applications (such as tuned) require it.

This module is implemented inside perf, provided by the kernel.

At the moment we provide a distinct perf for each kernel installed in the system. There is really no reason to do that, because perf is both backward and forward compatible, but this is a different issue and we are not going to solve it in this context and it will be addressed in a separate bug.

For now, to solve this specific issue, we need to enable the python module when we build perf (as part of the kernel build) and ship the library inside the linux-tools-<kernel_abi_version> package.

However, this brings a new problem, because we need to install the module in a standard python path (so that python applications can be able to use it in a regular way), but we need to support multiple installed versions and add some logic to transparently select the right one when a generic user-space python application uses `import perf`.

For this reason we need to provide a python wrapper module that is imported via a regular `import perf` and it transparently loads the actual python perf module, based on the kernel that is currently running.

[Test case]

Install linux-tools-<kernel_version> and run the following simple test case:

 $ python -c 'import perf; [print(c) for c in perf.cpu_map()]'

[Fix]

 - Enable the python perf module build during the regular kernel build
 - Provide a virtual `perf` python module wrapper in linux-tools-common

[Regression potential]

We are adding a new python module to linux-tools (that is something new, we don't ship any other python module), but we are not changing anything that is already provided, so the only regression that can happen is an increased size of the linux-tools package.

[Original bug report]

The tuned package has some plugins which rely on the perf python module [1], and right now they are not working because we do not have the perf python module available in Ubuntu.

Initially, this was reported in this other bug [2], but it seems the scope of that bug is bigger than what we (Server) need for tuned. So filing this new bug as requested by the Kernel team to provide just the python module.

For reference, in Fedora it's shipped in the bin:python3-perf package:

[root@f39 ~]# rpm -ql python3-perf
/usr/lib/.build-id
/usr/lib/.build-id/80
/usr/lib/.build-id/80/9022196f598cb3327545c2d497b1d9fdf55630
/usr/lib64/python3.12/site-packages/perf-0.1-py3.12.egg-info
/usr/lib64/python3.12/site-packages/perf-0.1-py3.12.egg-info/PKG-INFO
/usr/lib64/python3.12/site-packages/perf-0.1-py3.12.egg-info/SOURCES.txt
/usr/lib64/python3.12/site-packages/perf-0.1-py3.12.egg-info/dependency_links.txt
/usr/lib64/python3.12/site-packages/perf-0.1-py3.12.egg-info/top_level.txt
/usr/lib64/python3.12/site-packages/perf.cpython-312-x86_64-linux-gnu.so
/usr/share/licenses/python3-perf
/usr/share/licenses/python3-perf/COPYING

Built from their kernel-tools package[3].

[1] https://bugs.launchpad.net/ubuntu/+source/tuned/+bug/2051290
[2] https://bugs.launchpad.net/ubuntu/+source/linux/+bug/1613393
[3] https://src.fedoraproject.org/rpms/kernel-tools/blob/rawhide/f/kernel-tools.spec#_148

CVE References

description: updated
Andrea Righi (arighi)
description: updated
Revision history for this message
Andrea Righi (arighi) wrote :

Patch sent to the kernel team mailing list for review: https://lists.ubuntu.com/archives/kernel-team/2024-March/149751.html

Andrea Righi (arighi)
Changed in linux (Ubuntu):
status: New → Fix Committed
Revision history for this message
Ubuntu Kernel Bot (ubuntu-kernel-bot) wrote :

This bug is awaiting verification that the linux/6.8.0-32.32 kernel in -proposed solves the problem. Please test the kernel and update this bug with the results. If the problem is solved, change the tag 'verification-needed-noble-linux' to 'verification-done-noble-linux'. If the problem still exists, change the tag 'verification-needed-noble-linux' to 'verification-failed-noble-linux'.

If verification is not done by 5 working days from today, this fix will be dropped from the source code, and this bug will be closed.

See https://wiki.ubuntu.com/Testing/EnableProposed for documentation how to enable and use -proposed. Thank you!

tags: added: kernel-spammed-noble-linux-v2 verification-needed-noble-linux
Revision history for this message
Andreas Hasenack (ahasenack) wrote :

Noble verification

Confirming the bug:
$ uname -a
Linux n-perf 6.8.0-31-generic #31-Ubuntu SMP PREEMPT_DYNAMIC Sat Apr 20 00:40:06 UTC 2024 x86_64 x86_64 x86_64 GNU/Linux

$ sudo apt install linux-tools-$(uname -r)
(...)

$ python3 -c 'import perf; [print(c) for c in perf.cpu_map()]'
Traceback (most recent call last):
  File "<string>", line 1, in <module>
ModuleNotFoundError: No module named 'perf'

Updating to kernel in noble-proposed and rebooting:
$ uname -a
Linux n-perf 6.8.0-32-generic #32-Ubuntu SMP PREEMPT_DYNAMIC Wed May 1 15:30:59 UTC 2024 x86_64 x86_64 x86_64 GNU/Linux

linux-tools was also updated:
$ dpkg -l linux-tools-$(uname -r)
Desired=Unknown/Install/Remove/Purge/Hold
| Status=Not/Inst/Conf-files/Unpacked/halF-conf/Half-inst/trig-aWait/Trig-pend
|/ Err?=(none)/Reinst-required (Status,Err: uppercase=bad)
||/ Name Version Architecture Description
+++-============================-============-============-========================================================
ii linux-tools-6.8.0-32-generic 6.8.0-32.32 amd64 Linux kernel version specific tools for version 6.8.0-32

The python command now works:
$ python3 -c 'import perf; [print(c) for c in perf.cpu_map()]'
0

Another verification also shows the module is now available:

$ python3 -c 'import perf; print(perf.__file__)'
/usr/lib/python3/dist-packages/linux-tools-6.8.0-32/perf.cpython-312-x86_64-linux-gnu.so

Noble verification succeeded.

tags: added: verification-done-noble-linux
removed: verification-needed-noble-linux
Changed in linux (Ubuntu Noble):
status: New → Fix Committed
Revision history for this message
Andreas Hasenack (ahasenack) wrote :

Kernel updated have a different procedure, but I added a noble task and marked it as fix committed, since the package is in noble-proposed. I also updated the verification tag.

Revision history for this message
Launchpad Janitor (janitor) wrote :
Download full text (74.9 KiB)

This bug was fixed in the package linux - 6.8.0-35.35

---------------
linux (6.8.0-35.35) noble; urgency=medium

  * noble/linux: 6.8.0-35.35 -proposed tracker (LP: #2065886)

  * CVE-2024-21823
    - VFIO: Add the SPR_DSA and SPR_IAX devices to the denylist
    - dmaengine: idxd: add a new security check to deal with a hardware erratum
    - dmaengine: idxd: add a write() method for applications to submit work

linux (6.8.0-34.34) noble; urgency=medium

  * noble/linux: 6.8.0-34.34 -proposed tracker (LP: #2065167)

  * Packaging resync (LP: #1786013)
    - [Packaging] debian.master/dkms-versions -- update from kernel-versions
      (main/2024.04.29)

linux (6.8.0-32.32) noble; urgency=medium

  * noble/linux: 6.8.0-32.32 -proposed tracker (LP: #2064344)

  * Packaging resync (LP: #1786013)
    - [Packaging] drop getabis data
    - [Packaging] update variants
    - [Packaging] update annotations scripts
    - [Packaging] debian.master/dkms-versions -- update from kernel-versions
      (main/2024.04.29)

  * Enable Nezha board (LP: #1975592)
    - [Config] Enable CONFIG_REGULATOR_FIXED_VOLTAGE on riscv64

  * Enable Nezha board (LP: #1975592) // Enable StarFive VisionFive 2 board
    (LP: #2013232)
    - [Config] Enable CONFIG_SERIAL_8250_DW on riscv64

  * RISC-V kernel config is out of sync with other archs (LP: #1981437)
    - [Config] Sync riscv64 config with other architectures

  * obsolete out-of-tree ivsc dkms in favor of in-tree one (LP: #2061747)
    - ACPI: scan: Defer enumeration of devices with a _DEP pointing to IVSC device
    - Revert "mei: vsc: Call wake_up() in the threaded IRQ handler"
    - mei: vsc: Unregister interrupt handler for system suspend
    - media: ipu-bridge: Add ov01a10 in Dell XPS 9315
    - SAUCE: media: ipu-bridge: Support more sensors

  * Fix after-suspend-mediacard/sdhc-insert test failed (LP: #2042500)
    - PCI/ASPM: Move pci_configure_ltr() to aspm.c
    - PCI/ASPM: Always build aspm.c
    - PCI/ASPM: Move pci_save_ltr_state() to aspm.c
    - PCI/ASPM: Save L1 PM Substates Capability for suspend/resume
    - PCI/ASPM: Call pci_save_ltr_state() from pci_save_pcie_state()
    - PCI/ASPM: Disable L1 before configuring L1 Substates
    - PCI/ASPM: Update save_state when configuration changes

  * RTL8852BE fw security fail then lost WIFI function during suspend/resume
    cycle (LP: #2063096)
    - wifi: rtw89: download firmware with five times retry

  * intel_rapl_common: Add support for ARL and LNL (LP: #2061953)
    - powercap: intel_rapl: Add support for Lunar Lake-M paltform
    - powercap: intel_rapl: Add support for Arrow Lake

  * Kernel panic during checkbox stress_ng_test on Grace running noble 6.8
    (arm64+largemem) kernel (LP: #2058557)
    - aio: Fix null ptr deref in aio_complete() wakeup

  * Avoid creating non-working backlight sysfs knob from ASUS board
    (LP: #2060422)
    - platform/x86: asus-wmi: Consider device is absent when the read is ~0

  * Include cifs.ko in linux-modules package (LP: #2042546)
    - [Packaging] Replace fs/cifs with fs/smb/client in inclusion list

  * Add Real-time Linux Analysis tool (rtla) to linux-tools (LP: #2059080)
    - SAUCE: rtla: fix deb build
 ...

Changed in linux (Ubuntu Noble):
status: Fix Committed → Fix Released
Revision history for this message
Ubuntu Kernel Bot (ubuntu-kernel-bot) wrote :

This bug is awaiting verification that the linux-azure/6.8.0-1008.8 kernel in -proposed solves the problem. Please test the kernel and update this bug with the results. If the problem is solved, change the tag 'verification-needed-noble-linux-azure' to 'verification-done-noble-linux-azure'. If the problem still exists, change the tag 'verification-needed-noble-linux-azure' to 'verification-failed-noble-linux-azure'.

If verification is not done by 5 working days from today, this fix will be dropped from the source code, and this bug will be closed.

See https://wiki.ubuntu.com/Testing/EnableProposed for documentation how to enable and use -proposed. Thank you!

tags: added: kernel-spammed-noble-linux-azure-v2 verification-needed-noble-linux-azure
Revision history for this message
Ubuntu Kernel Bot (ubuntu-kernel-bot) wrote :

This bug is awaiting verification that the linux-gke/6.8.0-1004.7 kernel in -proposed solves the problem. Please test the kernel and update this bug with the results. If the problem is solved, change the tag 'verification-needed-noble-linux-gke' to 'verification-done-noble-linux-gke'. If the problem still exists, change the tag 'verification-needed-noble-linux-gke' to 'verification-failed-noble-linux-gke'.

If verification is not done by 5 working days from today, this fix will be dropped from the source code, and this bug will be closed.

See https://wiki.ubuntu.com/Testing/EnableProposed for documentation how to enable and use -proposed. Thank you!

tags: added: kernel-spammed-noble-linux-gke-v2 verification-needed-noble-linux-gke
Revision history for this message
Ubuntu Kernel Bot (ubuntu-kernel-bot) wrote :

This bug is awaiting verification that the linux-aws/6.8.0-1009.9 kernel in -proposed solves the problem. Please test the kernel and update this bug with the results. If the problem is solved, change the tag 'verification-needed-noble-linux-aws' to 'verification-done-noble-linux-aws'. If the problem still exists, change the tag 'verification-needed-noble-linux-aws' to 'verification-failed-noble-linux-aws'.

If verification is not done by 5 working days from today, this fix will be dropped from the source code, and this bug will be closed.

See https://wiki.ubuntu.com/Testing/EnableProposed for documentation how to enable and use -proposed. Thank you!

tags: added: kernel-spammed-noble-linux-aws-v2 verification-needed-noble-linux-aws
Revision history for this message
Ubuntu Kernel Bot (ubuntu-kernel-bot) wrote :

This bug is awaiting verification that the linux-gcp/6.8.0-1008.9 kernel in -proposed solves the problem. Please test the kernel and update this bug with the results. If the problem is solved, change the tag 'verification-needed-noble-linux-gcp' to 'verification-done-noble-linux-gcp'. If the problem still exists, change the tag 'verification-needed-noble-linux-gcp' to 'verification-failed-noble-linux-gcp'.

If verification is not done by 5 working days from today, this fix will be dropped from the source code, and this bug will be closed.

See https://wiki.ubuntu.com/Testing/EnableProposed for documentation how to enable and use -proposed. Thank you!

tags: added: kernel-spammed-noble-linux-gcp-v2 verification-needed-noble-linux-gcp
Revision history for this message
Ubuntu Kernel Bot (ubuntu-kernel-bot) wrote :

This bug is awaiting verification that the linux-ibm/6.8.0-1006.6 kernel in -proposed solves the problem. Please test the kernel and update this bug with the results. If the problem is solved, change the tag 'verification-needed-noble-linux-ibm' to 'verification-done-noble-linux-ibm'. If the problem still exists, change the tag 'verification-needed-noble-linux-ibm' to 'verification-failed-noble-linux-ibm'.

If verification is not done by 5 working days from today, this fix will be dropped from the source code, and this bug will be closed.

See https://wiki.ubuntu.com/Testing/EnableProposed for documentation how to enable and use -proposed. Thank you!

tags: added: kernel-spammed-noble-linux-ibm-v2 verification-needed-noble-linux-ibm
Revision history for this message
Ubuntu Kernel Bot (ubuntu-kernel-bot) wrote :

This bug is awaiting verification that the linux-intel/6.8.0-1005.12 kernel in -proposed solves the problem. Please test the kernel and update this bug with the results. If the problem is solved, change the tag 'verification-needed-noble-linux-intel' to 'verification-done-noble-linux-intel'. If the problem still exists, change the tag 'verification-needed-noble-linux-intel' to 'verification-failed-noble-linux-intel'.

If verification is not done by 5 working days from today, this fix will be dropped from the source code, and this bug will be closed.

See https://wiki.ubuntu.com/Testing/EnableProposed for documentation how to enable and use -proposed. Thank you!

tags: added: kernel-spammed-noble-linux-intel-v2 verification-needed-noble-linux-intel
Revision history for this message
Ubuntu Kernel Bot (ubuntu-kernel-bot) wrote :

This bug is awaiting verification that the linux-nvidia/6.8.0-1007.7 kernel in -proposed solves the problem. Please test the kernel and update this bug with the results. If the problem is solved, change the tag 'verification-needed-noble-linux-nvidia' to 'verification-done-noble-linux-nvidia'. If the problem still exists, change the tag 'verification-needed-noble-linux-nvidia' to 'verification-failed-noble-linux-nvidia'.

If verification is not done by 5 working days from today, this fix will be dropped from the source code, and this bug will be closed.

See https://wiki.ubuntu.com/Testing/EnableProposed for documentation how to enable and use -proposed. Thank you!

tags: added: kernel-spammed-noble-linux-nvidia-v2 verification-needed-noble-linux-nvidia
Revision history for this message
Ubuntu Kernel Bot (ubuntu-kernel-bot) wrote :

This bug is awaiting verification that the linux-oem-6.8/6.8.0-1006.6 kernel in -proposed solves the problem. Please test the kernel and update this bug with the results. If the problem is solved, change the tag 'verification-needed-noble-linux-oem-6.8' to 'verification-done-noble-linux-oem-6.8'. If the problem still exists, change the tag 'verification-needed-noble-linux-oem-6.8' to 'verification-failed-noble-linux-oem-6.8'.

If verification is not done by 5 working days from today, this fix will be dropped from the source code, and this bug will be closed.

See https://wiki.ubuntu.com/Testing/EnableProposed for documentation how to enable and use -proposed. Thank you!

tags: added: kernel-spammed-noble-linux-oem-6.8-v2 verification-needed-noble-linux-oem-6.8
Revision history for this message
Ubuntu Kernel Bot (ubuntu-kernel-bot) wrote :

This bug is awaiting verification that the linux-riscv/6.8.0-35.35.1 kernel in -proposed solves the problem. Please test the kernel and update this bug with the results. If the problem is solved, change the tag 'verification-needed-noble-linux-riscv' to 'verification-done-noble-linux-riscv'. If the problem still exists, change the tag 'verification-needed-noble-linux-riscv' to 'verification-failed-noble-linux-riscv'.

If verification is not done by 5 working days from today, this fix will be dropped from the source code, and this bug will be closed.

See https://wiki.ubuntu.com/Testing/EnableProposed for documentation how to enable and use -proposed. Thank you!

tags: added: kernel-spammed-noble-linux-riscv-v2 verification-needed-noble-linux-riscv
Revision history for this message
Ubuntu Kernel Bot (ubuntu-kernel-bot) wrote :

This bug is awaiting verification that the linux-raspi-realtime/6.8.0-2004.4 kernel in -proposed solves the problem. Please test the kernel and update this bug with the results. If the problem is solved, change the tag 'verification-needed-noble-linux-raspi-realtime' to 'verification-done-noble-linux-raspi-realtime'. If the problem still exists, change the tag 'verification-needed-noble-linux-raspi-realtime' to 'verification-failed-noble-linux-raspi-realtime'.

If verification is not done by 5 working days from today, this fix will be dropped from the source code, and this bug will be closed.

See https://wiki.ubuntu.com/Testing/EnableProposed for documentation how to enable and use -proposed. Thank you!

tags: added: kernel-spammed-noble-linux-raspi-realtime-v2 verification-needed-noble-linux-raspi-realtime
Revision history for this message
Ubuntu Kernel Bot (ubuntu-kernel-bot) wrote :

This bug is awaiting verification that the linux-lowlatency/6.8.0-35.35.1 kernel in -proposed solves the problem. Please test the kernel and update this bug with the results. If the problem is solved, change the tag 'verification-needed-noble-linux-lowlatency' to 'verification-done-noble-linux-lowlatency'. If the problem still exists, change the tag 'verification-needed-noble-linux-lowlatency' to 'verification-failed-noble-linux-lowlatency'.

If verification is not done by 5 working days from today, this fix will be dropped from the source code, and this bug will be closed.

See https://wiki.ubuntu.com/Testing/EnableProposed for documentation how to enable and use -proposed. Thank you!

tags: added: kernel-spammed-noble-linux-lowlatency-v2 verification-needed-noble-linux-lowlatency
Revision history for this message
Ubuntu Kernel Bot (ubuntu-kernel-bot) wrote :

This bug is awaiting verification that the linux-oracle/6.8.0-1006.6 kernel in -proposed solves the problem. Please test the kernel and update this bug with the results. If the problem is solved, change the tag 'verification-needed-noble-linux-oracle' to 'verification-done-noble-linux-oracle'. If the problem still exists, change the tag 'verification-needed-noble-linux-oracle' to 'verification-failed-noble-linux-oracle'.

If verification is not done by 5 working days from today, this fix will be dropped from the source code, and this bug will be closed.

See https://wiki.ubuntu.com/Testing/EnableProposed for documentation how to enable and use -proposed. Thank you!

tags: added: kernel-spammed-noble-linux-oracle-v2 verification-needed-noble-linux-oracle
Revision history for this message
Ubuntu Kernel Bot (ubuntu-kernel-bot) wrote :

This bug is awaiting verification that the linux-ibm-gt/6.8.0-1004.5 kernel in -proposed solves the problem. Please test the kernel and update this bug with the results. If the problem is solved, change the tag 'verification-needed-noble-linux-ibm-gt' to 'verification-done-noble-linux-ibm-gt'. If the problem still exists, change the tag 'verification-needed-noble-linux-ibm-gt' to 'verification-failed-noble-linux-ibm-gt'.

If verification is not done by 5 working days from today, this fix will be dropped from the source code, and this bug will be closed.

See https://wiki.ubuntu.com/Testing/EnableProposed for documentation how to enable and use -proposed. Thank you!

tags: added: kernel-spammed-noble-linux-ibm-gt-v2 verification-needed-noble-linux-ibm-gt
Revision history for this message
Ubuntu Kernel Bot (ubuntu-kernel-bot) wrote :

This bug is awaiting verification that the linux-nvidia-6.8/6.8.0-1008.8~22.04.1 kernel in -proposed solves the problem. Please test the kernel and update this bug with the results. If the problem is solved, change the tag 'verification-needed-jammy-linux-nvidia-6.8' to 'verification-done-jammy-linux-nvidia-6.8'. If the problem still exists, change the tag 'verification-needed-jammy-linux-nvidia-6.8' to 'verification-failed-jammy-linux-nvidia-6.8'.

If verification is not done by 5 working days from today, this fix will be dropped from the source code, and this bug will be closed.

See https://wiki.ubuntu.com/Testing/EnableProposed for documentation how to enable and use -proposed. Thank you!

tags: added: kernel-spammed-jammy-linux-nvidia-6.8-v2 verification-needed-jammy-linux-nvidia-6.8
Revision history for this message
Ubuntu Kernel Bot (ubuntu-kernel-bot) wrote :

This bug is awaiting verification that the linux-ibm-6.8/6.8.0-1008.8~22.04.1 kernel in -proposed solves the problem. Please test the kernel and update this bug with the results. If the problem is solved, change the tag 'verification-needed-jammy-linux-ibm-6.8' to 'verification-done-jammy-linux-ibm-6.8'. If the problem still exists, change the tag 'verification-needed-jammy-linux-ibm-6.8' to 'verification-failed-jammy-linux-ibm-6.8'.

If verification is not done by 5 working days from today, this fix will be dropped from the source code, and this bug will be closed.

See https://wiki.ubuntu.com/Testing/EnableProposed for documentation how to enable and use -proposed. Thank you!

tags: added: kernel-spammed-jammy-linux-ibm-6.8-v2 verification-needed-jammy-linux-ibm-6.8
Revision history for this message
Ubuntu Kernel Bot (ubuntu-kernel-bot) wrote :

This bug is awaiting verification that the linux-lowlatency-hwe-6.8/6.8.0-38.38.1~22.04.2 kernel in -proposed solves the problem. Please test the kernel and update this bug with the results. If the problem is solved, change the tag 'verification-needed-jammy-linux-lowlatency-hwe-6.8' to 'verification-done-jammy-linux-lowlatency-hwe-6.8'. If the problem still exists, change the tag 'verification-needed-jammy-linux-lowlatency-hwe-6.8' to 'verification-failed-jammy-linux-lowlatency-hwe-6.8'.

If verification is not done by 5 working days from today, this fix will be dropped from the source code, and this bug will be closed.

See https://wiki.ubuntu.com/Testing/EnableProposed for documentation how to enable and use -proposed. Thank you!

tags: added: kernel-spammed-jammy-linux-lowlatency-hwe-6.8-v2 verification-needed-jammy-linux-lowlatency-hwe-6.8
Revision history for this message
Andreas Hasenack (ahasenack) wrote :

I can see this is available in oracular-proposed's kernel and linux-tools package:

ubuntu@o-dep8:~$ uname -r
6.10.0-15-generic
ubuntu@o-dep8:~$ apt-cache policy linux-tools-$(uname -r)
linux-tools-6.10.0-15-generic:
  Installed: 6.10.0-15.15
  Candidate: 6.10.0-15.15
  Version table:
 *** 6.10.0-15.15 100
        100 http://br.archive.ubuntu.com/ubuntu oracular-proposed/main amd64 Packages
        100 /var/lib/dpkg/status

ubuntu@o-dep8:~$ python3 -c "import perf; [print(c) for c in perf.cpu_map()]"
0

(the python module can be imported and run some trivial code)

Revision history for this message
Andreas Hasenack (ahasenack) wrote :

What dependency could I add to src:tuned that would pull in the correct linux-tools-* package that has the python3 perf module?

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.